vdesign-ui 0.1.9 → 0.1.10

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 +338 -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 +135 -187
  162. package/dist/vdesign-ui.css +1 -1
  163. package/dist/vdesign-ui.umd.js +135 -187
  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,338 @@
1
+ <template>
2
+ <div :class="wrapClasses" class="vd-input">
3
+ <template v-if="inputTextArea || type !== 'textarea'">
4
+ <span v-if="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 || append || isWordLimitVisible"
41
+ class="vd-input-form__right"
42
+ >
43
+ <span v-if="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" class="vd-input-form__append">
49
+ <slot name="appends">{{ 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
+ <slot name="passwordClose">
68
+ <vd-icon name="icon_btn_close" @click="handleClear"></vd-icon>
69
+ </slot>
70
+ </span>
71
+ <span v-if="passwordIcon" class="vd-input-form__password--password">
72
+ <slot name="passwordIcon">
73
+ <vd-icon
74
+ :name="passwordVisible ? 'icon_btn_eye' : 'icon_btn_eye_close'"
75
+ @click="handlePasswordVisible"
76
+ ></vd-icon>
77
+ </slot>
78
+ </span>
79
+ </span>
80
+ </template>
81
+ <template v-else>
82
+ <textarea
83
+ ref="textarea"
84
+ :type="type"
85
+ v-bind="$attrs"
86
+ :wrap="wrap"
87
+ :class="inputClasses"
88
+ :disabled="disabled"
89
+ :placeholder="placeholder"
90
+ :value="currentValue"
91
+ :rows="rows"
92
+ :name="name"
93
+ @input="handleInput"
94
+ :style="textareaStyles"
95
+ >
96
+ </textarea>
97
+ <div
98
+ v-if="isWordLimitVisible"
99
+ :class="[
100
+ 'vd-input__word-limit',
101
+ { 'vd-input__word-limit--error': isOverLimit },
102
+ ]"
103
+ >
104
+ <span>{{ textLength }}</span
105
+ >/<span>{{ upperLimit }}</span>
106
+ </div>
107
+ </template>
108
+ </div>
109
+ </template>
110
+
111
+ <script>
112
+ import calcTextareaHeight from "./calcTextareaHeight";
113
+ const prefixCls = "vd-input";
114
+
115
+ export default {
116
+ name: "vd-input",
117
+ props: {
118
+ type: {
119
+ type: String,
120
+ default: "text",
121
+ },
122
+ prefix: {
123
+ type: [Boolean, String],
124
+ default: false,
125
+ },
126
+ suffix: {
127
+ type: [Boolean, String],
128
+ default: false,
129
+ },
130
+ // 设计如此,单独的文字
131
+ append: {
132
+ type: [Boolean, String],
133
+ default: false,
134
+ },
135
+ placeholder: {
136
+ type: String,
137
+ },
138
+ error: {
139
+ type: Boolean,
140
+ },
141
+ bigSize: {
142
+ type: Boolean,
143
+ },
144
+ passwordIcon: {
145
+ type: Boolean,
146
+ },
147
+ passwordClose: {
148
+ type: Boolean,
149
+ },
150
+ passwordType: {
151
+ type: String,
152
+ default: "icon_btn_eye_close",
153
+ },
154
+ form: {
155
+ type: String,
156
+ },
157
+ disabled: {
158
+ type: Boolean,
159
+ },
160
+ value: {
161
+ type: [String, Number],
162
+ default: "",
163
+ },
164
+ rows: {
165
+ type: Number,
166
+ default: 2,
167
+ },
168
+ name: {
169
+ type: String,
170
+ },
171
+ // 设计如此多行textarea,跟input属性一样
172
+ inputTextArea: {
173
+ type: Boolean,
174
+ },
175
+ warning: {
176
+ type: Boolean,
177
+ },
178
+ hairline: {
179
+ type: Boolean,
180
+ default: true,
181
+ },
182
+ autosize: {
183
+ type: [Boolean, Object],
184
+ default: false,
185
+ },
186
+ elementId: {
187
+ type: String,
188
+ },
189
+ wrap: {
190
+ type: String,
191
+ default: "soft",
192
+ },
193
+ // 新增0118
194
+ showWordLimit: {
195
+ type: Boolean,
196
+ default: false,
197
+ },
198
+ },
199
+ data() {
200
+ return {
201
+ focusClass: false,
202
+ currentValue: this.value,
203
+ isOnComposition: false,
204
+ textareaStyles: {},
205
+ passwordVisible: false,
206
+ };
207
+ },
208
+ computed: {
209
+ wrapClasses() {
210
+ return [
211
+ {
212
+ [`${prefixCls}-${this.form}`]: this.form,
213
+ [`${prefixCls}--disabled`]: this.disabled,
214
+ [`${prefixCls}-${this.type}`]: this.type,
215
+ [`${prefixCls}-${this.type}--warning`]: this.warning,
216
+ [`${prefixCls}--bigsize`]: this.bigSize,
217
+ [`${prefixCls}--error`]: this.error,
218
+ [`${prefixCls}--active`]: this.focusClass,
219
+ [`${prefixCls}-inputarea`]: this.inputTextArea,
220
+ "vd-hairline--bottom": this.hairline,
221
+ "vd-textarea-auto": this.inputTextArea,
222
+ },
223
+ ];
224
+ },
225
+ inputClasses() {
226
+ return [
227
+ `${prefixCls}__control`,
228
+ {
229
+ [`${prefixCls}-${this.type}__control`]: this.type,
230
+ },
231
+ ];
232
+ },
233
+ textLength() {
234
+ if (typeof this.value === "number") {
235
+ return String(this.value).length;
236
+ }
237
+ return (this.value || "").length;
238
+ },
239
+ upperLimit() {
240
+ return this.$attrs.maxlength;
241
+ },
242
+ isWordLimitVisible() {
243
+ return (
244
+ this.showWordLimit &&
245
+ this.$attrs.maxlength &&
246
+ (this.type === "text" || this.type === "textarea")
247
+ );
248
+ },
249
+ isOverLimit() {
250
+ return this.textLength >= this.upperLimit;
251
+ },
252
+ },
253
+ methods: {
254
+ handleFocus(event) {
255
+ if (this.form) {
256
+ this.focusClass = true;
257
+ }
258
+ this.$emit("focus", event);
259
+ },
260
+ handleBlur(event) {
261
+ if (this.form) {
262
+ this.focusClass = false;
263
+ }
264
+ this.$emit("blur", event);
265
+ },
266
+ focus() {
267
+ if (this.type === "textarea") {
268
+ this.$refs.textarea.focus();
269
+ } else {
270
+ this.$refs.input.focus();
271
+ }
272
+ },
273
+ blur() {
274
+ if (this.type === "textarea") {
275
+ this.$refs.textarea.blur();
276
+ } else {
277
+ this.$refs.input.blur();
278
+ }
279
+ },
280
+
281
+ handleInput(event) {
282
+ if (this.isOnComposition) return;
283
+ let value = event.target.value;
284
+ if (this.number && value !== "")
285
+ value = Number.isNaN(Number(value)) ? value : Number(value);
286
+ this.$emit("input", value);
287
+ this.setCurrentValue(value);
288
+ this.$emit("change", event);
289
+ },
290
+
291
+ setCurrentValue(value) {
292
+ if (value === this.currentValue) return;
293
+ this.$nextTick(() => {
294
+ this.resizeTextarea();
295
+ });
296
+ this.currentValue = value;
297
+ },
298
+ resizeTextarea() {
299
+ const autosize = this.autosize;
300
+ if (!autosize || this.type !== "textarea") {
301
+ return false;
302
+ }
303
+ const minRows = autosize.minRows;
304
+ const maxRows = autosize.maxRows;
305
+ this.textareaStyles = calcTextareaHeight(
306
+ this.$refs.textarea,
307
+ minRows,
308
+ maxRows
309
+ );
310
+ },
311
+ handleClear() {
312
+ const e = { target: { value: "" } };
313
+ this.$emit("input", "");
314
+ this.setCurrentValue("");
315
+ this.$emit("change", e);
316
+ this.$emit("clear");
317
+ },
318
+ handlePasswordVisible() {
319
+ this.passwordVisible = !this.passwordVisible;
320
+ this.$nextTick(() => {
321
+ this.focus();
322
+ });
323
+ },
324
+ },
325
+ watch: {
326
+ value(val) {
327
+ this.setCurrentValue(val);
328
+ },
329
+ },
330
+ mounted() {
331
+ this.resizeTextarea();
332
+ },
333
+ };
334
+ </script>
335
+
336
+ <style lang="less">
337
+ @import "./style.less";
338
+ </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;