vdesign-ui 0.2.5 → 0.2.6

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 (195) hide show
  1. package/package.json +1 -1
  2. package/dist/components/actionbar/index.js +0 -8
  3. package/dist/components/actionbar/index.vue +0 -39
  4. package/dist/components/actionbar/style.less +0 -44
  5. package/dist/components/actionbar-cell/index.js +0 -7
  6. package/dist/components/actionbar-cell/index.vue +0 -38
  7. package/dist/components/actions/index.js +0 -7
  8. package/dist/components/actions/index.vue +0 -76
  9. package/dist/components/actions/style.less +0 -109
  10. package/dist/components/actions-cell/index.js +0 -7
  11. package/dist/components/actions-cell/index.vue +0 -94
  12. package/dist/components/actions-cell/style.less +0 -39
  13. package/dist/components/activityviews/index.js +0 -8
  14. package/dist/components/activityviews/index.vue +0 -192
  15. package/dist/components/activityviews/style.less +0 -152
  16. package/dist/components/badge/index.js +0 -8
  17. package/dist/components/badge/index.vue +0 -49
  18. package/dist/components/badge/style.less +0 -54
  19. package/dist/components/button/index.js +0 -8
  20. package/dist/components/button/index.vue +0 -93
  21. package/dist/components/button/style.less +0 -558
  22. package/dist/components/calendar/end.png +0 -0
  23. package/dist/components/calendar/index-element.vue +0 -84
  24. package/dist/components/calendar/index.js +0 -8
  25. package/dist/components/calendar/index.vue +0 -52
  26. package/dist/components/calendar/start.png +0 -0
  27. package/dist/components/calendar/style.less +0 -138
  28. package/dist/components/checkbox/index.js +0 -8
  29. package/dist/components/checkbox/index.vue +0 -161
  30. package/dist/components/checkbox/style.less +0 -289
  31. package/dist/components/checkbox-group/index.js +0 -7
  32. package/dist/components/checkbox-group/index.vue +0 -69
  33. package/dist/components/common/state/index.vue +0 -33
  34. package/dist/components/common/state/style.less +0 -48
  35. package/dist/components/data-list/index.js +0 -10
  36. package/dist/components/data-list/index.vue +0 -19
  37. package/dist/components/data-list/style.less +0 -623
  38. package/dist/components/datetime-picker/index.js +0 -8
  39. package/dist/components/datetime-picker/index.vue +0 -37
  40. package/dist/components/datetime-picker/style.less +0 -24
  41. package/dist/components/dialog/index.js +0 -8
  42. package/dist/components/dialog/index.vue +0 -164
  43. package/dist/components/dialog/overlay-manager.js +0 -18
  44. package/dist/components/dialog/style.less +0 -139
  45. package/dist/components/divider/index.js +0 -8
  46. package/dist/components/divider/index.vue +0 -54
  47. package/dist/components/divider/style.less +0 -92
  48. package/dist/components/dropdown/index.js +0 -8
  49. package/dist/components/dropdown/index.vue +0 -218
  50. package/dist/components/dropdown/style.less +0 -432
  51. package/dist/components/empty/404-dark.png +0 -0
  52. package/dist/components/empty/404.png +0 -0
  53. package/dist/components/empty/index.js +0 -8
  54. package/dist/components/empty/index.vue +0 -138
  55. package/dist/components/empty/network-dark.png +0 -0
  56. package/dist/components/empty/network.png +0 -0
  57. package/dist/components/empty/nocoupons-dark.png +0 -0
  58. package/dist/components/empty/nocoupons.png +0 -0
  59. package/dist/components/empty/nodata-dark.png +0 -0
  60. package/dist/components/empty/nodata.png +0 -0
  61. package/dist/components/empty/nomargin-dark.png +0 -0
  62. package/dist/components/empty/nomargin.png +0 -0
  63. package/dist/components/empty/nonotice-dark.png +0 -0
  64. package/dist/components/empty/nonotice.png +0 -0
  65. package/dist/components/empty/noocomments-dark.png +0 -0
  66. package/dist/components/empty/noocomments.png +0 -0
  67. package/dist/components/empty/noorders-dark.png +0 -0
  68. package/dist/components/empty/noorders.png +0 -0
  69. package/dist/components/empty/noposition-dark.png +0 -0
  70. package/dist/components/empty/noposition.png +0 -0
  71. package/dist/components/empty/nosearch-dark.png +0 -0
  72. package/dist/components/empty/nosearch.png +0 -0
  73. package/dist/components/empty/style.less +0 -61
  74. package/dist/components/footer/index.js +0 -7
  75. package/dist/components/footer/index.vue +0 -33
  76. package/dist/components/footer/style.less +0 -21
  77. package/dist/components/footnav/index.js +0 -7
  78. package/dist/components/footnav/index.vue +0 -93
  79. package/dist/components/footnav/style.less +0 -23
  80. package/dist/components/footnav-item/index.js +0 -7
  81. package/dist/components/footnav-item/index.vue +0 -50
  82. package/dist/components/footnav-item/style.less +0 -39
  83. package/dist/components/form/index.js +0 -7
  84. package/dist/components/form/index.vue +0 -12
  85. package/dist/components/headnav/index.js +0 -7
  86. package/dist/components/headnav/index.vue +0 -185
  87. package/dist/components/headnav/style.less +0 -232
  88. package/dist/components/icon/font/iconfont.css +0 -163
  89. package/dist/components/icon/font/iconfont.js +0 -6
  90. package/dist/components/icon/index.js +0 -9
  91. package/dist/components/icon/index.vue +0 -96
  92. package/dist/components/icon/style.less +0 -44
  93. package/dist/components/input/calcTextareaHeight.js +0 -162
  94. package/dist/components/input/index.js +0 -8
  95. package/dist/components/input/index.vue +0 -345
  96. package/dist/components/input/style.less +0 -471
  97. package/dist/components/list/index.js +0 -8
  98. package/dist/components/list/index.vue +0 -152
  99. package/dist/components/list/style.less +0 -213
  100. package/dist/components/loading/index.js +0 -7
  101. package/dist/components/loading/index.vue +0 -68
  102. package/dist/components/loading/style.less +0 -54
  103. package/dist/components/mixins/clickoutside.js +0 -81
  104. package/dist/components/mixins/dom.js +0 -41
  105. package/dist/components/mixins/languageMixin.js +0 -41
  106. package/dist/components/mixins/outlineConfigPlugin.js +0 -45
  107. package/dist/components/mixins/router-link.js +0 -23
  108. package/dist/components/mixins/themeMixin.js +0 -43
  109. package/dist/components/noticebar/index.js +0 -8
  110. package/dist/components/noticebar/index.vue +0 -258
  111. package/dist/components/noticebar/style.less +0 -328
  112. package/dist/components/overlay/index.js +0 -8
  113. package/dist/components/overlay/index.vue +0 -184
  114. package/dist/components/overlay/style.less +0 -23
  115. package/dist/components/pagebreak/index.js +0 -7
  116. package/dist/components/pagebreak/index.vue +0 -67
  117. package/dist/components/pagebreak/style.less +0 -42
  118. package/dist/components/password/index.js +0 -8
  119. package/dist/components/password/index.vue +0 -60
  120. package/dist/components/popover/index.js +0 -8
  121. package/dist/components/popover/index.vue +0 -100
  122. package/dist/components/popover/style.less +0 -346
  123. package/dist/components/popover/vue-popover.vue +0 -314
  124. package/dist/components/popup/index.js +0 -7
  125. package/dist/components/popup/index.vue +0 -243
  126. package/dist/components/radio/index.js +0 -8
  127. package/dist/components/radio/index.vue +0 -184
  128. package/dist/components/radio/style.less +0 -294
  129. package/dist/components/radio-group/index.js +0 -6
  130. package/dist/components/radio-group/index.vue +0 -58
  131. package/dist/components/result/completed-dark.png +0 -0
  132. package/dist/components/result/completed.png +0 -0
  133. package/dist/components/result/error-dark.png +0 -0
  134. package/dist/components/result/error.png +0 -0
  135. package/dist/components/result/index.js +0 -8
  136. package/dist/components/result/index.vue +0 -73
  137. package/dist/components/result/style.less +0 -44
  138. package/dist/components/result/wait-dark.png +0 -0
  139. package/dist/components/result/wait.png +0 -0
  140. package/dist/components/search/index.js +0 -8
  141. package/dist/components/search/index.vue +0 -66
  142. package/dist/components/selector/index.js +0 -8
  143. package/dist/components/selector/index.vue +0 -161
  144. package/dist/components/selector/style.less +0 -484
  145. package/dist/components/skeleton/index.js +0 -7
  146. package/dist/components/skeleton/index.vue +0 -206
  147. package/dist/components/skeleton/style.less +0 -197
  148. package/dist/components/slider/draggable.js +0 -49
  149. package/dist/components/slider/index.js +0 -7
  150. package/dist/components/slider/index.vue +0 -167
  151. package/dist/components/slider/style.less +0 -100
  152. package/dist/components/slider/utils.js +0 -60
  153. package/dist/components/step/index.js +0 -7
  154. package/dist/components/step/index.vue +0 -48
  155. package/dist/components/step/style.less +0 -58
  156. package/dist/components/step-item/index.js +0 -7
  157. package/dist/components/step-item/index.vue +0 -126
  158. package/dist/components/step-item/style.less +0 -362
  159. package/dist/components/stepper/index.js +0 -8
  160. package/dist/components/stepper/index.vue +0 -146
  161. package/dist/components/style/index.vue +0 -42
  162. package/dist/components/switch/index.js +0 -8
  163. package/dist/components/switch/index.vue +0 -72
  164. package/dist/components/switch/style.less +0 -56
  165. package/dist/components/tab/index.js +0 -7
  166. package/dist/components/tab/index.vue +0 -53
  167. package/dist/components/tabs/index.js +0 -8
  168. package/dist/components/tabs/index.vue +0 -172
  169. package/dist/components/tabs/style.less +0 -377
  170. package/dist/components/tag/index.js +0 -7
  171. package/dist/components/tag/index.vue +0 -64
  172. package/dist/components/tag/style.less +0 -211
  173. package/dist/components/title/index.js +0 -8
  174. package/dist/components/title/index.vue +0 -99
  175. package/dist/components/title/style.less +0 -188
  176. package/dist/components/toast/index.js +0 -94
  177. package/dist/components/toast/index.vue +0 -49
  178. package/dist/components/toast/style.less +0 -55
  179. package/dist/components/transition/index.js +0 -8
  180. package/dist/components/transition/index.vue +0 -13
  181. package/dist/components/transition/style.less +0 -208
  182. package/dist/components/upload/index.js +0 -7
  183. package/dist/components/upload/index.vue +0 -106
  184. package/dist/components/upload/style.less +0 -147
  185. package/dist/components/utils/assist.js +0 -34
  186. package/dist/components/utils/env.js +0 -2
  187. package/dist/demo.html +0 -10
  188. package/dist/locale/ar.js +0 -98
  189. package/dist/locale/en.js +0 -98
  190. package/dist/locale/zh.js +0 -98
  191. package/dist/token.css +0 -2990
  192. package/dist/vdesign-ui.common.js +0 -27486
  193. package/dist/vdesign-ui.css +0 -1
  194. package/dist/vdesign-ui.umd.js +0 -27496
  195. package/dist/vdesign-ui.umd.min.js +0 -32
@@ -1,96 +0,0 @@
1
- <script>
2
- import "./font/iconfont.css";
3
- import "./font/iconfont.js";
4
-
5
- export default {
6
- name: 'vd-icon',
7
- props: {
8
- name: {
9
- type: String,
10
- default: '',
11
- },
12
- size: {
13
- type: String,
14
- default: '',
15
- },
16
- color: {
17
- type: String,
18
- default: '',
19
- },
20
- },
21
- computed: {
22
- isImage() {
23
- return this.name.includes('/');
24
- },
25
- isSvg() {
26
- // 判断是否为 SVG 图标,依据 name 是否以 '_svg' 结尾
27
- return this.name.endsWith('_svg');
28
- },
29
- sizeClass() {
30
- return this.size ? `vd-icon-${this.size}` : '';
31
- },
32
- },
33
- render(createElement) {
34
- if (this.name) {
35
- if (this.isSvg) {
36
- // Render SVG icon
37
- return createElement(
38
- 'svg',
39
- {
40
- class: [
41
- 'vd-iconfont',
42
- 'vd-svg-icon',
43
- `vd-icon-${this.name}`,
44
- this.sizeClass,
45
- ],
46
- style: { fill: this.color },
47
- on: {
48
- click: (event) => this.$emit('click', event),
49
- },
50
- },
51
- [
52
- createElement('use', {
53
- attrs: {
54
- 'xlink:href': `#vd-icon-${this.name}`,
55
- },
56
- }),
57
- ]
58
- );
59
- } else {
60
- // Render icon with possible image
61
- const children = this.isImage
62
- ? [
63
- createElement('img', {
64
- class: 'vd-img-icon',
65
- attrs: { src: this.name },
66
- }),
67
- ]
68
- : [];
69
-
70
- return createElement(
71
- 'i',
72
- {
73
- class: [
74
- 'vd-iconfont',
75
- this.isImage ? '' : `vd-icon-${this.name}`,
76
- this.sizeClass,
77
- ],
78
- style: { color: this.color },
79
- on: {
80
- click: (event) => this.$emit('click', event),
81
- },
82
- },
83
- children
84
- );
85
- }
86
- } else {
87
- // Render slot content
88
- return this.$slots.default;
89
- }
90
- },
91
- };
92
- </script>
93
-
94
- <style lang="less">
95
- @import "./style.less";
96
- </style>
@@ -1,44 +0,0 @@
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: var(--icon-medium);
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: var(--icon-small);
36
- }
37
-
38
- .vd-icon-medium {
39
- font-size: var(--icon-medium);
40
- }
41
-
42
- .vd-icon-large {
43
- font-size: var(--icon-large);
44
- }
@@ -1,162 +0,0 @@
1
- // 定义全局的环境检查
2
- const inBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3
-
4
- const HIDDEN_TEXTAREA_STYLE = `
5
- min-height:0 !important;
6
- max-height:none !important;
7
- height:0 !important;
8
- visibility:hidden !important;
9
- overflow:hidden !important;
10
- position:absolute !important;
11
- z-index:-1000 !important;
12
- top:0 !important;
13
- right:0 !important;
14
- `;
15
-
16
- const SIZING_STYLE = [
17
- 'letter-spacing',
18
- 'line-height',
19
- 'padding-top',
20
- 'padding-bottom',
21
- 'font-family',
22
- 'font-weight',
23
- 'font-size',
24
- 'text-rendering',
25
- 'text-transform',
26
- 'width',
27
- 'text-indent',
28
- 'padding-left',
29
- 'padding-right',
30
- 'border-width',
31
- 'box-sizing',
32
- ];
33
-
34
- let computedStyleCache = {};
35
- let hiddenTextarea = null;
36
-
37
- // 计算节点的样式信息
38
- function calculateNodeStyling(node, useCache = false) {
39
- if (!inBrowser || !node) {
40
- // 如果不在浏览器环境中,返回默认的样式对象,防止报错
41
- return {
42
- sizingStyle: '',
43
- paddingSize: 0,
44
- borderSize: 0,
45
- boxSizing: 'content-box',
46
- };
47
- }
48
-
49
- const nodeRef = (
50
- node.getAttribute('id') ||
51
- node.getAttribute('data-reactid') ||
52
- node.getAttribute('name')
53
- );
54
-
55
- if (useCache && computedStyleCache[nodeRef]) {
56
- return computedStyleCache[nodeRef];
57
- }
58
-
59
- const style = window.getComputedStyle(node);
60
-
61
- const boxSizing = (
62
- style.getPropertyValue('box-sizing') ||
63
- style.getPropertyValue('-moz-box-sizing') ||
64
- style.getPropertyValue('-webkit-box-sizing')
65
- );
66
-
67
- const paddingSize = (
68
- parseFloat(style.getPropertyValue('padding-bottom')) +
69
- parseFloat(style.getPropertyValue('padding-top'))
70
- );
71
-
72
- const borderSize = (
73
- parseFloat(style.getPropertyValue('border-bottom-width')) +
74
- parseFloat(style.getPropertyValue('border-top-width'))
75
- );
76
-
77
- const sizingStyle = SIZING_STYLE
78
- .map(name => `${name}:${style.getPropertyValue(name)}`)
79
- .join(';');
80
-
81
- const nodeInfo = {
82
- sizingStyle,
83
- paddingSize,
84
- borderSize,
85
- boxSizing,
86
- };
87
-
88
- if (useCache && nodeRef) {
89
- computedStyleCache[nodeRef] = nodeInfo;
90
- }
91
-
92
- return nodeInfo;
93
- }
94
-
95
- // 计算 textarea 的高度
96
- export default function calcTextareaHeight(uiTextNode, minRows = null, maxRows = null, useCache = false) {
97
- if (!inBrowser || !uiTextNode) {
98
- // 如果不在浏览器环境中,返回默认的高度,避免 SSR 中出错
99
- return { height: '0px', minHeight: '0px', maxHeight: '0px', overflowY: 'hidden' };
100
- }
101
-
102
- if (!hiddenTextarea) {
103
- // 创建一个隐藏的 textarea 元素来测量高度
104
- hiddenTextarea = document.createElement('textarea');
105
- document.body.appendChild(hiddenTextarea);
106
- }
107
-
108
- if (uiTextNode.getAttribute('wrap')) {
109
- hiddenTextarea.setAttribute('wrap', uiTextNode.getAttribute('wrap'));
110
- } else {
111
- hiddenTextarea.removeAttribute('wrap');
112
- }
113
-
114
- const { paddingSize, borderSize, boxSizing, sizingStyle } = calculateNodeStyling(uiTextNode, useCache);
115
-
116
- hiddenTextarea.setAttribute('style', `${sizingStyle};${HIDDEN_TEXTAREA_STYLE}`);
117
- hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';
118
-
119
- let minHeight = Number.MIN_SAFE_INTEGER;
120
- let maxHeight = Number.MAX_SAFE_INTEGER;
121
- let height = hiddenTextarea.scrollHeight;
122
- let overflowY;
123
-
124
- if (boxSizing === 'border-box') {
125
- height += borderSize;
126
- } else if (boxSizing === 'content-box') {
127
- height -= paddingSize;
128
- }
129
-
130
- if (minRows !== null || maxRows !== null) {
131
- hiddenTextarea.value = ' ';
132
- const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
133
-
134
- if (minRows !== null) {
135
- minHeight = singleRowHeight * minRows;
136
- if (boxSizing === 'border-box') {
137
- minHeight += paddingSize + borderSize;
138
- }
139
- height = Math.max(minHeight, height);
140
- }
141
-
142
- if (maxRows !== null) {
143
- maxHeight = singleRowHeight * maxRows;
144
- if (boxSizing === 'border-box') {
145
- maxHeight += paddingSize + borderSize;
146
- }
147
- overflowY = height > maxHeight ? '' : 'hidden';
148
- height = Math.min(maxHeight, height);
149
- }
150
- }
151
-
152
- if (!maxRows) {
153
- overflowY = 'hidden';
154
- }
155
-
156
- return {
157
- height: `${height}px`,
158
- minHeight: `${minHeight}px`,
159
- maxHeight: `${maxHeight}px`,
160
- overflowY,
161
- };
162
- }
@@ -1,8 +0,0 @@
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;
@@ -1,345 +0,0 @@
1
- <template>
2
- <div :class="wrapClasses" class="vd-input">
3
- <!-- 前缀,还有前缀右边框 -->
4
- <span v-if="hasPrefix" class="vd-input-form__prefix" :class="borderRightClasses">
5
- <slot name="prefix">{{ prefix }}</slot>
6
- </span>
7
- <textarea
8
- v-if="type === 'textarea'"
9
- ref="textarea"
10
- v-bind="$attrs"
11
- :rows="rows"
12
- :class="inputClasses"
13
- :disabled="disabled"
14
- :readonly="readonly"
15
- :value="currentValue"
16
- @focus="handleFocus"
17
- @blur="handleBlur"
18
- @input="handleInput"
19
- :style="textareaStyles"
20
- >
21
- </textarea>
22
- <input
23
- v-else
24
- ref="input"
25
- v-bind="$attrs"
26
- :type="passwordIcon ? (passwordVisible ? 'text' : 'password') : type"
27
- :class="inputClasses"
28
- :disabled="disabled"
29
- :readonly="readonly"
30
- :value="currentValue"
31
- @input="handleInput"
32
- @focus="handleFocus"
33
- @blur="handleBlur"
34
- />
35
-
36
- <!-- 右侧功能区域 -->
37
-
38
- <div
39
- v-if="showRightSection"
40
- class="vd-input-form__right"
41
- >
42
- <!-- 清除按钮 -->
43
- <span v-if="showClear" class="vd-input-form__suffix">
44
- <vd-icon name="icon_btn_clean" @mousedown.prevent.native="handleClear"></vd-icon>
45
- </span>
46
- <!-- (大数字的时候)设计要求的自定义文字 -->
47
- <span v-if="hasAppend" class="vd-input-form__append">
48
- <slot name="append">{{ append }}</slot>
49
- </span>
50
- <!-- 字数限制 -->
51
- <div
52
- v-if="isWordLimitVisible"
53
- :class="wordLimitClasses"
54
- >
55
- <span>{{ textLength }}</span
56
- >/<span>{{ upperLimit }}</span>
57
- </div>
58
- </div>
59
- <!-- 密码的时候,单独的清空按钮 -->
60
- <span
61
- v-if="showPasswordControls"
62
- class="vd-input-form__password"
63
- >
64
- <span v-if="showPasswordClear" class="vd-input-form__password--close">
65
- <vd-icon name="icon_btn_close" @mousedown.prevent.native="handleClear"></vd-icon>
66
- </span>
67
- <span v-if="showPasswordIcon" class="vd-input-form__password--password">
68
- <vd-icon
69
- :name="passwordVisible ? 'icon_btn_eye' : 'icon_btn_eye_close'"
70
- @click="handlePasswordVisible"
71
- ></vd-icon>
72
- </span>
73
- </span>
74
- </div>
75
- </template>
76
-
77
- <script>
78
- import VdIcon from '../icon';
79
- import calcTextareaHeight from "./calcTextareaHeight";
80
- const prefixCls = "vd-input";
81
-
82
- export default {
83
- name: "vd-input",
84
- components: {
85
- VdIcon,
86
- },
87
- props: {
88
- value: {
89
- type: [String, Number],
90
- default: "",
91
- },
92
- type: {
93
- type: String,
94
- default: "text",
95
- },
96
- prefix: {
97
- type: [Boolean, String],
98
- default: ''
99
- },
100
- borderRight: {
101
- type: Boolean,
102
- default: true
103
- },
104
- // 设计如此,单独的文字
105
- append: {
106
- type: [Boolean, String],
107
- default: ''
108
- },
109
- error: {
110
- type: Boolean,
111
- },
112
- bigSize: {
113
- type: Boolean,
114
- },
115
- passwordIcon: {
116
- type: Boolean,
117
- },
118
- passwordClose: {
119
- type: Boolean,
120
- },
121
- // 输入框类型 表单类型,常规输入库,搜索框
122
- form: {
123
- type: String,
124
- },
125
- disabled: {
126
- type: Boolean,
127
- },
128
- rows: {
129
- type: Number,
130
- default: 2,
131
- },
132
- // 设计如此多行textarea,跟input属性一样
133
- inputTextArea: {
134
- type: Boolean,
135
- },
136
- warning: {
137
- type: Boolean,
138
- },
139
- hairline: {
140
- type: Boolean,
141
- default: true,
142
- },
143
- autosize: {
144
- type: [Boolean, Object],
145
- default: false,
146
- },
147
- // 新增0118
148
- showWordLimit: {
149
- type: Boolean,
150
- default: false,
151
- },
152
- clearable:Boolean,
153
- readonly:Boolean
154
- },
155
- data() {
156
- return {
157
- focusClass: false,
158
- currentValue: this.value,
159
- textareaStyles: {},
160
- passwordVisible: false,
161
- focused: false,
162
- };
163
- },
164
- computed: {
165
- hasPrefix() {
166
- return (this.prefix !== undefined && this.prefix !== '') || this.$slots.prefix;
167
- },
168
- // 是否显示右侧区域
169
- showRightSection() {
170
- return this.showClear || this.hasAppend || this.isWordLimitVisible;
171
- },
172
- // 是否有附加内容
173
- hasAppend() {
174
- return (this.append !== undefined && this.append !== '') || this.$slots.append;
175
- },
176
- // 是否显示清除按钮(假设已经在 computed 中定义)
177
- showClear() {
178
- return (
179
- this.clearable &&
180
- this.focused &&
181
- this.currentValue !== '' &&
182
- !this.disabled &&
183
- !this.readonly
184
- );
185
- },
186
- wordLimitClasses() {
187
- return [
188
- 'vd-input__word-limit',
189
- { 'vd-input__word-limit--error': this.isOverLimit },
190
- ];
191
- },
192
- showPasswordClear() {
193
- return (
194
- this.passwordClose &&
195
- this.focused &&
196
- this.currentValue !== '' &&
197
- !this.disabled &&
198
- !this.readonly
199
- );
200
- },
201
- showPasswordIcon() {
202
- return this.passwordIcon && this.type === 'password';
203
- },
204
- showPasswordControls() {
205
- return this.showPasswordClear || this.showPasswordIcon;
206
- },
207
- wrapClasses() {
208
- return [
209
- {
210
- [`${prefixCls}-${this.form}`]: this.form,
211
- [`${prefixCls}--disabled`]: this.disabled,
212
- [`${prefixCls}-${this.type}`]: this.type,
213
- [`${prefixCls}-${this.type}--warning`]: this.warning,
214
- [`${prefixCls}--bigsize`]: this.bigSize,
215
- [`${prefixCls}--error`]: this.error,
216
- [`${prefixCls}--active`]: this.focused,
217
- [`${prefixCls}-inputarea`]: this.inputTextArea,
218
- "vd-hairline--bottom": this.hairline,
219
- "vd-textarea-auto": this.inputTextArea,
220
- },
221
- ];
222
- },
223
- borderRightClasses(){
224
- return [
225
- "vd-hairline--right",
226
- {
227
- [`${prefixCls}--border`]: this.borderRight,
228
- }
229
- ]
230
- },
231
- inputClasses() {
232
- return [
233
- `${prefixCls}__control`,
234
- {
235
- [`${prefixCls}-${this.type}__control`]: this.type,
236
- },
237
- ];
238
- },
239
- // 当前输入的文本长度
240
- textLength() {
241
- if (typeof this.value === "number") {
242
- return String(this.value).length;
243
- }
244
- return (this.value || "").length;
245
- },
246
- upperLimit() {
247
- return this.$attrs.maxlength;
248
- },
249
- isWordLimitVisible() {
250
- return (
251
- this.showWordLimit &&
252
- this.$attrs.maxlength &&
253
- (this.type === "text" || this.type === "textarea")
254
- );
255
- },
256
- isOverLimit() {
257
- return this.textLength >= this.upperLimit;
258
- },
259
- },
260
- methods: {
261
- handleFocus(event) {
262
- this.focused = true;
263
- this.$emit("focus", event);
264
-
265
- if (this.readonly) {
266
- this.blur();
267
- }
268
- },
269
- handleBlur(event) {
270
- this.focused = false;
271
- this.$emit("blur", event);
272
- },
273
- focus() {
274
- if (this.type === "textarea") {
275
- this.$refs.textarea && this.$refs.textarea.focus();
276
- } else {
277
- this.$refs.input && this.$refs.input.focus();
278
- }
279
- },
280
- blur() {
281
- if (this.type === "textarea") {
282
- this.$refs.textarea && this.$refs.textarea.blur();
283
- } else {
284
- this.$refs.input && this.$refs.input.blur();
285
- }
286
- },
287
-
288
- handleInput(event) {
289
- let value = event.target.value;
290
- this.$emit("input", value);
291
- this.setCurrentValue(value);
292
- this.$emit("change", event);
293
- },
294
-
295
- setCurrentValue(value) {
296
- if (value === this.currentValue) return;
297
- this.currentValue = value;
298
- this.$nextTick(() => {
299
- this.resizeTextarea();
300
- });
301
- },
302
- resizeTextarea() {
303
- if (!this.autosize || this.type !== "textarea") {
304
- return;
305
- }
306
- const { minRows, maxRows } = this.autosize;
307
- this.textareaStyles = calcTextareaHeight(
308
- this.$refs.textarea,
309
- minRows,
310
- maxRows
311
- );
312
- },
313
- handleClear() {
314
- const e = { target: { value: "" } };
315
- this.$emit("input", "");
316
- this.setCurrentValue("");
317
- this.$emit("change", e);
318
- this.$emit("clear");
319
- this.$nextTick(() => {
320
- this.focus();
321
- });
322
- },
323
-
324
- // 切换密码显示状态
325
- handlePasswordVisible() {
326
- this.passwordVisible = !this.passwordVisible;
327
- this.$nextTick(() => {
328
- this.focus();
329
- });
330
- },
331
- },
332
- watch: {
333
- value(val) {
334
- this.setCurrentValue(val);
335
- },
336
- },
337
- mounted() {
338
- this.resizeTextarea();
339
- },
340
- };
341
- </script>
342
-
343
- <style lang="less">
344
- @import "./style.less";
345
- </style>