vxe-pc-ui 4.17.0 → 4.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.esm.js +297 -152
- package/dist/style.css +1 -1
- package/dist/style.min.css +1 -1
- package/es/date-picker/src/date-picker.js +6 -2
- package/es/date-range-picker/src/date-range-picker.js +6 -2
- package/es/icon/style.css +1 -1
- package/es/input/src/input.js +79 -51
- package/es/number-input/src/number-input.js +31 -23
- package/es/password-input/src/password-input.js +133 -62
- package/es/password-input/style.css +5 -0
- package/es/password-input/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/textarea/src/textarea.js +43 -13
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-password-input/style.css +5 -0
- package/es/vxe-password-input/style.min.css +1 -1
- package/lib/date-picker/src/date-picker.js +6 -1
- package/lib/date-picker/src/date-picker.min.js +1 -1
- package/lib/date-range-picker/src/date-range-picker.js +6 -1
- package/lib/date-range-picker/src/date-range-picker.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +321 -168
- package/lib/index.umd.min.js +1 -1
- package/lib/input/src/input.js +83 -53
- package/lib/input/src/input.min.js +1 -1
- package/lib/number-input/src/number-input.js +35 -25
- package/lib/number-input/src/number-input.min.js +1 -1
- package/lib/password-input/src/password-input.js +140 -71
- package/lib/password-input/src/password-input.min.js +1 -1
- package/lib/password-input/style/style.css +5 -0
- package/lib/password-input/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/textarea/src/textarea.js +46 -13
- package/lib/textarea/src/textarea.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-password-input/style/style.css +5 -0
- package/lib/vxe-password-input/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/date-picker/src/date-picker.ts +6 -2
- package/packages/date-range-picker/src/date-range-picker.ts +6 -2
- package/packages/input/src/input.ts +85 -56
- package/packages/number-input/src/number-input.ts +32 -25
- package/packages/password-input/src/password-input.ts +145 -69
- package/packages/textarea/src/textarea.ts +49 -17
- package/styles/components/password-input.scss +4 -0
- package/types/components/date-picker.d.ts +2 -0
- package/types/components/date-range-picker.d.ts +2 -0
- package/types/components/input.d.ts +2 -0
- package/types/components/number-input.d.ts +2 -0
- package/types/components/password-input.d.ts +4 -0
- package/types/components/table-module/edit.d.ts +37 -4
- package/types/components/table.d.ts +9 -2
- package/types/components/textarea.d.ts +2 -0
- package/types/ui/renderer.d.ts +9 -3
- /package/es/icon/{iconfont.1786782471977.ttf → iconfont.1786868252000.ttf} +0 -0
- /package/es/icon/{iconfont.1786782471977.woff → iconfont.1786868252000.woff} +0 -0
- /package/es/icon/{iconfont.1786782471977.woff2 → iconfont.1786868252000.woff2} +0 -0
- /package/es/{iconfont.1786782471977.ttf → iconfont.1786868252000.ttf} +0 -0
- /package/es/{iconfont.1786782471977.woff → iconfont.1786868252000.woff} +0 -0
- /package/es/{iconfont.1786782471977.woff2 → iconfont.1786868252000.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1786782471977.ttf → iconfont.1786868252000.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1786782471977.woff → iconfont.1786868252000.woff} +0 -0
- /package/lib/icon/style/{iconfont.1786782471977.woff2 → iconfont.1786868252000.woff2} +0 -0
- /package/lib/{iconfont.1786782471977.ttf → iconfont.1786868252000.ttf} +0 -0
- /package/lib/{iconfont.1786782471977.woff → iconfont.1786868252000.woff} +0 -0
- /package/lib/{iconfont.1786782471977.woff2 → iconfont.1786868252000.woff2} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { h, ref, Ref, computed, reactive, inject, nextTick, watch, PropType } from 'vue'
|
|
1
|
+
import { h, ref, Ref, computed, reactive, inject, nextTick, watch, PropType, onMounted } from 'vue'
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
3
|
import XEUtils from 'xe-utils'
|
|
4
4
|
import { getConfig, getIcon, getI18n, createEvent, useSize, renderEmptyElement } from '../../ui'
|
|
5
|
-
import { getFuncText } from '../../ui/src/utils'
|
|
5
|
+
import { getFuncText, getText } from '../../ui/src/utils'
|
|
6
6
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
7
7
|
|
|
8
|
-
import type { VxePasswordInputConstructor, VxePasswordInputEmits, PasswordInputReactData, PasswordInputMethods, VxePasswordInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines } from '../../../types'
|
|
8
|
+
import type { VxePasswordInputConstructor, VxePasswordInputEmits, PasswordInputReactData, PasswordInputMethods, VxePasswordInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf } from '../../../types'
|
|
9
9
|
|
|
10
10
|
export default defineVxeComponent({
|
|
11
11
|
name: 'VxePasswordInput',
|
|
@@ -29,6 +29,10 @@ export default defineVxeComponent({
|
|
|
29
29
|
default: 'off'
|
|
30
30
|
},
|
|
31
31
|
className: String as PropType<VxePasswordInputPropTypes.ClassName>,
|
|
32
|
+
inputClassName: {
|
|
33
|
+
type: String as PropType<VxePasswordInputPropTypes.InputClassName>,
|
|
34
|
+
default: () => getConfig().passwordInput.inputClassName
|
|
35
|
+
},
|
|
32
36
|
size: {
|
|
33
37
|
type: String as PropType<VxePasswordInputPropTypes.Size>,
|
|
34
38
|
default: () => getConfig().passwordInput.size || getConfig().size
|
|
@@ -39,6 +43,10 @@ export default defineVxeComponent({
|
|
|
39
43
|
type: Boolean as PropType<VxePasswordInputPropTypes.Controls>,
|
|
40
44
|
default: () => getConfig().passwordInput.controls
|
|
41
45
|
},
|
|
46
|
+
editable: {
|
|
47
|
+
type: Boolean as PropType<VxePasswordInputPropTypes.Editable>,
|
|
48
|
+
default: true
|
|
49
|
+
},
|
|
42
50
|
|
|
43
51
|
// 已废弃
|
|
44
52
|
autocomplete: String as PropType<VxePasswordInputPropTypes.Autocomplete>
|
|
@@ -87,17 +95,10 @@ export default defineVxeComponent({
|
|
|
87
95
|
getRefMaps: () => refMaps
|
|
88
96
|
} as unknown as VxePasswordInputConstructor
|
|
89
97
|
|
|
90
|
-
let passwordInputMethods = {} as PasswordInputMethods
|
|
91
|
-
|
|
92
98
|
const computeIsClearable = computed(() => {
|
|
93
99
|
return props.clearable
|
|
94
100
|
})
|
|
95
101
|
|
|
96
|
-
const computeInpReadonly = computed(() => {
|
|
97
|
-
const { readonly } = props
|
|
98
|
-
return readonly
|
|
99
|
-
})
|
|
100
|
-
|
|
101
102
|
const computeInpPlaceholder = computed(() => {
|
|
102
103
|
const { placeholder } = props
|
|
103
104
|
if (placeholder) {
|
|
@@ -110,6 +111,34 @@ export default defineVxeComponent({
|
|
|
110
111
|
return getI18n('vxe.base.pleaseInput')
|
|
111
112
|
})
|
|
112
113
|
|
|
114
|
+
const computeFormReadonly = computed(() => {
|
|
115
|
+
if (getConfig().inputReadonly === 'obsolete') {
|
|
116
|
+
if ($xeForm) {
|
|
117
|
+
return $xeForm.props.readonly
|
|
118
|
+
}
|
|
119
|
+
return false
|
|
120
|
+
}
|
|
121
|
+
const { readonly } = props
|
|
122
|
+
if (readonly === null) {
|
|
123
|
+
if ($xeForm) {
|
|
124
|
+
return $xeForm.props.readonly
|
|
125
|
+
}
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
return readonly
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const computeIsDisabled = computed(() => {
|
|
132
|
+
const { disabled } = props
|
|
133
|
+
if (disabled === null) {
|
|
134
|
+
if ($xeForm) {
|
|
135
|
+
return $xeForm.props.disabled
|
|
136
|
+
}
|
|
137
|
+
return false
|
|
138
|
+
}
|
|
139
|
+
return disabled
|
|
140
|
+
})
|
|
141
|
+
|
|
113
142
|
const computeInputType = computed(() => {
|
|
114
143
|
const { showPwd } = reactData
|
|
115
144
|
if (showPwd) {
|
|
@@ -123,9 +152,32 @@ export default defineVxeComponent({
|
|
|
123
152
|
return immediate
|
|
124
153
|
})
|
|
125
154
|
|
|
155
|
+
const computeInputReadonly = computed(() => {
|
|
156
|
+
const { editable } = props
|
|
157
|
+
const formReadonly = computeFormReadonly.value
|
|
158
|
+
return formReadonly || !editable
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
const computeDomValue = computed(() => {
|
|
162
|
+
const { inputValue } = reactData
|
|
163
|
+
return inputValue
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
const dispatchEvent = (type: ValueOf<VxePasswordInputEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
167
|
+
emit(type, createEvent(evnt, { $passwordInput: $xePasswordInput }, params))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const updateDomValue = () => {
|
|
171
|
+
const domValue = computeDomValue.value
|
|
172
|
+
const inputElem = refInputTarget.value
|
|
173
|
+
if (inputElem) {
|
|
174
|
+
inputElem.value = XEUtils.eqNull(domValue) ? '' : ('' + domValue)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
126
178
|
const triggerEvent = (evnt: Event & { type: 'input' | 'change' | 'click' | 'focus' | 'blur' }) => {
|
|
127
179
|
const { inputValue } = reactData
|
|
128
|
-
|
|
180
|
+
dispatchEvent(evnt.type, { value: inputValue }, evnt)
|
|
129
181
|
}
|
|
130
182
|
|
|
131
183
|
const emitInputEvent = (value: any, evnt: Event) => {
|
|
@@ -134,7 +186,7 @@ export default defineVxeComponent({
|
|
|
134
186
|
if (inpImmediate) {
|
|
135
187
|
handleChange(value, evnt)
|
|
136
188
|
} else {
|
|
137
|
-
|
|
189
|
+
dispatchEvent('input', { value }, evnt)
|
|
138
190
|
}
|
|
139
191
|
}
|
|
140
192
|
|
|
@@ -147,9 +199,9 @@ export default defineVxeComponent({
|
|
|
147
199
|
const handleChange = (value: string, evnt: Event | { type: string }) => {
|
|
148
200
|
reactData.inputValue = value
|
|
149
201
|
emit('update:modelValue', value)
|
|
150
|
-
|
|
202
|
+
dispatchEvent('input', { value }, evnt as any)
|
|
151
203
|
if (XEUtils.toValueString(props.modelValue) !== value) {
|
|
152
|
-
|
|
204
|
+
dispatchEvent('change', { value }, evnt as any)
|
|
153
205
|
// 自动更新校验状态
|
|
154
206
|
if ($xeForm && formItemInfo) {
|
|
155
207
|
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
|
|
@@ -159,7 +211,7 @@ export default defineVxeComponent({
|
|
|
159
211
|
|
|
160
212
|
const changeEvent = (evnt: Event & { type: 'change' }) => {
|
|
161
213
|
triggerEvent(evnt)
|
|
162
|
-
|
|
214
|
+
dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
|
|
163
215
|
// 自动更新校验状态
|
|
164
216
|
if ($xeForm && formItemInfo) {
|
|
165
217
|
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, reactData.inputValue)
|
|
@@ -175,7 +227,7 @@ export default defineVxeComponent({
|
|
|
175
227
|
const { inputValue } = reactData
|
|
176
228
|
const value = inputValue
|
|
177
229
|
reactData.isActivated = false
|
|
178
|
-
|
|
230
|
+
dispatchEvent('blur', { value }, evnt)
|
|
179
231
|
// 自动更新校验状态
|
|
180
232
|
if ($xeForm && formItemInfo) {
|
|
181
233
|
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
|
|
@@ -183,12 +235,13 @@ export default defineVxeComponent({
|
|
|
183
235
|
}
|
|
184
236
|
|
|
185
237
|
const passwordToggleEvent = (evnt: Event) => {
|
|
186
|
-
const { readonly, disabled } = props
|
|
187
238
|
const { showPwd } = reactData
|
|
188
|
-
|
|
239
|
+
const isDisabled = computeIsDisabled.value
|
|
240
|
+
const formReadonly = computeFormReadonly.value
|
|
241
|
+
if (!isDisabled && !formReadonly) {
|
|
189
242
|
reactData.showPwd = !showPwd
|
|
190
243
|
}
|
|
191
|
-
|
|
244
|
+
dispatchEvent('toggle-visible', { visible: reactData.showPwd }, evnt)
|
|
192
245
|
}
|
|
193
246
|
|
|
194
247
|
const clickEvent = (evnt: Event & { type: 'click' }) => {
|
|
@@ -198,26 +251,50 @@ export default defineVxeComponent({
|
|
|
198
251
|
const clearValueEvent = (evnt: Event, value: VxePasswordInputPropTypes.ModelValue) => {
|
|
199
252
|
focus()
|
|
200
253
|
handleChange('', evnt)
|
|
201
|
-
|
|
202
|
-
|
|
254
|
+
dispatchEvent('clear', { value }, evnt)
|
|
255
|
+
dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
|
|
203
256
|
}
|
|
204
257
|
|
|
205
258
|
const clickSuffixEvent = (evnt: Event) => {
|
|
206
|
-
const
|
|
207
|
-
if (!
|
|
259
|
+
const isDisabled = computeIsDisabled.value
|
|
260
|
+
if (!isDisabled) {
|
|
208
261
|
const { inputValue } = reactData
|
|
209
|
-
|
|
262
|
+
dispatchEvent('suffix-click', { value: inputValue }, evnt)
|
|
210
263
|
}
|
|
211
264
|
}
|
|
212
265
|
|
|
213
266
|
const clickPrefixEvent = (evnt: Event) => {
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
267
|
+
const isDisabled = computeIsDisabled.value
|
|
268
|
+
if (!isDisabled) {
|
|
216
269
|
const { inputValue } = reactData
|
|
217
|
-
|
|
270
|
+
dispatchEvent('prefix-click', { value: inputValue }, evnt)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const passwordInputMethods: PasswordInputMethods = {
|
|
275
|
+
dispatchEvent,
|
|
276
|
+
focus () {
|
|
277
|
+
const inputElem = refInputTarget.value
|
|
278
|
+
reactData.isActivated = true
|
|
279
|
+
inputElem.focus()
|
|
280
|
+
return nextTick()
|
|
281
|
+
},
|
|
282
|
+
blur () {
|
|
283
|
+
const inputElem = refInputTarget.value
|
|
284
|
+
inputElem.blur()
|
|
285
|
+
reactData.isActivated = false
|
|
286
|
+
return nextTick()
|
|
287
|
+
},
|
|
288
|
+
select () {
|
|
289
|
+
const inputElem = refInputTarget.value
|
|
290
|
+
inputElem.select()
|
|
291
|
+
reactData.isActivated = false
|
|
292
|
+
return nextTick()
|
|
218
293
|
}
|
|
219
294
|
}
|
|
220
295
|
|
|
296
|
+
Object.assign($xePasswordInput, passwordInputMethods)
|
|
297
|
+
|
|
221
298
|
const renderPasswordIcon = () => {
|
|
222
299
|
const { showPwd } = reactData
|
|
223
300
|
return h('div', {
|
|
@@ -252,14 +329,15 @@ export default defineVxeComponent({
|
|
|
252
329
|
}
|
|
253
330
|
|
|
254
331
|
const renderSuffixIcon = () => {
|
|
255
|
-
const {
|
|
332
|
+
const { suffixIcon, controls } = props
|
|
256
333
|
const { inputValue } = reactData
|
|
257
|
-
const
|
|
334
|
+
const isDisabled = computeIsDisabled.value
|
|
258
335
|
const isClearable = computeIsClearable.value
|
|
336
|
+
const suffixSlot = slots.suffix
|
|
259
337
|
return isClearable || controls || suffixSlot || suffixIcon
|
|
260
338
|
? h('div', {
|
|
261
339
|
class: ['vxe-password-input--suffix', {
|
|
262
|
-
'is--clear': isClearable && !
|
|
340
|
+
'is--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
|
|
263
341
|
}]
|
|
264
342
|
}, [
|
|
265
343
|
isClearable
|
|
@@ -289,45 +367,22 @@ export default defineVxeComponent({
|
|
|
289
367
|
: null
|
|
290
368
|
}
|
|
291
369
|
|
|
292
|
-
passwordInputMethods = {
|
|
293
|
-
dispatchEvent (type, params, evnt) {
|
|
294
|
-
emit(type, createEvent(evnt, { $passwordInput: $xePasswordInput }, params))
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
focus () {
|
|
298
|
-
const inputElem = refInputTarget.value
|
|
299
|
-
reactData.isActivated = true
|
|
300
|
-
inputElem.focus()
|
|
301
|
-
return nextTick()
|
|
302
|
-
},
|
|
303
|
-
blur () {
|
|
304
|
-
const inputElem = refInputTarget.value
|
|
305
|
-
inputElem.blur()
|
|
306
|
-
reactData.isActivated = false
|
|
307
|
-
return nextTick()
|
|
308
|
-
},
|
|
309
|
-
select () {
|
|
310
|
-
const inputElem = refInputTarget.value
|
|
311
|
-
inputElem.select()
|
|
312
|
-
reactData.isActivated = false
|
|
313
|
-
return nextTick()
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
Object.assign($xePasswordInput, passwordInputMethods)
|
|
318
|
-
|
|
319
|
-
watch(() => props.modelValue, (val) => {
|
|
320
|
-
reactData.inputValue = val
|
|
321
|
-
})
|
|
322
|
-
|
|
323
370
|
const renderVN = () => {
|
|
324
|
-
const { className,
|
|
371
|
+
const { className, inputClassName, name, readonly, autocomplete, autoComplete, maxLength } = props
|
|
325
372
|
const { inputValue, isActivated } = reactData
|
|
373
|
+
const isDisabled = computeIsDisabled.value
|
|
374
|
+
const formReadonly = computeFormReadonly.value
|
|
375
|
+
if (formReadonly) {
|
|
376
|
+
return h('div', {
|
|
377
|
+
ref: refElem,
|
|
378
|
+
class: ['vxe-password-input--readonly', className]
|
|
379
|
+
}, getText(inputValue))
|
|
380
|
+
}
|
|
326
381
|
const vSize = computeSize.value
|
|
327
|
-
const inpReadonly = computeInpReadonly.value
|
|
328
382
|
const inputType = computeInputType.value
|
|
329
383
|
const inpPlaceholder = computeInpPlaceholder.value
|
|
330
384
|
const isClearable = computeIsClearable.value
|
|
385
|
+
const inputReadonly = computeInputReadonly.value
|
|
331
386
|
const prefix = renderPrefixIcon()
|
|
332
387
|
const suffix = renderSuffixIcon()
|
|
333
388
|
return h('div', {
|
|
@@ -337,9 +392,9 @@ export default defineVxeComponent({
|
|
|
337
392
|
'is--prefix': !!prefix,
|
|
338
393
|
'is--suffix': !!suffix,
|
|
339
394
|
'is--readonly': readonly,
|
|
340
|
-
'is--disabled':
|
|
395
|
+
'is--disabled': isDisabled,
|
|
341
396
|
'is--active': isActivated,
|
|
342
|
-
'show--clear': isClearable && !
|
|
397
|
+
'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
|
|
343
398
|
}],
|
|
344
399
|
spellcheck: false
|
|
345
400
|
}, [
|
|
@@ -349,13 +404,12 @@ export default defineVxeComponent({
|
|
|
349
404
|
}, [
|
|
350
405
|
h('input', {
|
|
351
406
|
ref: refInputTarget,
|
|
352
|
-
class: 'vxe-password-input--inner',
|
|
353
|
-
value: inputValue,
|
|
407
|
+
class: 'vxe-password-input--inner' + (inputClassName ? (' ' + inputClassName) : ''),
|
|
354
408
|
name,
|
|
355
409
|
type: inputType,
|
|
356
410
|
placeholder: inpPlaceholder,
|
|
357
|
-
readonly:
|
|
358
|
-
disabled,
|
|
411
|
+
readonly: inputReadonly,
|
|
412
|
+
disabled: isDisabled,
|
|
359
413
|
autocomplete: autocomplete || autoComplete,
|
|
360
414
|
maxlength: maxLength,
|
|
361
415
|
onClick: clickEvent,
|
|
@@ -369,6 +423,28 @@ export default defineVxeComponent({
|
|
|
369
423
|
])
|
|
370
424
|
}
|
|
371
425
|
|
|
426
|
+
watch(() => props.modelValue, (val) => {
|
|
427
|
+
reactData.inputValue = val
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
const rDvFlag = ref(0)
|
|
431
|
+
watch(computeFormReadonly, () => {
|
|
432
|
+
rDvFlag.value++
|
|
433
|
+
})
|
|
434
|
+
watch(computeDomValue, () => {
|
|
435
|
+
rDvFlag.value++
|
|
436
|
+
})
|
|
437
|
+
watch(rDvFlag, () => {
|
|
438
|
+
updateDomValue()
|
|
439
|
+
nextTick(() => {
|
|
440
|
+
updateDomValue()
|
|
441
|
+
})
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
onMounted(() => {
|
|
445
|
+
updateDomValue()
|
|
446
|
+
})
|
|
447
|
+
|
|
372
448
|
$xePasswordInput.renderVN = renderVN
|
|
373
449
|
|
|
374
450
|
return $xePasswordInput
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { h, ref, Ref, computed, nextTick, watch, PropType, reactive, inject } from 'vue'
|
|
1
|
+
import { h, ref, Ref, computed, nextTick, watch, PropType, reactive, inject, onMounted } from 'vue'
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
3
|
import XEUtils from 'xe-utils'
|
|
4
4
|
import { getConfig, getI18n, createEvent, useSize } from '../../ui'
|
|
5
5
|
import { getFuncText } from '../../ui/src/utils'
|
|
6
6
|
import { createComponentLog } from '../../ui/src/log'
|
|
7
7
|
|
|
8
|
-
import type { VxeTextareaPropTypes, TextareaReactData, TextareaMethods, VxeTextareaConstructor, VxeTextareaEmits, TextareaPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines } from '../../../types'
|
|
8
|
+
import type { VxeTextareaPropTypes, TextareaReactData, TextareaMethods, VxeTextareaConstructor, VxeTextareaEmits, TextareaPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf } from '../../../types'
|
|
9
9
|
|
|
10
10
|
const { warnLog } = createComponentLog('textarea')
|
|
11
11
|
|
|
@@ -16,6 +16,10 @@ export default defineVxeComponent({
|
|
|
16
16
|
props: {
|
|
17
17
|
modelValue: [String, Number] as PropType<VxeTextareaPropTypes.ModelValue>,
|
|
18
18
|
className: String as PropType<VxeTextareaPropTypes.ClassName>,
|
|
19
|
+
inputClassName: {
|
|
20
|
+
type: String as PropType<VxeTextareaPropTypes.InputClassName>,
|
|
21
|
+
default: () => getConfig().textarea.inputClassName
|
|
22
|
+
},
|
|
19
23
|
immediate: {
|
|
20
24
|
type: Boolean as PropType<VxeTextareaPropTypes.Immediate>,
|
|
21
25
|
default: true
|
|
@@ -114,8 +118,6 @@ export default defineVxeComponent({
|
|
|
114
118
|
getRefMaps: () => refMaps
|
|
115
119
|
} as unknown as VxeTextareaConstructor
|
|
116
120
|
|
|
117
|
-
let textareaMethods = {} as TextareaMethods
|
|
118
|
-
|
|
119
121
|
const computeFormReadonly = computed(() => {
|
|
120
122
|
const { readonly } = props
|
|
121
123
|
if (readonly === null) {
|
|
@@ -178,6 +180,23 @@ export default defineVxeComponent({
|
|
|
178
180
|
return Object.assign({ minRows: 1, maxRows: 10 }, getConfig().textarea.autoSize, autoSize)
|
|
179
181
|
})
|
|
180
182
|
|
|
183
|
+
const computeDomValue = computed(() => {
|
|
184
|
+
const { inputValue } = reactData
|
|
185
|
+
return inputValue
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
const dispatchEvent = (type: ValueOf<VxeTextareaEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
189
|
+
emit(type, createEvent(evnt, { $textarea: $xeTextarea }, params))
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const updateDomValue = () => {
|
|
193
|
+
const domValue = computeDomValue.value
|
|
194
|
+
const taElem = refTextarea.value
|
|
195
|
+
if (taElem) {
|
|
196
|
+
taElem.value = XEUtils.eqNull(domValue) ? '' : ('' + domValue)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
181
200
|
const updateAutoTxt = () => {
|
|
182
201
|
const { size, autosize, autoSize } = props
|
|
183
202
|
const { inputValue } = reactData
|
|
@@ -239,7 +258,7 @@ export default defineVxeComponent({
|
|
|
239
258
|
|
|
240
259
|
const triggerEvent = (evnt: Event & { type: 'focus' | 'blur' | 'change' }) => {
|
|
241
260
|
const value = reactData.inputValue
|
|
242
|
-
|
|
261
|
+
dispatchEvent(evnt.type, { value }, evnt)
|
|
243
262
|
}
|
|
244
263
|
|
|
245
264
|
const handleChange = (value: string, evnt: Event) => {
|
|
@@ -270,7 +289,7 @@ export default defineVxeComponent({
|
|
|
270
289
|
$xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
|
|
271
290
|
}
|
|
272
291
|
}
|
|
273
|
-
|
|
292
|
+
dispatchEvent('input', { value }, evnt)
|
|
274
293
|
handleResize()
|
|
275
294
|
}
|
|
276
295
|
|
|
@@ -281,7 +300,7 @@ export default defineVxeComponent({
|
|
|
281
300
|
} else {
|
|
282
301
|
handleChange(reactData.inputValue, evnt)
|
|
283
302
|
}
|
|
284
|
-
|
|
303
|
+
dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
|
|
285
304
|
}
|
|
286
305
|
|
|
287
306
|
const blurEvent = (evnt: Event & { type: 'blur' }) => {
|
|
@@ -290,20 +309,16 @@ export default defineVxeComponent({
|
|
|
290
309
|
if (!immediate) {
|
|
291
310
|
handleChange(inputValue, evnt)
|
|
292
311
|
}
|
|
293
|
-
|
|
312
|
+
dispatchEvent('blur', { value: inputValue }, evnt)
|
|
294
313
|
}
|
|
295
314
|
|
|
296
|
-
textareaMethods = {
|
|
297
|
-
dispatchEvent
|
|
298
|
-
emit(type, createEvent(evnt, { $textarea: $xeTextarea }, params))
|
|
299
|
-
},
|
|
300
|
-
|
|
315
|
+
const textareaMethods: TextareaMethods = {
|
|
316
|
+
dispatchEvent,
|
|
301
317
|
focus () {
|
|
302
318
|
const textElem = refTextarea.value
|
|
303
319
|
textElem.focus()
|
|
304
320
|
return nextTick()
|
|
305
321
|
},
|
|
306
|
-
|
|
307
322
|
blur () {
|
|
308
323
|
const textElem = refTextarea.value
|
|
309
324
|
textElem.blur()
|
|
@@ -314,7 +329,7 @@ export default defineVxeComponent({
|
|
|
314
329
|
Object.assign($xeTextarea, textareaMethods)
|
|
315
330
|
|
|
316
331
|
const renderVN = () => {
|
|
317
|
-
const { className, resize, autosize, autoSize, showWordCount, countMethod, rows, cols } = props
|
|
332
|
+
const { className, inputClassName, resize, autosize, autoSize, showWordCount, countMethod, rows, cols } = props
|
|
318
333
|
const { inputValue } = reactData
|
|
319
334
|
const vSize = computeSize.value
|
|
320
335
|
const isDisabled = computeIsDisabled.value
|
|
@@ -349,8 +364,7 @@ export default defineVxeComponent({
|
|
|
349
364
|
}, [
|
|
350
365
|
h('textarea', {
|
|
351
366
|
ref: refTextarea,
|
|
352
|
-
class: 'vxe-textarea--inner',
|
|
353
|
-
value: inputValue,
|
|
367
|
+
class: 'vxe-textarea--inner' + (inputClassName ? (' ' + inputClassName) : ''),
|
|
354
368
|
name: props.name,
|
|
355
369
|
placeholder: inpPlaceholder,
|
|
356
370
|
maxlength: inpMaxLength,
|
|
@@ -404,6 +418,24 @@ export default defineVxeComponent({
|
|
|
404
418
|
handleResize()
|
|
405
419
|
})
|
|
406
420
|
|
|
421
|
+
const rDvFlag = ref(0)
|
|
422
|
+
watch(computeFormReadonly, () => {
|
|
423
|
+
rDvFlag.value++
|
|
424
|
+
})
|
|
425
|
+
watch(computeDomValue, () => {
|
|
426
|
+
rDvFlag.value++
|
|
427
|
+
})
|
|
428
|
+
watch(rDvFlag, () => {
|
|
429
|
+
updateDomValue()
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
onMounted(() => {
|
|
433
|
+
updateDomValue()
|
|
434
|
+
nextTick(() => {
|
|
435
|
+
updateDomValue()
|
|
436
|
+
})
|
|
437
|
+
})
|
|
438
|
+
|
|
407
439
|
nextTick(() => {
|
|
408
440
|
const { autosize, autoSize } = props
|
|
409
441
|
if (autosize) {
|
|
@@ -30,6 +30,7 @@ export namespace VxeDatePickerPropTypes {
|
|
|
30
30
|
export type Size = VxeComponentSizeType
|
|
31
31
|
export type ModelValue = string | number | Date | null
|
|
32
32
|
export type ClassName = string
|
|
33
|
+
export type InputClassName = string
|
|
33
34
|
export type Immediate = boolean
|
|
34
35
|
export type Name = string
|
|
35
36
|
export type Type = VxeDatePanelPropTypes.Type
|
|
@@ -148,6 +149,7 @@ export interface VxeDatePickerProps {
|
|
|
148
149
|
size?: VxeDatePickerPropTypes.Size
|
|
149
150
|
modelValue?: VxeDatePickerPropTypes.ModelValue
|
|
150
151
|
className?: VxeDatePickerPropTypes.ClassName
|
|
152
|
+
inputClassName?: VxeDatePickerPropTypes.InputClassName
|
|
151
153
|
immediate?: VxeDatePickerPropTypes.Immediate
|
|
152
154
|
name?: VxeDatePickerPropTypes.Name
|
|
153
155
|
type?: VxeDatePickerPropTypes.Type
|
|
@@ -32,6 +32,7 @@ export namespace VxeDateRangePickerPropTypes {
|
|
|
32
32
|
export type StartValue = string | number | Date | null
|
|
33
33
|
export type EndValue = string | number | Date | null
|
|
34
34
|
export type ClassName = string
|
|
35
|
+
export type InputClassName = string
|
|
35
36
|
export type Immediate = boolean
|
|
36
37
|
export type Name = string
|
|
37
38
|
export type Type = VxeDatePanelPropTypes.Type
|
|
@@ -133,6 +134,7 @@ export interface VxeDateRangePickerProps {
|
|
|
133
134
|
startValue?: VxeDateRangePickerPropTypes.StartValue
|
|
134
135
|
endValue?: VxeDateRangePickerPropTypes.EndValue
|
|
135
136
|
className?: VxeDateRangePickerPropTypes.ClassName
|
|
137
|
+
inputClassName?: VxeDateRangePickerPropTypes.InputClassName
|
|
136
138
|
immediate?: VxeDateRangePickerPropTypes.Immediate
|
|
137
139
|
name?: VxeDateRangePickerPropTypes.Name
|
|
138
140
|
type?: VxeDateRangePickerPropTypes.Type
|
|
@@ -27,6 +27,7 @@ export namespace VxeInputPropTypes {
|
|
|
27
27
|
export type Size = VxeComponentSizeType
|
|
28
28
|
export type ModelValue = string | number | Date | undefined | null
|
|
29
29
|
export type ClassName = string
|
|
30
|
+
export type InputClassName = string
|
|
30
31
|
export type Immediate = boolean
|
|
31
32
|
export type Name = string
|
|
32
33
|
export type Title = string
|
|
@@ -94,6 +95,7 @@ export interface VxeInputProps {
|
|
|
94
95
|
size?: VxeInputPropTypes.Size
|
|
95
96
|
modelValue?: VxeInputPropTypes.ModelValue
|
|
96
97
|
className?: VxeInputPropTypes.ClassName
|
|
98
|
+
inputClassName?: VxeInputPropTypes.InputClassName
|
|
97
99
|
immediate?: VxeInputPropTypes.Immediate
|
|
98
100
|
name?: VxeInputPropTypes.Name
|
|
99
101
|
title?: VxeInputPropTypes.Title
|
|
@@ -26,6 +26,7 @@ export namespace VxeNumberInputPropTypes {
|
|
|
26
26
|
export type Size = VxeComponentSizeType
|
|
27
27
|
export type ModelValue = string | number | null
|
|
28
28
|
export type ClassName = string
|
|
29
|
+
export type InputClassName = string
|
|
29
30
|
export type Immediate = boolean
|
|
30
31
|
export type Name = string
|
|
31
32
|
export type Type = 'number' | 'integer' | 'float' | 'amount'
|
|
@@ -112,6 +113,7 @@ export interface VxeNumberInputProps {
|
|
|
112
113
|
size?: VxeNumberInputPropTypes.Size
|
|
113
114
|
modelValue?: VxeNumberInputPropTypes.ModelValue
|
|
114
115
|
className?: VxeNumberInputPropTypes.ClassName
|
|
116
|
+
inputClassName?: VxeNumberInputPropTypes.InputClassName
|
|
115
117
|
immediate?: VxeNumberInputPropTypes.Immediate
|
|
116
118
|
name?: VxeNumberInputPropTypes.Name
|
|
117
119
|
type?: VxeNumberInputPropTypes.Type
|
|
@@ -27,6 +27,7 @@ export namespace VxePasswordInputPropTypes {
|
|
|
27
27
|
export type ModelValue = string | null
|
|
28
28
|
export type Immediate = boolean
|
|
29
29
|
export type ClassName = string
|
|
30
|
+
export type InputClassName = string
|
|
30
31
|
export type Name = string
|
|
31
32
|
export type Clearable = boolean
|
|
32
33
|
export type Readonly = boolean
|
|
@@ -37,6 +38,7 @@ export namespace VxePasswordInputPropTypes {
|
|
|
37
38
|
export type PrefixIcon = string
|
|
38
39
|
export type SuffixIcon = string
|
|
39
40
|
export type Controls = boolean
|
|
41
|
+
export type Editable = boolean
|
|
40
42
|
/**
|
|
41
43
|
* 请使用 AutoComplete
|
|
42
44
|
* @deprecated
|
|
@@ -49,6 +51,7 @@ export interface VxePasswordInputProps {
|
|
|
49
51
|
modelValue?: VxePasswordInputPropTypes.ModelValue
|
|
50
52
|
immediate?: VxePasswordInputPropTypes.Immediate
|
|
51
53
|
className?: VxePasswordInputPropTypes.ClassName
|
|
54
|
+
inputClassName?: VxePasswordInputPropTypes.InputClassName
|
|
52
55
|
name?: VxePasswordInputPropTypes.Name
|
|
53
56
|
clearable?: VxePasswordInputPropTypes.Clearable
|
|
54
57
|
readonly?: VxePasswordInputPropTypes.Readonly
|
|
@@ -59,6 +62,7 @@ export interface VxePasswordInputProps {
|
|
|
59
62
|
prefixIcon?: VxePasswordInputPropTypes.PrefixIcon
|
|
60
63
|
suffixIcon?: VxePasswordInputPropTypes.SuffixIcon
|
|
61
64
|
controls?: VxePasswordInputPropTypes.Controls
|
|
65
|
+
editable?: VxePasswordInputPropTypes.Editable
|
|
62
66
|
/**
|
|
63
67
|
* 请使用 AutoComplete
|
|
64
68
|
* @deprecated
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VxeTableDefines } from '../table'
|
|
1
|
+
import { VxeTableConstructor, VxeTableDefines } from '../table'
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-use-before-define */
|
|
4
4
|
|
|
@@ -206,7 +206,17 @@ export interface TableEditPrivateMethods<D = any> {
|
|
|
206
206
|
/**
|
|
207
207
|
* @private
|
|
208
208
|
*/
|
|
209
|
-
handleEdit(params:
|
|
209
|
+
handleEdit(params: {
|
|
210
|
+
$table: VxeTableConstructor<D>
|
|
211
|
+
column: VxeTableDefines.ColumnInfo<D>
|
|
212
|
+
columnIndex: number
|
|
213
|
+
_columnIndex: number
|
|
214
|
+
$columnIndex: number
|
|
215
|
+
row: D
|
|
216
|
+
rowIndex: number
|
|
217
|
+
$rowIndex: number
|
|
218
|
+
_rowIndex: number
|
|
219
|
+
}, evnt: any, options?: {
|
|
210
220
|
isClear?: boolean
|
|
211
221
|
}): Promise<any>
|
|
212
222
|
/**
|
|
@@ -216,11 +226,34 @@ export interface TableEditPrivateMethods<D = any> {
|
|
|
216
226
|
/**
|
|
217
227
|
* @private
|
|
218
228
|
*/
|
|
219
|
-
|
|
229
|
+
handleCellFocus(cell: HTMLElement, params: {
|
|
230
|
+
$table: VxeTableConstructor<D>
|
|
231
|
+
column: VxeTableDefines.ColumnInfo<D>
|
|
232
|
+
row: D
|
|
233
|
+
}): HTMLInputElement | null
|
|
234
|
+
/**
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
handleFocus(params: {
|
|
238
|
+
$table: VxeTableConstructor<D>
|
|
239
|
+
column: VxeTableDefines.ColumnInfo<D>
|
|
240
|
+
row: D
|
|
241
|
+
cell: HTMLElement
|
|
242
|
+
}, evnt?: Event | null): void
|
|
220
243
|
/**
|
|
221
244
|
* @private
|
|
222
245
|
*/
|
|
223
|
-
handleSelected(params:
|
|
246
|
+
handleSelected(params: {
|
|
247
|
+
$table: VxeTableConstructor<D>
|
|
248
|
+
column: VxeTableDefines.ColumnInfo<D>
|
|
249
|
+
columnIndex: number
|
|
250
|
+
_columnIndex: number
|
|
251
|
+
$columnIndex: number
|
|
252
|
+
row: D
|
|
253
|
+
rowIndex: number
|
|
254
|
+
$rowIndex: number
|
|
255
|
+
_rowIndex: number
|
|
256
|
+
}, evnt: Event | null): Promise<any>
|
|
224
257
|
/**
|
|
225
258
|
* @private
|
|
226
259
|
*/
|