vdesign-ui 0.1.9 → 0.1.11

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 (165) hide show
  1. package/dist/components/actionbar/actionbar-cell/index.vue +34 -0
  2. package/dist/components/actionbar/index.js +8 -0
  3. package/dist/components/actionbar/index.vue +39 -0
  4. package/dist/components/actionbar/style.less +48 -0
  5. package/dist/components/actions-cell/actions/index.js +7 -0
  6. package/dist/components/actions-cell/actions/index.vue +67 -0
  7. package/dist/components/actions-cell/actions/style.less +75 -0
  8. package/dist/components/actions-cell/index.js +7 -0
  9. package/dist/components/actions-cell/index.vue +94 -0
  10. package/dist/components/actions-cell/style.less +39 -0
  11. package/dist/components/activityviews/index.js +8 -0
  12. package/dist/components/activityviews/index.vue +110 -0
  13. package/dist/components/activityviews/style.less +146 -0
  14. package/dist/components/badge/index.js +8 -0
  15. package/dist/components/badge/index.vue +49 -0
  16. package/dist/components/badge/style.less +66 -0
  17. package/dist/components/button/index.js +8 -0
  18. package/dist/components/button/index.vue +89 -0
  19. package/dist/components/button/style.less +563 -0
  20. package/dist/components/calendar/end.png +0 -0
  21. package/dist/components/calendar/index-element.vue +84 -0
  22. package/dist/components/calendar/index.js +8 -0
  23. package/dist/components/calendar/index.vue +52 -0
  24. package/dist/components/calendar/start.png +0 -0
  25. package/dist/components/calendar/style.less +167 -0
  26. package/dist/components/checkbox/assist.js +34 -0
  27. package/dist/components/checkbox/checkbox-group/index.js +8 -0
  28. package/dist/components/checkbox/checkbox-group/index.vue +69 -0
  29. package/dist/components/checkbox/index.js +8 -0
  30. package/dist/components/checkbox/index.vue +184 -0
  31. package/dist/components/checkbox/style.less +289 -0
  32. package/dist/components/common/state/index.vue +80 -0
  33. package/dist/components/data-list/index.js +10 -0
  34. package/dist/components/data-list/index.vue +19 -0
  35. package/dist/components/data-list/style.less +624 -0
  36. package/dist/components/datetime-picker/index.js +8 -0
  37. package/dist/components/datetime-picker/index.vue +37 -0
  38. package/dist/components/datetime-picker/style.less +25 -0
  39. package/dist/components/dialog/index copy.vue +112 -0
  40. package/dist/components/dialog/index.js +8 -0
  41. package/dist/components/dialog/index.vue +111 -0
  42. package/dist/components/dialog/style.less +122 -0
  43. package/dist/components/divider/index.js +8 -0
  44. package/dist/components/divider/index.vue +54 -0
  45. package/dist/components/divider/style.less +92 -0
  46. package/dist/components/dropdown/index.js +8 -0
  47. package/dist/components/dropdown/index.vue +210 -0
  48. package/dist/components/dropdown/style.less +402 -0
  49. package/dist/components/empty/empty-404.png +0 -0
  50. package/dist/components/empty/empty-img.png +0 -0
  51. package/dist/components/empty/empty-network.png +0 -0
  52. package/dist/components/empty/index.js +8 -0
  53. package/dist/components/empty/index.vue +65 -0
  54. package/dist/components/empty/style.less +53 -0
  55. package/dist/components/footer/index.js +7 -0
  56. package/dist/components/footer/index.vue +29 -0
  57. package/dist/components/footer/style.less +22 -0
  58. package/dist/components/footnav/footnav-item/index.js +7 -0
  59. package/dist/components/footnav/footnav-item/index.vue +75 -0
  60. package/dist/components/footnav/footnav-item/style.less +38 -0
  61. package/dist/components/footnav/index.js +7 -0
  62. package/dist/components/footnav/index.vue +82 -0
  63. package/dist/components/footnav/style.less +22 -0
  64. package/dist/components/form/index.js +7 -0
  65. package/dist/components/form/index.vue +12 -0
  66. package/dist/components/headnav/index.js +7 -0
  67. package/dist/components/headnav/index.vue +139 -0
  68. package/dist/components/headnav/style.less +232 -0
  69. package/dist/components/icon/font/iconfont.css +817 -0
  70. package/dist/components/icon/font/iconfont.js +2 -0
  71. package/dist/components/icon/index.js +9 -0
  72. package/dist/components/icon/index.vue +46 -0
  73. package/dist/components/icon/style.less +44 -0
  74. package/dist/components/input/calcTextareaHeight.js +266 -0
  75. package/dist/components/input/index.js +8 -0
  76. package/dist/components/input/index.vue +334 -0
  77. package/dist/components/input/password/index.js +8 -0
  78. package/dist/components/input/password/index.vue +60 -0
  79. package/dist/components/input/search/index.js +8 -0
  80. package/dist/components/input/search/index.vue +64 -0
  81. package/dist/components/input/stepper/index.js +8 -0
  82. package/dist/components/input/stepper/index.vue +136 -0
  83. package/dist/components/input/style.less +482 -0
  84. package/dist/components/list/index.js +8 -0
  85. package/dist/components/list/index.vue +159 -0
  86. package/dist/components/list/style.less +290 -0
  87. package/dist/components/loading/index.js +7 -0
  88. package/dist/components/loading/index.vue +53 -0
  89. package/dist/components/loading/loading.png +0 -0
  90. package/dist/components/loading/refresh.png +0 -0
  91. package/dist/components/loading/style.less +48 -0
  92. package/dist/components/mixins/clickoutside.js +81 -0
  93. package/dist/components/mixins/dom.js +41 -0
  94. package/dist/components/mixins/languageMixin.js +38 -0
  95. package/dist/components/mixins/outlineConfigPlugin.js +40 -0
  96. package/dist/components/mixins/router-link.js +23 -0
  97. package/dist/components/noticebar/index.js +8 -0
  98. package/dist/components/noticebar/index.vue +246 -0
  99. package/dist/components/noticebar/style.less +309 -0
  100. package/dist/components/overlay/index.js +8 -0
  101. package/dist/components/overlay/index.vue +161 -0
  102. package/dist/components/overlay/style.less +23 -0
  103. package/dist/components/pagebreak/index.js +7 -0
  104. package/dist/components/pagebreak/index.vue +60 -0
  105. package/dist/components/pagebreak/style.less +43 -0
  106. package/dist/components/popover/index.js +8 -0
  107. package/dist/components/popover/index.vue +99 -0
  108. package/dist/components/popover/style.less +349 -0
  109. package/dist/components/popover/vue-popover.vue +314 -0
  110. package/dist/components/radio/assist.js +34 -0
  111. package/dist/components/radio/index.js +8 -0
  112. package/dist/components/radio/index.vue +159 -0
  113. package/dist/components/radio/radio-group/index.vue +70 -0
  114. package/dist/components/radio/style.less +297 -0
  115. package/dist/components/result/completed.png +0 -0
  116. package/dist/components/result/error.png +0 -0
  117. package/dist/components/result/index.js +8 -0
  118. package/dist/components/result/index.vue +47 -0
  119. package/dist/components/result/style.less +42 -0
  120. package/dist/components/result/wait.png +0 -0
  121. package/dist/components/selector/index.js +8 -0
  122. package/dist/components/selector/index.vue +124 -0
  123. package/dist/components/selector/style.less +474 -0
  124. package/dist/components/skeleton/index.js +7 -0
  125. package/dist/components/skeleton/index.vue +134 -0
  126. package/dist/components/skeleton/style.less +192 -0
  127. package/dist/components/slider/draggable.js +49 -0
  128. package/dist/components/slider/index.js +7 -0
  129. package/dist/components/slider/index.vue +173 -0
  130. package/dist/components/slider/style.less +95 -0
  131. package/dist/components/slider/utils.js +60 -0
  132. package/dist/components/step/index.js +7 -0
  133. package/dist/components/step/index.vue +48 -0
  134. package/dist/components/step/style.less +59 -0
  135. package/dist/components/step-item/index.js +7 -0
  136. package/dist/components/step-item/index.vue +89 -0
  137. package/dist/components/step-item/style.less +361 -0
  138. package/dist/components/style/index.vue +42 -0
  139. package/dist/components/switch/index.js +8 -0
  140. package/dist/components/switch/index.vue +72 -0
  141. package/dist/components/switch/style.less +54 -0
  142. package/dist/components/tabs/index.js +8 -0
  143. package/dist/components/tabs/index.vue +185 -0
  144. package/dist/components/tabs/style.less +383 -0
  145. package/dist/components/tabs/tab/index.vue +52 -0
  146. package/dist/components/tag/index.js +7 -0
  147. package/dist/components/tag/index.vue +50 -0
  148. package/dist/components/tag/style.less +211 -0
  149. package/dist/components/title/index.js +8 -0
  150. package/dist/components/title/index.vue +92 -0
  151. package/dist/components/title/style.less +188 -0
  152. package/dist/components/toast/index.js +80 -0
  153. package/dist/components/toast/index.vue +44 -0
  154. package/dist/components/toast/style.less +55 -0
  155. package/dist/components/transition/index.js +8 -0
  156. package/dist/components/transition/index.vue +13 -0
  157. package/dist/components/transition/style.less +208 -0
  158. package/dist/components/upload/index.js +7 -0
  159. package/dist/components/upload/index.vue +224 -0
  160. package/dist/components/upload/style.less +156 -0
  161. package/dist/vdesign-ui.common.js +182 -238
  162. package/dist/vdesign-ui.css +1 -1
  163. package/dist/vdesign-ui.umd.js +182 -238
  164. package/dist/vdesign-ui.umd.min.js +3 -3
  165. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ .vd-iconfont {
2
+ display: inline-block;
3
+ background-size: contain;
4
+ fill: currentColor;
5
+ backface-visibility: hidden;
6
+ transform: translateZ(0) scale(1, 1);
7
+ // font-family: "Icon" !important;
8
+ font-size: calc(var(--icon-medium) * 1px);
9
+ font-style: normal;
10
+ font-weight: normal;
11
+ font-variant: normal;
12
+ text-transform: none;
13
+ line-height: 1;
14
+ letter-spacing: 0;
15
+ -webkit-font-smoothing: antialiased;
16
+ -moz-osx-font-smoothing: grayscale;
17
+ }
18
+
19
+ .vd-svg-icon {
20
+ width: 1em;
21
+ height: 1em;
22
+ vertical-align: -0.15em;
23
+ fill: currentColor;
24
+ overflow: hidden;
25
+ }
26
+
27
+ .vd-img-icon {
28
+ display: block;
29
+ width: 1em;
30
+ height: 1em;
31
+ object-fit: contain;
32
+ }
33
+
34
+ .vd-icon-small {
35
+ font-size: calc(var(--icon-small) * 1px);
36
+ }
37
+
38
+ .vd-icon-medium {
39
+ font-size: calc(var(--icon-medium) * 1px);
40
+ }
41
+
42
+ .vd-icon-large {
43
+ font-size: calc(var(--icon-large) * 1px);
44
+ }
@@ -0,0 +1,266 @@
1
+ // Thanks to
2
+ // https://github.com/andreypopp/react-textarea-autosize/
3
+
4
+ // let hiddenTextarea;
5
+ //
6
+ // const HIDDEN_STYLE = `
7
+ // height:0 !important;
8
+ // min-height:0 !important;
9
+ // max-height:none !important;
10
+ // visibility:hidden !important;
11
+ // overflow:hidden !important;
12
+ // position:absolute !important;
13
+ // z-index:-1000 !important;
14
+ // top:0 !important;
15
+ // right:0 !important
16
+ // `;
17
+ //
18
+ // const CONTEXT_STYLE = [
19
+ // 'letter-spacing',
20
+ // 'line-height',
21
+ // 'padding-top',
22
+ // 'padding-bottom',
23
+ // 'font-family',
24
+ // 'font-weight',
25
+ // 'font-size',
26
+ // 'text-rendering',
27
+ // 'text-transform',
28
+ // 'width',
29
+ // 'text-indent',
30
+ // 'padding-left',
31
+ // 'padding-right',
32
+ // 'border-width',
33
+ // 'box-sizing'
34
+ // ];
35
+ //
36
+ // function calculateNodeStyling(node) {
37
+ // const style = window.getComputedStyle(node);
38
+ //
39
+ // const boxSizing = style.getPropertyValue('box-sizing');
40
+ //
41
+ // const paddingSize = (
42
+ // parseFloat(style.getPropertyValue('padding-bottom')) +
43
+ // parseFloat(style.getPropertyValue('padding-top'))
44
+ // );
45
+ //
46
+ // const borderSize = (
47
+ // parseFloat(style.getPropertyValue('border-bottom-width')) +
48
+ // parseFloat(style.getPropertyValue('border-top-width'))
49
+ // );
50
+ //
51
+ // const contextStyle = CONTEXT_STYLE
52
+ // .map(name => `${name}:${style.getPropertyValue(name)}`)
53
+ // .join(';');
54
+ //
55
+ // return {contextStyle, paddingSize, borderSize, boxSizing};
56
+ // }
57
+ //
58
+ // export default function calcTextareaHeight(targetNode, minRows = null, maxRows = null) {
59
+ // if (!hiddenTextarea) {
60
+ // hiddenTextarea = document.createElement('textarea');
61
+ // document.body.appendChild(hiddenTextarea);
62
+ // }
63
+ //
64
+ // let {
65
+ // paddingSize,
66
+ // borderSize,
67
+ // boxSizing,
68
+ // contextStyle
69
+ // } = calculateNodeStyling(targetNode);
70
+ //
71
+ // hiddenTextarea.setAttribute('style', `${contextStyle};${HIDDEN_STYLE}`);
72
+ // hiddenTextarea.value = targetNode.value || targetNode.placeholder || '';
73
+ //
74
+ // let height = hiddenTextarea.scrollHeight;
75
+ // let minHeight = -Infinity;
76
+ // let maxHeight = Infinity;
77
+ // let overflowY;
78
+ //
79
+ // if (boxSizing === 'border-box') {
80
+ // height = height + borderSize;
81
+ // } else if (boxSizing === 'content-box') {
82
+ // height = height - paddingSize;
83
+ // }
84
+ //
85
+ // hiddenTextarea.value = '';
86
+ // let singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
87
+ //
88
+ // if (minRows !== null) {
89
+ // minHeight = singleRowHeight * minRows;
90
+ // if (boxSizing === 'border-box') {
91
+ // minHeight = minHeight + paddingSize + borderSize;
92
+ // }
93
+ // height = Math.max(minHeight, height);
94
+ // }
95
+ // if (maxRows !== null) {
96
+ // maxHeight = singleRowHeight * maxRows;
97
+ // if (boxSizing === 'border-box') {
98
+ // maxHeight = maxHeight + paddingSize + borderSize;
99
+ // }
100
+ // overflowY = height > maxHeight ? '' : 'hidden';
101
+ // height = Math.min(maxHeight, height);
102
+ // }
103
+ //
104
+ // if (!maxRows) {
105
+ // overflowY = 'hidden';
106
+ // }
107
+ //
108
+ // return {
109
+ // height: `${height}px`,
110
+ // minHeight: `${minHeight}px`,
111
+ // maxHeight: `${maxHeight}px`,
112
+ // overflowY
113
+ // };
114
+ // }
115
+
116
+ const HIDDEN_TEXTAREA_STYLE = `
117
+ min-height:0 !important;
118
+ max-height:none !important;
119
+ height:0 !important;
120
+ visibility:hidden !important;
121
+ overflow:hidden !important;
122
+ position:absolute !important;
123
+ z-index:-1000 !important;
124
+ top:0 !important;
125
+ right:0 !important
126
+ `;
127
+
128
+ const SIZING_STYLE = [
129
+ 'letter-spacing',
130
+ 'line-height',
131
+ 'padding-top',
132
+ 'padding-bottom',
133
+ 'font-family',
134
+ 'font-weight',
135
+ 'font-size',
136
+ 'text-rendering',
137
+ 'text-transform',
138
+ 'width',
139
+ 'text-indent',
140
+ 'padding-left',
141
+ 'padding-right',
142
+ 'border-width',
143
+ 'box-sizing',
144
+ ];
145
+
146
+ let computedStyleCache = {};
147
+ let hiddenTextarea;
148
+
149
+ function calculateNodeStyling(node, useCache = false) {
150
+ const nodeRef = (
151
+ node.getAttribute('id') ||
152
+ node.getAttribute('data-reactid') ||
153
+ node.getAttribute('name'));
154
+
155
+ if (useCache && computedStyleCache[nodeRef]) {
156
+ return computedStyleCache[nodeRef];
157
+ }
158
+
159
+ const style = window.getComputedStyle(node);
160
+
161
+ const boxSizing = (
162
+ style.getPropertyValue('box-sizing') ||
163
+ style.getPropertyValue('-moz-box-sizing') ||
164
+ style.getPropertyValue('-webkit-box-sizing')
165
+ );
166
+
167
+ const paddingSize = (
168
+ parseFloat(style.getPropertyValue('padding-bottom')) +
169
+ parseFloat(style.getPropertyValue('padding-top'))
170
+ );
171
+
172
+ const borderSize = (
173
+ parseFloat(style.getPropertyValue('border-bottom-width')) +
174
+ parseFloat(style.getPropertyValue('border-top-width'))
175
+ );
176
+
177
+ const sizingStyle = SIZING_STYLE
178
+ .map(name => `${name}:${style.getPropertyValue(name)}`)
179
+ .join(';');
180
+
181
+ const nodeInfo = {
182
+ sizingStyle,
183
+ paddingSize,
184
+ borderSize,
185
+ boxSizing,
186
+ };
187
+
188
+ if (useCache && nodeRef) {
189
+ computedStyleCache[nodeRef] = nodeInfo;
190
+ }
191
+
192
+ return nodeInfo;
193
+ }
194
+
195
+ export default function calcTextareaHeight(uiTextNode, minRows = null, maxRows = null, useCache = false) {
196
+ if (!hiddenTextarea) {
197
+ hiddenTextarea = document.createElement('textarea');
198
+ document.body.appendChild(hiddenTextarea);
199
+ }
200
+
201
+ // Fix wrap="off" issue
202
+ // https://github.com/ant-design/ant-design/issues/6577
203
+ if (uiTextNode.getAttribute('wrap')) {
204
+ hiddenTextarea.setAttribute('wrap', uiTextNode.getAttribute('wrap'));
205
+ } else {
206
+ hiddenTextarea.removeAttribute('wrap');
207
+ }
208
+
209
+ // Copy all CSS properties that have an impact on the height of the content in
210
+ // the textbox
211
+ let {
212
+ paddingSize, borderSize,
213
+ boxSizing, sizingStyle,
214
+ } = calculateNodeStyling(uiTextNode, useCache);
215
+
216
+ // Need to have the overflow attribute to hide the scrollbar otherwise
217
+ // text-lines will not calculated properly as the shadow will technically be
218
+ // narrower for content
219
+ hiddenTextarea.setAttribute('style', `${sizingStyle};${HIDDEN_TEXTAREA_STYLE}`);
220
+ hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';
221
+
222
+ let minHeight = Number.MIN_SAFE_INTEGER;
223
+ let maxHeight = Number.MAX_SAFE_INTEGER;
224
+ let height = hiddenTextarea.scrollHeight;
225
+ let overflowY;
226
+
227
+ if (boxSizing === 'border-box') {
228
+ // border-box: add border, since height = content + padding + border
229
+ height = height + borderSize;
230
+ } else if (boxSizing === 'content-box') {
231
+ // remove padding, since height = content
232
+ height = height - paddingSize;
233
+ }
234
+
235
+ if (minRows !== null || maxRows !== null) {
236
+ // measure height of a textarea with a single row
237
+ hiddenTextarea.value = ' ';
238
+ let singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
239
+ if (minRows !== null) {
240
+ minHeight = singleRowHeight * minRows;
241
+ if (boxSizing === 'border-box') {
242
+ minHeight = minHeight + paddingSize + borderSize;
243
+ }
244
+ height = Math.max(minHeight, height);
245
+ }
246
+ if (maxRows !== null) {
247
+ maxHeight = singleRowHeight * maxRows;
248
+ if (boxSizing === 'border-box') {
249
+ maxHeight = maxHeight + paddingSize + borderSize;
250
+ }
251
+ overflowY = height > maxHeight ? '' : 'hidden';
252
+ height = Math.min(maxHeight, height);
253
+ }
254
+ }
255
+ // Remove scroll bar flash when autosize without maxRows
256
+ if (!maxRows) {
257
+ overflowY = 'hidden';
258
+ }
259
+
260
+ return {
261
+ height: `${height}px`,
262
+ minHeight: `${minHeight}px`,
263
+ maxHeight: `${maxHeight}px`,
264
+ overflowY
265
+ };
266
+ }
@@ -0,0 +1,8 @@
1
+ import HInput from './index.vue';
2
+ import './style.less';
3
+
4
+ HInput.install = function (Vue) {
5
+ Vue.component(HInput.name, HInput);
6
+ };
7
+
8
+ export default HInput;
@@ -0,0 +1,334 @@
1
+ <template>
2
+ <div :class="wrapClasses" class="vd-input">
3
+ <template v-if="inputTextArea || type !== 'textarea'">
4
+ <span v-if="prefix || $slots.prefix" class="vd-input-form__prefix vd-hairline--right">
5
+ <slot name="prefix">{{ prefix }}</slot>
6
+ </span>
7
+ <input
8
+ v-if="!inputTextArea"
9
+ ref="input"
10
+ v-bind="$attrs"
11
+ :type="passwordIcon ? (passwordVisible ? 'text' : 'password') : type"
12
+ :class="inputClasses"
13
+ :disabled="disabled"
14
+ :placeholder="placeholder"
15
+ :value="currentValue"
16
+ @input="handleInput"
17
+ @focus="handleFocus"
18
+ @blur="handleBlur"
19
+ />
20
+
21
+ <textarea
22
+ v-else
23
+ ref="textarea"
24
+ v-bind="$attrs"
25
+ :id="elementId"
26
+ :wrap="wrap"
27
+ :type="type"
28
+ :rows="rows"
29
+ :class="inputClasses"
30
+ :disabled="disabled"
31
+ :placeholder="placeholder"
32
+ :value="currentValue"
33
+ @focus="handleFocus"
34
+ @blur="handleBlur"
35
+ @input="handleInput"
36
+ :style="textareaStyles"
37
+ >
38
+ </textarea>
39
+ <div
40
+ v-if="suffix || $slots.suffix || append || $slots.append || isWordLimitVisible"
41
+ class="vd-input-form__right"
42
+ >
43
+ <span v-if="suffix || $slots.suffix" class="vd-input-form__suffix">
44
+ <slot name="suffix">
45
+ <vd-icon name="icon_btn_clean" @click="handleClear"></vd-icon>
46
+ </slot>
47
+ </span>
48
+ <span v-if="append || $slots.append" class="vd-input-form__append">
49
+ <slot name="append">{{ append }}</slot>
50
+ </span>
51
+ <div
52
+ v-if="isWordLimitVisible"
53
+ :class="[
54
+ 'vd-input__word-limit',
55
+ { 'vd-input__word-limit--error': isOverLimit },
56
+ ]"
57
+ >
58
+ <span>{{ textLength }}</span
59
+ >/<span>{{ upperLimit }}</span>
60
+ </div>
61
+ </div>
62
+ <span
63
+ v-if="passwordClose || passwordIcon"
64
+ class="vd-input-form__password"
65
+ >
66
+ <span v-if="passwordClose" class="vd-input-form__password--close">
67
+ <vd-icon name="icon_btn_close" @click="handleClear"></vd-icon>
68
+ </span>
69
+ <span v-if="passwordIcon" class="vd-input-form__password--password">
70
+ <vd-icon
71
+ :name="passwordVisible ? 'icon_btn_eye' : 'icon_btn_eye_close'"
72
+ @click="handlePasswordVisible"
73
+ ></vd-icon>
74
+ </span>
75
+ </span>
76
+ </template>
77
+ <template v-else>
78
+ <textarea
79
+ ref="textarea"
80
+ :type="type"
81
+ v-bind="$attrs"
82
+ :wrap="wrap"
83
+ :class="inputClasses"
84
+ :disabled="disabled"
85
+ :placeholder="placeholder"
86
+ :value="currentValue"
87
+ :rows="rows"
88
+ :name="name"
89
+ @input="handleInput"
90
+ :style="textareaStyles"
91
+ >
92
+ </textarea>
93
+ <div
94
+ v-if="isWordLimitVisible"
95
+ :class="[
96
+ 'vd-input__word-limit',
97
+ { 'vd-input__word-limit--error': isOverLimit },
98
+ ]"
99
+ >
100
+ <span>{{ textLength }}</span
101
+ >/<span>{{ upperLimit }}</span>
102
+ </div>
103
+ </template>
104
+ </div>
105
+ </template>
106
+
107
+ <script>
108
+ import calcTextareaHeight from "./calcTextareaHeight";
109
+ const prefixCls = "vd-input";
110
+
111
+ export default {
112
+ name: "vd-input",
113
+ props: {
114
+ type: {
115
+ type: String,
116
+ default: "text",
117
+ },
118
+ prefix: {
119
+ type: [Boolean, String],
120
+ default: false,
121
+ },
122
+ suffix: {
123
+ type: [Boolean, String],
124
+ default: false,
125
+ },
126
+ // 设计如此,单独的文字
127
+ append: {
128
+ type: [Boolean, String],
129
+ default: false,
130
+ },
131
+ placeholder: {
132
+ type: String,
133
+ },
134
+ error: {
135
+ type: Boolean,
136
+ },
137
+ bigSize: {
138
+ type: Boolean,
139
+ },
140
+ passwordIcon: {
141
+ type: Boolean,
142
+ },
143
+ passwordClose: {
144
+ type: Boolean,
145
+ },
146
+ passwordType: {
147
+ type: String,
148
+ default: "icon_btn_eye_close",
149
+ },
150
+ form: {
151
+ type: String,
152
+ },
153
+ disabled: {
154
+ type: Boolean,
155
+ },
156
+ value: {
157
+ type: [String, Number],
158
+ default: "",
159
+ },
160
+ rows: {
161
+ type: Number,
162
+ default: 2,
163
+ },
164
+ name: {
165
+ type: String,
166
+ },
167
+ // 设计如此多行textarea,跟input属性一样
168
+ inputTextArea: {
169
+ type: Boolean,
170
+ },
171
+ warning: {
172
+ type: Boolean,
173
+ },
174
+ hairline: {
175
+ type: Boolean,
176
+ default: true,
177
+ },
178
+ autosize: {
179
+ type: [Boolean, Object],
180
+ default: false,
181
+ },
182
+ elementId: {
183
+ type: String,
184
+ },
185
+ wrap: {
186
+ type: String,
187
+ default: "soft",
188
+ },
189
+ // 新增0118
190
+ showWordLimit: {
191
+ type: Boolean,
192
+ default: false,
193
+ },
194
+ },
195
+ data() {
196
+ return {
197
+ focusClass: false,
198
+ currentValue: this.value,
199
+ isOnComposition: false,
200
+ textareaStyles: {},
201
+ passwordVisible: false,
202
+ };
203
+ },
204
+ computed: {
205
+ wrapClasses() {
206
+ return [
207
+ {
208
+ [`${prefixCls}-${this.form}`]: this.form,
209
+ [`${prefixCls}--disabled`]: this.disabled,
210
+ [`${prefixCls}-${this.type}`]: this.type,
211
+ [`${prefixCls}-${this.type}--warning`]: this.warning,
212
+ [`${prefixCls}--bigsize`]: this.bigSize,
213
+ [`${prefixCls}--error`]: this.error,
214
+ [`${prefixCls}--active`]: this.focusClass,
215
+ [`${prefixCls}-inputarea`]: this.inputTextArea,
216
+ "vd-hairline--bottom": this.hairline,
217
+ "vd-textarea-auto": this.inputTextArea,
218
+ },
219
+ ];
220
+ },
221
+ inputClasses() {
222
+ return [
223
+ `${prefixCls}__control`,
224
+ {
225
+ [`${prefixCls}-${this.type}__control`]: this.type,
226
+ },
227
+ ];
228
+ },
229
+ textLength() {
230
+ if (typeof this.value === "number") {
231
+ return String(this.value).length;
232
+ }
233
+ return (this.value || "").length;
234
+ },
235
+ upperLimit() {
236
+ return this.$attrs.maxlength;
237
+ },
238
+ isWordLimitVisible() {
239
+ return (
240
+ this.showWordLimit &&
241
+ this.$attrs.maxlength &&
242
+ (this.type === "text" || this.type === "textarea")
243
+ );
244
+ },
245
+ isOverLimit() {
246
+ return this.textLength >= this.upperLimit;
247
+ },
248
+ },
249
+ methods: {
250
+ handleFocus(event) {
251
+ if (this.form) {
252
+ this.focusClass = true;
253
+ }
254
+ this.$emit("focus", event);
255
+ },
256
+ handleBlur(event) {
257
+ if (this.form) {
258
+ this.focusClass = false;
259
+ }
260
+ this.$emit("blur", event);
261
+ },
262
+ focus() {
263
+ if (this.type === "textarea") {
264
+ this.$refs.textarea.focus();
265
+ } else {
266
+ this.$refs.input.focus();
267
+ }
268
+ },
269
+ blur() {
270
+ if (this.type === "textarea") {
271
+ this.$refs.textarea.blur();
272
+ } else {
273
+ this.$refs.input.blur();
274
+ }
275
+ },
276
+
277
+ handleInput(event) {
278
+ if (this.isOnComposition) return;
279
+ let value = event.target.value;
280
+ if (this.number && value !== "")
281
+ value = Number.isNaN(Number(value)) ? value : Number(value);
282
+ this.$emit("input", value);
283
+ this.setCurrentValue(value);
284
+ this.$emit("change", event);
285
+ },
286
+
287
+ setCurrentValue(value) {
288
+ if (value === this.currentValue) return;
289
+ this.$nextTick(() => {
290
+ this.resizeTextarea();
291
+ });
292
+ this.currentValue = value;
293
+ },
294
+ resizeTextarea() {
295
+ const autosize = this.autosize;
296
+ if (!autosize || this.type !== "textarea") {
297
+ return false;
298
+ }
299
+ const minRows = autosize.minRows;
300
+ const maxRows = autosize.maxRows;
301
+ this.textareaStyles = calcTextareaHeight(
302
+ this.$refs.textarea,
303
+ minRows,
304
+ maxRows
305
+ );
306
+ },
307
+ handleClear() {
308
+ const e = { target: { value: "" } };
309
+ this.$emit("input", "");
310
+ this.setCurrentValue("");
311
+ this.$emit("change", e);
312
+ this.$emit("clear");
313
+ },
314
+ handlePasswordVisible() {
315
+ this.passwordVisible = !this.passwordVisible;
316
+ this.$nextTick(() => {
317
+ this.focus();
318
+ });
319
+ },
320
+ },
321
+ watch: {
322
+ value(val) {
323
+ this.setCurrentValue(val);
324
+ },
325
+ },
326
+ mounted() {
327
+ this.resizeTextarea();
328
+ },
329
+ };
330
+ </script>
331
+
332
+ <style lang="less">
333
+ @import "./style.less";
334
+ </style>
@@ -0,0 +1,8 @@
1
+ import Password from './index.vue';
2
+ import './style.less';
3
+
4
+ Password.install = function (Vue) {
5
+ Vue.component(Password.name, Password);
6
+ };
7
+
8
+ export default Password;