iov-design 2.15.59 → 2.15.61
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/README.md +148 -148
- package/lib/alert.js +24 -105
- package/lib/aside.js +24 -34
- package/lib/autocomplete.js +36 -240
- package/lib/avatar.js +21 -20
- package/lib/backtop.js +27 -52
- package/lib/badge.js +30 -58
- package/lib/breadcrumb-item.js +24 -53
- package/lib/breadcrumb.js +24 -37
- package/lib/button-group.js +24 -29
- package/lib/button.js +38 -60
- package/lib/calendar.js +29 -146
- package/lib/card.js +24 -51
- package/lib/carousel-item.js +30 -68
- package/lib/carousel.js +27 -159
- package/lib/cascader-panel.js +41 -64
- package/lib/cascader.js +37 -470
- package/lib/checkbox-button.js +28 -164
- package/lib/checkbox-group.js +24 -37
- package/lib/checkbox.js +35 -189
- package/lib/col.js +1 -0
- package/lib/collapse-item.js +27 -125
- package/lib/collapse.js +24 -37
- package/lib/color-picker.js +104 -424
- package/lib/container.js +24 -34
- package/lib/date-picker.js +126 -1981
- package/lib/descriptions-item.js +1 -0
- package/lib/descriptions.js +1 -0
- package/lib/dialog.js +24 -137
- package/lib/divider.js +29 -64
- package/lib/drawer.js +24 -139
- package/lib/dropdown-item.js +27 -45
- package/lib/dropdown-menu.js +24 -51
- package/lib/dropdown.js +21 -20
- package/lib/empty.js +24 -61
- package/lib/footer.js +24 -34
- package/lib/form-item.js +42 -128
- package/lib/form.js +27 -40
- package/lib/header.js +24 -34
- package/lib/icon.js +24 -29
- package/lib/image.js +36 -220
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +1 -0
- package/lib/input-number.js +30 -163
- package/lib/input.js +42 -274
- package/lib/iov-design.common.js +1638 -11132
- package/lib/link.js +33 -55
- package/lib/loading.js +24 -77
- package/lib/locale/format.js +10 -10
- package/lib/main.js +24 -29
- package/lib/menu-item-group.js +24 -40
- package/lib/menu-item.js +27 -83
- package/lib/menu.js +21 -20
- package/lib/message-box.js +24 -321
- package/lib/message.js +30 -82
- package/lib/mixins/migrating.js +20 -20
- package/lib/notification.js +24 -109
- package/lib/option-group.js +24 -50
- package/lib/option.js +27 -76
- package/lib/page-header.js +24 -56
- package/lib/pagination.js +24 -97
- package/lib/popconfirm.js +24 -97
- package/lib/popover.js +24 -89
- package/lib/progress.js +30 -133
- package/lib/radio-button.js +29 -111
- package/lib/radio-group.js +24 -39
- package/lib/radio.js +36 -152
- package/lib/rate.js +24 -94
- package/lib/result.js +72 -187
- package/lib/row.js +1 -0
- package/lib/scrollbar.js +1 -0
- package/lib/select.js +48 -637
- package/lib/skeleton-item.js +36 -68
- package/lib/skeleton.js +28 -70
- package/lib/slider.js +36 -267
- package/lib/spinner.js +24 -51
- package/lib/statistic.js +24 -76
- package/lib/step.js +29 -118
- package/lib/steps.js +27 -40
- package/lib/submenu.js +21 -20
- package/lib/switch.js +24 -130
- package/lib/tab-pane.js +24 -52
- package/lib/table-column.js +1 -0
- package/lib/table.js +93 -633
- package/lib/tabs.js +34 -49
- package/lib/tag.js +22 -21
- package/lib/theme-chalk/base.css +1 -1
- package/lib/theme-chalk/button.css +1 -1
- package/lib/theme-chalk/calendar.css +1 -1
- package/lib/theme-chalk/cascader-panel.css +1 -1
- package/lib/theme-chalk/cascader.css +1 -1
- package/lib/theme-chalk/dropdown.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/iovfont.css +1 -1
- package/lib/theme-chalk/link.css +1 -1
- package/lib/theme-chalk/message-box.css +1 -1
- package/lib/theme-chalk/pagination.css +1 -1
- package/lib/theme-chalk/radio.css +1 -1
- package/lib/theme-chalk/select.css +1 -1
- package/lib/theme-chalk/table-column.css +1 -1
- package/lib/theme-chalk/table.css +1 -1
- package/lib/theme-chalk/tabs.css +1 -1
- package/lib/theme-chalk/tag.css +1 -1
- package/lib/theme-chalk/transfer.css +1 -1
- package/lib/time-picker.js +58 -820
- package/lib/time-select.js +42 -303
- package/lib/timeline-item.js +29 -75
- package/lib/timeline.js +21 -20
- package/lib/tooltip.js +1 -0
- package/lib/transfer.js +36 -299
- package/lib/tree.js +54 -243
- package/lib/upload.js +86 -654
- package/lib/utils/clickoutside.js +7 -7
- package/lib/utils/vue-popper.js +7 -7
- package/package.json +154 -154
- package/packages/autocomplete/src/autocomplete-suggestions.vue +76 -76
- package/packages/autocomplete/src/autocomplete.vue +285 -285
- package/packages/button/src/button.vue +90 -90
- package/packages/calendar/src/date-table.vue +200 -200
- package/packages/calendar/src/main.vue +280 -280
- package/packages/carousel/src/item.vue +138 -138
- package/packages/carousel/src/main.vue +315 -315
- package/packages/cascader/src/cascader.vue +776 -776
- package/packages/cascader-panel/src/cascader-menu.vue +138 -138
- package/packages/cascader-panel/src/cascader-node.vue +246 -246
- package/packages/cascader-panel/src/cascader-panel.vue +391 -391
- package/packages/cascader-panel/src/node.js +166 -166
- package/packages/cascader-panel/src/store.js +58 -58
- package/packages/checkbox/src/checkbox-button.vue +199 -199
- package/packages/checkbox/src/checkbox-group.vue +49 -49
- package/packages/checkbox/src/checkbox.vue +225 -225
- package/packages/collapse/src/collapse-item.vue +114 -114
- package/packages/color-picker/src/components/picker-dropdown.vue +121 -121
- package/packages/color-picker/src/main.vue +188 -188
- package/packages/date-picker/src/basic/date-table.vue +441 -441
- package/packages/date-picker/src/basic/month-table.vue +269 -269
- package/packages/date-picker/src/basic/time-spinner.vue +304 -304
- package/packages/date-picker/src/basic/year-table.vue +111 -111
- package/packages/date-picker/src/panel/date-range.vue +680 -680
- package/packages/date-picker/src/panel/date.vue +609 -609
- package/packages/date-picker/src/panel/month-range.vue +289 -289
- package/packages/date-picker/src/panel/time-range.vue +248 -248
- package/packages/date-picker/src/panel/time-select.vue +178 -178
- package/packages/date-picker/src/panel/time.vue +186 -186
- package/packages/date-picker/src/picker.vue +967 -967
- package/packages/descriptions/src/index.js +180 -180
- package/packages/dialog/src/component.vue +262 -262
- package/packages/drawer/src/main.vue +205 -205
- package/packages/dropdown/src/dropdown-item.vue +37 -37
- package/packages/dropdown/src/dropdown-menu.vue +63 -63
- package/packages/dropdown/src/dropdown.vue +293 -293
- package/packages/empty/src/index.vue +70 -70
- package/packages/form/src/form-item.vue +324 -324
- package/packages/form/src/form.vue +182 -182
- package/packages/image/src/image-viewer.vue +330 -330
- package/packages/image/src/main.vue +249 -249
- package/packages/infinite-scroll/src/main.js +150 -150
- package/packages/input/src/input.vue +477 -477
- package/packages/input-number/src/input-number.vue +283 -283
- package/packages/link/src/main.vue +2 -0
- package/packages/loading/src/directive.js +133 -133
- package/packages/loading/src/index.js +106 -106
- package/packages/menu/src/menu-item.vue +112 -112
- package/packages/menu/src/menu.vue +325 -325
- package/packages/menu/src/submenu.vue +349 -349
- package/packages/message/src/main.js +91 -91
- package/packages/message-box/src/main.js +216 -216
- package/packages/message-box/src/main.vue +333 -333
- package/packages/notification/src/main.js +94 -94
- package/packages/page-header/src/main.vue +30 -30
- package/packages/pagination/src/pagination.js +390 -390
- package/packages/popconfirm/src/main.vue +104 -104
- package/packages/popover/src/main.vue +239 -239
- package/packages/radio/src/radio-button.vue +115 -115
- package/packages/radio/src/radio-group.vue +115 -115
- package/packages/radio/src/radio.vue +148 -148
- package/packages/rate/src/main.vue +348 -348
- package/packages/scrollbar/src/bar.js +92 -92
- package/packages/scrollbar/src/main.js +130 -130
- package/packages/select/src/option-group.vue +60 -60
- package/packages/select/src/option.vue +171 -171
- package/packages/select/src/select-dropdown.vue +74 -74
- package/packages/select/src/select.vue +979 -979
- package/packages/slider/src/button.vue +238 -238
- package/packages/slider/src/main.vue +427 -427
- package/packages/statistic/src/main.vue +204 -204
- package/packages/steps/src/steps.vue +68 -68
- package/packages/switch/src/component.vue +182 -182
- package/packages/table/src/config.js +153 -153
- package/packages/table/src/filter-panel.vue +194 -194
- package/packages/table/src/store/current.js +76 -76
- package/packages/table/src/store/helper.js +41 -41
- package/packages/table/src/store/index.js +147 -147
- package/packages/table/src/store/watcher.js +502 -502
- package/packages/table/src/table-body.js +469 -469
- package/packages/table/src/table-column.js +328 -328
- package/packages/table/src/table-header.js +571 -571
- package/packages/table/src/table-layout.js +249 -249
- package/packages/table/src/table-row.js +101 -101
- package/packages/table/src/table.vue +740 -740
- package/packages/table/src/util.js +273 -273
- package/packages/tabs/src/tab-bar.vue +57 -57
- package/packages/tabs/src/tab-nav.vue +294 -294
- package/packages/tabs/src/tabs.vue +201 -201
- package/packages/tag/src/tag.vue +1 -1
- package/packages/theme-chalk/src/button.scss +416 -416
- package/packages/theme-chalk/src/cascader.scss +252 -252
- package/packages/theme-chalk/src/checkbox.scss +419 -419
- package/packages/theme-chalk/src/common/var.scss +795 -816
- package/packages/theme-chalk/src/form.scss +201 -201
- package/packages/theme-chalk/src/input.scss +591 -591
- package/packages/theme-chalk/src/iovfont.scss +803 -784
- package/packages/theme-chalk/src/link.scss +36 -19
- package/packages/theme-chalk/src/message-box.scss +207 -207
- package/packages/theme-chalk/src/mixins/_button.scss +136 -136
- package/packages/theme-chalk/src/mixins/mixins.scss +190 -190
- package/packages/theme-chalk/src/radio-button.scss +115 -115
- package/packages/theme-chalk/src/radio.scss +1 -0
- package/packages/theme-chalk/src/select.scss +270 -270
- package/packages/theme-chalk/src/table.scss +1 -2
- package/packages/theme-chalk/src/tabs.scss +755 -750
- package/packages/theme-chalk/src/tag.scss +4 -4
- package/packages/theme-chalk/src/upload.scss +568 -568
- package/packages/tooltip/src/main.js +242 -242
- package/packages/transfer/src/main.vue +231 -231
- package/packages/transfer/src/transfer-panel.vue +251 -251
- package/packages/tree/src/model/node.js +484 -484
- package/packages/tree/src/tree-node.vue +279 -279
- package/packages/tree/src/tree.vue +496 -496
- package/packages/upload/src/index.vue +420 -420
- package/packages/upload/src/upload-file.vue +98 -98
- package/packages/upload/src/upload-list.vue +115 -115
- package/packages/upload/src/upload-picture.vue +98 -98
- package/packages/upload/src/upload.vue +231 -231
- package/packages/upload/src/utils.js +31 -31
- package/src/directives/repeat-click.js +26 -26
- package/src/index.js +259 -259
- package/src/locale/format.js +46 -46
- package/src/locale/index.js +48 -48
- package/src/locale/lang/lo-LA.js +126 -126
- package/src/mixins/locale.js +9 -9
- package/src/mixins/migrating.js +54 -54
- package/src/transitions/collapse-transition.js +77 -77
- package/src/utils/clickoutside.js +76 -76
- package/src/utils/date-util.js +282 -282
- package/src/utils/popup/index.js +218 -218
- package/src/utils/popup/popup-manager.js +194 -194
- package/src/utils/util.js +245 -245
- package/src/utils/vdom.js +5 -5
- package/src/utils/vue-popper.js +198 -198
|
@@ -1,477 +1,477 @@
|
|
|
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 || $slots.prefixLabel || $slots.suffixLabel,
|
|
9
|
-
'el-input-group--append': $slots.append,
|
|
10
|
-
'el-input-group--prepend': $slots.prepend,
|
|
11
|
-
'is-focus': ($slots.suffixLabel || $slots.prefixLabel) && focused,
|
|
12
|
-
'el-input--prefix': $slots.prefix || prefixIcon,
|
|
13
|
-
'el-input--suffix': $slots.suffix || suffixIcon || clearable || showPassword
|
|
14
|
-
}
|
|
15
|
-
]"
|
|
16
|
-
@mouseenter="hovering = true"
|
|
17
|
-
@mouseleave="hovering = false"
|
|
18
|
-
>
|
|
19
|
-
<template v-if="type !== 'textarea'">
|
|
20
|
-
<!-- 前置元素 -->
|
|
21
|
-
<div class="el-input-group__prepend" v-if="$slots.prepend">
|
|
22
|
-
<slot name="prepend"></slot>
|
|
23
|
-
</div>
|
|
24
|
-
<div class="el-input-group__inner" :class="{
|
|
25
|
-
'is-disabled': inputDisabled,
|
|
26
|
-
'el-input-group--prefix': $slots.prefixLabel,
|
|
27
|
-
'el-input-group--suffix': $slots.suffixLabel,
|
|
28
|
-
'is-focus': ($slots.suffixLabel || $slots.prefixLabel) && focused
|
|
29
|
-
}">
|
|
30
|
-
<!-- 前置标签 -->
|
|
31
|
-
<div class="el-input-group__prefix-label" v-if="$slots.prefixLabel">
|
|
32
|
-
<slot name="prefixLabel"></slot>
|
|
33
|
-
</div>
|
|
34
|
-
<input
|
|
35
|
-
:tabindex="tabindex"
|
|
36
|
-
v-if="type !== 'textarea'"
|
|
37
|
-
class="el-input__inner"
|
|
38
|
-
v-bind="$attrs"
|
|
39
|
-
:type="showPassword ? (passwordVisible ? 'text': 'password') : type"
|
|
40
|
-
:disabled="inputDisabled"
|
|
41
|
-
:readonly="readonly"
|
|
42
|
-
:autocomplete="autoComplete || autocomplete"
|
|
43
|
-
ref="input"
|
|
44
|
-
@compositionstart="handleCompositionStart"
|
|
45
|
-
@compositionupdate="handleCompositionUpdate"
|
|
46
|
-
@compositionend="handleCompositionEnd"
|
|
47
|
-
@input="handleInput"
|
|
48
|
-
@focus="handleFocus"
|
|
49
|
-
@blur="handleBlur"
|
|
50
|
-
@change="handleChange"
|
|
51
|
-
:aria-label="label"
|
|
52
|
-
>
|
|
53
|
-
<!-- 前置内容 -->
|
|
54
|
-
<span class="el-input__prefix" v-if="$slots.prefix || prefixIcon">
|
|
55
|
-
<slot name="prefix"></slot>
|
|
56
|
-
<i class="el-input__icon" v-if="prefixIcon" :class="prefixIcon"></i>
|
|
57
|
-
</span>
|
|
58
|
-
<!-- 后置内容 -->
|
|
59
|
-
<span class="el-input__suffix" v-if="getSuffixVisible()">
|
|
60
|
-
<span class="el-input__suffix-inner">
|
|
61
|
-
<i v-if="showClear" class="el-input__icon iov-icon-close-mini el-input__clear" @mousedown.prevent @click="clear"></i>
|
|
62
|
-
<!-- 后置标签 -->
|
|
63
|
-
<span class="el-input-group__suffix-label" v-if="$slots.suffixLabel">
|
|
64
|
-
<slot name="suffixLabel"></slot>
|
|
65
|
-
</span>
|
|
66
|
-
<template v-if="!showClear || !showPwdVisible || !isWordLimitVisible">
|
|
67
|
-
<slot name="suffix"></slot>
|
|
68
|
-
<i class="el-input__icon" v-if="suffixIcon" :class="suffixIcon"></i>
|
|
69
|
-
</template>
|
|
70
|
-
<i v-if="showPwdVisible" class="el-input__icon" :class="passwordVisible ? 'iov-icon-eye' : 'iov-icon-eye-close'" @click="handlePasswordVisible"></i>
|
|
71
|
-
<span v-if="isWordLimitVisible" class="el-input__count">
|
|
72
|
-
<span class="el-input__count-inner">
|
|
73
|
-
{{ textLength }}/{{ upperLimit }}
|
|
74
|
-
</span>
|
|
75
|
-
</span>
|
|
76
|
-
<i class="el-input__icon" v-if="validateState && needStatusIcon" :class="['el-input__validateIcon', validateIcon]"></i>
|
|
77
|
-
</span>
|
|
78
|
-
</span>
|
|
79
|
-
</div>
|
|
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
|
-
@compositionupdate="handleCompositionUpdate"
|
|
91
|
-
@compositionend="handleCompositionEnd"
|
|
92
|
-
@input="handleInput"
|
|
93
|
-
ref="textarea"
|
|
94
|
-
v-bind="$attrs"
|
|
95
|
-
:disabled="inputDisabled"
|
|
96
|
-
:readonly="readonly"
|
|
97
|
-
:autocomplete="autoComplete || autocomplete"
|
|
98
|
-
:style="textareaStyle"
|
|
99
|
-
@focus="handleFocus"
|
|
100
|
-
@blur="handleBlur"
|
|
101
|
-
@change="handleChange"
|
|
102
|
-
:aria-label="label"
|
|
103
|
-
>
|
|
104
|
-
</textarea>
|
|
105
|
-
<span v-if="isWordLimitVisible && type === 'textarea'" class="el-input__count">{{ textLength }}/{{ upperLimit }}</span>
|
|
106
|
-
</div>
|
|
107
|
-
</template>
|
|
108
|
-
<script>
|
|
109
|
-
import { addClass, removeClass } from 'iov-design/src/utils/dom';
|
|
110
|
-
import emitter from 'iov-design/src/mixins/emitter';
|
|
111
|
-
import Migrating from 'iov-design/src/mixins/migrating';
|
|
112
|
-
import calcTextareaHeight from './calcTextareaHeight';
|
|
113
|
-
import merge from 'iov-design/src/utils/merge';
|
|
114
|
-
import {isKorean} from 'iov-design/src/utils/shared';
|
|
115
|
-
|
|
116
|
-
export default {
|
|
117
|
-
name: 'ElInput',
|
|
118
|
-
|
|
119
|
-
componentName: 'ElInput',
|
|
120
|
-
|
|
121
|
-
mixins: [emitter, Migrating],
|
|
122
|
-
|
|
123
|
-
inheritAttrs: false,
|
|
124
|
-
|
|
125
|
-
inject: {
|
|
126
|
-
elForm: {
|
|
127
|
-
default: ''
|
|
128
|
-
},
|
|
129
|
-
elFormItem: {
|
|
130
|
-
default: ''
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
data() {
|
|
135
|
-
return {
|
|
136
|
-
textareaCalcStyle: {},
|
|
137
|
-
hovering: false,
|
|
138
|
-
focused: false,
|
|
139
|
-
isComposing: false,
|
|
140
|
-
passwordVisible: false
|
|
141
|
-
};
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
props: {
|
|
145
|
-
value: [String, Number],
|
|
146
|
-
size: String,
|
|
147
|
-
resize: String,
|
|
148
|
-
form: String,
|
|
149
|
-
disabled: Boolean,
|
|
150
|
-
readonly: Boolean,
|
|
151
|
-
type: {
|
|
152
|
-
type: String,
|
|
153
|
-
default: 'text'
|
|
154
|
-
},
|
|
155
|
-
autosize: {
|
|
156
|
-
type: [Boolean, Object],
|
|
157
|
-
default: false
|
|
158
|
-
},
|
|
159
|
-
autocomplete: {
|
|
160
|
-
type: String,
|
|
161
|
-
default: 'off'
|
|
162
|
-
},
|
|
163
|
-
/** @Deprecated in next major version */
|
|
164
|
-
autoComplete: {
|
|
165
|
-
type: String,
|
|
166
|
-
validator(val) {
|
|
167
|
-
process.env.NODE_ENV !== 'production' &&
|
|
168
|
-
console.warn('[Element Warn][Input]\'auto-complete\' property will be deprecated in next major version. please use \'autocomplete\' instead.');
|
|
169
|
-
return true;
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
validateEvent: {
|
|
173
|
-
type: Boolean,
|
|
174
|
-
default: true
|
|
175
|
-
},
|
|
176
|
-
suffixIcon: String,
|
|
177
|
-
prefixIcon: String,
|
|
178
|
-
label: String,
|
|
179
|
-
clearable: {
|
|
180
|
-
type: Boolean,
|
|
181
|
-
default: false
|
|
182
|
-
},
|
|
183
|
-
showPassword: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
default: false
|
|
186
|
-
},
|
|
187
|
-
showWordLimit: {
|
|
188
|
-
type: Boolean,
|
|
189
|
-
default: false
|
|
190
|
-
},
|
|
191
|
-
tabindex: String
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
computed: {
|
|
195
|
-
_elFormItemSize() {
|
|
196
|
-
return (this.elFormItem || {}).elFormItemSize;
|
|
197
|
-
},
|
|
198
|
-
validateState() {
|
|
199
|
-
return this.elFormItem ? this.elFormItem.validateState : '';
|
|
200
|
-
},
|
|
201
|
-
needStatusIcon() {
|
|
202
|
-
return this.elForm ? this.elForm.statusIcon : false;
|
|
203
|
-
},
|
|
204
|
-
validateIcon() {
|
|
205
|
-
return {
|
|
206
|
-
validating: 'iov-icon-loading',
|
|
207
|
-
success: 'iov-icon-circle-success',
|
|
208
|
-
error: 'iov-icon-circle-fail'
|
|
209
|
-
}[this.validateState];
|
|
210
|
-
},
|
|
211
|
-
textareaStyle() {
|
|
212
|
-
return merge({}, this.textareaCalcStyle, { resize: this.resize });
|
|
213
|
-
},
|
|
214
|
-
inputSize() {
|
|
215
|
-
return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
|
|
216
|
-
},
|
|
217
|
-
inputDisabled() {
|
|
218
|
-
return this.disabled || (this.elForm || {}).disabled;
|
|
219
|
-
},
|
|
220
|
-
nativeInputValue() {
|
|
221
|
-
return this.value === null || this.value === undefined ? '' : String(this.value);
|
|
222
|
-
},
|
|
223
|
-
showClear() {
|
|
224
|
-
return this.clearable &&
|
|
225
|
-
!this.inputDisabled &&
|
|
226
|
-
!this.readonly &&
|
|
227
|
-
this.nativeInputValue &&
|
|
228
|
-
(this.focused || this.hovering);
|
|
229
|
-
},
|
|
230
|
-
showPwdVisible() {
|
|
231
|
-
return this.showPassword &&
|
|
232
|
-
!this.inputDisabled &&
|
|
233
|
-
!this.readonly &&
|
|
234
|
-
(!!this.nativeInputValue || this.focused);
|
|
235
|
-
},
|
|
236
|
-
isWordLimitVisible() {
|
|
237
|
-
return this.showWordLimit &&
|
|
238
|
-
this.$attrs.maxlength &&
|
|
239
|
-
(this.type === 'text' || this.type === 'textarea') &&
|
|
240
|
-
!this.inputDisabled &&
|
|
241
|
-
!this.readonly &&
|
|
242
|
-
!this.showPassword;
|
|
243
|
-
},
|
|
244
|
-
upperLimit() {
|
|
245
|
-
return this.$attrs.maxlength;
|
|
246
|
-
},
|
|
247
|
-
textLength() {
|
|
248
|
-
if (typeof this.value === 'number') {
|
|
249
|
-
return String(this.value).length;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return (this.value || '').length;
|
|
253
|
-
},
|
|
254
|
-
inputExceed() {
|
|
255
|
-
// show exceed style if length of initial value greater then maxlength
|
|
256
|
-
return this.isWordLimitVisible &&
|
|
257
|
-
(this.textLength > this.upperLimit);
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
watch: {
|
|
262
|
-
value(val) {
|
|
263
|
-
this.$nextTick(this.resizeTextarea);
|
|
264
|
-
if (this.validateEvent) {
|
|
265
|
-
this.dispatch('ElFormItem', 'el.form.change', [val]);
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
// native input value is set explicitly
|
|
269
|
-
// do not use v-model / :value in template
|
|
270
|
-
// see: https://github.com/ElemeFE/element/issues/14521
|
|
271
|
-
nativeInputValue() {
|
|
272
|
-
this.setNativeInputValue();
|
|
273
|
-
},
|
|
274
|
-
// when change between <input> and <textarea>,
|
|
275
|
-
// update DOM dependent value and styles
|
|
276
|
-
// https://github.com/ElemeFE/element/issues/14857
|
|
277
|
-
type() {
|
|
278
|
-
this.$nextTick(() => {
|
|
279
|
-
this.setNativeInputValue();
|
|
280
|
-
this.resizeTextarea();
|
|
281
|
-
this.updateIconOffset();
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
methods: {
|
|
287
|
-
focus() {
|
|
288
|
-
this.getInput().focus();
|
|
289
|
-
},
|
|
290
|
-
blur() {
|
|
291
|
-
this.getInput().blur();
|
|
292
|
-
},
|
|
293
|
-
getMigratingConfig() {
|
|
294
|
-
return {
|
|
295
|
-
props: {
|
|
296
|
-
'icon': 'icon is removed, use suffix-icon / prefix-icon instead.',
|
|
297
|
-
'on-icon-click': 'on-icon-click is removed.'
|
|
298
|
-
},
|
|
299
|
-
events: {
|
|
300
|
-
'click': 'click is removed.'
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
},
|
|
304
|
-
handleBlur(event) {
|
|
305
|
-
this.focused = false;
|
|
306
|
-
this.$emit('blur', event);
|
|
307
|
-
if (this.validateEvent) {
|
|
308
|
-
this.dispatch('ElFormItem', 'el.form.blur', [this.value]);
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
select() {
|
|
312
|
-
this.getInput().select();
|
|
313
|
-
},
|
|
314
|
-
resizeTextarea() {
|
|
315
|
-
if (this.$isServer) return;
|
|
316
|
-
const { autosize, type } = this;
|
|
317
|
-
if (type !== 'textarea') return;
|
|
318
|
-
if (!autosize) {
|
|
319
|
-
this.textareaCalcStyle = {
|
|
320
|
-
minHeight: calcTextareaHeight(this.$refs.textarea).minHeight
|
|
321
|
-
};
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
const minRows = autosize.minRows;
|
|
325
|
-
const maxRows = autosize.maxRows;
|
|
326
|
-
|
|
327
|
-
this.textareaCalcStyle = calcTextareaHeight(this.$refs.textarea, minRows, maxRows);
|
|
328
|
-
},
|
|
329
|
-
setNativeInputValue() {
|
|
330
|
-
const input = this.getInput();
|
|
331
|
-
if (!input) return;
|
|
332
|
-
if (input.value === this.nativeInputValue) return;
|
|
333
|
-
input.value = this.nativeInputValue;
|
|
334
|
-
},
|
|
335
|
-
handleFocus(event) {
|
|
336
|
-
this.focused = true;
|
|
337
|
-
this.$emit('focus', event);
|
|
338
|
-
},
|
|
339
|
-
handleCompositionStart(event) {
|
|
340
|
-
this.$emit('compositionstart', event);
|
|
341
|
-
this.isComposing = true;
|
|
342
|
-
},
|
|
343
|
-
handleCompositionUpdate(event) {
|
|
344
|
-
this.$emit('compositionupdate', event);
|
|
345
|
-
const text = event.target.value;
|
|
346
|
-
const lastCharacter = text[text.length - 1] || '';
|
|
347
|
-
this.isComposing = !isKorean(lastCharacter);
|
|
348
|
-
},
|
|
349
|
-
handleCompositionEnd(event) {
|
|
350
|
-
this.$emit('compositionend', event);
|
|
351
|
-
if (this.isComposing) {
|
|
352
|
-
this.isComposing = false;
|
|
353
|
-
this.handleInput(event);
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
handleInput(event) {
|
|
357
|
-
// should not emit input during composition
|
|
358
|
-
// see: https://github.com/ElemeFE/element/issues/10516
|
|
359
|
-
if (this.isComposing) return;
|
|
360
|
-
|
|
361
|
-
// hack for https://github.com/ElemeFE/element/issues/8548
|
|
362
|
-
// should remove the following line when we don't support IE
|
|
363
|
-
if (event.target.value === this.nativeInputValue) return;
|
|
364
|
-
|
|
365
|
-
this.$emit('input', event.target.value);
|
|
366
|
-
|
|
367
|
-
// ensure native input value is controlled
|
|
368
|
-
// see: https://github.com/ElemeFE/element/issues/12850
|
|
369
|
-
this.$nextTick(this.setNativeInputValue);
|
|
370
|
-
},
|
|
371
|
-
handleChange(event) {
|
|
372
|
-
this.$emit('change', event.target.value);
|
|
373
|
-
},
|
|
374
|
-
handlePendantCls(place) {
|
|
375
|
-
const pendantMap = {
|
|
376
|
-
suffix: 'append',
|
|
377
|
-
prefix: 'prepend'
|
|
378
|
-
};
|
|
379
|
-
const pendant = pendantMap[place];
|
|
380
|
-
const pendantEl = this.$el.querySelector(`.el-input-group__${pendant}`);
|
|
381
|
-
if (!pendantEl) return;
|
|
382
|
-
const isSelect = pendantEl.querySelector('.el-select');
|
|
383
|
-
const isButton = pendantEl.querySelector('.el-button');
|
|
384
|
-
if (isSelect) {
|
|
385
|
-
addClass(pendantEl, 'is-select');
|
|
386
|
-
} else {
|
|
387
|
-
removeClass(pendantEl, 'is-select');
|
|
388
|
-
}
|
|
389
|
-
if (isButton) {
|
|
390
|
-
addClass(pendantEl, 'is-button');
|
|
391
|
-
} else {
|
|
392
|
-
removeClass(pendantEl, 'is-button');
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
calcIconOffset(place) {
|
|
396
|
-
let elList = [].slice.call(this.$el.querySelectorAll(`.el-input__${place}`) || []);
|
|
397
|
-
if (!elList.length) return;
|
|
398
|
-
let el = null;
|
|
399
|
-
for (let i = 0; i < elList.length; i++) {
|
|
400
|
-
if (elList[i].parentNode.parentNode === this.$el) {
|
|
401
|
-
el = elList[i];
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
if (!el) return;
|
|
406
|
-
const pendantMap = {
|
|
407
|
-
suffix: 'append',
|
|
408
|
-
prefix: 'prepend'
|
|
409
|
-
};
|
|
410
|
-
const embedMap = {
|
|
411
|
-
suffix: 'suffixLabel',
|
|
412
|
-
prefix: 'prefixLabel'
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
const pendant = pendantMap[place];
|
|
416
|
-
const embed = embedMap[place];
|
|
417
|
-
|
|
418
|
-
const pendantEl = this.$el.querySelector(`.el-input-group__${pendant}`);
|
|
419
|
-
const embedEl = this.$el.querySelector(`.el-input-group__${place}-label`);
|
|
420
|
-
|
|
421
|
-
if (this.$slots[pendant] && this.$slots[embed]) {
|
|
422
|
-
el.style.transform = place === 'prefix' ? `translateX(${pendantEl.offsetWidth + embedEl.offsetWidth}px)` : '';
|
|
423
|
-
} else if (this.$slots[pendant]) {
|
|
424
|
-
el.style.transform = place === 'prefix' ? `translateX(${pendantEl.offsetWidth}px)` : '';
|
|
425
|
-
} else if (this.$slots[embed]) {
|
|
426
|
-
el.style.transform = place === 'prefix' ? `translateX(${embedEl.offsetWidth}px)` : '';
|
|
427
|
-
} else {
|
|
428
|
-
el.removeAttribute('style');
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
updateIconOffset() {
|
|
432
|
-
this.handlePendantCls('prefix');
|
|
433
|
-
this.handlePendantCls('suffix');
|
|
434
|
-
|
|
435
|
-
this.calcIconOffset('prefix');
|
|
436
|
-
this.calcIconOffset('suffix');
|
|
437
|
-
},
|
|
438
|
-
clear() {
|
|
439
|
-
this.$emit('input', '');
|
|
440
|
-
this.$emit('change', '');
|
|
441
|
-
this.$emit('clear');
|
|
442
|
-
},
|
|
443
|
-
handlePasswordVisible() {
|
|
444
|
-
this.passwordVisible = !this.passwordVisible;
|
|
445
|
-
this.$nextTick(() => {
|
|
446
|
-
this.focus();
|
|
447
|
-
});
|
|
448
|
-
},
|
|
449
|
-
getInput() {
|
|
450
|
-
return this.$refs.input || this.$refs.textarea;
|
|
451
|
-
},
|
|
452
|
-
getSuffixVisible() {
|
|
453
|
-
return this.$slots.suffix ||
|
|
454
|
-
this.$slots.suffixLabel ||
|
|
455
|
-
this.suffixIcon ||
|
|
456
|
-
this.showClear ||
|
|
457
|
-
this.showPassword ||
|
|
458
|
-
this.isWordLimitVisible ||
|
|
459
|
-
(this.validateState && this.needStatusIcon);
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
created() {
|
|
464
|
-
this.$on('inputSelect', this.select);
|
|
465
|
-
},
|
|
466
|
-
|
|
467
|
-
mounted() {
|
|
468
|
-
this.setNativeInputValue();
|
|
469
|
-
this.resizeTextarea();
|
|
470
|
-
this.updateIconOffset();
|
|
471
|
-
},
|
|
472
|
-
|
|
473
|
-
updated() {
|
|
474
|
-
this.$nextTick(this.updateIconOffset);
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
</script>
|
|
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 || $slots.prefixLabel || $slots.suffixLabel,
|
|
9
|
+
'el-input-group--append': $slots.append,
|
|
10
|
+
'el-input-group--prepend': $slots.prepend,
|
|
11
|
+
'is-focus': ($slots.suffixLabel || $slots.prefixLabel) && focused,
|
|
12
|
+
'el-input--prefix': $slots.prefix || prefixIcon,
|
|
13
|
+
'el-input--suffix': $slots.suffix || suffixIcon || clearable || showPassword
|
|
14
|
+
}
|
|
15
|
+
]"
|
|
16
|
+
@mouseenter="hovering = true"
|
|
17
|
+
@mouseleave="hovering = false"
|
|
18
|
+
>
|
|
19
|
+
<template v-if="type !== 'textarea'">
|
|
20
|
+
<!-- 前置元素 -->
|
|
21
|
+
<div class="el-input-group__prepend" v-if="$slots.prepend">
|
|
22
|
+
<slot name="prepend"></slot>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="el-input-group__inner" :class="{
|
|
25
|
+
'is-disabled': inputDisabled,
|
|
26
|
+
'el-input-group--prefix': $slots.prefixLabel,
|
|
27
|
+
'el-input-group--suffix': $slots.suffixLabel,
|
|
28
|
+
'is-focus': ($slots.suffixLabel || $slots.prefixLabel) && focused
|
|
29
|
+
}">
|
|
30
|
+
<!-- 前置标签 -->
|
|
31
|
+
<div class="el-input-group__prefix-label" v-if="$slots.prefixLabel">
|
|
32
|
+
<slot name="prefixLabel"></slot>
|
|
33
|
+
</div>
|
|
34
|
+
<input
|
|
35
|
+
:tabindex="tabindex"
|
|
36
|
+
v-if="type !== 'textarea'"
|
|
37
|
+
class="el-input__inner"
|
|
38
|
+
v-bind="$attrs"
|
|
39
|
+
:type="showPassword ? (passwordVisible ? 'text': 'password') : type"
|
|
40
|
+
:disabled="inputDisabled"
|
|
41
|
+
:readonly="readonly"
|
|
42
|
+
:autocomplete="autoComplete || autocomplete"
|
|
43
|
+
ref="input"
|
|
44
|
+
@compositionstart="handleCompositionStart"
|
|
45
|
+
@compositionupdate="handleCompositionUpdate"
|
|
46
|
+
@compositionend="handleCompositionEnd"
|
|
47
|
+
@input="handleInput"
|
|
48
|
+
@focus="handleFocus"
|
|
49
|
+
@blur="handleBlur"
|
|
50
|
+
@change="handleChange"
|
|
51
|
+
:aria-label="label"
|
|
52
|
+
>
|
|
53
|
+
<!-- 前置内容 -->
|
|
54
|
+
<span class="el-input__prefix" v-if="$slots.prefix || prefixIcon">
|
|
55
|
+
<slot name="prefix"></slot>
|
|
56
|
+
<i class="el-input__icon" v-if="prefixIcon" :class="prefixIcon"></i>
|
|
57
|
+
</span>
|
|
58
|
+
<!-- 后置内容 -->
|
|
59
|
+
<span class="el-input__suffix" v-if="getSuffixVisible()">
|
|
60
|
+
<span class="el-input__suffix-inner">
|
|
61
|
+
<i v-if="showClear" class="el-input__icon iov-icon-close-mini el-input__clear" @mousedown.prevent @click="clear"></i>
|
|
62
|
+
<!-- 后置标签 -->
|
|
63
|
+
<span class="el-input-group__suffix-label" v-if="$slots.suffixLabel">
|
|
64
|
+
<slot name="suffixLabel"></slot>
|
|
65
|
+
</span>
|
|
66
|
+
<template v-if="!showClear || !showPwdVisible || !isWordLimitVisible">
|
|
67
|
+
<slot name="suffix"></slot>
|
|
68
|
+
<i class="el-input__icon" v-if="suffixIcon" :class="suffixIcon"></i>
|
|
69
|
+
</template>
|
|
70
|
+
<i v-if="showPwdVisible" class="el-input__icon" :class="passwordVisible ? 'iov-icon-eye' : 'iov-icon-eye-close'" @click="handlePasswordVisible"></i>
|
|
71
|
+
<span v-if="isWordLimitVisible" class="el-input__count">
|
|
72
|
+
<span class="el-input__count-inner">
|
|
73
|
+
{{ textLength }}/{{ upperLimit }}
|
|
74
|
+
</span>
|
|
75
|
+
</span>
|
|
76
|
+
<i class="el-input__icon" v-if="validateState && needStatusIcon" :class="['el-input__validateIcon', validateIcon]"></i>
|
|
77
|
+
</span>
|
|
78
|
+
</span>
|
|
79
|
+
</div>
|
|
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
|
+
@compositionupdate="handleCompositionUpdate"
|
|
91
|
+
@compositionend="handleCompositionEnd"
|
|
92
|
+
@input="handleInput"
|
|
93
|
+
ref="textarea"
|
|
94
|
+
v-bind="$attrs"
|
|
95
|
+
:disabled="inputDisabled"
|
|
96
|
+
:readonly="readonly"
|
|
97
|
+
:autocomplete="autoComplete || autocomplete"
|
|
98
|
+
:style="textareaStyle"
|
|
99
|
+
@focus="handleFocus"
|
|
100
|
+
@blur="handleBlur"
|
|
101
|
+
@change="handleChange"
|
|
102
|
+
:aria-label="label"
|
|
103
|
+
>
|
|
104
|
+
</textarea>
|
|
105
|
+
<span v-if="isWordLimitVisible && type === 'textarea'" class="el-input__count">{{ textLength }}/{{ upperLimit }}</span>
|
|
106
|
+
</div>
|
|
107
|
+
</template>
|
|
108
|
+
<script>
|
|
109
|
+
import { addClass, removeClass } from 'iov-design/src/utils/dom';
|
|
110
|
+
import emitter from 'iov-design/src/mixins/emitter';
|
|
111
|
+
import Migrating from 'iov-design/src/mixins/migrating';
|
|
112
|
+
import calcTextareaHeight from './calcTextareaHeight';
|
|
113
|
+
import merge from 'iov-design/src/utils/merge';
|
|
114
|
+
import {isKorean} from 'iov-design/src/utils/shared';
|
|
115
|
+
|
|
116
|
+
export default {
|
|
117
|
+
name: 'ElInput',
|
|
118
|
+
|
|
119
|
+
componentName: 'ElInput',
|
|
120
|
+
|
|
121
|
+
mixins: [emitter, Migrating],
|
|
122
|
+
|
|
123
|
+
inheritAttrs: false,
|
|
124
|
+
|
|
125
|
+
inject: {
|
|
126
|
+
elForm: {
|
|
127
|
+
default: ''
|
|
128
|
+
},
|
|
129
|
+
elFormItem: {
|
|
130
|
+
default: ''
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
data() {
|
|
135
|
+
return {
|
|
136
|
+
textareaCalcStyle: {},
|
|
137
|
+
hovering: false,
|
|
138
|
+
focused: false,
|
|
139
|
+
isComposing: false,
|
|
140
|
+
passwordVisible: false
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
props: {
|
|
145
|
+
value: [String, Number],
|
|
146
|
+
size: String,
|
|
147
|
+
resize: String,
|
|
148
|
+
form: String,
|
|
149
|
+
disabled: Boolean,
|
|
150
|
+
readonly: Boolean,
|
|
151
|
+
type: {
|
|
152
|
+
type: String,
|
|
153
|
+
default: 'text'
|
|
154
|
+
},
|
|
155
|
+
autosize: {
|
|
156
|
+
type: [Boolean, Object],
|
|
157
|
+
default: false
|
|
158
|
+
},
|
|
159
|
+
autocomplete: {
|
|
160
|
+
type: String,
|
|
161
|
+
default: 'off'
|
|
162
|
+
},
|
|
163
|
+
/** @Deprecated in next major version */
|
|
164
|
+
autoComplete: {
|
|
165
|
+
type: String,
|
|
166
|
+
validator(val) {
|
|
167
|
+
process.env.NODE_ENV !== 'production' &&
|
|
168
|
+
console.warn('[Element Warn][Input]\'auto-complete\' property will be deprecated in next major version. please use \'autocomplete\' instead.');
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
validateEvent: {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: true
|
|
175
|
+
},
|
|
176
|
+
suffixIcon: String,
|
|
177
|
+
prefixIcon: String,
|
|
178
|
+
label: String,
|
|
179
|
+
clearable: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
default: false
|
|
182
|
+
},
|
|
183
|
+
showPassword: {
|
|
184
|
+
type: Boolean,
|
|
185
|
+
default: false
|
|
186
|
+
},
|
|
187
|
+
showWordLimit: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
default: false
|
|
190
|
+
},
|
|
191
|
+
tabindex: String
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
computed: {
|
|
195
|
+
_elFormItemSize() {
|
|
196
|
+
return (this.elFormItem || {}).elFormItemSize;
|
|
197
|
+
},
|
|
198
|
+
validateState() {
|
|
199
|
+
return this.elFormItem ? this.elFormItem.validateState : '';
|
|
200
|
+
},
|
|
201
|
+
needStatusIcon() {
|
|
202
|
+
return this.elForm ? this.elForm.statusIcon : false;
|
|
203
|
+
},
|
|
204
|
+
validateIcon() {
|
|
205
|
+
return {
|
|
206
|
+
validating: 'iov-icon-loading',
|
|
207
|
+
success: 'iov-icon-circle-success',
|
|
208
|
+
error: 'iov-icon-circle-fail'
|
|
209
|
+
}[this.validateState];
|
|
210
|
+
},
|
|
211
|
+
textareaStyle() {
|
|
212
|
+
return merge({}, this.textareaCalcStyle, { resize: this.resize });
|
|
213
|
+
},
|
|
214
|
+
inputSize() {
|
|
215
|
+
return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
|
|
216
|
+
},
|
|
217
|
+
inputDisabled() {
|
|
218
|
+
return this.disabled || (this.elForm || {}).disabled;
|
|
219
|
+
},
|
|
220
|
+
nativeInputValue() {
|
|
221
|
+
return this.value === null || this.value === undefined ? '' : String(this.value);
|
|
222
|
+
},
|
|
223
|
+
showClear() {
|
|
224
|
+
return this.clearable &&
|
|
225
|
+
!this.inputDisabled &&
|
|
226
|
+
!this.readonly &&
|
|
227
|
+
this.nativeInputValue &&
|
|
228
|
+
(this.focused || this.hovering);
|
|
229
|
+
},
|
|
230
|
+
showPwdVisible() {
|
|
231
|
+
return this.showPassword &&
|
|
232
|
+
!this.inputDisabled &&
|
|
233
|
+
!this.readonly &&
|
|
234
|
+
(!!this.nativeInputValue || this.focused);
|
|
235
|
+
},
|
|
236
|
+
isWordLimitVisible() {
|
|
237
|
+
return this.showWordLimit &&
|
|
238
|
+
this.$attrs.maxlength &&
|
|
239
|
+
(this.type === 'text' || this.type === 'textarea') &&
|
|
240
|
+
!this.inputDisabled &&
|
|
241
|
+
!this.readonly &&
|
|
242
|
+
!this.showPassword;
|
|
243
|
+
},
|
|
244
|
+
upperLimit() {
|
|
245
|
+
return this.$attrs.maxlength;
|
|
246
|
+
},
|
|
247
|
+
textLength() {
|
|
248
|
+
if (typeof this.value === 'number') {
|
|
249
|
+
return String(this.value).length;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return (this.value || '').length;
|
|
253
|
+
},
|
|
254
|
+
inputExceed() {
|
|
255
|
+
// show exceed style if length of initial value greater then maxlength
|
|
256
|
+
return this.isWordLimitVisible &&
|
|
257
|
+
(this.textLength > this.upperLimit);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
watch: {
|
|
262
|
+
value(val) {
|
|
263
|
+
this.$nextTick(this.resizeTextarea);
|
|
264
|
+
if (this.validateEvent) {
|
|
265
|
+
this.dispatch('ElFormItem', 'el.form.change', [val]);
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
// native input value is set explicitly
|
|
269
|
+
// do not use v-model / :value in template
|
|
270
|
+
// see: https://github.com/ElemeFE/element/issues/14521
|
|
271
|
+
nativeInputValue() {
|
|
272
|
+
this.setNativeInputValue();
|
|
273
|
+
},
|
|
274
|
+
// when change between <input> and <textarea>,
|
|
275
|
+
// update DOM dependent value and styles
|
|
276
|
+
// https://github.com/ElemeFE/element/issues/14857
|
|
277
|
+
type() {
|
|
278
|
+
this.$nextTick(() => {
|
|
279
|
+
this.setNativeInputValue();
|
|
280
|
+
this.resizeTextarea();
|
|
281
|
+
this.updateIconOffset();
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
methods: {
|
|
287
|
+
focus() {
|
|
288
|
+
this.getInput().focus();
|
|
289
|
+
},
|
|
290
|
+
blur() {
|
|
291
|
+
this.getInput().blur();
|
|
292
|
+
},
|
|
293
|
+
getMigratingConfig() {
|
|
294
|
+
return {
|
|
295
|
+
props: {
|
|
296
|
+
'icon': 'icon is removed, use suffix-icon / prefix-icon instead.',
|
|
297
|
+
'on-icon-click': 'on-icon-click is removed.'
|
|
298
|
+
},
|
|
299
|
+
events: {
|
|
300
|
+
'click': 'click is removed.'
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
},
|
|
304
|
+
handleBlur(event) {
|
|
305
|
+
this.focused = false;
|
|
306
|
+
this.$emit('blur', event);
|
|
307
|
+
if (this.validateEvent) {
|
|
308
|
+
this.dispatch('ElFormItem', 'el.form.blur', [this.value]);
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
select() {
|
|
312
|
+
this.getInput().select();
|
|
313
|
+
},
|
|
314
|
+
resizeTextarea() {
|
|
315
|
+
if (this.$isServer) return;
|
|
316
|
+
const { autosize, type } = this;
|
|
317
|
+
if (type !== 'textarea') return;
|
|
318
|
+
if (!autosize) {
|
|
319
|
+
this.textareaCalcStyle = {
|
|
320
|
+
minHeight: calcTextareaHeight(this.$refs.textarea).minHeight
|
|
321
|
+
};
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const minRows = autosize.minRows;
|
|
325
|
+
const maxRows = autosize.maxRows;
|
|
326
|
+
|
|
327
|
+
this.textareaCalcStyle = calcTextareaHeight(this.$refs.textarea, minRows, maxRows);
|
|
328
|
+
},
|
|
329
|
+
setNativeInputValue() {
|
|
330
|
+
const input = this.getInput();
|
|
331
|
+
if (!input) return;
|
|
332
|
+
if (input.value === this.nativeInputValue) return;
|
|
333
|
+
input.value = this.nativeInputValue;
|
|
334
|
+
},
|
|
335
|
+
handleFocus(event) {
|
|
336
|
+
this.focused = true;
|
|
337
|
+
this.$emit('focus', event);
|
|
338
|
+
},
|
|
339
|
+
handleCompositionStart(event) {
|
|
340
|
+
this.$emit('compositionstart', event);
|
|
341
|
+
this.isComposing = true;
|
|
342
|
+
},
|
|
343
|
+
handleCompositionUpdate(event) {
|
|
344
|
+
this.$emit('compositionupdate', event);
|
|
345
|
+
const text = event.target.value;
|
|
346
|
+
const lastCharacter = text[text.length - 1] || '';
|
|
347
|
+
this.isComposing = !isKorean(lastCharacter);
|
|
348
|
+
},
|
|
349
|
+
handleCompositionEnd(event) {
|
|
350
|
+
this.$emit('compositionend', event);
|
|
351
|
+
if (this.isComposing) {
|
|
352
|
+
this.isComposing = false;
|
|
353
|
+
this.handleInput(event);
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
handleInput(event) {
|
|
357
|
+
// should not emit input during composition
|
|
358
|
+
// see: https://github.com/ElemeFE/element/issues/10516
|
|
359
|
+
if (this.isComposing) return;
|
|
360
|
+
|
|
361
|
+
// hack for https://github.com/ElemeFE/element/issues/8548
|
|
362
|
+
// should remove the following line when we don't support IE
|
|
363
|
+
if (event.target.value === this.nativeInputValue) return;
|
|
364
|
+
|
|
365
|
+
this.$emit('input', event.target.value);
|
|
366
|
+
|
|
367
|
+
// ensure native input value is controlled
|
|
368
|
+
// see: https://github.com/ElemeFE/element/issues/12850
|
|
369
|
+
this.$nextTick(this.setNativeInputValue);
|
|
370
|
+
},
|
|
371
|
+
handleChange(event) {
|
|
372
|
+
this.$emit('change', event.target.value);
|
|
373
|
+
},
|
|
374
|
+
handlePendantCls(place) {
|
|
375
|
+
const pendantMap = {
|
|
376
|
+
suffix: 'append',
|
|
377
|
+
prefix: 'prepend'
|
|
378
|
+
};
|
|
379
|
+
const pendant = pendantMap[place];
|
|
380
|
+
const pendantEl = this.$el.querySelector(`.el-input-group__${pendant}`);
|
|
381
|
+
if (!pendantEl) return;
|
|
382
|
+
const isSelect = pendantEl.querySelector('.el-select');
|
|
383
|
+
const isButton = pendantEl.querySelector('.el-button');
|
|
384
|
+
if (isSelect) {
|
|
385
|
+
addClass(pendantEl, 'is-select');
|
|
386
|
+
} else {
|
|
387
|
+
removeClass(pendantEl, 'is-select');
|
|
388
|
+
}
|
|
389
|
+
if (isButton) {
|
|
390
|
+
addClass(pendantEl, 'is-button');
|
|
391
|
+
} else {
|
|
392
|
+
removeClass(pendantEl, 'is-button');
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
calcIconOffset(place) {
|
|
396
|
+
let elList = [].slice.call(this.$el.querySelectorAll(`.el-input__${place}`) || []);
|
|
397
|
+
if (!elList.length) return;
|
|
398
|
+
let el = null;
|
|
399
|
+
for (let i = 0; i < elList.length; i++) {
|
|
400
|
+
if (elList[i].parentNode.parentNode === this.$el) {
|
|
401
|
+
el = elList[i];
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (!el) return;
|
|
406
|
+
const pendantMap = {
|
|
407
|
+
suffix: 'append',
|
|
408
|
+
prefix: 'prepend'
|
|
409
|
+
};
|
|
410
|
+
const embedMap = {
|
|
411
|
+
suffix: 'suffixLabel',
|
|
412
|
+
prefix: 'prefixLabel'
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
const pendant = pendantMap[place];
|
|
416
|
+
const embed = embedMap[place];
|
|
417
|
+
|
|
418
|
+
const pendantEl = this.$el.querySelector(`.el-input-group__${pendant}`);
|
|
419
|
+
const embedEl = this.$el.querySelector(`.el-input-group__${place}-label`);
|
|
420
|
+
|
|
421
|
+
if (this.$slots[pendant] && this.$slots[embed]) {
|
|
422
|
+
el.style.transform = place === 'prefix' ? `translateX(${pendantEl.offsetWidth + embedEl.offsetWidth}px)` : '';
|
|
423
|
+
} else if (this.$slots[pendant]) {
|
|
424
|
+
el.style.transform = place === 'prefix' ? `translateX(${pendantEl.offsetWidth}px)` : '';
|
|
425
|
+
} else if (this.$slots[embed]) {
|
|
426
|
+
el.style.transform = place === 'prefix' ? `translateX(${embedEl.offsetWidth}px)` : '';
|
|
427
|
+
} else {
|
|
428
|
+
el.removeAttribute('style');
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
updateIconOffset() {
|
|
432
|
+
this.handlePendantCls('prefix');
|
|
433
|
+
this.handlePendantCls('suffix');
|
|
434
|
+
|
|
435
|
+
this.calcIconOffset('prefix');
|
|
436
|
+
this.calcIconOffset('suffix');
|
|
437
|
+
},
|
|
438
|
+
clear() {
|
|
439
|
+
this.$emit('input', '');
|
|
440
|
+
this.$emit('change', '');
|
|
441
|
+
this.$emit('clear');
|
|
442
|
+
},
|
|
443
|
+
handlePasswordVisible() {
|
|
444
|
+
this.passwordVisible = !this.passwordVisible;
|
|
445
|
+
this.$nextTick(() => {
|
|
446
|
+
this.focus();
|
|
447
|
+
});
|
|
448
|
+
},
|
|
449
|
+
getInput() {
|
|
450
|
+
return this.$refs.input || this.$refs.textarea;
|
|
451
|
+
},
|
|
452
|
+
getSuffixVisible() {
|
|
453
|
+
return this.$slots.suffix ||
|
|
454
|
+
this.$slots.suffixLabel ||
|
|
455
|
+
this.suffixIcon ||
|
|
456
|
+
this.showClear ||
|
|
457
|
+
this.showPassword ||
|
|
458
|
+
this.isWordLimitVisible ||
|
|
459
|
+
(this.validateState && this.needStatusIcon);
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
created() {
|
|
464
|
+
this.$on('inputSelect', this.select);
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
mounted() {
|
|
468
|
+
this.setNativeInputValue();
|
|
469
|
+
this.resizeTextarea();
|
|
470
|
+
this.updateIconOffset();
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
updated() {
|
|
474
|
+
this.$nextTick(this.updateIconOffset);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
</script>
|