| <template> |
| <span> |
| <textarea |
| class="form-control" |
| rows="3" |
| ref="inputElem" |
| :readonly="readonly" |
| :id="id" |
| :placeholder="placeHolder" |
| :disabled="disabled" |
| @input="handleInput" |
| @keydown="onKeyDown" |
| :value="modelValue" |
| /> |
| <FormElementDescription |
| :description="description" |
| ></FormElementDescription> |
| </span> |
| </template> |
|
|
| <script lang="ts"> |
| |
|
|
| import { randomID } from "@/Core/Utils/MiscUtils"; |
| import { Options, Vue } from "vue-class-component"; |
| import { Prop } from "vue-property-decorator"; |
| import FormElementDescription from "@/UI/Forms/FormElementDescription.vue"; |
| import { formInputDelayUpdate } from "@/Core/GlobalVars"; |
|
|
| |
| |
| |
| @Options({ |
| components: { |
| FormElementDescription, |
| }, |
| }) |
| export default class FormTextArea extends Vue { |
| @Prop({ required: true }) modelValue!: any; |
| @Prop({ default: randomID() }) id!: string; |
| @Prop({ default: "placeholder" }) placeHolder!: string; |
| @Prop({ default: false }) disabled!: boolean; |
| @Prop({ required: false }) filterFunc!: Function; |
| @Prop({}) description!: string; |
| @Prop({ default: formInputDelayUpdate }) |
| delayBetweenChangesDetected!: number; |
| @Prop({ default: false }) readonly!: boolean; |
|
|
| lastHandleInputTimeStamp = 0; |
| timeOutLastHandleInput: any = null; |
|
|
| |
| |
| |
| |
| |
| |
| onKeyDown(_e: KeyboardEvent) { |
| this.$emit("onKeyDown"); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| handleInput(e: any): void { |
| if (this.filterFunc) { |
| |
|
|
| |
| let carot = e.target.selectionStart; |
|
|
| |
| e.target.value = this.filterFunc(e.target.value); |
|
|
| |
| this.$nextTick(() => { |
| e.target.setSelectionRange(carot, carot); |
| }); |
| } |
|
|
| |
| |
|
|
| |
| if ( |
| Date.now() - this.lastHandleInputTimeStamp < |
| this.delayBetweenChangesDetected |
| ) { |
| return; |
| } |
|
|
| this.lastHandleInputTimeStamp = Date.now(); |
| this.timeOutLastHandleInput = setTimeout(() => { |
| let val = e.target.value; |
| this.$emit("update:modelValue", val); |
|
|
| |
| |
| this.$emit("onChange"); |
| }, this.delayBetweenChangesDetected); |
| } |
| } |
| </script> |
|
|
| <!-- Add "scoped" attribute to limit CSS to this component only --> |
| <style lang="scss" scoped></style> |
|
|