This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+96
View File
@@ -0,0 +1,96 @@
// Styles
import "../../../src/components/VTextarea/VTextarea.sass"; // Extensions
import VTextField from '../VTextField/VTextField'; // Utilities
import mixins from '../../util/mixins';
const baseMixins = mixins(VTextField);
/* @vue/component */
export default baseMixins.extend({
name: 'v-textarea',
props: {
autoGrow: Boolean,
noResize: Boolean,
rowHeight: {
type: [Number, String],
default: 24,
validator: v => !isNaN(parseFloat(v))
},
rows: {
type: [Number, String],
default: 5,
validator: v => !isNaN(parseInt(v, 10))
}
},
computed: {
classes() {
return {
'v-textarea': true,
'v-textarea--auto-grow': this.autoGrow,
'v-textarea--no-resize': this.noResizeHandle,
...VTextField.options.computed.classes.call(this)
};
},
noResizeHandle() {
return this.noResize || this.autoGrow;
}
},
watch: {
lazyValue() {
this.autoGrow && this.$nextTick(this.calculateInputHeight);
},
rowHeight() {
this.autoGrow && this.$nextTick(this.calculateInputHeight);
}
},
mounted() {
setTimeout(() => {
this.autoGrow && this.calculateInputHeight();
}, 0);
},
methods: {
calculateInputHeight() {
const input = this.$refs.input;
if (!input) return;
input.style.height = '0';
const height = input.scrollHeight;
const minHeight = parseInt(this.rows, 10) * parseFloat(this.rowHeight); // This has to be done ASAP, waiting for Vue
// to update the DOM causes ugly layout jumping
input.style.height = Math.max(minHeight, height) + 'px';
},
genInput() {
const input = VTextField.options.methods.genInput.call(this);
input.tag = 'textarea';
delete input.data.attrs.type;
input.data.attrs.rows = this.rows;
return input;
},
onInput(e) {
VTextField.options.methods.onInput.call(this, e);
this.autoGrow && this.calculateInputHeight();
},
onKeyDown(e) {
// Prevents closing of a
// dialog when pressing
// enter
if (this.isFocused && e.keyCode === 13) {
e.stopPropagation();
}
this.$emit('keydown', e);
}
}
});
//# sourceMappingURL=VTextarea.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VTextarea/VTextarea.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;;AAyBP,IAAA,SAAS,CAAE,CAAF,EAAkB;AACzB;AACA;AACA;AACA,UAAI,KAAK,SAAL,IAAkB,CAAC,CAAC,OAAF,KAAc,EAApC,EAAwC;AACtC,QAAA,CAAC,CAAC,eAAF;AACD;;AAED,WAAK,KAAL,CAAW,SAAX,EAAsB,CAAtB;AACD;;AAlCM;AA/CsB,CAAlB,CAAf","sourcesContent":["// Styles\nimport './VTextarea.sass'\n\n// Extensions\nimport VTextField from '../VTextField/VTextField'\n\n// Utilities\nimport mixins from '../../util/mixins'\n\n// Types\nimport Vue from 'vue'\n\ninterface options extends Vue {\n $refs: {\n input: HTMLTextAreaElement\n }\n}\n\nconst baseMixins = mixins<options &\n InstanceType<typeof VTextField>\n>(\n VTextField\n)\n\n/* @vue/component */\nexport default baseMixins.extend({\n name: 'v-textarea',\n\n props: {\n autoGrow: Boolean,\n noResize: Boolean,\n rowHeight: {\n type: [Number, String],\n default: 24,\n validator: (v: any) => !isNaN(parseFloat(v)),\n },\n rows: {\n type: [Number, String],\n default: 5,\n validator: (v: any) => !isNaN(parseInt(v, 10)),\n },\n },\n\n computed: {\n classes (): object {\n return {\n 'v-textarea': true,\n 'v-textarea--auto-grow': this.autoGrow,\n 'v-textarea--no-resize': this.noResizeHandle,\n ...VTextField.options.computed.classes.call(this),\n }\n },\n noResizeHandle (): boolean {\n return this.noResize || this.autoGrow\n },\n },\n\n watch: {\n lazyValue () {\n this.autoGrow && this.$nextTick(this.calculateInputHeight)\n },\n rowHeight () {\n this.autoGrow && this.$nextTick(this.calculateInputHeight)\n },\n },\n\n mounted () {\n setTimeout(() => {\n this.autoGrow && this.calculateInputHeight()\n }, 0)\n },\n\n methods: {\n calculateInputHeight () {\n const input = this.$refs.input\n if (!input) return\n\n input.style.height = '0'\n const height = input.scrollHeight\n const minHeight = parseInt(this.rows, 10) * parseFloat(this.rowHeight)\n // This has to be done ASAP, waiting for Vue\n // to update the DOM causes ugly layout jumping\n input.style.height = Math.max(minHeight, height) + 'px'\n },\n genInput () {\n const input = VTextField.options.methods.genInput.call(this)\n\n input.tag = 'textarea'\n delete input.data!.attrs!.type\n input.data!.attrs!.rows = this.rows\n\n return input\n },\n onInput (e: Event) {\n VTextField.options.methods.onInput.call(this, e)\n this.autoGrow && this.calculateInputHeight()\n },\n onKeyDown (e: KeyboardEvent) {\n // Prevents closing of a\n // dialog when pressing\n // enter\n if (this.isFocused && e.keyCode === 13) {\n e.stopPropagation()\n }\n\n this.$emit('keydown', e)\n },\n },\n})\n"],"sourceRoot":"","file":"VTextarea.js"}
+4
View File
@@ -0,0 +1,4 @@
import VTextarea from './VTextarea';
export { VTextarea };
export default VTextarea;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VTextarea/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAP,MAAsB,aAAtB;AAEA,SAAS,SAAT;AACA,eAAe,SAAf","sourcesContent":["import VTextarea from './VTextarea'\n\nexport { VTextarea }\nexport default VTextarea\n"],"sourceRoot":"","file":"index.js"}