vxe-pc-ui 4.17.1 → 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.
Files changed (57) hide show
  1. package/dist/all.esm.js +265 -144
  2. package/dist/style.css +1 -1
  3. package/dist/style.min.css +1 -1
  4. package/es/icon/style.css +1 -1
  5. package/es/input/src/input.js +73 -49
  6. package/es/number-input/src/number-input.js +28 -24
  7. package/es/password-input/src/password-input.js +128 -61
  8. package/es/password-input/style.css +5 -0
  9. package/es/password-input/style.min.css +1 -1
  10. package/es/style.css +1 -1
  11. package/es/style.min.css +1 -1
  12. package/es/textarea/src/textarea.js +37 -11
  13. package/es/ui/index.js +1 -1
  14. package/es/ui/src/log.js +1 -1
  15. package/es/vxe-password-input/style.css +5 -0
  16. package/es/vxe-password-input/style.min.css +1 -1
  17. package/lib/icon/style/style.css +1 -1
  18. package/lib/icon/style/style.min.css +1 -1
  19. package/lib/index.umd.js +287 -164
  20. package/lib/index.umd.min.js +1 -1
  21. package/lib/input/src/input.js +77 -52
  22. package/lib/input/src/input.min.js +1 -1
  23. package/lib/number-input/src/number-input.js +31 -26
  24. package/lib/number-input/src/number-input.min.js +1 -1
  25. package/lib/password-input/src/password-input.js +134 -70
  26. package/lib/password-input/src/password-input.min.js +1 -1
  27. package/lib/password-input/style/style.css +5 -0
  28. package/lib/password-input/style/style.min.css +1 -1
  29. package/lib/style.css +1 -1
  30. package/lib/style.min.css +1 -1
  31. package/lib/textarea/src/textarea.js +40 -12
  32. package/lib/textarea/src/textarea.min.js +1 -1
  33. package/lib/ui/index.js +1 -1
  34. package/lib/ui/index.min.js +1 -1
  35. package/lib/ui/src/log.js +1 -1
  36. package/lib/ui/src/log.min.js +1 -1
  37. package/lib/vxe-password-input/style/style.css +5 -0
  38. package/lib/vxe-password-input/style/style.min.css +1 -1
  39. package/package.json +1 -1
  40. package/packages/input/src/input.ts +79 -54
  41. package/packages/number-input/src/number-input.ts +29 -26
  42. package/packages/password-input/src/password-input.ts +140 -68
  43. package/packages/textarea/src/textarea.ts +43 -15
  44. package/styles/components/password-input.scss +4 -0
  45. package/types/components/password-input.d.ts +2 -0
  46. /package/es/icon/{iconfont.1786796113388.ttf → iconfont.1786868252000.ttf} +0 -0
  47. /package/es/icon/{iconfont.1786796113388.woff → iconfont.1786868252000.woff} +0 -0
  48. /package/es/icon/{iconfont.1786796113388.woff2 → iconfont.1786868252000.woff2} +0 -0
  49. /package/es/{iconfont.1786796113388.ttf → iconfont.1786868252000.ttf} +0 -0
  50. /package/es/{iconfont.1786796113388.woff → iconfont.1786868252000.woff} +0 -0
  51. /package/es/{iconfont.1786796113388.woff2 → iconfont.1786868252000.woff2} +0 -0
  52. /package/lib/icon/style/{iconfont.1786796113388.ttf → iconfont.1786868252000.ttf} +0 -0
  53. /package/lib/icon/style/{iconfont.1786796113388.woff → iconfont.1786868252000.woff} +0 -0
  54. /package/lib/icon/style/{iconfont.1786796113388.woff2 → iconfont.1786868252000.woff2} +0 -0
  55. /package/lib/{iconfont.1786796113388.ttf → iconfont.1786868252000.ttf} +0 -0
  56. /package/lib/{iconfont.1786796113388.woff → iconfont.1786868252000.woff} +0 -0
  57. /package/lib/{iconfont.1786796113388.woff2 → iconfont.1786868252000.woff2} +0 -0
@@ -324,6 +324,11 @@ export default defineVxeComponent({
324
324
  return false
325
325
  })
326
326
 
327
+ const computeInpClassNamevalue = computed(() => {
328
+ const { inputClassName } = props
329
+ return 'vxe-number-input--input' + (inputClassName ? (' ' + inputClassName) : '')
330
+ })
331
+
327
332
  const refMaps: InputPrivateRef = {
328
333
  refElem,
329
334
  refInput: refInputTarget
@@ -343,7 +348,9 @@ export default defineVxeComponent({
343
348
  getComputeMaps: () => computeMaps
344
349
  } as unknown as VxeNumberInputConstructor
345
350
 
346
- let numberInputMethods = {} as NumberInputMethods
351
+ const dispatchEvent = (type: ValueOf<VxeNumberInputEmits>, params: Record<string, any>, evnt: Event | null) => {
352
+ emit(type, createEvent(evnt, { $numberInput: $xeNumberInput }, params))
353
+ }
347
354
 
348
355
  const handleNumberString = (val: any) => {
349
356
  if (XEUtils.eqNull(val)) {
@@ -374,7 +381,7 @@ export default defineVxeComponent({
374
381
 
375
382
  const triggerEvent = (evnt: Event & { type: 'input' | 'change' | 'keydown' | 'keyup' | 'wheel' | 'click' | 'focus' | 'blur' }) => {
376
383
  const { inputValue } = reactData
377
- numberInputMethods.dispatchEvent(evnt.type, { value: inputValue }, evnt)
384
+ dispatchEvent(evnt.type, { value: inputValue }, evnt)
378
385
  }
379
386
 
380
387
  const handleChange = (val: number | null, inputValue: string, evnt: Event | { type: string }) => {
@@ -389,9 +396,9 @@ export default defineVxeComponent({
389
396
  reactData.inputValue = inputValue || ''
390
397
  })
391
398
  }
392
- numberInputMethods.dispatchEvent('input', { value }, evnt as Event)
399
+ dispatchEvent('input', { value }, evnt as Event)
393
400
  if (isChange) {
394
- numberInputMethods.dispatchEvent('change', { value }, evnt as Event)
401
+ dispatchEvent('change', { value }, evnt as Event)
395
402
  // 自动更新校验状态
396
403
  if ($xeForm && formItemInfo) {
397
404
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
@@ -406,7 +413,7 @@ export default defineVxeComponent({
406
413
  if (inpImmediate) {
407
414
  handleChange(value, inputValue, evnt)
408
415
  } else {
409
- numberInputMethods.dispatchEvent('input', { value }, evnt)
416
+ dispatchEvent('input', { value }, evnt)
410
417
  // 自动更新校验状态
411
418
  if ($xeForm && formItemInfo) {
412
419
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
@@ -425,7 +432,7 @@ export default defineVxeComponent({
425
432
  if (!inpImmediate) {
426
433
  triggerEvent(evnt)
427
434
  }
428
- $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
435
+ dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
429
436
  }
430
437
 
431
438
  const focusEvent = (evnt: Event & { type: 'focus' }) => {
@@ -443,22 +450,22 @@ export default defineVxeComponent({
443
450
  const isDisabled = computeIsDisabled.value
444
451
  if (!isDisabled) {
445
452
  const { inputValue } = reactData
446
- numberInputMethods.dispatchEvent('prefix-click', { value: inputValue }, evnt)
453
+ dispatchEvent('prefix-click', { value: inputValue }, evnt)
447
454
  }
448
455
  }
449
456
 
450
457
  const clearValueEvent = (evnt: Event, value: VxeNumberInputPropTypes.ModelValue) => {
451
458
  focus()
452
459
  handleChange(null, '', evnt)
453
- numberInputMethods.dispatchEvent('clear', { value }, evnt)
454
- $xeNumberInput.dispatchEvent('lazy-change', { value }, evnt)
460
+ dispatchEvent('clear', { value }, evnt)
461
+ dispatchEvent('lazy-change', { value }, evnt)
455
462
  }
456
463
 
457
464
  const clickSuffixEvent = (evnt: Event) => {
458
465
  const isDisabled = computeIsDisabled.value
459
466
  if (!isDisabled) {
460
467
  const { inputValue } = reactData
461
- numberInputMethods.dispatchEvent('suffix-click', { value: inputValue }, evnt)
468
+ dispatchEvent('suffix-click', { value: inputValue }, evnt)
462
469
  }
463
470
  }
464
471
 
@@ -563,7 +570,7 @@ export default defineVxeComponent({
563
570
  afterCheckValue()
564
571
  reactData.isFocus = false
565
572
  reactData.isActivated = false
566
- numberInputMethods.dispatchEvent('blur', { value }, evnt)
573
+ dispatchEvent('blur', { value }, evnt)
567
574
  // 自动更新校验状态
568
575
  if ($xeForm && formItemInfo) {
569
576
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
@@ -596,10 +603,10 @@ export default defineVxeComponent({
596
603
  numberChange(true, evnt)
597
604
  }
598
605
  reactData.isActivated = true
599
- numberInputMethods.dispatchEvent('plus-number', { value: reactData.inputValue }, evnt)
600
- $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
606
+ dispatchEvent('plus-number', { value: reactData.inputValue }, evnt)
607
+ dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
601
608
  // 已废弃
602
- numberInputMethods.dispatchEvent('next-number', { value: reactData.inputValue }, evnt)
609
+ dispatchEvent('next-number', { value: reactData.inputValue }, evnt)
603
610
  }
604
611
 
605
612
  const numberMinusEvent = (evnt: Event) => {
@@ -610,10 +617,10 @@ export default defineVxeComponent({
610
617
  numberChange(false, evnt)
611
618
  }
612
619
  reactData.isActivated = true
613
- numberInputMethods.dispatchEvent('minus-number', { value: reactData.inputValue }, evnt)
614
- $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
620
+ dispatchEvent('minus-number', { value: reactData.inputValue }, evnt)
621
+ dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
615
622
  // 已废弃
616
- numberInputMethods.dispatchEvent('prev-number', { value: reactData.inputValue }, evnt)
623
+ dispatchEvent('prev-number', { value: reactData.inputValue }, evnt)
617
624
  }
618
625
 
619
626
  const numberKeydownEvent = (evnt: KeyboardEvent) => {
@@ -809,13 +816,8 @@ export default defineVxeComponent({
809
816
  }
810
817
  }
811
818
 
812
- const dispatchEvent = (type: ValueOf<VxeNumberInputEmits>, params: Record<string, any>, evnt: Event | null) => {
813
- emit(type, createEvent(evnt, { $numberInput: $xeNumberInput }, params))
814
- }
815
-
816
- numberInputMethods = {
819
+ const numberInputMethods: NumberInputMethods = {
817
820
  dispatchEvent,
818
-
819
821
  focus () {
820
822
  const inputReadonly = computeInputReadonly.value
821
823
  if (!inputReadonly) {
@@ -919,13 +921,14 @@ export default defineVxeComponent({
919
921
  }
920
922
 
921
923
  const renderInput = () => {
922
- const { inputClassName, type, name, autocomplete, autoComplete } = props
924
+ const { type, name, autocomplete, autoComplete } = props
923
925
  const { inputValue, isFocus } = reactData
924
926
  const isDisabled = computeIsDisabled.value
925
927
  const numLabel = computeNumLabel.value
926
928
  const inputReadonly = computeInputReadonly.value
927
929
  const inpMaxLength = computeInpMaxLength.value
928
930
  const inpPlaceholder = computeInpPlaceholder.value
931
+ const inpClassName = computeInpClassNamevalue.value
929
932
  return h('div', {
930
933
  key: 'ni',
931
934
  class: 'vxe-number-input--input-wrapper'
@@ -936,10 +939,10 @@ export default defineVxeComponent({
936
939
  }, [
937
940
  h('input', {
938
941
  ref: refInputTarget,
939
- class: 'vxe-number-input--input' + (inputClassName ? (' ' + inputClassName) : ''),
940
- value: !isFocus && type === 'amount' ? numLabel : inputValue,
942
+ class: inpClassName,
941
943
  name,
942
944
  type: 'text',
945
+ value: !isFocus && type === 'amount' ? numLabel : inputValue,
943
946
  placeholder: inpPlaceholder,
944
947
  maxlength: inpMaxLength,
945
948
  readonly: inputReadonly,
@@ -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',
@@ -43,6 +43,10 @@ export default defineVxeComponent({
43
43
  type: Boolean as PropType<VxePasswordInputPropTypes.Controls>,
44
44
  default: () => getConfig().passwordInput.controls
45
45
  },
46
+ editable: {
47
+ type: Boolean as PropType<VxePasswordInputPropTypes.Editable>,
48
+ default: true
49
+ },
46
50
 
47
51
  // 已废弃
48
52
  autocomplete: String as PropType<VxePasswordInputPropTypes.Autocomplete>
@@ -91,17 +95,10 @@ export default defineVxeComponent({
91
95
  getRefMaps: () => refMaps
92
96
  } as unknown as VxePasswordInputConstructor
93
97
 
94
- let passwordInputMethods = {} as PasswordInputMethods
95
-
96
98
  const computeIsClearable = computed(() => {
97
99
  return props.clearable
98
100
  })
99
101
 
100
- const computeInpReadonly = computed(() => {
101
- const { readonly } = props
102
- return readonly
103
- })
104
-
105
102
  const computeInpPlaceholder = computed(() => {
106
103
  const { placeholder } = props
107
104
  if (placeholder) {
@@ -114,6 +111,34 @@ export default defineVxeComponent({
114
111
  return getI18n('vxe.base.pleaseInput')
115
112
  })
116
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
+
117
142
  const computeInputType = computed(() => {
118
143
  const { showPwd } = reactData
119
144
  if (showPwd) {
@@ -127,9 +152,32 @@ export default defineVxeComponent({
127
152
  return immediate
128
153
  })
129
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
+
130
178
  const triggerEvent = (evnt: Event & { type: 'input' | 'change' | 'click' | 'focus' | 'blur' }) => {
131
179
  const { inputValue } = reactData
132
- passwordInputMethods.dispatchEvent(evnt.type, { value: inputValue }, evnt)
180
+ dispatchEvent(evnt.type, { value: inputValue }, evnt)
133
181
  }
134
182
 
135
183
  const emitInputEvent = (value: any, evnt: Event) => {
@@ -138,7 +186,7 @@ export default defineVxeComponent({
138
186
  if (inpImmediate) {
139
187
  handleChange(value, evnt)
140
188
  } else {
141
- passwordInputMethods.dispatchEvent('input', { value }, evnt)
189
+ dispatchEvent('input', { value }, evnt)
142
190
  }
143
191
  }
144
192
 
@@ -151,9 +199,9 @@ export default defineVxeComponent({
151
199
  const handleChange = (value: string, evnt: Event | { type: string }) => {
152
200
  reactData.inputValue = value
153
201
  emit('update:modelValue', value)
154
- passwordInputMethods.dispatchEvent('input', { value }, evnt as any)
202
+ dispatchEvent('input', { value }, evnt as any)
155
203
  if (XEUtils.toValueString(props.modelValue) !== value) {
156
- passwordInputMethods.dispatchEvent('change', { value }, evnt as any)
204
+ dispatchEvent('change', { value }, evnt as any)
157
205
  // 自动更新校验状态
158
206
  if ($xeForm && formItemInfo) {
159
207
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
@@ -163,7 +211,7 @@ export default defineVxeComponent({
163
211
 
164
212
  const changeEvent = (evnt: Event & { type: 'change' }) => {
165
213
  triggerEvent(evnt)
166
- $xePasswordInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
214
+ dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
167
215
  // 自动更新校验状态
168
216
  if ($xeForm && formItemInfo) {
169
217
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, reactData.inputValue)
@@ -179,7 +227,7 @@ export default defineVxeComponent({
179
227
  const { inputValue } = reactData
180
228
  const value = inputValue
181
229
  reactData.isActivated = false
182
- $xePasswordInput.dispatchEvent('blur', { value }, evnt)
230
+ dispatchEvent('blur', { value }, evnt)
183
231
  // 自动更新校验状态
184
232
  if ($xeForm && formItemInfo) {
185
233
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
@@ -187,12 +235,13 @@ export default defineVxeComponent({
187
235
  }
188
236
 
189
237
  const passwordToggleEvent = (evnt: Event) => {
190
- const { readonly, disabled } = props
191
238
  const { showPwd } = reactData
192
- if (!disabled && !readonly) {
239
+ const isDisabled = computeIsDisabled.value
240
+ const formReadonly = computeFormReadonly.value
241
+ if (!isDisabled && !formReadonly) {
193
242
  reactData.showPwd = !showPwd
194
243
  }
195
- $xePasswordInput.dispatchEvent('toggle-visible', { visible: reactData.showPwd }, evnt)
244
+ dispatchEvent('toggle-visible', { visible: reactData.showPwd }, evnt)
196
245
  }
197
246
 
198
247
  const clickEvent = (evnt: Event & { type: 'click' }) => {
@@ -202,26 +251,50 @@ export default defineVxeComponent({
202
251
  const clearValueEvent = (evnt: Event, value: VxePasswordInputPropTypes.ModelValue) => {
203
252
  focus()
204
253
  handleChange('', evnt)
205
- $xePasswordInput.dispatchEvent('clear', { value }, evnt)
206
- $xePasswordInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
254
+ dispatchEvent('clear', { value }, evnt)
255
+ dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
207
256
  }
208
257
 
209
258
  const clickSuffixEvent = (evnt: Event) => {
210
- const { disabled } = props
211
- if (!disabled) {
259
+ const isDisabled = computeIsDisabled.value
260
+ if (!isDisabled) {
212
261
  const { inputValue } = reactData
213
- $xePasswordInput.dispatchEvent('suffix-click', { value: inputValue }, evnt)
262
+ dispatchEvent('suffix-click', { value: inputValue }, evnt)
214
263
  }
215
264
  }
216
265
 
217
266
  const clickPrefixEvent = (evnt: Event) => {
218
- const { disabled } = props
219
- if (!disabled) {
267
+ const isDisabled = computeIsDisabled.value
268
+ if (!isDisabled) {
220
269
  const { inputValue } = reactData
221
- $xePasswordInput.dispatchEvent('prefix-click', { value: inputValue }, evnt)
270
+ dispatchEvent('prefix-click', { value: inputValue }, evnt)
222
271
  }
223
272
  }
224
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()
293
+ }
294
+ }
295
+
296
+ Object.assign($xePasswordInput, passwordInputMethods)
297
+
225
298
  const renderPasswordIcon = () => {
226
299
  const { showPwd } = reactData
227
300
  return h('div', {
@@ -256,14 +329,15 @@ export default defineVxeComponent({
256
329
  }
257
330
 
258
331
  const renderSuffixIcon = () => {
259
- const { disabled, suffixIcon, controls } = props
332
+ const { suffixIcon, controls } = props
260
333
  const { inputValue } = reactData
261
- const suffixSlot = slots.suffix
334
+ const isDisabled = computeIsDisabled.value
262
335
  const isClearable = computeIsClearable.value
336
+ const suffixSlot = slots.suffix
263
337
  return isClearable || controls || suffixSlot || suffixIcon
264
338
  ? h('div', {
265
339
  class: ['vxe-password-input--suffix', {
266
- 'is--clear': isClearable && !disabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
340
+ 'is--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
267
341
  }]
268
342
  }, [
269
343
  isClearable
@@ -293,45 +367,22 @@ export default defineVxeComponent({
293
367
  : null
294
368
  }
295
369
 
296
- passwordInputMethods = {
297
- dispatchEvent (type, params, evnt) {
298
- emit(type, createEvent(evnt, { $passwordInput: $xePasswordInput }, params))
299
- },
300
-
301
- focus () {
302
- const inputElem = refInputTarget.value
303
- reactData.isActivated = true
304
- inputElem.focus()
305
- return nextTick()
306
- },
307
- blur () {
308
- const inputElem = refInputTarget.value
309
- inputElem.blur()
310
- reactData.isActivated = false
311
- return nextTick()
312
- },
313
- select () {
314
- const inputElem = refInputTarget.value
315
- inputElem.select()
316
- reactData.isActivated = false
317
- return nextTick()
318
- }
319
- }
320
-
321
- Object.assign($xePasswordInput, passwordInputMethods)
322
-
323
- watch(() => props.modelValue, (val) => {
324
- reactData.inputValue = val
325
- })
326
-
327
370
  const renderVN = () => {
328
- const { className, inputClassName, name, disabled, readonly, autocomplete, autoComplete, maxLength } = props
371
+ const { className, inputClassName, name, readonly, autocomplete, autoComplete, maxLength } = props
329
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
+ }
330
381
  const vSize = computeSize.value
331
- const inpReadonly = computeInpReadonly.value
332
382
  const inputType = computeInputType.value
333
383
  const inpPlaceholder = computeInpPlaceholder.value
334
384
  const isClearable = computeIsClearable.value
385
+ const inputReadonly = computeInputReadonly.value
335
386
  const prefix = renderPrefixIcon()
336
387
  const suffix = renderSuffixIcon()
337
388
  return h('div', {
@@ -341,9 +392,9 @@ export default defineVxeComponent({
341
392
  'is--prefix': !!prefix,
342
393
  'is--suffix': !!suffix,
343
394
  'is--readonly': readonly,
344
- 'is--disabled': disabled,
395
+ 'is--disabled': isDisabled,
345
396
  'is--active': isActivated,
346
- 'show--clear': isClearable && !disabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
397
+ 'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
347
398
  }],
348
399
  spellcheck: false
349
400
  }, [
@@ -354,12 +405,11 @@ export default defineVxeComponent({
354
405
  h('input', {
355
406
  ref: refInputTarget,
356
407
  class: 'vxe-password-input--inner' + (inputClassName ? (' ' + inputClassName) : ''),
357
- value: inputValue,
358
408
  name,
359
409
  type: inputType,
360
410
  placeholder: inpPlaceholder,
361
- readonly: inpReadonly,
362
- disabled,
411
+ readonly: inputReadonly,
412
+ disabled: isDisabled,
363
413
  autocomplete: autocomplete || autoComplete,
364
414
  maxlength: maxLength,
365
415
  onClick: clickEvent,
@@ -373,6 +423,28 @@ export default defineVxeComponent({
373
423
  ])
374
424
  }
375
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
+
376
448
  $xePasswordInput.renderVN = renderVN
377
449
 
378
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
 
@@ -118,8 +118,6 @@ export default defineVxeComponent({
118
118
  getRefMaps: () => refMaps
119
119
  } as unknown as VxeTextareaConstructor
120
120
 
121
- let textareaMethods = {} as TextareaMethods
122
-
123
121
  const computeFormReadonly = computed(() => {
124
122
  const { readonly } = props
125
123
  if (readonly === null) {
@@ -182,6 +180,23 @@ export default defineVxeComponent({
182
180
  return Object.assign({ minRows: 1, maxRows: 10 }, getConfig().textarea.autoSize, autoSize)
183
181
  })
184
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
+
185
200
  const updateAutoTxt = () => {
186
201
  const { size, autosize, autoSize } = props
187
202
  const { inputValue } = reactData
@@ -243,7 +258,7 @@ export default defineVxeComponent({
243
258
 
244
259
  const triggerEvent = (evnt: Event & { type: 'focus' | 'blur' | 'change' }) => {
245
260
  const value = reactData.inputValue
246
- $xeTextarea.dispatchEvent(evnt.type, { value }, evnt)
261
+ dispatchEvent(evnt.type, { value }, evnt)
247
262
  }
248
263
 
249
264
  const handleChange = (value: string, evnt: Event) => {
@@ -274,7 +289,7 @@ export default defineVxeComponent({
274
289
  $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
275
290
  }
276
291
  }
277
- $xeTextarea.dispatchEvent('input', { value }, evnt)
292
+ dispatchEvent('input', { value }, evnt)
278
293
  handleResize()
279
294
  }
280
295
 
@@ -285,7 +300,7 @@ export default defineVxeComponent({
285
300
  } else {
286
301
  handleChange(reactData.inputValue, evnt)
287
302
  }
288
- $xeTextarea.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
303
+ dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
289
304
  }
290
305
 
291
306
  const blurEvent = (evnt: Event & { type: 'blur' }) => {
@@ -294,20 +309,16 @@ export default defineVxeComponent({
294
309
  if (!immediate) {
295
310
  handleChange(inputValue, evnt)
296
311
  }
297
- $xeTextarea.dispatchEvent('blur', { value: inputValue }, evnt)
312
+ dispatchEvent('blur', { value: inputValue }, evnt)
298
313
  }
299
314
 
300
- textareaMethods = {
301
- dispatchEvent (type, params, evnt) {
302
- emit(type, createEvent(evnt, { $textarea: $xeTextarea }, params))
303
- },
304
-
315
+ const textareaMethods: TextareaMethods = {
316
+ dispatchEvent,
305
317
  focus () {
306
318
  const textElem = refTextarea.value
307
319
  textElem.focus()
308
320
  return nextTick()
309
321
  },
310
-
311
322
  blur () {
312
323
  const textElem = refTextarea.value
313
324
  textElem.blur()
@@ -354,7 +365,6 @@ export default defineVxeComponent({
354
365
  h('textarea', {
355
366
  ref: refTextarea,
356
367
  class: 'vxe-textarea--inner' + (inputClassName ? (' ' + inputClassName) : ''),
357
- value: inputValue,
358
368
  name: props.name,
359
369
  placeholder: inpPlaceholder,
360
370
  maxlength: inpMaxLength,
@@ -408,6 +418,24 @@ export default defineVxeComponent({
408
418
  handleResize()
409
419
  })
410
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
+
411
439
  nextTick(() => {
412
440
  const { autosize, autoSize } = props
413
441
  if (autosize) {
@@ -26,6 +26,10 @@
26
26
  }
27
27
  }
28
28
 
29
+ .vxe-password-input--readonly {
30
+ color: var(--vxe-ui-font-color);
31
+ display: inline-flex;
32
+ }
29
33
  .vxe-password-input--wrapper {
30
34
  flex-grow: 1;
31
35
  overflow: hidden;
@@ -38,6 +38,7 @@ export namespace VxePasswordInputPropTypes {
38
38
  export type PrefixIcon = string
39
39
  export type SuffixIcon = string
40
40
  export type Controls = boolean
41
+ export type Editable = boolean
41
42
  /**
42
43
  * 请使用 AutoComplete
43
44
  * @deprecated
@@ -61,6 +62,7 @@ export interface VxePasswordInputProps {
61
62
  prefixIcon?: VxePasswordInputPropTypes.PrefixIcon
62
63
  suffixIcon?: VxePasswordInputPropTypes.SuffixIcon
63
64
  controls?: VxePasswordInputPropTypes.Controls
65
+ editable?: VxePasswordInputPropTypes.Editable
64
66
  /**
65
67
  * 请使用 AutoComplete
66
68
  * @deprecated