umy-ui-table 1.2.0
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/LICENSE +21 -0
- package/README.md +111 -0
- package/lib/button.js +1 -0
- package/lib/icon.js +1 -0
- package/lib/index.js +1 -0
- package/lib/locale/format.js +56 -0
- package/lib/locale/index.js +72 -0
- package/lib/locale/lang/en.js +123 -0
- package/lib/locale/lang/zh-CN.js +119 -0
- package/lib/mixins/locale.js +17 -0
- package/lib/theme-chalk/base.css +0 -0
- package/lib/theme-chalk/button.css +1 -0
- package/lib/theme-chalk/fonts/element-icons.ttf +0 -0
- package/lib/theme-chalk/fonts/element-icons.woff +0 -0
- package/lib/theme-chalk/fonts/iconfont.1785562768224.ttf +0 -0
- package/lib/theme-chalk/fonts/iconfont.1785562768224.woff +0 -0
- package/lib/theme-chalk/fonts/iconfont.1785562768224.woff2 +0 -0
- package/lib/theme-chalk/icon.css +1 -0
- package/lib/theme-chalk/index.css +1 -0
- package/lib/theme-chalk/u-table-column.css +0 -0
- package/lib/theme-chalk/u-table.css +1 -0
- package/lib/theme-chalk/ux-grid.css +1 -0
- package/lib/theme-chalk/ux-table-column.css +0 -0
- package/lib/u-table-column.js +1 -0
- package/lib/u-table.js +1 -0
- package/lib/umd/locale/en.js +139 -0
- package/lib/umd/locale/zh-CN.js +135 -0
- package/lib/umy-ui.common.js +1 -0
- package/lib/utils/svg.js +33 -0
- package/lib/utils/types.js +35 -0
- package/lib/utils/util.js +268 -0
- package/lib/ux-grid.js +1 -0
- package/lib/ux-table-column.js +1 -0
- package/package.json +117 -0
- package/packages/button/index.js +7 -0
- package/packages/button/src/button-group.vue +10 -0
- package/packages/button/src/button.vue +166 -0
- package/packages/checkbox/index.js +8 -0
- package/packages/checkbox/src/checkbox-button.vue +199 -0
- package/packages/checkbox/src/checkbox-group.vue +48 -0
- package/packages/checkbox/src/checkbox.vue +222 -0
- package/packages/checkbox-button/index.js +8 -0
- package/packages/checkbox-group/index.js +8 -0
- package/packages/icon/index.js +7 -0
- package/packages/icon/src/icon.vue +40 -0
- package/packages/input/index.js +2 -0
- package/packages/input/src/calcTextareaHeight.js +104 -0
- package/packages/input/src/input.vue +424 -0
- package/packages/option/index.js +2 -0
- package/packages/pagination/index.js +2 -0
- package/packages/pagination/src/pager.vue +163 -0
- package/packages/pagination/src/pagination.js +386 -0
- package/packages/scrollbar/index.js +8 -0
- package/packages/scrollbar/src/bar.js +92 -0
- package/packages/scrollbar/src/main.js +130 -0
- package/packages/scrollbar/src/util.js +34 -0
- package/packages/select/index.js +2 -0
- package/packages/select/src/navigation-mixin.js +54 -0
- package/packages/select/src/option-group.vue +60 -0
- package/packages/select/src/option.vue +163 -0
- package/packages/select/src/select-dropdown.vue +74 -0
- package/packages/select/src/select.vue +889 -0
- package/packages/table/index.js +8 -0
- package/packages/table/src/config.js +123 -0
- package/packages/table/src/dropdown.js +28 -0
- package/packages/table/src/filter-panel.vue +194 -0
- package/packages/table/src/layout-observer.js +68 -0
- package/packages/table/src/store/current.js +71 -0
- package/packages/table/src/store/expand.js +65 -0
- package/packages/table/src/store/helper.js +37 -0
- package/packages/table/src/store/index.js +145 -0
- package/packages/table/src/store/tree.js +208 -0
- package/packages/table/src/store/watcher.js +448 -0
- package/packages/table/src/table-body.js +493 -0
- package/packages/table/src/table-column.js +381 -0
- package/packages/table/src/table-footer.js +174 -0
- package/packages/table/src/table-header.js +537 -0
- package/packages/table/src/table-layout.js +231 -0
- package/packages/table/src/table.vue +741 -0
- package/packages/table/src/util.js +256 -0
- package/packages/tag/index.js +8 -0
- package/packages/tag/src/tag.vue +58 -0
- package/packages/tools/directives/mousewheel.js +18 -0
- package/packages/tools/directives/repeat-click.js +24 -0
- package/packages/tools/locale/format.js +46 -0
- package/packages/tools/locale/index.js +48 -0
- package/packages/tools/locale/lang/en.js +120 -0
- package/packages/tools/locale/lang/zh-CN.js +116 -0
- package/packages/tools/mixins/emitter.js +33 -0
- package/packages/tools/mixins/focus.js +9 -0
- package/packages/tools/mixins/locale.js +9 -0
- package/packages/tools/mixins/migrating.js +54 -0
- package/packages/tools/transitions/collapse-transition.js +77 -0
- package/packages/tools/utils/after-leave.js +27 -0
- package/packages/tools/utils/aria-dialog.js +90 -0
- package/packages/tools/utils/aria-utils.js +122 -0
- package/packages/tools/utils/clickoutside.js +76 -0
- package/packages/tools/utils/date-util.js +292 -0
- package/packages/tools/utils/date.js +368 -0
- package/packages/tools/utils/dom.js +227 -0
- package/packages/tools/utils/menu/aria-menubar.js +14 -0
- package/packages/tools/utils/menu/aria-menuitem.js +49 -0
- package/packages/tools/utils/menu/aria-submenu.js +59 -0
- package/packages/tools/utils/merge.js +15 -0
- package/packages/tools/utils/popper.js +1276 -0
- package/packages/tools/utils/popup/index.js +218 -0
- package/packages/tools/utils/popup/popup-manager.js +194 -0
- package/packages/tools/utils/resize-event.js +35 -0
- package/packages/tools/utils/scroll-into-view.js +27 -0
- package/packages/tools/utils/scrollbar-width.js +29 -0
- package/packages/tools/utils/shared.js +7 -0
- package/packages/tools/utils/svg.js +1 -0
- package/packages/tools/utils/types.js +28 -0
- package/packages/tools/utils/util.js +241 -0
- package/packages/tools/utils/vdom.js +5 -0
- package/packages/tools/utils/vue-popper.js +198 -0
- package/packages/tooltip/index.js +8 -0
- package/packages/tooltip/src/main.js +241 -0
- package/packages/u-table/index.js +4 -0
- package/packages/u-table/revise-el-table-mixins/index.js +10 -0
- package/packages/u-table/revise-el-table-mixins/table-extend.js +60 -0
- package/packages/u-table/revise-el-table-mixins/table.mixins.js +261 -0
- package/packages/u-table/revise-el-table-mixins/virtual-table-body-render.js +132 -0
- package/packages/u-table/src/u-table.vue +248 -0
- package/packages/u-table/u-table-mixins/index.js +483 -0
- package/packages/u-table/u-table-tree-mixins/methods.js +120 -0
- package/packages/u-table/u-table-tree-mixins/u-table-tree-mixins.js +161 -0
- package/packages/u-table-column/index.js +8 -0
- package/packages/utils/common.js +27 -0
- package/packages/ux-grid/index.js +6 -0
- package/packages/ux-grid/mixins/index.js +707 -0
- package/packages/ux-grid/src/interceptor.js +6 -0
- package/packages/ux-grid/src/ux-grid.vue +301 -0
- package/packages/ux-table-column/index.js +10 -0
- package/tools/locale/format.js +46 -0
- package/tools/locale/index.js +54 -0
- package/tools/locale/lang/en.js +120 -0
- package/tools/locale/lang/zh-CN.js +116 -0
- package/tools/mixins/locale.js +9 -0
- package/tools/utils/svg.js +1 -0
- package/tools/utils/types.js +28 -0
- package/tools/utils/util.js +241 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
let hiddenTextarea;
|
|
2
|
+
|
|
3
|
+
const HIDDEN_STYLE = `
|
|
4
|
+
height:0 !important;
|
|
5
|
+
visibility:hidden !important;
|
|
6
|
+
overflow:hidden !important;
|
|
7
|
+
position:absolute !important;
|
|
8
|
+
z-index:-1000 !important;
|
|
9
|
+
top:0 !important;
|
|
10
|
+
right:0 !important
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const CONTEXT_STYLE = [
|
|
14
|
+
'letter-spacing',
|
|
15
|
+
'line-height',
|
|
16
|
+
'padding-top',
|
|
17
|
+
'padding-bottom',
|
|
18
|
+
'font-family',
|
|
19
|
+
'font-weight',
|
|
20
|
+
'font-size',
|
|
21
|
+
'text-rendering',
|
|
22
|
+
'text-transform',
|
|
23
|
+
'width',
|
|
24
|
+
'text-indent',
|
|
25
|
+
'padding-left',
|
|
26
|
+
'padding-right',
|
|
27
|
+
'border-width',
|
|
28
|
+
'box-sizing'
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
function calculateNodeStyling(targetElement) {
|
|
32
|
+
const style = window.getComputedStyle(targetElement);
|
|
33
|
+
|
|
34
|
+
const boxSizing = style.getPropertyValue('box-sizing');
|
|
35
|
+
|
|
36
|
+
const paddingSize = (
|
|
37
|
+
parseFloat(style.getPropertyValue('padding-bottom')) +
|
|
38
|
+
parseFloat(style.getPropertyValue('padding-top'))
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const borderSize = (
|
|
42
|
+
parseFloat(style.getPropertyValue('border-bottom-width')) +
|
|
43
|
+
parseFloat(style.getPropertyValue('border-top-width'))
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const contextStyle = CONTEXT_STYLE
|
|
47
|
+
.map(name => `${name}:${style.getPropertyValue(name)}`)
|
|
48
|
+
.join(';');
|
|
49
|
+
|
|
50
|
+
return { contextStyle, paddingSize, borderSize, boxSizing };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function calcTextareaHeight(
|
|
54
|
+
targetElement,
|
|
55
|
+
minRows = 1,
|
|
56
|
+
maxRows = null
|
|
57
|
+
) {
|
|
58
|
+
if (!hiddenTextarea) {
|
|
59
|
+
hiddenTextarea = document.createElement('textarea');
|
|
60
|
+
document.body.appendChild(hiddenTextarea);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let {
|
|
64
|
+
paddingSize,
|
|
65
|
+
borderSize,
|
|
66
|
+
boxSizing,
|
|
67
|
+
contextStyle
|
|
68
|
+
} = calculateNodeStyling(targetElement);
|
|
69
|
+
|
|
70
|
+
hiddenTextarea.setAttribute('style', `${contextStyle};${HIDDEN_STYLE}`);
|
|
71
|
+
hiddenTextarea.value = targetElement.value || targetElement.placeholder || '';
|
|
72
|
+
|
|
73
|
+
let height = hiddenTextarea.scrollHeight;
|
|
74
|
+
const result = {};
|
|
75
|
+
|
|
76
|
+
if (boxSizing === 'border-box') {
|
|
77
|
+
height = height + borderSize;
|
|
78
|
+
} else if (boxSizing === 'content-box') {
|
|
79
|
+
height = height - paddingSize;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
hiddenTextarea.value = '';
|
|
83
|
+
let singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
|
|
84
|
+
|
|
85
|
+
if (minRows !== null) {
|
|
86
|
+
let minHeight = singleRowHeight * minRows;
|
|
87
|
+
if (boxSizing === 'border-box') {
|
|
88
|
+
minHeight = minHeight + paddingSize + borderSize;
|
|
89
|
+
}
|
|
90
|
+
height = Math.max(minHeight, height);
|
|
91
|
+
result.minHeight = `${ minHeight }px`;
|
|
92
|
+
}
|
|
93
|
+
if (maxRows !== null) {
|
|
94
|
+
let maxHeight = singleRowHeight * maxRows;
|
|
95
|
+
if (boxSizing === 'border-box') {
|
|
96
|
+
maxHeight = maxHeight + paddingSize + borderSize;
|
|
97
|
+
}
|
|
98
|
+
height = Math.min(maxHeight, height);
|
|
99
|
+
}
|
|
100
|
+
result.height = `${ height }px`;
|
|
101
|
+
hiddenTextarea.parentNode && hiddenTextarea.parentNode.removeChild(hiddenTextarea);
|
|
102
|
+
hiddenTextarea = null;
|
|
103
|
+
return result;
|
|
104
|
+
};
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="[
|
|
3
|
+
type === 'textarea' ? 'el-textarea' : 'el-input',
|
|
4
|
+
inputSize ? 'el-input--' + inputSize : '',
|
|
5
|
+
{
|
|
6
|
+
'is-disabled': inputDisabled,
|
|
7
|
+
'is-exceed': inputExceed,
|
|
8
|
+
'el-input-group': $slots.prepend || $slots.append,
|
|
9
|
+
'el-input-group--append': $slots.append,
|
|
10
|
+
'el-input-group--prepend': $slots.prepend,
|
|
11
|
+
'el-input--prefix': $slots.prefix || prefixIcon,
|
|
12
|
+
'el-input--suffix': $slots.suffix || suffixIcon || clearable || showPassword
|
|
13
|
+
}
|
|
14
|
+
]"
|
|
15
|
+
@mouseenter="hovering = true"
|
|
16
|
+
@mouseleave="hovering = false"
|
|
17
|
+
>
|
|
18
|
+
<template v-if="type !== 'textarea'">
|
|
19
|
+
<!-- 前置元素 -->
|
|
20
|
+
<div class="el-input-group__prepend" v-if="$slots.prepend">
|
|
21
|
+
<slot name="prepend"></slot>
|
|
22
|
+
</div>
|
|
23
|
+
<input
|
|
24
|
+
:tabindex="tabindex"
|
|
25
|
+
v-if="type !== 'textarea'"
|
|
26
|
+
class="el-input__inner"
|
|
27
|
+
v-bind="$attrs"
|
|
28
|
+
:type="showPassword ? (passwordVisible ? 'text': 'password') : type"
|
|
29
|
+
:disabled="inputDisabled"
|
|
30
|
+
:readonly="readonly"
|
|
31
|
+
:autocomplete="autoComplete || autocomplete"
|
|
32
|
+
ref="input"
|
|
33
|
+
@compositionstart="handleCompositionStart"
|
|
34
|
+
@compositionend="handleCompositionEnd"
|
|
35
|
+
@input="handleInput"
|
|
36
|
+
@focus="handleFocus"
|
|
37
|
+
@blur="handleBlur"
|
|
38
|
+
@change="handleChange"
|
|
39
|
+
:aria-label="label"
|
|
40
|
+
>
|
|
41
|
+
<!-- 前置内容 -->
|
|
42
|
+
<span class="el-input__prefix" v-if="$slots.prefix || prefixIcon">
|
|
43
|
+
<slot name="prefix"></slot>
|
|
44
|
+
<i class="el-input__icon"
|
|
45
|
+
v-if="prefixIcon"
|
|
46
|
+
:class="prefixIcon">
|
|
47
|
+
</i>
|
|
48
|
+
</span>
|
|
49
|
+
<!-- 后置内容 -->
|
|
50
|
+
<span
|
|
51
|
+
class="el-input__suffix"
|
|
52
|
+
v-if="getSuffixVisible()">
|
|
53
|
+
<span class="el-input__suffix-inner">
|
|
54
|
+
<template v-if="!showClear || !showPwdVisible || !isWordLimitVisible">
|
|
55
|
+
<slot name="suffix"></slot>
|
|
56
|
+
<i class="el-input__icon"
|
|
57
|
+
v-if="suffixIcon"
|
|
58
|
+
:class="suffixIcon">
|
|
59
|
+
</i>
|
|
60
|
+
</template>
|
|
61
|
+
<i v-if="showClear"
|
|
62
|
+
class="el-input__icon el-icon-circle-close el-input__clear"
|
|
63
|
+
@click="clear"
|
|
64
|
+
></i>
|
|
65
|
+
<i v-if="showPwdVisible"
|
|
66
|
+
class="el-input__icon el-icon-view el-input__clear"
|
|
67
|
+
@click="handlePasswordVisible"
|
|
68
|
+
></i>
|
|
69
|
+
<span v-if="isWordLimitVisible" class="el-input__count">
|
|
70
|
+
<span class="el-input__count-inner">
|
|
71
|
+
{{ textLength }}/{{ upperLimit }}
|
|
72
|
+
</span>
|
|
73
|
+
</span>
|
|
74
|
+
</span>
|
|
75
|
+
<i class="el-input__icon"
|
|
76
|
+
v-if="validateState"
|
|
77
|
+
:class="['el-input__validateIcon', validateIcon]">
|
|
78
|
+
</i>
|
|
79
|
+
</span>
|
|
80
|
+
<!-- 后置元素 -->
|
|
81
|
+
<div class="el-input-group__append" v-if="$slots.append">
|
|
82
|
+
<slot name="append"></slot>
|
|
83
|
+
</div>
|
|
84
|
+
</template>
|
|
85
|
+
<textarea
|
|
86
|
+
v-else
|
|
87
|
+
:tabindex="tabindex"
|
|
88
|
+
class="el-textarea__inner"
|
|
89
|
+
@compositionstart="handleCompositionStart"
|
|
90
|
+
@compositionend="handleCompositionEnd"
|
|
91
|
+
@input="handleInput"
|
|
92
|
+
ref="textarea"
|
|
93
|
+
v-bind="$attrs"
|
|
94
|
+
:disabled="inputDisabled"
|
|
95
|
+
:readonly="readonly"
|
|
96
|
+
:autocomplete="autoComplete || autocomplete"
|
|
97
|
+
:style="textareaStyle"
|
|
98
|
+
@focus="handleFocus"
|
|
99
|
+
@blur="handleBlur"
|
|
100
|
+
@change="handleChange"
|
|
101
|
+
:aria-label="label"
|
|
102
|
+
>
|
|
103
|
+
</textarea>
|
|
104
|
+
<span v-if="isWordLimitVisible && type === 'textarea'" class="el-input__count">{{ textLength }}/{{ upperLimit }}</span>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
<script>
|
|
108
|
+
import emitter from '../../tools/mixins/emitter';
|
|
109
|
+
import Migrating from '../../tools/mixins/migrating';
|
|
110
|
+
import calcTextareaHeight from './calcTextareaHeight';
|
|
111
|
+
import merge from '../../tools/utils/merge';
|
|
112
|
+
|
|
113
|
+
export default {
|
|
114
|
+
name: 'ElInput',
|
|
115
|
+
|
|
116
|
+
componentName: 'ElInput',
|
|
117
|
+
|
|
118
|
+
mixins: [emitter, Migrating],
|
|
119
|
+
|
|
120
|
+
inheritAttrs: false,
|
|
121
|
+
|
|
122
|
+
inject: {
|
|
123
|
+
elForm: {
|
|
124
|
+
default: ''
|
|
125
|
+
},
|
|
126
|
+
elFormItem: {
|
|
127
|
+
default: ''
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
data() {
|
|
132
|
+
return {
|
|
133
|
+
textareaCalcStyle: {},
|
|
134
|
+
hovering: false,
|
|
135
|
+
focused: false,
|
|
136
|
+
isComposing: false,
|
|
137
|
+
passwordVisible: false
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
props: {
|
|
142
|
+
value: [String, Number],
|
|
143
|
+
size: String,
|
|
144
|
+
resize: String,
|
|
145
|
+
form: String,
|
|
146
|
+
disabled: Boolean,
|
|
147
|
+
readonly: Boolean,
|
|
148
|
+
type: {
|
|
149
|
+
type: String,
|
|
150
|
+
default: 'text'
|
|
151
|
+
},
|
|
152
|
+
autosize: {
|
|
153
|
+
type: [Boolean, Object],
|
|
154
|
+
default: false
|
|
155
|
+
},
|
|
156
|
+
autocomplete: {
|
|
157
|
+
type: String,
|
|
158
|
+
default: 'off'
|
|
159
|
+
},
|
|
160
|
+
/** @Deprecated in next major version */
|
|
161
|
+
autoComplete: {
|
|
162
|
+
type: String,
|
|
163
|
+
validator(val) {
|
|
164
|
+
process.env.NODE_ENV !== 'production' &&
|
|
165
|
+
console.warn('[Element Warn][Input]\'auto-complete\' property will be deprecated in next major version. please use \'autocomplete\' instead.');
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
validateEvent: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
default: true
|
|
172
|
+
},
|
|
173
|
+
suffixIcon: String,
|
|
174
|
+
prefixIcon: String,
|
|
175
|
+
label: String,
|
|
176
|
+
clearable: {
|
|
177
|
+
type: Boolean,
|
|
178
|
+
default: false
|
|
179
|
+
},
|
|
180
|
+
showPassword: {
|
|
181
|
+
type: Boolean,
|
|
182
|
+
default: false
|
|
183
|
+
},
|
|
184
|
+
showWordLimit: {
|
|
185
|
+
type: Boolean,
|
|
186
|
+
default: false
|
|
187
|
+
},
|
|
188
|
+
tabindex: String
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
computed: {
|
|
192
|
+
_elFormItemSize() {
|
|
193
|
+
return (this.elFormItem || {}).elFormItemSize;
|
|
194
|
+
},
|
|
195
|
+
validateState() {
|
|
196
|
+
return this.elFormItem ? this.elFormItem.validateState : '';
|
|
197
|
+
},
|
|
198
|
+
needStatusIcon() {
|
|
199
|
+
return this.elForm ? this.elForm.statusIcon : false;
|
|
200
|
+
},
|
|
201
|
+
validateIcon() {
|
|
202
|
+
return {
|
|
203
|
+
validating: 'el-icon-loading',
|
|
204
|
+
success: 'el-icon-circle-check',
|
|
205
|
+
error: 'el-icon-circle-close'
|
|
206
|
+
}[this.validateState];
|
|
207
|
+
},
|
|
208
|
+
textareaStyle() {
|
|
209
|
+
return merge({}, this.textareaCalcStyle, { resize: this.resize });
|
|
210
|
+
},
|
|
211
|
+
inputSize() {
|
|
212
|
+
return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
|
|
213
|
+
},
|
|
214
|
+
inputDisabled() {
|
|
215
|
+
return this.disabled || (this.elForm || {}).disabled;
|
|
216
|
+
},
|
|
217
|
+
nativeInputValue() {
|
|
218
|
+
return this.value === null || this.value === undefined ? '' : String(this.value);
|
|
219
|
+
},
|
|
220
|
+
showClear() {
|
|
221
|
+
return this.clearable &&
|
|
222
|
+
!this.inputDisabled &&
|
|
223
|
+
!this.readonly &&
|
|
224
|
+
this.nativeInputValue &&
|
|
225
|
+
(this.focused || this.hovering);
|
|
226
|
+
},
|
|
227
|
+
showPwdVisible() {
|
|
228
|
+
return this.showPassword &&
|
|
229
|
+
!this.inputDisabled &&
|
|
230
|
+
!this.readonly &&
|
|
231
|
+
(!!this.nativeInputValue || this.focused);
|
|
232
|
+
},
|
|
233
|
+
isWordLimitVisible() {
|
|
234
|
+
return this.showWordLimit &&
|
|
235
|
+
this.$attrs.maxlength &&
|
|
236
|
+
(this.type === 'text' || this.type === 'textarea') &&
|
|
237
|
+
!this.inputDisabled &&
|
|
238
|
+
!this.readonly &&
|
|
239
|
+
!this.showPassword;
|
|
240
|
+
},
|
|
241
|
+
upperLimit() {
|
|
242
|
+
return this.$attrs.maxlength;
|
|
243
|
+
},
|
|
244
|
+
textLength() {
|
|
245
|
+
if (typeof this.value === 'number') {
|
|
246
|
+
return String(this.value).length;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return (this.value || '').length;
|
|
250
|
+
},
|
|
251
|
+
inputExceed() {
|
|
252
|
+
// show exceed style if length of initial value greater then maxlength
|
|
253
|
+
return this.isWordLimitVisible &&
|
|
254
|
+
(this.textLength > this.upperLimit);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
watch: {
|
|
259
|
+
value(val) {
|
|
260
|
+
this.$nextTick(this.resizeTextarea);
|
|
261
|
+
if (this.validateEvent) {
|
|
262
|
+
this.dispatch('ElFormItem', 'el.form.change', [val]);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
// native input value is set explicitly
|
|
266
|
+
// do not use v-model / :value in template
|
|
267
|
+
// see: https://github.com/ElemeFE/element/issues/14521
|
|
268
|
+
nativeInputValue() {
|
|
269
|
+
this.setNativeInputValue();
|
|
270
|
+
},
|
|
271
|
+
// when change between <input> and <textarea>,
|
|
272
|
+
// update DOM dependent value and styles
|
|
273
|
+
// https://github.com/ElemeFE/element/issues/14857
|
|
274
|
+
type() {
|
|
275
|
+
this.$nextTick(() => {
|
|
276
|
+
this.setNativeInputValue();
|
|
277
|
+
this.resizeTextarea();
|
|
278
|
+
this.updateIconOffset();
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
methods: {
|
|
284
|
+
focus() {
|
|
285
|
+
this.getInput().focus();
|
|
286
|
+
},
|
|
287
|
+
blur() {
|
|
288
|
+
this.getInput().blur();
|
|
289
|
+
},
|
|
290
|
+
getMigratingConfig() {
|
|
291
|
+
return {
|
|
292
|
+
props: {
|
|
293
|
+
'icon': 'icon is removed, use suffix-icon / prefix-icon instead.',
|
|
294
|
+
'on-icon-click': 'on-icon-click is removed.'
|
|
295
|
+
},
|
|
296
|
+
events: {
|
|
297
|
+
'click': 'click is removed.'
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
handleBlur(event) {
|
|
302
|
+
this.focused = false;
|
|
303
|
+
this.$emit('blur', event);
|
|
304
|
+
if (this.validateEvent) {
|
|
305
|
+
this.dispatch('ElFormItem', 'el.form.blur', [this.value]);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
select() {
|
|
309
|
+
this.getInput().select();
|
|
310
|
+
},
|
|
311
|
+
resizeTextarea() {
|
|
312
|
+
if (this.$isServer) return;
|
|
313
|
+
const { autosize, type } = this;
|
|
314
|
+
if (type !== 'textarea') return;
|
|
315
|
+
if (!autosize) {
|
|
316
|
+
this.textareaCalcStyle = {
|
|
317
|
+
minHeight: calcTextareaHeight(this.$refs.textarea).minHeight
|
|
318
|
+
};
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const minRows = autosize.minRows;
|
|
322
|
+
const maxRows = autosize.maxRows;
|
|
323
|
+
|
|
324
|
+
this.textareaCalcStyle = calcTextareaHeight(this.$refs.textarea, minRows, maxRows);
|
|
325
|
+
},
|
|
326
|
+
setNativeInputValue() {
|
|
327
|
+
const input = this.getInput();
|
|
328
|
+
if (!input) return;
|
|
329
|
+
if (input.value === this.nativeInputValue) return;
|
|
330
|
+
input.value = this.nativeInputValue;
|
|
331
|
+
},
|
|
332
|
+
handleFocus(event) {
|
|
333
|
+
this.focused = true;
|
|
334
|
+
this.$emit('focus', event);
|
|
335
|
+
},
|
|
336
|
+
handleCompositionStart() {
|
|
337
|
+
this.isComposing = true;
|
|
338
|
+
},
|
|
339
|
+
handleCompositionEnd(event) {
|
|
340
|
+
this.isComposing = false;
|
|
341
|
+
this.handleInput(event);
|
|
342
|
+
},
|
|
343
|
+
handleInput(event) {
|
|
344
|
+
// should not emit input during composition
|
|
345
|
+
// see: https://github.com/ElemeFE/element/issues/10516
|
|
346
|
+
if (this.isComposing) return;
|
|
347
|
+
|
|
348
|
+
// hack for https://github.com/ElemeFE/element/issues/8548
|
|
349
|
+
// should remove the following line when we don't support IE
|
|
350
|
+
if (event.target.value === this.nativeInputValue) return;
|
|
351
|
+
|
|
352
|
+
this.$emit('input', event.target.value);
|
|
353
|
+
|
|
354
|
+
// ensure native input value is controlled
|
|
355
|
+
// see: https://github.com/ElemeFE/element/issues/12850
|
|
356
|
+
this.$nextTick(this.setNativeInputValue);
|
|
357
|
+
},
|
|
358
|
+
handleChange(event) {
|
|
359
|
+
this.$emit('change', event.target.value);
|
|
360
|
+
},
|
|
361
|
+
calcIconOffset(place) {
|
|
362
|
+
let elList = [].slice.call(this.$el.querySelectorAll(`.el-input__${place}`) || []);
|
|
363
|
+
if (!elList.length) return;
|
|
364
|
+
let el = null;
|
|
365
|
+
for (let i = 0; i < elList.length; i++) {
|
|
366
|
+
if (elList[i].parentNode === this.$el) {
|
|
367
|
+
el = elList[i];
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (!el) return;
|
|
372
|
+
const pendantMap = {
|
|
373
|
+
suffix: 'append',
|
|
374
|
+
prefix: 'prepend'
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
const pendant = pendantMap[place];
|
|
378
|
+
if (this.$slots[pendant]) {
|
|
379
|
+
el.style.transform = `translateX(${place === 'suffix' ? '-' : ''}${this.$el.querySelector(`.el-input-group__${pendant}`).offsetWidth}px)`;
|
|
380
|
+
} else {
|
|
381
|
+
el.removeAttribute('style');
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
updateIconOffset() {
|
|
385
|
+
this.calcIconOffset('prefix');
|
|
386
|
+
this.calcIconOffset('suffix');
|
|
387
|
+
},
|
|
388
|
+
clear() {
|
|
389
|
+
this.$emit('input', '');
|
|
390
|
+
this.$emit('change', '');
|
|
391
|
+
this.$emit('clear');
|
|
392
|
+
},
|
|
393
|
+
handlePasswordVisible() {
|
|
394
|
+
this.passwordVisible = !this.passwordVisible;
|
|
395
|
+
this.focus();
|
|
396
|
+
},
|
|
397
|
+
getInput() {
|
|
398
|
+
return this.$refs.input || this.$refs.textarea;
|
|
399
|
+
},
|
|
400
|
+
getSuffixVisible() {
|
|
401
|
+
return this.$slots.suffix ||
|
|
402
|
+
this.suffixIcon ||
|
|
403
|
+
this.showClear ||
|
|
404
|
+
this.showPassword ||
|
|
405
|
+
this.isWordLimitVisible ||
|
|
406
|
+
(this.validateState && this.needStatusIcon);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
created() {
|
|
411
|
+
this.$on('inputSelect', this.select);
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
mounted() {
|
|
415
|
+
this.setNativeInputValue();
|
|
416
|
+
this.resizeTextarea();
|
|
417
|
+
this.updateIconOffset();
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
updated() {
|
|
421
|
+
this.$nextTick(this.updateIconOffset);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
</script>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ul @click="onPagerClick" class="el-pager">
|
|
3
|
+
<li
|
|
4
|
+
:class="{ active: currentPage === 1, disabled }"
|
|
5
|
+
v-if="pageCount > 0"
|
|
6
|
+
class="number">1</li>
|
|
7
|
+
<li
|
|
8
|
+
class="el-icon more btn-quickprev"
|
|
9
|
+
:class="[quickprevIconClass, { disabled }]"
|
|
10
|
+
v-if="showPrevMore"
|
|
11
|
+
@mouseenter="onMouseenter('left')"
|
|
12
|
+
@mouseleave="quickprevIconClass = 'el-icon-more'">
|
|
13
|
+
</li>
|
|
14
|
+
<li
|
|
15
|
+
v-for="pager in pagers"
|
|
16
|
+
:key="pager"
|
|
17
|
+
:class="{ active: currentPage === pager, disabled }"
|
|
18
|
+
class="number">{{ pager }}</li>
|
|
19
|
+
<li
|
|
20
|
+
class="el-icon more btn-quicknext"
|
|
21
|
+
:class="[quicknextIconClass, { disabled }]"
|
|
22
|
+
v-if="showNextMore"
|
|
23
|
+
@mouseenter="onMouseenter('right')"
|
|
24
|
+
@mouseleave="quicknextIconClass = 'el-icon-more'">
|
|
25
|
+
</li>
|
|
26
|
+
<li
|
|
27
|
+
:class="{ active: currentPage === pageCount, disabled }"
|
|
28
|
+
class="number"
|
|
29
|
+
v-if="pageCount > 1">{{ pageCount }}</li>
|
|
30
|
+
</ul>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script type="text/babel">
|
|
34
|
+
export default {
|
|
35
|
+
name: 'ElPager',
|
|
36
|
+
|
|
37
|
+
props: {
|
|
38
|
+
currentPage: Number,
|
|
39
|
+
|
|
40
|
+
pageCount: Number,
|
|
41
|
+
|
|
42
|
+
pagerCount: Number,
|
|
43
|
+
|
|
44
|
+
disabled: Boolean
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
watch: {
|
|
48
|
+
showPrevMore(val) {
|
|
49
|
+
if (!val) this.quickprevIconClass = 'el-icon-more';
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
showNextMore(val) {
|
|
53
|
+
if (!val) this.quicknextIconClass = 'el-icon-more';
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
methods: {
|
|
58
|
+
onPagerClick(event) {
|
|
59
|
+
const target = event.target;
|
|
60
|
+
if (target.tagName === 'UL' || this.disabled) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let newPage = Number(event.target.textContent);
|
|
65
|
+
const pageCount = this.pageCount;
|
|
66
|
+
const currentPage = this.currentPage;
|
|
67
|
+
const pagerCountOffset = this.pagerCount - 2;
|
|
68
|
+
|
|
69
|
+
if (target.className.indexOf('more') !== -1) {
|
|
70
|
+
if (target.className.indexOf('quickprev') !== -1) {
|
|
71
|
+
newPage = currentPage - pagerCountOffset;
|
|
72
|
+
} else if (target.className.indexOf('quicknext') !== -1) {
|
|
73
|
+
newPage = currentPage + pagerCountOffset;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* istanbul ignore if */
|
|
78
|
+
if (!isNaN(newPage)) {
|
|
79
|
+
if (newPage < 1) {
|
|
80
|
+
newPage = 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (newPage > pageCount) {
|
|
84
|
+
newPage = pageCount;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (newPage !== currentPage) {
|
|
89
|
+
this.$emit('change', newPage);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
onMouseenter(direction) {
|
|
94
|
+
if (this.disabled) return;
|
|
95
|
+
if (direction === 'left') {
|
|
96
|
+
this.quickprevIconClass = 'el-icon-d-arrow-left';
|
|
97
|
+
} else {
|
|
98
|
+
this.quicknextIconClass = 'el-icon-d-arrow-right';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
computed: {
|
|
104
|
+
pagers() {
|
|
105
|
+
const pagerCount = this.pagerCount;
|
|
106
|
+
const halfPagerCount = (pagerCount - 1) / 2;
|
|
107
|
+
|
|
108
|
+
const currentPage = Number(this.currentPage);
|
|
109
|
+
const pageCount = Number(this.pageCount);
|
|
110
|
+
|
|
111
|
+
let showPrevMore = false;
|
|
112
|
+
let showNextMore = false;
|
|
113
|
+
|
|
114
|
+
if (pageCount > pagerCount) {
|
|
115
|
+
if (currentPage > pagerCount - halfPagerCount) {
|
|
116
|
+
showPrevMore = true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (currentPage < pageCount - halfPagerCount) {
|
|
120
|
+
showNextMore = true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const array = [];
|
|
125
|
+
|
|
126
|
+
if (showPrevMore && !showNextMore) {
|
|
127
|
+
const startPage = pageCount - (pagerCount - 2);
|
|
128
|
+
for (let i = startPage; i < pageCount; i++) {
|
|
129
|
+
array.push(i);
|
|
130
|
+
}
|
|
131
|
+
} else if (!showPrevMore && showNextMore) {
|
|
132
|
+
for (let i = 2; i < pagerCount; i++) {
|
|
133
|
+
array.push(i);
|
|
134
|
+
}
|
|
135
|
+
} else if (showPrevMore && showNextMore) {
|
|
136
|
+
const offset = Math.floor(pagerCount / 2) - 1;
|
|
137
|
+
for (let i = currentPage - offset ; i <= currentPage + offset; i++) {
|
|
138
|
+
array.push(i);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
for (let i = 2; i < pageCount; i++) {
|
|
142
|
+
array.push(i);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.showPrevMore = showPrevMore;
|
|
147
|
+
this.showNextMore = showNextMore;
|
|
148
|
+
|
|
149
|
+
return array;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
data() {
|
|
154
|
+
return {
|
|
155
|
+
current: null,
|
|
156
|
+
showPrevMore: false,
|
|
157
|
+
showNextMore: false,
|
|
158
|
+
quicknextIconClass: 'el-icon-more',
|
|
159
|
+
quickprevIconClass: 'el-icon-more'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
</script>
|