mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-10 09:22:34 +00:00
Add form support to Textarea
This commit is contained in:
parent
2785def67c
commit
cff6d40f0d
3 changed files with 20 additions and 39 deletions
|
@ -1,25 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import BaseComponent from '@primevue/core/basecomponent';
|
import BaseInput from '@primevue/core/baseinput';
|
||||||
import TextareaStyle from 'primevue/textarea/style';
|
import TextareaStyle from 'primevue/textarea/style';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BaseTextarea',
|
name: 'BaseTextarea',
|
||||||
extends: BaseComponent,
|
extends: BaseInput,
|
||||||
props: {
|
props: {
|
||||||
modelValue: null,
|
autoResize: Boolean
|
||||||
autoResize: Boolean,
|
|
||||||
invalid: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
variant: {
|
|
||||||
type: String,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
fluid: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
style: TextareaStyle,
|
style: TextareaStyle,
|
||||||
provide() {
|
provide() {
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<textarea :class="cx('root')" :value="modelValue" :aria-invalid="invalid || undefined" @input="onInput" v-bind="ptmi('root', ptmParams)"></textarea>
|
<textarea :class="cx('root')" :value="d_value" :disabled="disabled" :aria-invalid="invalid || undefined" @input="onInput" v-bind="attrs"></textarea>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { isEmpty } from '@primeuix/utils/object';
|
import { mergeProps } from 'vue';
|
||||||
import BaseTextarea from './BaseTextarea.vue';
|
import BaseTextarea from './BaseTextarea.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Textarea',
|
name: 'Textarea',
|
||||||
extends: BaseTextarea,
|
extends: BaseTextarea,
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
emits: ['update:modelValue'],
|
|
||||||
inject: {
|
|
||||||
$pcFluid: { default: null }
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.$el.offsetParent && this.autoResize) {
|
if (this.$el.offsetParent && this.autoResize) {
|
||||||
this.resize();
|
this.resize();
|
||||||
|
@ -41,22 +37,20 @@ export default {
|
||||||
this.resize();
|
this.resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('update:modelValue', event.target.value);
|
this.updateValue(event.target.value, event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filled() {
|
attrs() {
|
||||||
return this.modelValue != null && this.modelValue.toString().length > 0;
|
return mergeProps(
|
||||||
},
|
this.ptmi('root', {
|
||||||
ptmParams() {
|
|
||||||
return {
|
|
||||||
context: {
|
context: {
|
||||||
disabled: this.$attrs.disabled || this.$attrs.disabled === ''
|
filled: this.$filled,
|
||||||
|
disabled: this.disabled
|
||||||
}
|
}
|
||||||
};
|
}),
|
||||||
},
|
this.formField
|
||||||
hasFluid() {
|
);
|
||||||
return isEmpty(this.fluid) ? !!this.$pcFluid : this.fluid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,11 +65,11 @@ const classes = {
|
||||||
root: ({ instance, props }) => [
|
root: ({ instance, props }) => [
|
||||||
'p-textarea p-component',
|
'p-textarea p-component',
|
||||||
{
|
{
|
||||||
'p-filled': instance.filled,
|
'p-filled': instance.$filled,
|
||||||
'p-textarea-resizable ': props.autoResize,
|
'p-textarea-resizable ': props.autoResize,
|
||||||
'p-invalid': props.invalid,
|
'p-invalid': instance.$invalid,
|
||||||
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled' || instance.$primevue.config.inputVariant === 'filled',
|
'p-variant-filled': instance.$variant === 'filled',
|
||||||
'p-textarea-fluid': instance.hasFluid
|
'p-textarea-fluid': instance.$fluid
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue