vdesign-ui 0.1.19 → 0.1.20
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.
- package/dist/components/actionbar/actionbar-cell/index.vue +34 -0
- package/dist/components/actionbar/index.js +8 -0
- package/dist/components/actionbar/index.vue +39 -0
- package/dist/components/actionbar/style.less +48 -0
- package/dist/components/actions-cell/actions/index.js +7 -0
- package/dist/components/actions-cell/actions/index.vue +76 -0
- package/dist/components/actions-cell/actions/style.less +112 -0
- package/dist/components/actions-cell/index.js +7 -0
- package/dist/components/actions-cell/index.vue +94 -0
- package/dist/components/actions-cell/style.less +39 -0
- package/dist/components/activityviews/index.js +8 -0
- package/dist/components/activityviews/index.vue +140 -0
- package/dist/components/activityviews/style.less +138 -0
- package/dist/components/badge/index.js +8 -0
- package/dist/components/badge/index.vue +49 -0
- package/dist/components/badge/style.less +66 -0
- package/dist/components/button/index.js +8 -0
- package/dist/components/button/index.vue +89 -0
- package/dist/components/button/style.less +563 -0
- package/dist/components/calendar/end.png +0 -0
- package/dist/components/calendar/index-element.vue +84 -0
- package/dist/components/calendar/index.js +8 -0
- package/dist/components/calendar/index.vue +52 -0
- package/dist/components/calendar/start.png +0 -0
- package/dist/components/calendar/style.less +167 -0
- package/dist/components/checkbox/assist.js +34 -0
- package/dist/components/checkbox/checkbox-group/index.js +8 -0
- package/dist/components/checkbox/checkbox-group/index.vue +69 -0
- package/dist/components/checkbox/index.js +8 -0
- package/dist/components/checkbox/index.vue +184 -0
- package/dist/components/checkbox/style.less +291 -0
- package/dist/components/common/state/index.vue +80 -0
- package/dist/components/data-list/index.js +10 -0
- package/dist/components/data-list/index.vue +19 -0
- package/dist/components/data-list/style.less +624 -0
- package/dist/components/datetime-picker/index.js +8 -0
- package/dist/components/datetime-picker/index.vue +37 -0
- package/dist/components/datetime-picker/style.less +24 -0
- package/dist/components/dialog/index.js +8 -0
- package/dist/components/dialog/index.vue +162 -0
- package/dist/components/dialog/overlay-manager.js +18 -0
- package/dist/components/dialog/style.less +132 -0
- package/dist/components/divider/index.js +8 -0
- package/dist/components/divider/index.vue +54 -0
- package/dist/components/divider/style.less +92 -0
- package/dist/components/dropdown/index.js +8 -0
- package/dist/components/dropdown/index.vue +210 -0
- package/dist/components/dropdown/style.less +418 -0
- package/dist/components/empty/404-dark.png +0 -0
- package/dist/components/empty/404.png +0 -0
- package/dist/components/empty/index.js +8 -0
- package/dist/components/empty/index.vue +95 -0
- package/dist/components/empty/network-dark.png +0 -0
- package/dist/components/empty/network.png +0 -0
- package/dist/components/empty/nodata-dark.png +0 -0
- package/dist/components/empty/nodata.png +0 -0
- package/dist/components/empty/style.less +60 -0
- package/dist/components/footer/index.js +7 -0
- package/dist/components/footer/index.vue +29 -0
- package/dist/components/footer/style.less +22 -0
- package/dist/components/footnav/footnav-item/index.js +7 -0
- package/dist/components/footnav/footnav-item/index.vue +75 -0
- package/dist/components/footnav/footnav-item/style.less +39 -0
- package/dist/components/footnav/index.js +7 -0
- package/dist/components/footnav/index.vue +97 -0
- package/dist/components/footnav/style.less +23 -0
- package/dist/components/form/index.js +7 -0
- package/dist/components/form/index.vue +12 -0
- package/dist/components/headnav/index.js +7 -0
- package/dist/components/headnav/index.vue +163 -0
- package/dist/components/headnav/style.less +245 -0
- package/dist/components/icon/font/iconfont.css +1050 -0
- package/dist/components/icon/font/iconfont.js +2 -0
- package/dist/components/icon/index.js +9 -0
- package/dist/components/icon/index.vue +46 -0
- package/dist/components/icon/style.less +44 -0
- package/dist/components/input/calcTextareaHeight.js +266 -0
- package/dist/components/input/index.js +8 -0
- package/dist/components/input/index.vue +343 -0
- package/dist/components/input/password/index.js +8 -0
- package/dist/components/input/password/index.vue +60 -0
- package/dist/components/input/search/index.js +8 -0
- package/dist/components/input/search/index.vue +66 -0
- package/dist/components/input/stepper/index.js +8 -0
- package/dist/components/input/stepper/index.vue +136 -0
- package/dist/components/input/style.less +497 -0
- package/dist/components/list/index.js +8 -0
- package/dist/components/list/index.vue +159 -0
- package/dist/components/list/style.less +292 -0
- package/dist/components/loading/index.js +7 -0
- package/dist/components/loading/index.vue +53 -0
- package/dist/components/loading/loading.png +0 -0
- package/dist/components/loading/refresh.png +0 -0
- package/dist/components/loading/style.less +48 -0
- package/dist/components/mixins/clickoutside.js +81 -0
- package/dist/components/mixins/dom.js +41 -0
- package/dist/components/mixins/languageMixin.js +38 -0
- package/dist/components/mixins/outlineConfigPlugin.js +40 -0
- package/dist/components/mixins/router-link.js +23 -0
- package/dist/components/mixins/themeMixin.js +29 -0
- package/dist/components/noticebar/index.js +8 -0
- package/dist/components/noticebar/index.vue +247 -0
- package/dist/components/noticebar/style.less +332 -0
- package/dist/components/overlay/index.js +8 -0
- package/dist/components/overlay/index.vue +161 -0
- package/dist/components/overlay/style.less +23 -0
- package/dist/components/pagebreak/index.js +7 -0
- package/dist/components/pagebreak/index.vue +60 -0
- package/dist/components/pagebreak/style.less +43 -0
- package/dist/components/popover/index.js +8 -0
- package/dist/components/popover/index.vue +99 -0
- package/dist/components/popover/style.less +346 -0
- package/dist/components/popover/vue-popover.vue +314 -0
- package/dist/components/radio/assist.js +34 -0
- package/dist/components/radio/index.js +8 -0
- package/dist/components/radio/index.vue +159 -0
- package/dist/components/radio/radio-group/index.vue +70 -0
- package/dist/components/radio/style.less +297 -0
- package/dist/components/result/completed-dark.png +0 -0
- package/dist/components/result/completed.png +0 -0
- package/dist/components/result/error-dark.png +0 -0
- package/dist/components/result/error.png +0 -0
- package/dist/components/result/index.js +8 -0
- package/dist/components/result/index.vue +75 -0
- package/dist/components/result/style.less +42 -0
- package/dist/components/result/wait-dark.png +0 -0
- package/dist/components/result/wait.png +0 -0
- package/dist/components/selector/index.js +8 -0
- package/dist/components/selector/index.vue +124 -0
- package/dist/components/selector/style.less +474 -0
- package/dist/components/skeleton/index.js +7 -0
- package/dist/components/skeleton/index.vue +142 -0
- package/dist/components/skeleton/style.less +192 -0
- package/dist/components/slider/draggable.js +49 -0
- package/dist/components/slider/index.js +7 -0
- package/dist/components/slider/index.vue +173 -0
- package/dist/components/slider/style.less +96 -0
- package/dist/components/slider/utils.js +60 -0
- package/dist/components/step/index.js +7 -0
- package/dist/components/step/index.vue +48 -0
- package/dist/components/step/style.less +59 -0
- package/dist/components/step-item/index.js +7 -0
- package/dist/components/step-item/index.vue +117 -0
- package/dist/components/step-item/style.less +361 -0
- package/dist/components/style/index.vue +42 -0
- package/dist/components/switch/index.js +8 -0
- package/dist/components/switch/index.vue +72 -0
- package/dist/components/switch/style.less +56 -0
- package/dist/components/tabs/index.js +8 -0
- package/dist/components/tabs/index.vue +145 -0
- package/dist/components/tabs/style.less +385 -0
- package/dist/components/tabs/tab/index.vue +56 -0
- package/dist/components/tag/index.js +7 -0
- package/dist/components/tag/index.vue +50 -0
- package/dist/components/tag/style.less +211 -0
- package/dist/components/title/index.js +8 -0
- package/dist/components/title/index.vue +92 -0
- package/dist/components/title/style.less +188 -0
- package/dist/components/toast/index.js +80 -0
- package/dist/components/toast/index.vue +44 -0
- package/dist/components/toast/style.less +55 -0
- package/dist/components/transition/index.js +8 -0
- package/dist/components/transition/index.vue +13 -0
- package/dist/components/transition/style.less +208 -0
- package/dist/components/upload/index.js +7 -0
- package/dist/components/upload/index.vue +224 -0
- package/dist/components/upload/style.less +156 -0
- package/dist/demo.html +10 -0
- package/dist/locale/ar.js +98 -0
- package/dist/locale/en.js +98 -0
- package/dist/locale/zh.js +98 -0
- package/dist/token.css +2982 -0
- package/dist/vdesign-ui.common.js +27204 -0
- package/dist/vdesign-ui.css +1 -0
- package/dist/vdesign-ui.umd.js +27214 -0
- package/dist/vdesign-ui.umd.min.js +32 -0
- package/package.json +1 -1
- package/dist/css/chunk-1952c402.04c2303e.css +0 -1
- package/dist/css/chunk-6a5c6104.38021b56.css +0 -1
- package/dist/css/chunk-vendors.4ecfba63.css +0 -1
- package/dist/css/sites.395ce21f.css +0 -1
- package/dist/img/bg_mobile.5909f667.png +0 -0
- package/dist/img/icon.a67073c3.svg +0 -7
- package/dist/img/iphoneX.38c8778e.png +0 -0
- package/dist/img/logo-white.fad4f907.png +0 -0
- package/dist/img/logo.1eda11d6.png +0 -0
- package/dist/img/qrcode2.0a9d9044.png +0 -0
- package/dist/index.html +0 -1
- package/dist/js/chunk-1952c402.c58ecfb5.js +0 -1
- package/dist/js/chunk-2d2183be.2a64419d.js +0 -1
- package/dist/js/chunk-6a5c6104.c8fa5635.js +0 -1
- package/dist/js/chunk-vendors.490b7673.js +0 -37
- package/dist/js/sites.5a217467.js +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg v-if="svg" class="vd-iconfont vd-svg-icon" :class="[`vd-icon-${name}`, size ? `vd-icon-${size}` : '']"
|
|
3
|
+
:style="{ fill: color }" @click="$emit('click', $event)">
|
|
4
|
+
<use :xlink:href="`#vd-icon-${name}`" />
|
|
5
|
+
</svg>
|
|
6
|
+
<i v-else-if="name" class="vd-iconfont"
|
|
7
|
+
:class="[isImage(name) ? '' : `vd-icon-${name}`, size ? `vd-icon-${size}` : '']" :style="{ color }"
|
|
8
|
+
@click="$emit('click', $event)">
|
|
9
|
+
<img class="vd-img-icon" v-if="isImage(name)" :src="name" />
|
|
10
|
+
</i>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import './font/iconfont.js'
|
|
15
|
+
import "./font/iconfont.css";
|
|
16
|
+
export default {
|
|
17
|
+
name: 'vd-icon',
|
|
18
|
+
props: {
|
|
19
|
+
name: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: '',
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: '',
|
|
26
|
+
},
|
|
27
|
+
color: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: '',
|
|
30
|
+
},
|
|
31
|
+
svg: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false,
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
isImage(name) {
|
|
38
|
+
return name ? name.indexOf('/') !== -1 : false;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style lang="less">
|
|
45
|
+
@import "./style.less";
|
|
46
|
+
</style>
|
|
@@ -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
|
+
}
|