vdesign-ui 0.2.9 → 0.2.12

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/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 +76 -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/languageMixin.js +41 -41
  83. package/dist/components/mixins/outlineConfigPlugin.js +45 -45
  84. package/dist/components/mixins/themeMixin.js +43 -43
  85. package/dist/components/noticebar/index.js +8 -8
  86. package/dist/components/noticebar/index.vue +258 -258
  87. package/dist/components/noticebar/style.less +328 -328
  88. package/dist/components/overlay/index.js +8 -8
  89. package/dist/components/overlay/index.vue +184 -184
  90. package/dist/components/overlay/style.less +23 -23
  91. package/dist/components/pagebreak/index.js +6 -6
  92. package/dist/components/pagebreak/index.vue +67 -67
  93. package/dist/components/pagebreak/style.less +41 -41
  94. package/dist/components/password/index.js +8 -8
  95. package/dist/components/password/index.vue +60 -60
  96. package/dist/components/popover/index.js +8 -8
  97. package/dist/components/popover/index.vue +100 -100
  98. package/dist/components/popover/style.less +346 -346
  99. package/dist/components/popover/vue-popover.vue +314 -314
  100. package/dist/components/popup/index.js +7 -7
  101. package/dist/components/popup/index.vue +243 -243
  102. package/dist/components/radio/index.js +8 -8
  103. package/dist/components/radio/index.vue +184 -184
  104. package/dist/components/radio/style.less +293 -293
  105. package/dist/components/radio-group/index.js +6 -6
  106. package/dist/components/radio-group/index.vue +58 -58
  107. package/dist/components/result/index.js +8 -8
  108. package/dist/components/result/index.vue +73 -73
  109. package/dist/components/result/style.less +43 -43
  110. package/dist/components/search/index.js +8 -8
  111. package/dist/components/search/index.vue +66 -66
  112. package/dist/components/selector/index.js +8 -8
  113. package/dist/components/selector/index.vue +161 -161
  114. package/dist/components/selector/style.less +484 -484
  115. package/dist/components/skeleton/index.js +6 -6
  116. package/dist/components/skeleton/index.vue +207 -206
  117. package/dist/components/skeleton/style.less +196 -196
  118. package/dist/components/slider/draggable.js +49 -49
  119. package/dist/components/slider/index.js +6 -6
  120. package/dist/components/slider/index.vue +167 -167
  121. package/dist/components/slider/style.less +99 -99
  122. package/dist/components/slider/utils.js +59 -59
  123. package/dist/components/step/index.js +7 -7
  124. package/dist/components/step/index.vue +48 -48
  125. package/dist/components/step/style.less +57 -57
  126. package/dist/components/step-item/index.js +7 -7
  127. package/dist/components/step-item/index.vue +126 -126
  128. package/dist/components/step-item/style.less +362 -362
  129. package/dist/components/stepper/index.js +8 -8
  130. package/dist/components/stepper/index.vue +146 -146
  131. package/dist/components/style/index.vue +42 -42
  132. package/dist/components/switch/index.js +8 -8
  133. package/dist/components/switch/index.vue +72 -72
  134. package/dist/components/switch/style.less +56 -56
  135. package/dist/components/tab/index.js +7 -7
  136. package/dist/components/tab/index.vue +94 -93
  137. package/dist/components/tabs/index.js +8 -8
  138. package/dist/components/tabs/index.vue +281 -271
  139. package/dist/components/tabs/style.less +408 -409
  140. package/dist/components/tag/index.js +6 -6
  141. package/dist/components/tag/index.vue +64 -64
  142. package/dist/components/tag/style.less +210 -210
  143. package/dist/components/title/index.js +8 -8
  144. package/dist/components/title/index.vue +99 -99
  145. package/dist/components/title/style.less +187 -187
  146. package/dist/components/toast/index.js +97 -86
  147. package/dist/components/toast/index.vue +49 -49
  148. package/dist/components/toast/style.less +57 -57
  149. package/dist/components/transition/index.js +8 -8
  150. package/dist/components/transition/index.vue +13 -13
  151. package/dist/components/transition/style.less +208 -208
  152. package/dist/components/upload/index.js +6 -6
  153. package/dist/components/upload/index.vue +106 -106
  154. package/dist/components/upload/style.less +147 -147
  155. package/dist/components/utils/assist.js +34 -34
  156. package/dist/components/utils/env.js +21 -21
  157. package/dist/locale/ar.js +97 -97
  158. package/dist/locale/en.js +97 -97
  159. package/dist/locale/zh.js +97 -97
  160. package/dist/token.css +2988 -2988
  161. package/dist/vdesign-ui.common.js +308 -8512
  162. package/dist/vdesign-ui.css +1 -1
  163. package/dist/vdesign-ui.umd.js +312 -8516
  164. package/dist/vdesign-ui.umd.min.js +2 -8
  165. package/package.json +113 -113
@@ -1,96 +1,96 @@
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
+ <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 +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: 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
+ .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 +1,162 @@
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
+ // 定义全局的环境检查
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 +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;
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;