vdesign-ui 0.2.12 → 0.2.14

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.
Files changed (167) hide show
  1. package/README.md +78 -78
  2. package/dist/components/actionbar/index.js +8 -8
  3. package/dist/components/actionbar/index.vue +39 -39
  4. package/dist/components/actionbar/style.less +44 -44
  5. package/dist/components/actionbar-cell/index.js +7 -7
  6. package/dist/components/actionbar-cell/index.vue +38 -38
  7. package/dist/components/actions/index.js +6 -6
  8. package/dist/components/actions/index.vue +77 -76
  9. package/dist/components/actions/style.less +109 -109
  10. package/dist/components/actions-cell/index.js +6 -6
  11. package/dist/components/actions-cell/index.vue +94 -94
  12. package/dist/components/actions-cell/style.less +38 -38
  13. package/dist/components/activityviews/index.js +8 -8
  14. package/dist/components/activityviews/index.vue +192 -192
  15. package/dist/components/activityviews/style.less +151 -151
  16. package/dist/components/badge/index.js +8 -8
  17. package/dist/components/badge/index.vue +49 -49
  18. package/dist/components/badge/style.less +54 -54
  19. package/dist/components/button/index.js +8 -8
  20. package/dist/components/button/index.vue +93 -93
  21. package/dist/components/button/style.less +558 -558
  22. package/dist/components/calendar/index-element.vue +84 -84
  23. package/dist/components/calendar/index.js +7 -7
  24. package/dist/components/calendar/index.vue +52 -52
  25. package/dist/components/calendar/style.less +138 -138
  26. package/dist/components/checkbox/index.js +8 -8
  27. package/dist/components/checkbox/index.vue +161 -161
  28. package/dist/components/checkbox/style.less +288 -288
  29. package/dist/components/checkbox-group/index.js +7 -7
  30. package/dist/components/checkbox-group/index.vue +69 -69
  31. package/dist/components/common/state/index.vue +33 -33
  32. package/dist/components/common/state/style.less +47 -47
  33. package/dist/components/data-list/index.js +10 -10
  34. package/dist/components/data-list/index.vue +19 -19
  35. package/dist/components/data-list/style.less +623 -623
  36. package/dist/components/datetime-picker/index.js +7 -7
  37. package/dist/components/datetime-picker/index.vue +37 -37
  38. package/dist/components/datetime-picker/style.less +23 -23
  39. package/dist/components/dialog/index.js +8 -8
  40. package/dist/components/dialog/index.vue +164 -164
  41. package/dist/components/dialog/overlay-manager.js +18 -18
  42. package/dist/components/dialog/style.less +138 -138
  43. package/dist/components/divider/index.js +8 -8
  44. package/dist/components/divider/index.vue +54 -54
  45. package/dist/components/divider/style.less +92 -92
  46. package/dist/components/dropdown/index.js +8 -8
  47. package/dist/components/dropdown/index.vue +218 -218
  48. package/dist/components/dropdown/style.less +432 -432
  49. package/dist/components/empty/index.js +8 -8
  50. package/dist/components/empty/index.vue +138 -138
  51. package/dist/components/empty/style.less +60 -60
  52. package/dist/components/footer/index.js +6 -6
  53. package/dist/components/footer/index.vue +33 -33
  54. package/dist/components/footer/style.less +20 -20
  55. package/dist/components/footnav/index.js +6 -6
  56. package/dist/components/footnav/index.vue +93 -93
  57. package/dist/components/footnav/style.less +22 -22
  58. package/dist/components/footnav-item/index.js +6 -6
  59. package/dist/components/footnav-item/index.vue +50 -50
  60. package/dist/components/footnav-item/style.less +39 -39
  61. package/dist/components/form/index.js +6 -6
  62. package/dist/components/form/index.vue +12 -12
  63. package/dist/components/headnav/index.js +6 -6
  64. package/dist/components/headnav/index.vue +185 -185
  65. package/dist/components/headnav/style.less +231 -231
  66. package/dist/components/icon/font/iconfont.css +163 -163
  67. package/dist/components/icon/font/iconfont.js +5 -5
  68. package/dist/components/icon/index.js +9 -9
  69. package/dist/components/icon/index.vue +96 -96
  70. package/dist/components/icon/style.less +44 -44
  71. package/dist/components/input/calcTextareaHeight.js +162 -162
  72. package/dist/components/input/index.js +8 -8
  73. package/dist/components/input/index.vue +345 -345
  74. package/dist/components/input/style.less +470 -470
  75. package/dist/components/list/index.js +8 -8
  76. package/dist/components/list/index.vue +152 -152
  77. package/dist/components/list/style.less +213 -213
  78. package/dist/components/loading/index.js +6 -6
  79. package/dist/components/loading/index.vue +68 -68
  80. package/dist/components/loading/style.less +53 -53
  81. package/dist/components/mixins/clickoutside.js +81 -81
  82. package/dist/components/mixins/dom.js +41 -41
  83. package/dist/components/mixins/languageMixin.js +41 -41
  84. package/dist/components/mixins/outlineConfigPlugin.js +45 -45
  85. package/dist/components/mixins/router-link.js +22 -22
  86. package/dist/components/mixins/themeMixin.js +43 -43
  87. package/dist/components/noticebar/index.js +8 -8
  88. package/dist/components/noticebar/index.vue +258 -258
  89. package/dist/components/noticebar/style.less +328 -328
  90. package/dist/components/overlay/index.js +8 -8
  91. package/dist/components/overlay/index.vue +184 -184
  92. package/dist/components/overlay/style.less +23 -23
  93. package/dist/components/pagebreak/index.js +6 -6
  94. package/dist/components/pagebreak/index.vue +67 -67
  95. package/dist/components/pagebreak/style.less +41 -41
  96. package/dist/components/password/index.js +8 -8
  97. package/dist/components/password/index.vue +60 -60
  98. package/dist/components/popover/index.js +8 -8
  99. package/dist/components/popover/index.vue +100 -100
  100. package/dist/components/popover/style.less +346 -346
  101. package/dist/components/popover/vue-popover.vue +314 -314
  102. package/dist/components/popup/index.js +7 -7
  103. package/dist/components/popup/index.vue +243 -243
  104. package/dist/components/radio/index.js +8 -8
  105. package/dist/components/radio/index.vue +184 -184
  106. package/dist/components/radio/style.less +293 -293
  107. package/dist/components/radio-group/index.js +6 -6
  108. package/dist/components/radio-group/index.vue +58 -58
  109. package/dist/components/result/index.js +8 -8
  110. package/dist/components/result/index.vue +73 -73
  111. package/dist/components/result/style.less +43 -43
  112. package/dist/components/search/index.js +8 -8
  113. package/dist/components/search/index.vue +66 -66
  114. package/dist/components/selector/index.js +8 -8
  115. package/dist/components/selector/index.vue +161 -161
  116. package/dist/components/selector/style.less +484 -484
  117. package/dist/components/skeleton/index.js +6 -6
  118. package/dist/components/skeleton/index.vue +207 -207
  119. package/dist/components/skeleton/style.less +196 -196
  120. package/dist/components/slider/draggable.js +49 -49
  121. package/dist/components/slider/index.js +6 -6
  122. package/dist/components/slider/index.vue +167 -167
  123. package/dist/components/slider/style.less +99 -99
  124. package/dist/components/slider/utils.js +59 -59
  125. package/dist/components/step/index.js +7 -7
  126. package/dist/components/step/index.vue +48 -48
  127. package/dist/components/step/style.less +66 -58
  128. package/dist/components/step-item/index.js +7 -7
  129. package/dist/components/step-item/index.vue +126 -126
  130. package/dist/components/step-item/style.less +399 -362
  131. package/dist/components/stepper/index.js +8 -8
  132. package/dist/components/stepper/index.vue +146 -146
  133. package/dist/components/style/index.vue +42 -42
  134. package/dist/components/switch/index.js +8 -8
  135. package/dist/components/switch/index.vue +72 -72
  136. package/dist/components/switch/style.less +56 -56
  137. package/dist/components/tab/index.js +7 -7
  138. package/dist/components/tab/index.vue +94 -94
  139. package/dist/components/tabs/index.js +8 -8
  140. package/dist/components/tabs/index.vue +292 -281
  141. package/dist/components/tabs/style.less +408 -408
  142. package/dist/components/tag/index.js +6 -6
  143. package/dist/components/tag/index.vue +64 -64
  144. package/dist/components/tag/style.less +210 -210
  145. package/dist/components/title/index.js +8 -8
  146. package/dist/components/title/index.vue +99 -99
  147. package/dist/components/title/style.less +187 -187
  148. package/dist/components/toast/index.js +97 -97
  149. package/dist/components/toast/index.vue +49 -49
  150. package/dist/components/toast/style.less +57 -57
  151. package/dist/components/transition/index.js +8 -8
  152. package/dist/components/transition/index.vue +13 -13
  153. package/dist/components/transition/style.less +208 -208
  154. package/dist/components/upload/index.js +6 -6
  155. package/dist/components/upload/index.vue +106 -106
  156. package/dist/components/upload/style.less +147 -147
  157. package/dist/components/utils/assist.js +34 -34
  158. package/dist/components/utils/env.js +21 -21
  159. package/dist/locale/ar.js +97 -97
  160. package/dist/locale/en.js +97 -97
  161. package/dist/locale/zh.js +97 -97
  162. package/dist/token.css +23 -17
  163. package/dist/vdesign-ui.common.js +141 -129
  164. package/dist/vdesign-ui.css +1 -1
  165. package/dist/vdesign-ui.umd.js +141 -129
  166. package/dist/vdesign-ui.umd.min.js +2 -2
  167. package/package.json +113 -113
@@ -1,8 +1,8 @@
1
- import Stepper from './index.vue';
2
- import './style.less';
3
-
4
- Stepper.install = function (Vue) {
5
- Vue.component(Stepper.name, Stepper);
6
- };
7
-
8
- export default Stepper;
1
+ import Stepper from './index.vue';
2
+ import './style.less';
3
+
4
+ Stepper.install = function (Vue) {
5
+ Vue.component(Stepper.name, Stepper);
6
+ };
7
+
8
+ export default Stepper;
@@ -1,146 +1,146 @@
1
- <template>
2
- <div class="vd-stepper" :class="wrapClasses">
3
- <vd-button v-if="!position" :class="minusButtonClass" icon="icon_btn_reduce" size="small"
4
- @click="onChange('minus')"></vd-button>
5
- <input
6
- type="number"
7
- :class="inputClasses"
8
- :disabled="disabled"
9
- :value="currentValue"
10
- :placeholder="placeholder"
11
- @input="onInput"
12
- @blur="onBlur"
13
- >
14
- <vd-button v-if="position === 'right'" class="vd-stepper__minus" icon="icon_btn_reduce" size="small"
15
- @click="onChange('minus')"></vd-button>
16
- <vd-button :class="plusButtonClass" icon="icon_btn_add" size="small"
17
- @click="onChange('plus')"></vd-button>
18
- </div>
19
- </template>
20
-
21
- <script>
22
- import VdButton from '../button';
23
- import languageMixin from '../mixins/languageMixin.js';
24
-
25
- const prefixCls = 'vd-stepper';
26
- export default {
27
- mixins: [languageMixin],
28
- components: {
29
- VdButton,
30
- },
31
- name: 'vd-stepper',
32
- props: {
33
- value: null,
34
- integer: Boolean,
35
- position: String,
36
- inputCenter: Boolean,
37
- disabled: Boolean,
38
- theme: String,
39
- min: {
40
- type: [String, Number],
41
- default: 1
42
- },
43
- max: {
44
- type: [String, Number],
45
- default: Infinity
46
- },
47
- step: {
48
- type: [String, Number],
49
- default: 1
50
- },
51
- placeholder: String
52
- },
53
- data() {
54
- let value;
55
- if (this.isDef(this.value)) {
56
- value = this.range(this.value);
57
- if (value !== this.value) {
58
- this.$emit('input', value);
59
- }
60
- } else {
61
- value = '';
62
- }
63
- return {
64
- currentValue: value,
65
- };
66
- },
67
- computed: {
68
- inputClasses() {
69
- return [
70
- `${prefixCls}-input`,
71
- ]
72
- },
73
- wrapClasses() {
74
- return [
75
- {
76
- [`${prefixCls}--disabled`]: this.disabled,
77
- [`${prefixCls}--${this.theme}`]: this.theme,
78
- [`${prefixCls}--center`]: this.inputCenter
79
- }
80
- ]
81
- },
82
- minusButtonClass() {
83
- const hairlineClass = this.language === 'ar' ? 'vd-hairline--left' : 'vd-hairline--right';
84
- return `vd-stepper__minus ${hairlineClass}`;
85
- },
86
- plusButtonClass() {
87
- const hairlineClass = this.language === 'ar' ? 'vd-hairline--right' : 'vd-hairline--left';
88
- return `vd-stepper__plus ${hairlineClass}`;
89
- }
90
- },
91
- watch: {
92
- value(val) {
93
- if (val !== this.currentValue) {
94
- this.currentValue = this.format(val);
95
- }
96
- },
97
- currentValue(val) {
98
- this.$emit('input', val);
99
- this.$emit('change', val);
100
- }
101
- },
102
- methods: {
103
- format(value) {
104
- if (value === '' || value === null || value === undefined) {
105
- return '';
106
- }
107
- value = String(value).replace(/[^0-9.-]/g, '');
108
- return this.integer ? Math.floor(value) : +value;
109
- },
110
- // limit value range
111
- range(value) {
112
- value = this.format(value);
113
- if (value === '') {
114
- return value;
115
- }
116
- return Math.max(Math.min(this.max, value), this.min);
117
- },
118
- onInput(event) {
119
- const { value } = event.target;
120
- const formatted = this.format(value);
121
- if (value !== String(formatted)) {
122
- event.target.value = formatted;
123
- }
124
- this.currentValue = formatted;
125
- },
126
- onChange(type) {
127
- if (this[`${type}Disabled`]) {
128
- this.$emit('overlimit', type);
129
- return;
130
- }
131
- const diff = type === 'minus' ? -this.step : +this.step;
132
- let value = this.currentValue === '' ? 0 : this.currentValue;
133
- value = Math.round((value + diff) * 100) / 100;
134
- this.currentValue = this.range(value);
135
- this.$emit(type);
136
- },
137
- onBlur(event) {
138
- this.currentValue = this.range(this.currentValue);
139
- this.$emit('blur', event);
140
- },
141
- isDef(value) {
142
- return value !== undefined && value !== null;
143
- }
144
- }
145
- }
146
- </script>
1
+ <template>
2
+ <div class="vd-stepper" :class="wrapClasses">
3
+ <vd-button v-if="!position" :class="minusButtonClass" icon="icon_btn_reduce" size="small"
4
+ @click="onChange('minus')"></vd-button>
5
+ <input
6
+ type="number"
7
+ :class="inputClasses"
8
+ :disabled="disabled"
9
+ :value="currentValue"
10
+ :placeholder="placeholder"
11
+ @input="onInput"
12
+ @blur="onBlur"
13
+ >
14
+ <vd-button v-if="position === 'right'" class="vd-stepper__minus" icon="icon_btn_reduce" size="small"
15
+ @click="onChange('minus')"></vd-button>
16
+ <vd-button :class="plusButtonClass" icon="icon_btn_add" size="small"
17
+ @click="onChange('plus')"></vd-button>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ import VdButton from '../button';
23
+ import languageMixin from '../mixins/languageMixin.js';
24
+
25
+ const prefixCls = 'vd-stepper';
26
+ export default {
27
+ mixins: [languageMixin],
28
+ components: {
29
+ VdButton,
30
+ },
31
+ name: 'vd-stepper',
32
+ props: {
33
+ value: null,
34
+ integer: Boolean,
35
+ position: String,
36
+ inputCenter: Boolean,
37
+ disabled: Boolean,
38
+ theme: String,
39
+ min: {
40
+ type: [String, Number],
41
+ default: 1
42
+ },
43
+ max: {
44
+ type: [String, Number],
45
+ default: Infinity
46
+ },
47
+ step: {
48
+ type: [String, Number],
49
+ default: 1
50
+ },
51
+ placeholder: String
52
+ },
53
+ data() {
54
+ let value;
55
+ if (this.isDef(this.value)) {
56
+ value = this.range(this.value);
57
+ if (value !== this.value) {
58
+ this.$emit('input', value);
59
+ }
60
+ } else {
61
+ value = '';
62
+ }
63
+ return {
64
+ currentValue: value,
65
+ };
66
+ },
67
+ computed: {
68
+ inputClasses() {
69
+ return [
70
+ `${prefixCls}-input`,
71
+ ]
72
+ },
73
+ wrapClasses() {
74
+ return [
75
+ {
76
+ [`${prefixCls}--disabled`]: this.disabled,
77
+ [`${prefixCls}--${this.theme}`]: this.theme,
78
+ [`${prefixCls}--center`]: this.inputCenter
79
+ }
80
+ ]
81
+ },
82
+ minusButtonClass() {
83
+ const hairlineClass = this.language === 'ar' ? 'vd-hairline--left' : 'vd-hairline--right';
84
+ return `vd-stepper__minus ${hairlineClass}`;
85
+ },
86
+ plusButtonClass() {
87
+ const hairlineClass = this.language === 'ar' ? 'vd-hairline--right' : 'vd-hairline--left';
88
+ return `vd-stepper__plus ${hairlineClass}`;
89
+ }
90
+ },
91
+ watch: {
92
+ value(val) {
93
+ if (val !== this.currentValue) {
94
+ this.currentValue = this.format(val);
95
+ }
96
+ },
97
+ currentValue(val) {
98
+ this.$emit('input', val);
99
+ this.$emit('change', val);
100
+ }
101
+ },
102
+ methods: {
103
+ format(value) {
104
+ if (value === '' || value === null || value === undefined) {
105
+ return '';
106
+ }
107
+ value = String(value).replace(/[^0-9.-]/g, '');
108
+ return this.integer ? Math.floor(value) : +value;
109
+ },
110
+ // limit value range
111
+ range(value) {
112
+ value = this.format(value);
113
+ if (value === '') {
114
+ return value;
115
+ }
116
+ return Math.max(Math.min(this.max, value), this.min);
117
+ },
118
+ onInput(event) {
119
+ const { value } = event.target;
120
+ const formatted = this.format(value);
121
+ if (value !== String(formatted)) {
122
+ event.target.value = formatted;
123
+ }
124
+ this.currentValue = formatted;
125
+ },
126
+ onChange(type) {
127
+ if (this[`${type}Disabled`]) {
128
+ this.$emit('overlimit', type);
129
+ return;
130
+ }
131
+ const diff = type === 'minus' ? -this.step : +this.step;
132
+ let value = this.currentValue === '' ? 0 : this.currentValue;
133
+ value = Math.round((value + diff) * 100) / 100;
134
+ this.currentValue = this.range(value);
135
+ this.$emit(type);
136
+ },
137
+ onBlur(event) {
138
+ this.currentValue = this.range(this.currentValue);
139
+ this.$emit('blur', event);
140
+ },
141
+ isDef(value) {
142
+ return value !== undefined && value !== null;
143
+ }
144
+ }
145
+ }
146
+ </script>
@@ -1,42 +1,42 @@
1
- <template>
2
- <div>
3
- <h2>默认包含了一些常用样式,可以直接通过 className 的方式使用,样式文件在packages/tokens/style.less里面</h2>
4
-
5
-
6
- <h3>文字省略</h3>
7
-
8
- <!-- 最多显示一行 -->
9
- <div class="vd-ellipsis">这是一段最多显示一行的文字,多余的内容会被省略</div>
10
-
11
- <!-- 最多显示两行 -->
12
- <div class="vd-multi-ellipsis--l2">
13
- 这是一段最多显示两行的文字,多余的内容会被省略
14
- </div>
15
-
16
- <!-- 最多显示三行 -->
17
- <div class="vd-multi-ellipsis--l3">
18
- 这是一段最多显示三行的文字,多余的内容会被省略
19
- </div>
20
-
21
- <h3>1px 边框</h3>
22
-
23
- <!-- 上边框 -->
24
- <div class="vd-hairline--top"></div>
25
-
26
- <!-- 下边框 -->
27
- <div class="vd-hairline--bottom"></div>
28
-
29
- <!-- 左边框 -->
30
- <div class="vd-hairline--left"></div>
31
-
32
- <!-- 右边框 -->
33
- <div class="vd-hairline--right"></div>
34
-
35
- <!-- 上下边框 -->
36
- <div class="vd-hairline--top-bottom"></div>
37
-
38
- <!-- 全边框 -->
39
- <div class="vd-hairline--surround"></div>
40
- </div>
41
- </template>
42
-
1
+ <template>
2
+ <div>
3
+ <h2>默认包含了一些常用样式,可以直接通过 className 的方式使用,样式文件在packages/tokens/style.less里面</h2>
4
+
5
+
6
+ <h3>文字省略</h3>
7
+
8
+ <!-- 最多显示一行 -->
9
+ <div class="vd-ellipsis">这是一段最多显示一行的文字,多余的内容会被省略</div>
10
+
11
+ <!-- 最多显示两行 -->
12
+ <div class="vd-multi-ellipsis--l2">
13
+ 这是一段最多显示两行的文字,多余的内容会被省略
14
+ </div>
15
+
16
+ <!-- 最多显示三行 -->
17
+ <div class="vd-multi-ellipsis--l3">
18
+ 这是一段最多显示三行的文字,多余的内容会被省略
19
+ </div>
20
+
21
+ <h3>1px 边框</h3>
22
+
23
+ <!-- 上边框 -->
24
+ <div class="vd-hairline--top"></div>
25
+
26
+ <!-- 下边框 -->
27
+ <div class="vd-hairline--bottom"></div>
28
+
29
+ <!-- 左边框 -->
30
+ <div class="vd-hairline--left"></div>
31
+
32
+ <!-- 右边框 -->
33
+ <div class="vd-hairline--right"></div>
34
+
35
+ <!-- 上下边框 -->
36
+ <div class="vd-hairline--top-bottom"></div>
37
+
38
+ <!-- 全边框 -->
39
+ <div class="vd-hairline--surround"></div>
40
+ </div>
41
+ </template>
42
+
@@ -1,8 +1,8 @@
1
- import Switch from './index.vue';
2
- import './style.less';
3
-
4
- Switch.install = function (Vue) {
5
- Vue.component(Switch.name, Switch);
6
- };
7
-
8
- export default Switch;
1
+ import Switch from './index.vue';
2
+ import './style.less';
3
+
4
+ Switch.install = function (Vue) {
5
+ Vue.component(Switch.name, Switch);
6
+ };
7
+
8
+ export default Switch;
@@ -1,72 +1,72 @@
1
- <template>
2
- <!-- 开关 -->
3
- <div class="vd-switch" :class="{ 'vd-switch-on': isActived }" :disabled="disabled" @click="handleClick">
4
- <span class="vd-switch-round"></span>
5
- </div>
6
- </template>
7
- <script>
8
- export default {
9
- name: 'vd-switch',
10
- props: {
11
- /**
12
- * v-model 绑定值
13
- */
14
- value: {
15
- type: Boolean,
16
- default: false
17
- },
18
- /**
19
- * 异步状态
20
- */
21
- async: {
22
- type: Boolean,
23
- default: false
24
- },
25
- /**
26
- * 禁用状态
27
- */
28
- disabled: {
29
- type: Boolean,
30
- default: false
31
- }
32
- },
33
- data() {
34
- return {
35
- /**
36
- * 激活状态
37
- */
38
- isActived: this.value
39
- }
40
- },
41
- methods: {
42
- /**
43
- * 点击 Switch 开关
44
- */
45
- handleClick() {
46
- const { disabled, async, isActived } = this
47
- /**
48
- * 判断是否被禁用
49
- */
50
- if (!disabled) {
51
- /**
52
- * 判断是否异步
53
- */
54
- !async && this.$emit('input', !isActived)
55
- this.$emit('on-click')
56
- // element.style.setProperty('--primary-color', 'blue');
57
- }
58
- },
59
- },
60
- watch: {
61
- /**
62
- * 监听 value 的值
63
- */
64
- value(value) {
65
- this.isActived = value
66
- }
67
- }
68
- }
69
- </script>
70
- <style lang="less">
71
- @import './style.less';
72
- </style>
1
+ <template>
2
+ <!-- 开关 -->
3
+ <div class="vd-switch" :class="{ 'vd-switch-on': isActived }" :disabled="disabled" @click="handleClick">
4
+ <span class="vd-switch-round"></span>
5
+ </div>
6
+ </template>
7
+ <script>
8
+ export default {
9
+ name: 'vd-switch',
10
+ props: {
11
+ /**
12
+ * v-model 绑定值
13
+ */
14
+ value: {
15
+ type: Boolean,
16
+ default: false
17
+ },
18
+ /**
19
+ * 异步状态
20
+ */
21
+ async: {
22
+ type: Boolean,
23
+ default: false
24
+ },
25
+ /**
26
+ * 禁用状态
27
+ */
28
+ disabled: {
29
+ type: Boolean,
30
+ default: false
31
+ }
32
+ },
33
+ data() {
34
+ return {
35
+ /**
36
+ * 激活状态
37
+ */
38
+ isActived: this.value
39
+ }
40
+ },
41
+ methods: {
42
+ /**
43
+ * 点击 Switch 开关
44
+ */
45
+ handleClick() {
46
+ const { disabled, async, isActived } = this
47
+ /**
48
+ * 判断是否被禁用
49
+ */
50
+ if (!disabled) {
51
+ /**
52
+ * 判断是否异步
53
+ */
54
+ !async && this.$emit('input', !isActived)
55
+ this.$emit('on-click')
56
+ // element.style.setProperty('--primary-color', 'blue');
57
+ }
58
+ },
59
+ },
60
+ watch: {
61
+ /**
62
+ * 监听 value 的值
63
+ */
64
+ value(value) {
65
+ this.isActived = value
66
+ }
67
+ }
68
+ }
69
+ </script>
70
+ <style lang="less">
71
+ @import './style.less';
72
+ </style>
@@ -1,56 +1,56 @@
1
- @prefix: ~"vd-switch";
2
-
3
- .@{prefix} {
4
- display: inline-block;
5
- position: relative;
6
- box-sizing: border-box;
7
- width: var(--width-switch-bg);
8
- height: var(--height-switch-bg);
9
- border-radius: var(--radius-switch-bg);
10
- background: var(--color-switch-off_bg-default);
11
- cursor: pointer;
12
-
13
- &-round {
14
- box-sizing: border-box;
15
- position: absolute;
16
- top: calc(var(--height-switch-bg) * -0.5);
17
- left: 0;
18
- transition: transform .3s;
19
- width: var(--height-switch-button);
20
- height: var(--height-switch-button);
21
- border-radius: var(--radius-switch-button);
22
- border: 1px solid var(--color-switch-off_button_border-default);
23
- background: var(--color-switch-off_button_bg-default);
24
- }
25
-
26
- &-on {
27
- border-color: var(--color-switch-on_button_border-default);
28
- background: var(--color-switch-on_bg-default);
29
-
30
- .@{prefix}-round {
31
- transform: translateX(var(--height-switch-button));
32
- background: var(--color-switch-on_button_bg-default);
33
- }
34
- }
35
-
36
- &[disabled] {
37
- border-color: var(--color-switch-off_button_border-disable);
38
- background: var(--color-switch-off_bg-disable);
39
-
40
- .@{prefix}-round {
41
- background: var(--color-switch-off_button_bg-disable);
42
- border-color: var(--color-switch-off_button_border-disable);
43
- }
44
- }
45
-
46
- // 选中&&禁用
47
- &-on[disabled] {
48
- border-color: var(--color-switch-on_button_border-disable);
49
- background: var(--color-switch-on_bg-disable);
50
-
51
- .@{prefix}-round {
52
- background: var(--color-switch-on_button_bg-disable);
53
- border-color: var(--color-switch-on_button_border-disable);
54
- }
55
- }
56
- }
1
+ @prefix: ~"vd-switch";
2
+
3
+ .@{prefix} {
4
+ display: inline-block;
5
+ position: relative;
6
+ box-sizing: border-box;
7
+ width: var(--width-switch-bg);
8
+ height: var(--height-switch-bg);
9
+ border-radius: var(--radius-switch-bg);
10
+ background: var(--color-switch-off_bg-default);
11
+ cursor: pointer;
12
+
13
+ &-round {
14
+ box-sizing: border-box;
15
+ position: absolute;
16
+ top: calc(var(--height-switch-bg) * -0.5);
17
+ left: 0;
18
+ transition: transform .3s;
19
+ width: var(--height-switch-button);
20
+ height: var(--height-switch-button);
21
+ border-radius: var(--radius-switch-button);
22
+ border: 1px solid var(--color-switch-off_button_border-default);
23
+ background: var(--color-switch-off_button_bg-default);
24
+ }
25
+
26
+ &-on {
27
+ border-color: var(--color-switch-on_button_border-default);
28
+ background: var(--color-switch-on_bg-default);
29
+
30
+ .@{prefix}-round {
31
+ transform: translateX(var(--height-switch-button));
32
+ background: var(--color-switch-on_button_bg-default);
33
+ }
34
+ }
35
+
36
+ &[disabled] {
37
+ border-color: var(--color-switch-off_button_border-disable);
38
+ background: var(--color-switch-off_bg-disable);
39
+
40
+ .@{prefix}-round {
41
+ background: var(--color-switch-off_button_bg-disable);
42
+ border-color: var(--color-switch-off_button_border-disable);
43
+ }
44
+ }
45
+
46
+ // 选中&&禁用
47
+ &-on[disabled] {
48
+ border-color: var(--color-switch-on_button_border-disable);
49
+ background: var(--color-switch-on_bg-disable);
50
+
51
+ .@{prefix}-round {
52
+ background: var(--color-switch-on_button_bg-disable);
53
+ border-color: var(--color-switch-on_button_border-disable);
54
+ }
55
+ }
56
+ }