element-pe 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attributes.json +1 -1
- package/dist/index.css +1 -1
- package/dist/index.full.js +632 -1287
- package/dist/index.full.min.js +9 -10
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +7 -8
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +630 -1289
- package/es/component.d.ts +24 -2
- package/es/components/affix/index.js +1 -1
- package/es/components/autocomplete/index.d.ts +4 -4
- package/es/components/autocomplete/src/index.vue.d.ts +2 -2
- package/es/components/carousel/index.d.ts +2 -2
- package/es/components/carousel/src/main.vue.d.ts +2 -2
- package/es/components/cascader/index.d.ts +2 -2
- package/es/components/cascader/src/index.vue.d.ts +1 -1
- package/es/components/checkbox/index.d.ts +6 -6
- package/es/components/checkbox/src/checkbox-button.vue.d.ts +1 -1
- package/es/components/checkbox/src/checkbox-group.vue.d.ts +1 -1
- package/es/components/checkbox/src/checkbox.vue.d.ts +2 -2
- package/es/components/color-picker/index.d.ts +2 -2
- package/es/components/color-picker/src/components/alpha-slider.vue.d.ts +1 -1
- package/es/components/color-picker/src/components/hue-slider.vue.d.ts +1 -1
- package/es/components/color-picker/src/index.vue.d.ts +1 -1
- package/es/components/descriptions/index.d.ts +8 -8
- package/es/components/descriptions/src/description-item.d.ts +2 -2
- package/es/components/descriptions/src/descriptions-cell.d.ts +1 -1
- package/es/components/descriptions/src/index.vue.d.ts +4 -4
- package/es/components/drawer/index.d.ts +6 -6
- package/es/components/drawer/src/index.vue.d.ts +3 -3
- package/es/components/dropdown/index.d.ts +2 -2
- package/es/components/dropdown/src/dropdown.vue.d.ts +2 -2
- package/es/components/form/index.js +2 -2
- package/es/components/icon/index.d.ts +1 -1
- package/es/components/icon/src/icon.vue.d.ts +1 -1
- package/es/components/image/index.d.ts +3 -3
- package/es/components/image/index.js +2 -3
- package/es/components/image/src/image.d.ts +1 -1
- package/es/components/image/src/image.vue.d.ts +3 -3
- package/es/components/image-viewer/index.d.ts +28 -104
- package/es/components/image-viewer/index.js +60 -61
- package/es/components/image-viewer/src/image-viewer.d.ts +14 -0
- package/es/components/image-viewer/src/image-viewer.vue.d.ts +55 -0
- package/es/components/input/index.d.ts +116 -360
- package/es/components/input/index.js +216 -209
- package/es/components/input/src/calc-textarea-height.d.ts +6 -0
- package/es/components/input/src/input.d.ts +46 -0
- package/es/components/input/src/input.vue.d.ts +162 -0
- package/es/components/input-number/index.d.ts +2 -2
- package/es/components/input-number/src/index.vue.d.ts +1 -1
- package/es/components/menu/index.d.ts +7 -3
- package/es/components/menu/index.js +8 -3
- package/es/components/menu/src/menu.d.ts +8 -3
- package/es/components/pagination/index.d.ts +2 -2
- package/es/components/pagination/src/pagination.d.ts +2 -2
- package/es/components/progress/index.js +0 -1
- package/es/components/radio/index.d.ts +2 -2
- package/es/components/radio/src/radio.vue.d.ts +2 -2
- package/es/components/rate/index.js +1 -1
- package/es/components/row/index.d.ts +4 -4
- package/es/components/row/src/row.d.ts +2 -2
- package/es/components/scrollbar/index.d.ts +4 -4
- package/es/components/scrollbar/src/index.vue.d.ts +2 -2
- package/es/components/select/index.d.ts +3 -3
- package/es/components/select/src/select.vue.d.ts +3 -3
- package/es/components/select-v2/index.d.ts +6 -6
- package/es/components/select-v2/index.js +2 -0
- package/es/components/select-v2/src/select.vue.d.ts +3 -3
- package/es/components/slider/index.d.ts +4 -4
- package/es/components/slider/src/button.vue.d.ts +2 -2
- package/es/components/slider/src/index.vue.d.ts +2 -2
- package/es/components/space/index.d.ts +2 -2
- package/es/components/space/src/space.d.ts +2 -2
- package/es/components/steps/index.d.ts +2 -2
- package/es/components/steps/src/index.vue.d.ts +2 -2
- package/es/components/table/index.d.ts +4 -4
- package/es/components/table/index.js +17 -9
- package/es/components/table/src/table.vue.d.ts +4 -4
- package/es/components/tag/index.d.ts +1 -1
- package/es/components/tag/src/tag.vue.d.ts +1 -1
- package/es/components/timeline/index.d.ts +4 -4
- package/es/components/timeline/src/item.vue.d.ts +2 -2
- package/es/components/tree/index.js +1 -1
- package/es/components/tree-v2/index.d.ts +1 -1
- package/es/components/tree-v2/index.js +2 -24
- package/es/components/tree-v2/src/tree.vue.d.ts +1 -1
- package/es/components/upload/index.d.ts +4 -4
- package/es/components/upload/src/index.vue.d.ts +2 -2
- package/es/components/upload/src/upload.vue.d.ts +2 -2
- package/es/components/virtual-list/src/builders/build-grid.d.ts +3 -3
- package/es/components/virtual-list/src/builders/build-list.d.ts +4 -4
- package/es/components/virtual-list/src/components/dynamic-size-grid.d.ts +3 -3
- package/es/components/virtual-list/src/components/dynamic-size-list.d.ts +4 -4
- package/es/components/virtual-list/src/components/fixed-size-grid.d.ts +3 -3
- package/es/components/virtual-list/src/components/fixed-size-list.d.ts +4 -4
- package/es/components/virtual-list/src/components/scrollbar.d.ts +1 -1
- package/es/utils/dom.d.ts +5 -5
- package/es/utils/dom.js +29 -36
- package/es/utils/props.d.ts +2 -2
- package/es/utils/props.js +15 -7
- package/es/utils/util.d.ts +2 -2
- package/es/utils/util.js +3 -3
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/component.d.ts +24 -2
- package/lib/components/affix/index.js +1 -1
- package/lib/components/autocomplete/index.d.ts +4 -4
- package/lib/components/autocomplete/src/index.vue.d.ts +2 -2
- package/lib/components/carousel/index.d.ts +2 -2
- package/lib/components/carousel/src/main.vue.d.ts +2 -2
- package/lib/components/cascader/index.d.ts +2 -2
- package/lib/components/cascader/src/index.vue.d.ts +1 -1
- package/lib/components/checkbox/index.d.ts +6 -6
- package/lib/components/checkbox/src/checkbox-button.vue.d.ts +1 -1
- package/lib/components/checkbox/src/checkbox-group.vue.d.ts +1 -1
- package/lib/components/checkbox/src/checkbox.vue.d.ts +2 -2
- package/lib/components/color-picker/index.d.ts +2 -2
- package/lib/components/color-picker/src/components/alpha-slider.vue.d.ts +1 -1
- package/lib/components/color-picker/src/components/hue-slider.vue.d.ts +1 -1
- package/lib/components/color-picker/src/index.vue.d.ts +1 -1
- package/lib/components/descriptions/index.d.ts +8 -8
- package/lib/components/descriptions/src/description-item.d.ts +2 -2
- package/lib/components/descriptions/src/descriptions-cell.d.ts +1 -1
- package/lib/components/descriptions/src/index.vue.d.ts +4 -4
- package/lib/components/drawer/index.d.ts +6 -6
- package/lib/components/drawer/src/index.vue.d.ts +3 -3
- package/lib/components/dropdown/index.d.ts +2 -2
- package/lib/components/dropdown/src/dropdown.vue.d.ts +2 -2
- package/lib/components/form/index.js +2 -2
- package/lib/components/icon/index.d.ts +1 -1
- package/lib/components/icon/src/icon.vue.d.ts +1 -1
- package/lib/components/image/index.d.ts +3 -3
- package/lib/components/image/index.js +2 -3
- package/lib/components/image/src/image.d.ts +1 -1
- package/lib/components/image/src/image.vue.d.ts +3 -3
- package/lib/components/image-viewer/index.d.ts +28 -104
- package/lib/components/image-viewer/index.js +61 -60
- package/lib/components/image-viewer/src/image-viewer.d.ts +14 -0
- package/lib/components/image-viewer/src/image-viewer.vue.d.ts +55 -0
- package/lib/components/input/index.d.ts +116 -360
- package/lib/components/input/index.js +215 -206
- package/lib/components/input/src/calc-textarea-height.d.ts +6 -0
- package/lib/components/input/src/input.d.ts +46 -0
- package/lib/components/input/src/input.vue.d.ts +162 -0
- package/lib/components/input-number/index.d.ts +2 -2
- package/lib/components/input-number/src/index.vue.d.ts +1 -1
- package/lib/components/menu/index.d.ts +7 -3
- package/lib/components/menu/index.js +8 -3
- package/lib/components/menu/src/menu.d.ts +8 -3
- package/lib/components/pagination/index.d.ts +2 -2
- package/lib/components/pagination/src/pagination.d.ts +2 -2
- package/lib/components/progress/index.js +0 -1
- package/lib/components/radio/index.d.ts +2 -2
- package/lib/components/radio/src/radio.vue.d.ts +2 -2
- package/lib/components/rate/index.js +1 -1
- package/lib/components/row/index.d.ts +4 -4
- package/lib/components/row/src/row.d.ts +2 -2
- package/lib/components/scrollbar/index.d.ts +4 -4
- package/lib/components/scrollbar/src/index.vue.d.ts +2 -2
- package/lib/components/select/index.d.ts +3 -3
- package/lib/components/select/src/select.vue.d.ts +3 -3
- package/lib/components/select-v2/index.d.ts +6 -6
- package/lib/components/select-v2/index.js +2 -0
- package/lib/components/select-v2/src/select.vue.d.ts +3 -3
- package/lib/components/slider/index.d.ts +4 -4
- package/lib/components/slider/src/button.vue.d.ts +2 -2
- package/lib/components/slider/src/index.vue.d.ts +2 -2
- package/lib/components/space/index.d.ts +2 -2
- package/lib/components/space/src/space.d.ts +2 -2
- package/lib/components/steps/index.d.ts +2 -2
- package/lib/components/steps/src/index.vue.d.ts +2 -2
- package/lib/components/table/index.d.ts +4 -4
- package/lib/components/table/index.js +17 -9
- package/lib/components/table/src/table.vue.d.ts +4 -4
- package/lib/components/tag/index.d.ts +1 -1
- package/lib/components/tag/src/tag.vue.d.ts +1 -1
- package/lib/components/timeline/index.d.ts +4 -4
- package/lib/components/timeline/src/item.vue.d.ts +2 -2
- package/lib/components/tree/index.js +1 -1
- package/lib/components/tree-v2/index.d.ts +1 -1
- package/lib/components/tree-v2/index.js +2 -24
- package/lib/components/tree-v2/src/tree.vue.d.ts +1 -1
- package/lib/components/upload/index.d.ts +4 -4
- package/lib/components/upload/src/index.vue.d.ts +2 -2
- package/lib/components/upload/src/upload.vue.d.ts +2 -2
- package/lib/components/virtual-list/src/builders/build-grid.d.ts +3 -3
- package/lib/components/virtual-list/src/builders/build-list.d.ts +4 -4
- package/lib/components/virtual-list/src/components/dynamic-size-grid.d.ts +3 -3
- package/lib/components/virtual-list/src/components/dynamic-size-list.d.ts +4 -4
- package/lib/components/virtual-list/src/components/fixed-size-grid.d.ts +3 -3
- package/lib/components/virtual-list/src/components/fixed-size-list.d.ts +4 -4
- package/lib/components/virtual-list/src/components/scrollbar.d.ts +1 -1
- package/lib/utils/dom.d.ts +5 -5
- package/lib/utils/dom.js +29 -36
- package/lib/utils/props.d.ts +2 -2
- package/lib/utils/props.js +15 -7
- package/lib/utils/util.d.ts +2 -2
- package/lib/utils/util.js +2 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -2
- package/packages/components/affix/src/affix.vue +1 -1
- package/packages/components/color-picker/src/index.vue +1 -1
- package/packages/components/form/__tests__/form.spec.ts +1 -1
- package/packages/components/form/src/form-item.vue +2 -2
- package/packages/components/image/src/image.ts +3 -3
- package/packages/components/image/src/image.vue +1 -1
- package/packages/components/image-viewer/__tests__/image-viewer.spec.ts +1 -1
- package/packages/components/image-viewer/index.ts +5 -10
- package/packages/components/image-viewer/src/image-viewer.ts +32 -0
- package/packages/components/image-viewer/src/{index.vue → image-viewer.vue} +73 -82
- package/packages/components/input/__tests__/input.spec.ts +7 -7
- package/packages/components/input/index.ts +5 -10
- package/packages/components/input/src/{calcTextareaHeight.ts → calc-textarea-height.ts} +9 -7
- package/packages/components/input/src/input.ts +100 -0
- package/packages/components/input/src/{index.vue → input.vue} +135 -239
- package/packages/components/menu/src/menu.ts +10 -3
- package/packages/components/progress/src/index.vue +0 -1
- package/packages/components/rate/src/index.vue +1 -1
- package/packages/components/select-v2/src/useSelect.ts +2 -0
- package/packages/components/space/__tests__/space.spec.ts +1 -1
- package/packages/components/switch/__tests__/switch.spec.ts +1 -1
- package/packages/components/table/src/store/tree.ts +18 -3
- package/packages/components/table/src/table-body/render-helper.ts +1 -1
- package/packages/components/table/src/table-column/index.ts +4 -1
- package/packages/components/table/src/table-layout.ts +2 -2
- package/packages/components/table/src/util.ts +1 -1
- package/packages/components/tree/src/model/node.ts +1 -1
- package/packages/element-plus/package.json +3 -2
- package/packages/element-plus/version.ts +1 -1
- package/packages/theme-chalk/package.json +1 -2
- package/packages/theme-chalk/src/message-box.scss +1 -0
- package/packages/utils/dist/es/dom.d.ts +5 -5
- package/packages/utils/dist/es/dom.js +29 -36
- package/packages/utils/dist/es/props.d.ts +2 -2
- package/packages/utils/dist/es/props.js +15 -7
- package/packages/utils/dist/es/util.d.ts +2 -2
- package/packages/utils/dist/es/util.js +3 -3
- package/packages/utils/dist/lib/dom.d.ts +5 -5
- package/packages/utils/dist/lib/dom.js +29 -36
- package/packages/utils/dist/lib/props.d.ts +2 -2
- package/packages/utils/dist/lib/props.js +15 -7
- package/packages/utils/dist/lib/util.d.ts +2 -2
- package/packages/utils/dist/lib/util.js +2 -2
- package/packages/utils/dom.ts +34 -41
- package/packages/utils/props.ts +27 -11
- package/packages/utils/tests/dom.spec.ts +183 -0
- package/packages/utils/util.ts +8 -9
- package/tags.json +1 -1
- package/theme-chalk/el-message-box.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/message-box.scss +1 -0
- package/web-types.json +1 -1
- package/es/components/image-viewer/src/index.vue.d.ts +0 -67
- package/es/components/input/src/calcTextareaHeight.d.ts +0 -6
- package/es/components/input/src/index.vue.d.ts +0 -197
- package/lib/components/image-viewer/src/index.vue.d.ts +0 -67
- package/lib/components/input/src/calcTextareaHeight.d.ts +0 -6
- package/lib/components/input/src/index.vue.d.ts +0 -197
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
},
|
|
17
17
|
$attrs.class,
|
|
18
18
|
]"
|
|
19
|
-
:style="
|
|
19
|
+
:style="containerStyle"
|
|
20
20
|
:widget="widget"
|
|
21
21
|
@mouseenter="onMouseEnter"
|
|
22
22
|
@mouseleave="onMouseLeave"
|
|
23
23
|
>
|
|
24
|
+
<!-- input -->
|
|
24
25
|
<template v-if="type !== 'textarea'">
|
|
25
|
-
<!--
|
|
26
|
+
<!-- prepend slot -->
|
|
26
27
|
<div v-if="$slots.prepend" class="el-input-group__prepend">
|
|
27
|
-
<slot name="prepend"
|
|
28
|
+
<slot name="prepend" />
|
|
28
29
|
</div>
|
|
30
|
+
|
|
29
31
|
<input
|
|
30
|
-
v-if="type !== 'textarea'"
|
|
31
32
|
ref="input"
|
|
32
33
|
class="el-input__inner"
|
|
33
34
|
v-bind="attrs"
|
|
@@ -48,72 +49,78 @@
|
|
|
48
49
|
@change="handleChange"
|
|
49
50
|
@keydown="handleKeydown"
|
|
50
51
|
/>
|
|
51
|
-
|
|
52
|
+
|
|
53
|
+
<!-- prefix slot -->
|
|
52
54
|
<span v-if="$slots.prefix || prefixIcon" class="el-input__prefix">
|
|
53
|
-
<slot name="prefix"
|
|
55
|
+
<slot name="prefix" />
|
|
54
56
|
<i v-if="prefixIcon" :class="['el-input__icon', prefixIcon]"></i>
|
|
55
57
|
</span>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
|
|
59
|
+
<!-- suffix slot -->
|
|
60
|
+
<span v-if="suffixVisible" class="el-input__suffix">
|
|
58
61
|
<span class="el-input__suffix-inner">
|
|
59
62
|
<template v-if="!showClear || !showPwdVisible || !isWordLimitVisible">
|
|
60
|
-
<slot name="suffix"
|
|
63
|
+
<slot name="suffix" />
|
|
61
64
|
<i v-if="suffixIcon" :class="['el-input__icon', suffixIcon]"></i>
|
|
62
65
|
</template>
|
|
66
|
+
|
|
63
67
|
<i
|
|
64
68
|
v-if="showClear"
|
|
65
69
|
class="el-input__icon el-icon-circle-close el-input__clear"
|
|
66
70
|
@mousedown.prevent
|
|
67
71
|
@click="clear"
|
|
68
|
-
|
|
72
|
+
/>
|
|
73
|
+
|
|
69
74
|
<i
|
|
70
75
|
v-if="showPwdVisible"
|
|
71
76
|
class="el-input__icon el-icon-view el-input__clear"
|
|
72
77
|
@click="handlePasswordVisible"
|
|
73
|
-
|
|
78
|
+
/>
|
|
79
|
+
|
|
74
80
|
<span v-if="isWordLimitVisible" class="el-input__count">
|
|
75
81
|
<span class="el-input__count-inner">
|
|
76
|
-
{{ textLength }}/{{ maxlength }}
|
|
82
|
+
{{ textLength }} / {{ maxlength }}
|
|
77
83
|
</span>
|
|
78
84
|
</span>
|
|
79
85
|
</span>
|
|
80
86
|
<i
|
|
81
87
|
v-if="validateState"
|
|
82
88
|
:class="['el-input__icon', 'el-input__validateIcon', validateIcon]"
|
|
83
|
-
|
|
89
|
+
/>
|
|
84
90
|
</span>
|
|
85
|
-
|
|
91
|
+
|
|
92
|
+
<!-- append slot -->
|
|
86
93
|
<div v-if="$slots.append" class="el-input-group__append">
|
|
87
|
-
<slot name="append"
|
|
94
|
+
<slot name="append" />
|
|
88
95
|
</div>
|
|
89
96
|
</template>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
v-if="isWordLimitVisible
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
>
|
|
97
|
+
|
|
98
|
+
<!-- textarea -->
|
|
99
|
+
<template v-else>
|
|
100
|
+
<textarea
|
|
101
|
+
ref="textarea"
|
|
102
|
+
class="el-textarea__inner"
|
|
103
|
+
v-bind="attrs"
|
|
104
|
+
:tabindex="tabindex"
|
|
105
|
+
:disabled="inputDisabled"
|
|
106
|
+
:readonly="readonly"
|
|
107
|
+
:autocomplete="autocomplete"
|
|
108
|
+
:style="computedTextareaStyle"
|
|
109
|
+
:aria-label="label"
|
|
110
|
+
:placeholder="placeholder"
|
|
111
|
+
@compositionstart="handleCompositionStart"
|
|
112
|
+
@compositionupdate="handleCompositionUpdate"
|
|
113
|
+
@compositionend="handleCompositionEnd"
|
|
114
|
+
@input="handleInput"
|
|
115
|
+
@focus="handleFocus"
|
|
116
|
+
@blur="handleBlur"
|
|
117
|
+
@change="handleChange"
|
|
118
|
+
@keydown="handleKeydown"
|
|
119
|
+
/>
|
|
120
|
+
<span v-if="isWordLimitVisible" class="el-input__count">
|
|
121
|
+
{{ textLength }} / {{ maxlength }}
|
|
122
|
+
</span>
|
|
123
|
+
</template>
|
|
117
124
|
</div>
|
|
118
125
|
</template>
|
|
119
126
|
|
|
@@ -131,146 +138,44 @@ import {
|
|
|
131
138
|
onUpdated,
|
|
132
139
|
} from 'vue'
|
|
133
140
|
import { elFormKey, elFormItemKey } from '@element-plus/tokens'
|
|
134
|
-
import { useAttrs } from '@element-plus/hooks'
|
|
141
|
+
import { useAttrs, useFormItem } from '@element-plus/hooks'
|
|
135
142
|
import {
|
|
136
143
|
UPDATE_MODEL_EVENT,
|
|
137
144
|
VALIDATE_STATE_MAP,
|
|
138
145
|
} from '@element-plus/utils/constants'
|
|
139
|
-
import { isObject
|
|
146
|
+
import { isObject } from '@element-plus/utils/util'
|
|
140
147
|
import isServer from '@element-plus/utils/isServer'
|
|
141
148
|
import { isKorean } from '@element-plus/utils/isDef'
|
|
142
|
-
import {
|
|
143
|
-
import
|
|
149
|
+
import { calcTextareaHeight } from './calc-textarea-height'
|
|
150
|
+
import { inputProps, inputEmits } from './input'
|
|
144
151
|
|
|
145
|
-
import type {
|
|
146
|
-
import type { ElFormContext, ElFormItemContext } from '@element-plus/tokens'
|
|
147
|
-
import type { ComponentSize } from '@element-plus/utils/types'
|
|
152
|
+
import type { StyleValue } from '@element-plus/utils/types'
|
|
148
153
|
|
|
149
|
-
type
|
|
150
|
-
| {
|
|
151
|
-
minRows?: number
|
|
152
|
-
maxRows?: number
|
|
153
|
-
}
|
|
154
|
-
| boolean
|
|
154
|
+
type TargetElement = HTMLInputElement | HTMLTextAreaElement
|
|
155
155
|
|
|
156
156
|
const PENDANT_MAP = {
|
|
157
157
|
suffix: 'append',
|
|
158
158
|
prefix: 'prepend',
|
|
159
|
-
}
|
|
159
|
+
} as const
|
|
160
160
|
|
|
161
161
|
export default defineComponent({
|
|
162
162
|
name: 'ElInput',
|
|
163
|
-
|
|
164
163
|
inheritAttrs: false,
|
|
165
164
|
|
|
166
|
-
props:
|
|
167
|
-
|
|
168
|
-
type: [String, Number],
|
|
169
|
-
default: '',
|
|
170
|
-
},
|
|
171
|
-
type: {
|
|
172
|
-
type: String,
|
|
173
|
-
default: 'text',
|
|
174
|
-
},
|
|
175
|
-
size: {
|
|
176
|
-
type: String as PropType<ComponentSize>,
|
|
177
|
-
validator: isValidComponentSize,
|
|
178
|
-
},
|
|
179
|
-
resize: {
|
|
180
|
-
type: String as PropType<'none' | 'both' | 'horizontal' | 'vertical'>,
|
|
181
|
-
validator: (val: string) =>
|
|
182
|
-
['none', 'both', 'horizontal', 'vertical'].includes(val),
|
|
183
|
-
},
|
|
184
|
-
autosize: {
|
|
185
|
-
type: [Boolean, Object] as PropType<AutosizeProp>,
|
|
186
|
-
default: false as AutosizeProp,
|
|
187
|
-
},
|
|
188
|
-
autocomplete: {
|
|
189
|
-
type: String,
|
|
190
|
-
default: 'off',
|
|
191
|
-
},
|
|
192
|
-
placeholder: {
|
|
193
|
-
type: String,
|
|
194
|
-
},
|
|
195
|
-
form: {
|
|
196
|
-
type: String,
|
|
197
|
-
default: '',
|
|
198
|
-
},
|
|
199
|
-
disabled: {
|
|
200
|
-
type: Boolean,
|
|
201
|
-
default: false,
|
|
202
|
-
},
|
|
203
|
-
readonly: {
|
|
204
|
-
type: Boolean,
|
|
205
|
-
default: false,
|
|
206
|
-
},
|
|
207
|
-
clearable: {
|
|
208
|
-
type: Boolean,
|
|
209
|
-
default: false,
|
|
210
|
-
},
|
|
211
|
-
showPassword: {
|
|
212
|
-
type: Boolean,
|
|
213
|
-
default: false,
|
|
214
|
-
},
|
|
215
|
-
showWordLimit: {
|
|
216
|
-
type: Boolean,
|
|
217
|
-
default: false,
|
|
218
|
-
},
|
|
219
|
-
suffixIcon: {
|
|
220
|
-
type: String,
|
|
221
|
-
default: '',
|
|
222
|
-
},
|
|
223
|
-
prefixIcon: {
|
|
224
|
-
type: String,
|
|
225
|
-
default: '',
|
|
226
|
-
},
|
|
227
|
-
label: {
|
|
228
|
-
type: String,
|
|
229
|
-
},
|
|
230
|
-
tabindex: {
|
|
231
|
-
type: [Number, String],
|
|
232
|
-
},
|
|
233
|
-
validateEvent: {
|
|
234
|
-
type: Boolean,
|
|
235
|
-
default: true,
|
|
236
|
-
},
|
|
237
|
-
inputStyle: {
|
|
238
|
-
type: Object,
|
|
239
|
-
default: () => ({}),
|
|
240
|
-
},
|
|
241
|
-
maxlength: {
|
|
242
|
-
type: [Number, String],
|
|
243
|
-
},
|
|
244
|
-
widget: {
|
|
245
|
-
type: String,
|
|
246
|
-
},
|
|
247
|
-
},
|
|
165
|
+
props: inputProps,
|
|
166
|
+
emits: inputEmits,
|
|
248
167
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
'input',
|
|
252
|
-
'change',
|
|
253
|
-
'focus',
|
|
254
|
-
'blur',
|
|
255
|
-
'clear',
|
|
256
|
-
'mouseleave',
|
|
257
|
-
'mouseenter',
|
|
258
|
-
'keydown',
|
|
259
|
-
'compositionstart',
|
|
260
|
-
'compositionupdate',
|
|
261
|
-
'compositionend',
|
|
262
|
-
],
|
|
263
|
-
|
|
264
|
-
setup(props, ctx) {
|
|
265
|
-
const instance = getCurrentInstance()
|
|
168
|
+
setup(props, { slots, emit, attrs: rawAttrs }) {
|
|
169
|
+
const instance = getCurrentInstance()!
|
|
266
170
|
const attrs = useAttrs()
|
|
267
|
-
const $ELEMENT = useGlobalConfig()
|
|
268
171
|
|
|
269
|
-
const elForm = inject(elFormKey,
|
|
270
|
-
const elFormItem = inject(elFormItemKey,
|
|
172
|
+
const elForm = inject(elFormKey, undefined)
|
|
173
|
+
const elFormItem = inject(elFormItemKey, undefined)
|
|
174
|
+
|
|
175
|
+
const { size: inputSize, disabled: inputDisabled } = useFormItem({})
|
|
271
176
|
|
|
272
|
-
const input = ref(
|
|
273
|
-
const textarea = ref(
|
|
177
|
+
const input = ref<HTMLInputElement>()
|
|
178
|
+
const textarea = ref<HTMLTextAreaElement>()
|
|
274
179
|
const focused = ref(false)
|
|
275
180
|
const hovering = ref(false)
|
|
276
181
|
const isComposing = ref(false)
|
|
@@ -278,59 +183,50 @@ export default defineComponent({
|
|
|
278
183
|
const _textareaCalcStyle = shallowRef(props.inputStyle)
|
|
279
184
|
|
|
280
185
|
const inputOrTextarea = computed(() => input.value || textarea.value)
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
)
|
|
284
|
-
const needStatusIcon = computed(() => elForm.statusIcon)
|
|
285
|
-
const validateState = computed(() => elFormItem.validateState || '')
|
|
186
|
+
const needStatusIcon = computed(() => elForm?.statusIcon ?? false)
|
|
187
|
+
const validateState = computed(() => elFormItem?.validateState || '')
|
|
286
188
|
const validateIcon = computed(() => VALIDATE_STATE_MAP[validateState.value])
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
189
|
+
const containerStyle = computed(() => rawAttrs.style as StyleValue)
|
|
190
|
+
const computedTextareaStyle = computed<StyleValue>(() => [
|
|
191
|
+
props.inputStyle,
|
|
192
|
+
_textareaCalcStyle.value,
|
|
193
|
+
{ resize: props.resize },
|
|
194
|
+
])
|
|
293
195
|
const nativeInputValue = computed(() =>
|
|
294
196
|
props.modelValue === null || props.modelValue === undefined
|
|
295
197
|
? ''
|
|
296
198
|
: String(props.modelValue)
|
|
297
199
|
)
|
|
298
|
-
const showClear = computed(
|
|
299
|
-
|
|
200
|
+
const showClear = computed(
|
|
201
|
+
() =>
|
|
300
202
|
props.clearable &&
|
|
301
203
|
!inputDisabled.value &&
|
|
302
204
|
!props.readonly &&
|
|
303
|
-
nativeInputValue.value &&
|
|
205
|
+
!!nativeInputValue.value &&
|
|
304
206
|
(focused.value || hovering.value)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return (
|
|
207
|
+
)
|
|
208
|
+
const showPwdVisible = computed(
|
|
209
|
+
() =>
|
|
309
210
|
props.showPassword &&
|
|
310
211
|
!inputDisabled.value &&
|
|
311
212
|
!props.readonly &&
|
|
312
213
|
(!!nativeInputValue.value || focused.value)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return (
|
|
214
|
+
)
|
|
215
|
+
const isWordLimitVisible = computed(
|
|
216
|
+
() =>
|
|
317
217
|
props.showWordLimit &&
|
|
318
|
-
props.maxlength &&
|
|
218
|
+
!!props.maxlength &&
|
|
319
219
|
(props.type === 'text' || props.type === 'textarea') &&
|
|
320
220
|
!inputDisabled.value &&
|
|
321
221
|
!props.readonly &&
|
|
322
222
|
!props.showPassword
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
return (
|
|
331
|
-
isWordLimitVisible.value && textLength.value > Number(props.maxlength)
|
|
332
|
-
)
|
|
333
|
-
})
|
|
223
|
+
)
|
|
224
|
+
const textLength = computed(() => Array.from(nativeInputValue.value).length)
|
|
225
|
+
const inputExceed = computed(
|
|
226
|
+
() =>
|
|
227
|
+
// show exceed style if length of initial value greater then maxlength
|
|
228
|
+
!!isWordLimitVisible.value && textLength.value > Number(props.maxlength)
|
|
229
|
+
)
|
|
334
230
|
|
|
335
231
|
const resizeTextarea = () => {
|
|
336
232
|
const { type, autosize } = props
|
|
@@ -341,11 +237,11 @@ export default defineComponent({
|
|
|
341
237
|
const minRows = isObject(autosize) ? autosize.minRows : undefined
|
|
342
238
|
const maxRows = isObject(autosize) ? autosize.maxRows : undefined
|
|
343
239
|
_textareaCalcStyle.value = {
|
|
344
|
-
...calcTextareaHeight(textarea.value
|
|
240
|
+
...calcTextareaHeight(textarea.value!, minRows, maxRows),
|
|
345
241
|
}
|
|
346
242
|
} else {
|
|
347
243
|
_textareaCalcStyle.value = {
|
|
348
|
-
minHeight: calcTextareaHeight(textarea.value).minHeight,
|
|
244
|
+
minHeight: calcTextareaHeight(textarea.value!).minHeight,
|
|
349
245
|
}
|
|
350
246
|
}
|
|
351
247
|
}
|
|
@@ -356,8 +252,9 @@ export default defineComponent({
|
|
|
356
252
|
input.value = nativeInputValue.value
|
|
357
253
|
}
|
|
358
254
|
|
|
359
|
-
const calcIconOffset = (place) => {
|
|
255
|
+
const calcIconOffset = (place: 'prefix' | 'suffix') => {
|
|
360
256
|
const { el } = instance.vnode
|
|
257
|
+
if (!el) return
|
|
361
258
|
const elList: HTMLSpanElement[] = Array.from(
|
|
362
259
|
el.querySelectorAll(`.el-input__${place}`)
|
|
363
260
|
)
|
|
@@ -367,7 +264,7 @@ export default defineComponent({
|
|
|
367
264
|
|
|
368
265
|
const pendant = PENDANT_MAP[place]
|
|
369
266
|
|
|
370
|
-
if (
|
|
267
|
+
if (slots[pendant]) {
|
|
371
268
|
target.style.transform = `translateX(${place === 'suffix' ? '-' : ''}${
|
|
372
269
|
el.querySelector(`.el-input-group__${pendant}`).offsetWidth
|
|
373
270
|
}px)`
|
|
@@ -381,8 +278,8 @@ export default defineComponent({
|
|
|
381
278
|
calcIconOffset('suffix')
|
|
382
279
|
}
|
|
383
280
|
|
|
384
|
-
const handleInput = (event) => {
|
|
385
|
-
let { value } = event.target
|
|
281
|
+
const handleInput = (event: Event) => {
|
|
282
|
+
let { value } = event.target as TargetElement
|
|
386
283
|
|
|
387
284
|
// should not emit input during composition
|
|
388
285
|
// see: https://github.com/ElemeFE/element/issues/10516
|
|
@@ -401,60 +298,60 @@ export default defineComponent({
|
|
|
401
298
|
value = Array.from(value).slice(0, Number(sliceIndex)).join('')
|
|
402
299
|
}
|
|
403
300
|
|
|
404
|
-
|
|
405
|
-
|
|
301
|
+
emit(UPDATE_MODEL_EVENT, value)
|
|
302
|
+
emit('input', value)
|
|
406
303
|
|
|
407
304
|
// ensure native input value is controlled
|
|
408
305
|
// see: https://github.com/ElemeFE/element/issues/12850
|
|
409
306
|
nextTick(setNativeInputValue)
|
|
410
307
|
}
|
|
411
308
|
|
|
412
|
-
const handleChange = (event) => {
|
|
413
|
-
|
|
309
|
+
const handleChange = (event: Event) => {
|
|
310
|
+
emit('change', (event.target as TargetElement).value)
|
|
414
311
|
}
|
|
415
312
|
|
|
416
313
|
const focus = () => {
|
|
417
314
|
// see: https://github.com/ElemeFE/element/issues/18573
|
|
418
315
|
nextTick(() => {
|
|
419
|
-
inputOrTextarea.value
|
|
316
|
+
inputOrTextarea.value?.focus()
|
|
420
317
|
})
|
|
421
318
|
}
|
|
422
319
|
|
|
423
320
|
const blur = () => {
|
|
424
|
-
inputOrTextarea.value
|
|
321
|
+
inputOrTextarea.value?.blur()
|
|
425
322
|
}
|
|
426
323
|
|
|
427
|
-
const handleFocus = (event) => {
|
|
324
|
+
const handleFocus = (event: FocusEvent) => {
|
|
428
325
|
focused.value = true
|
|
429
|
-
|
|
326
|
+
emit('focus', event)
|
|
430
327
|
}
|
|
431
328
|
|
|
432
|
-
const handleBlur = (event) => {
|
|
329
|
+
const handleBlur = (event: FocusEvent) => {
|
|
433
330
|
focused.value = false
|
|
434
|
-
|
|
331
|
+
emit('blur', event)
|
|
435
332
|
if (props.validateEvent) {
|
|
436
|
-
elFormItem
|
|
333
|
+
elFormItem?.validate?.('blur')
|
|
437
334
|
}
|
|
438
335
|
}
|
|
439
336
|
|
|
440
337
|
const select = () => {
|
|
441
|
-
inputOrTextarea.value
|
|
338
|
+
inputOrTextarea.value?.select()
|
|
442
339
|
}
|
|
443
340
|
|
|
444
341
|
const handleCompositionStart = (event: CompositionEvent) => {
|
|
445
|
-
|
|
342
|
+
emit('compositionstart', event)
|
|
446
343
|
isComposing.value = true
|
|
447
344
|
}
|
|
448
345
|
|
|
449
346
|
const handleCompositionUpdate = (event: CompositionEvent) => {
|
|
450
|
-
|
|
347
|
+
emit('compositionupdate', event)
|
|
451
348
|
const text = (event.target as HTMLInputElement)?.value
|
|
452
349
|
const lastCharacter = text[text.length - 1] || ''
|
|
453
350
|
isComposing.value = !isKorean(lastCharacter)
|
|
454
351
|
}
|
|
455
352
|
|
|
456
353
|
const handleCompositionEnd = (event: CompositionEvent) => {
|
|
457
|
-
|
|
354
|
+
emit('compositionend', event)
|
|
458
355
|
if (isComposing.value) {
|
|
459
356
|
isComposing.value = false
|
|
460
357
|
handleInput(event)
|
|
@@ -462,10 +359,10 @@ export default defineComponent({
|
|
|
462
359
|
}
|
|
463
360
|
|
|
464
361
|
const clear = () => {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
362
|
+
emit(UPDATE_MODEL_EVENT, '')
|
|
363
|
+
emit('change', '')
|
|
364
|
+
emit('clear')
|
|
365
|
+
emit('input', '')
|
|
469
366
|
}
|
|
470
367
|
|
|
471
368
|
const handlePasswordVisible = () => {
|
|
@@ -473,23 +370,22 @@ export default defineComponent({
|
|
|
473
370
|
focus()
|
|
474
371
|
}
|
|
475
372
|
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
props.suffixIcon ||
|
|
373
|
+
const suffixVisible = computed(
|
|
374
|
+
() =>
|
|
375
|
+
!!slots.suffix ||
|
|
376
|
+
!!props.suffixIcon ||
|
|
480
377
|
showClear.value ||
|
|
481
378
|
props.showPassword ||
|
|
482
379
|
isWordLimitVisible.value ||
|
|
483
|
-
(validateState.value && needStatusIcon.value)
|
|
484
|
-
|
|
485
|
-
}
|
|
380
|
+
(!!validateState.value && needStatusIcon.value)
|
|
381
|
+
)
|
|
486
382
|
|
|
487
383
|
watch(
|
|
488
384
|
() => props.modelValue,
|
|
489
385
|
() => {
|
|
490
386
|
nextTick(resizeTextarea)
|
|
491
387
|
if (props.validateEvent) {
|
|
492
|
-
elFormItem
|
|
388
|
+
elFormItem?.validate?.('change')
|
|
493
389
|
}
|
|
494
390
|
}
|
|
495
391
|
)
|
|
@@ -497,9 +393,7 @@ export default defineComponent({
|
|
|
497
393
|
// native input value is set explicitly
|
|
498
394
|
// do not use v-model / :value in template
|
|
499
395
|
// see: https://github.com/ElemeFE/element/issues/14521
|
|
500
|
-
watch(nativeInputValue, () =>
|
|
501
|
-
setNativeInputValue()
|
|
502
|
-
})
|
|
396
|
+
watch(nativeInputValue, () => setNativeInputValue())
|
|
503
397
|
|
|
504
398
|
// when change between <input> and <textarea>,
|
|
505
399
|
// update DOM dependent value and styles
|
|
@@ -525,18 +419,18 @@ export default defineComponent({
|
|
|
525
419
|
nextTick(updateIconOffset)
|
|
526
420
|
})
|
|
527
421
|
|
|
528
|
-
const onMouseLeave = (
|
|
422
|
+
const onMouseLeave = (evt: MouseEvent) => {
|
|
529
423
|
hovering.value = false
|
|
530
|
-
|
|
424
|
+
emit('mouseleave', evt)
|
|
531
425
|
}
|
|
532
426
|
|
|
533
|
-
const onMouseEnter = (
|
|
427
|
+
const onMouseEnter = (evt: MouseEvent) => {
|
|
534
428
|
hovering.value = true
|
|
535
|
-
|
|
429
|
+
emit('mouseenter', evt)
|
|
536
430
|
}
|
|
537
431
|
|
|
538
|
-
const handleKeydown = (
|
|
539
|
-
|
|
432
|
+
const handleKeydown = (evt: KeyboardEvent) => {
|
|
433
|
+
emit('keydown', evt)
|
|
540
434
|
}
|
|
541
435
|
|
|
542
436
|
return {
|
|
@@ -546,8 +440,8 @@ export default defineComponent({
|
|
|
546
440
|
inputSize,
|
|
547
441
|
validateState,
|
|
548
442
|
validateIcon,
|
|
443
|
+
containerStyle,
|
|
549
444
|
computedTextareaStyle,
|
|
550
|
-
resizeTextarea,
|
|
551
445
|
inputDisabled,
|
|
552
446
|
showClear,
|
|
553
447
|
showPwdVisible,
|
|
@@ -557,6 +451,9 @@ export default defineComponent({
|
|
|
557
451
|
inputExceed,
|
|
558
452
|
passwordVisible,
|
|
559
453
|
inputOrTextarea,
|
|
454
|
+
suffixVisible,
|
|
455
|
+
|
|
456
|
+
resizeTextarea,
|
|
560
457
|
handleInput,
|
|
561
458
|
handleChange,
|
|
562
459
|
handleFocus,
|
|
@@ -569,7 +466,6 @@ export default defineComponent({
|
|
|
569
466
|
select,
|
|
570
467
|
focus,
|
|
571
468
|
blur,
|
|
572
|
-
getSuffixVisible,
|
|
573
469
|
onMouseLeave,
|
|
574
470
|
onMouseEnter,
|
|
575
471
|
handleKeydown,
|
|
@@ -52,6 +52,10 @@ export const menuProps = buildProps({
|
|
|
52
52
|
type: Boolean,
|
|
53
53
|
default: true,
|
|
54
54
|
},
|
|
55
|
+
ellipsis: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true,
|
|
58
|
+
},
|
|
55
59
|
} as const)
|
|
56
60
|
export type MenuProps = ExtractPropTypes<typeof menuProps>
|
|
57
61
|
|
|
@@ -344,7 +348,7 @@ export default defineComponent({
|
|
|
344
348
|
})
|
|
345
349
|
const slotDefault = originalSlot.slice(0, sliceIndex)
|
|
346
350
|
const slotMore = originalSlot.slice(sliceIndex)
|
|
347
|
-
if (slotMore?.length) {
|
|
351
|
+
if (slotMore?.length && props.ellipsis) {
|
|
348
352
|
slot = slotDefault
|
|
349
353
|
vShowMore.push(
|
|
350
354
|
h(
|
|
@@ -367,7 +371,10 @@ export default defineComponent({
|
|
|
367
371
|
|
|
368
372
|
const ulStyle = useMenuCssVar(props)
|
|
369
373
|
|
|
370
|
-
const
|
|
374
|
+
const resizeMenu = (vNode: VNode) =>
|
|
375
|
+
props.ellipsis ? useVNodeResize(vNode) : vNode
|
|
376
|
+
|
|
377
|
+
const vMenu = resizeMenu(
|
|
371
378
|
h(
|
|
372
379
|
'ul',
|
|
373
380
|
{
|
|
@@ -381,7 +388,7 @@ export default defineComponent({
|
|
|
381
388
|
'el-menu--collapse': props.collapse,
|
|
382
389
|
},
|
|
383
390
|
},
|
|
384
|
-
[...slot.map((vnode) =>
|
|
391
|
+
[...slot.map((vnode) => resizeMenu(vnode)), ...vShowMore]
|
|
385
392
|
)
|
|
386
393
|
)
|
|
387
394
|
|
|
@@ -203,7 +203,7 @@ export default defineComponent({
|
|
|
203
203
|
: props.iconClasses
|
|
204
204
|
)
|
|
205
205
|
const decimalIconClass = computed(() =>
|
|
206
|
-
getValueFromMap(
|
|
206
|
+
getValueFromMap(currentValue.value, classMap.value)
|
|
207
207
|
)
|
|
208
208
|
const voidClass = computed(() =>
|
|
209
209
|
rateDisabled.value ? props.disabledVoidIconClass : props.voidIconClass
|