Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | 7x 7x 8x 7x 7x 1x 7x 8x 8x 8x | export default {
inheritAttrs: false,
inject: {
qForm: {
default: null
},
qFormItem: {
default: null
}
},
props: {
value: {
type: [String, Number],
default: ''
},
disabled: {
type: Boolean,
default: false
},
readonly: {
type: Boolean,
default: false
},
showSymbolLimit: {
type: Boolean,
default: false
},
counterLimit: {
type: Number,
default: null
},
validateEvent: {
type: Boolean,
default: true
},
label: { type: String, default: '' },
tabindex: { type: String, default: '' }
},
data() {
return {
hovering: false,
focused: false,
isComposing: false
};
},
computed: {
inputDisabled() {
return this.disabled || (this.qForm?.disabled ?? false);
},
nativeInputValue() {
return String(this.value ?? '');
},
isClearButtonShown() {
return Boolean(
this.clearable &&
!this.inputDisabled &&
!this.readonly &&
this.nativeInputValue &&
(this.focused || this.hovering)
);
},
isSymbolLimitShown() {
return (
this.showSymbolLimit &&
(this.$attrs.maxlength || this.counterLimit) &&
!this.inputDisabled &&
!this.readonly &&
!this.showPassword
);
},
upperLimit() {
return this.$attrs.maxlength ?? this.counterLimit;
},
textLength() {
return this.value?.length ?? 0;
}
},
watch: {
nativeInputValue() {
this.setNativeInputValue();
}
},
created() {
this.$on('inputSelect', this.select);
},
methods: {
focus() {
this.componentRef.focus();
},
blur() {
this.componentRef.blur();
},
handleBlur(event) {
this.focused = false;
this.$emit('blur', event);
if (this.validateEvent) this.qFormItem?.validateField('blur');
},
select() {
this.componentRef.select();
},
setNativeInputValue() {
const input = this.componentRef;
Iif (!input || input.value === this.nativeInputValue) return;
input.value = this.nativeInputValue;
},
handleFocus(event) {
this.focused = true;
this.$emit('focus', event);
},
handleCompositionStart() {
this.isComposing = true;
},
handleCompositionEnd(event) {
if (this.isComposing) {
this.isComposing = false;
this.handleInput(event);
}
},
handleInput(event) {
// should not emit input during composition
if (this.isComposing) return;
this.$emit('input', event.target.value, event);
// ensure native input value is controlled
this.$nextTick(this.setNativeInputValue);
},
handleChange(event) {
this.$emit('change', event.target.value);
}
}
};
|