|
8 | 8 | }"
|
9 | 9 | >
|
10 | 10 | <div v-if="!inline" :class="`${prefixClass}-input-wrapper`" @mousedown="openPopup">
|
11 |
| - <slot name="input"> |
| 11 | + <slot |
| 12 | + name="input" |
| 13 | + :props="{ |
| 14 | + name: 'date', |
| 15 | + type: 'text', |
| 16 | + autocomplete: 'off', |
| 17 | + value: text, |
| 18 | + class: inputClass, |
| 19 | + readonly: !editable, |
| 20 | + disabled, |
| 21 | + placeholder, |
| 22 | + ...inputAttr, |
| 23 | + }" |
| 24 | + :events="{ |
| 25 | + keydown: handleInputKeydown, |
| 26 | + focus: handleInputFocus, |
| 27 | + blur: handleInputBlur, |
| 28 | + input: handleInputInput, |
| 29 | + change: handleInputChange, |
| 30 | + }" |
| 31 | + > |
12 | 32 | <input
|
13 | 33 | ref="input"
|
14 |
| - v-bind="{ name: 'date', type: 'text', autocomplete: 'off', value: text, ...inputAttr }" |
15 |
| - :class="inputClass" |
16 |
| - :disabled="disabled" |
17 |
| - :readonly="!editable" |
18 |
| - :placeholder="placeholder" |
19 |
| - @keydown="handleInputKeydown" |
20 |
| - @focus="handleInputFocus" |
21 |
| - @blur="handleInputBlur" |
22 |
| - @input="handleInputInput" |
23 |
| - @change="handleInputChange" |
| 34 | + v-bind="{ |
| 35 | + name: 'date', |
| 36 | + type: 'text', |
| 37 | + autocomplete: 'off', |
| 38 | + value: text, |
| 39 | + class: inputClass, |
| 40 | + readonly: !editable, |
| 41 | + disabled, |
| 42 | + placeholder, |
| 43 | + ...inputAttr, |
| 44 | + }" |
| 45 | + v-on="{ |
| 46 | + keydown: handleInputKeydown, |
| 47 | + focus: handleInputFocus, |
| 48 | + blur: handleInputBlur, |
| 49 | + input: handleInputInput, |
| 50 | + change: handleInputChange, |
| 51 | + }" |
24 | 52 | />
|
25 | 53 | </slot>
|
26 | 54 | <i v-if="showClearIcon" :class="`${prefixClass}-icon-clear`" @mousedown.stop="handleClear">
|
@@ -456,10 +484,15 @@ export default {
|
456 | 484 | this.$emit('update:open', false);
|
457 | 485 | },
|
458 | 486 | blur() {
|
459 |
| - this.$refs.input.blur(); |
| 487 | + // when use slot input |
| 488 | + if (this.$refs.input) { |
| 489 | + this.$refs.input.blur(); |
| 490 | + } |
460 | 491 | },
|
461 | 492 | focus() {
|
462 |
| - this.$refs.input.focus(); |
| 493 | + if (this.$refs.input) { |
| 494 | + this.$refs.input.focus(); |
| 495 | + } |
463 | 496 | },
|
464 | 497 | handleInputChange() {
|
465 | 498 | if (!this.editable || this.userInput === null) return;
|
|
0 commit comments