Refactor #3965 - For Textarea

pull/3997/head
Tuğçe Küçükoğlu 2023-05-24 17:15:21 +03:00
parent ce6a30fb26
commit ee99bbb7c4
3 changed files with 55 additions and 18 deletions

View File

@ -0,0 +1,47 @@
<script>
import BaseComponent from 'primevue/basecomponent';
import { useStyle } from 'primevue/usestyle';
const styles = `
.p-inputtextarea-resizable {
overflow: hidden;
resize: none;
}
.p-fluid .p-inputtextarea {
width: 100%;
}
`;
const classes = {
root: ({ instance, props }) => [
'p-inputtextarea p-inputtext p-component',
{
'p-filled': instance.filled,
'p-inputtextarea-resizable ': props.autoResize
}
]
};
const { load: loadStyle, unload: unloadStyle } = useStyle(styles, { id: 'primevue_textarea_style', manual: true });
export default {
name: 'BaseTextarea',
extends: BaseComponent,
props: {
modelValue: null,
autoResize: Boolean
},
css: {
classes
},
watch: {
isUnstyled: {
immediate: true,
handler(newValue) {
!newValue && loadStyle();
}
}
}
};
</script>

View File

@ -56,6 +56,11 @@ export interface TextareaProps extends TextareaHTMLAttributes {
* @type {TextareaPassThroughOptions}
*/
pt?: TextareaPassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
}
/**

View File

@ -1,18 +1,14 @@
<template>
<textarea :class="['p-inputtextarea p-inputtext p-component', { 'p-filled': filled, 'p-inputtextarea-resizable ': autoResize }]" :value="modelValue" @input="onInput" v-bind="ptm('root')"></textarea>
<textarea :class="cx('root')" :value="modelValue" @input="onInput" v-bind="ptm('root')"></textarea>
</template>
<script>
import BaseComponent from 'primevue/basecomponent';
import BaseTextarea from './BaseTextarea.vue';
export default {
name: 'Textarea',
extends: BaseComponent,
extends: BaseTextarea,
emits: ['update:modelValue'],
props: {
modelValue: null,
autoResize: Boolean
},
mounted() {
if (this.$el.offsetParent && this.autoResize) {
this.resize();
@ -52,14 +48,3 @@ export default {
}
};
</script>
<style>
.p-inputtextarea-resizable {
overflow: hidden;
resize: none;
}
.p-fluid .p-inputtextarea {
width: 100%;
}
</style>