Refactor #4124 - Textarea pt context improvements

pull/4148/head
Tuğçe Küçükoğlu 2023-07-13 15:42:30 +03:00
parent 6afaa15de3
commit 02f67d1b0f
2 changed files with 25 additions and 1 deletions

View File

@ -19,6 +19,7 @@ export declare type TextareaPassThroughOptionType = TextareaPassThroughAttribute
export interface TextareaPassThroughMethodOptions {
instance: any;
props: TextareaProps;
context: TextareaContext;
}
/**
@ -44,6 +45,22 @@ export interface TextareaPassThroughAttributes {
[key: string]: any;
}
/**
* Defines current options in Textarea component.
*/
export interface TextareaContext {
/**
* Current filled state of the component as a boolean.
* @defaultValue false
*/
filled: boolean;
/**
* Current disabled state of the component as a boolean.
* @defaultValue false
*/
disabled: boolean;
}
/**
* Defines valid properties in Textarea component. In addition to these, all properties of TextareaHTMLAttributes can be used in this component.
* @extends TextareaHTMLAttributes

View File

@ -1,5 +1,5 @@
<template>
<textarea :class="cx('root')" :value="modelValue" @input="onInput" v-bind="ptm('root')" data-pc-name="textarea"></textarea>
<textarea :class="cx('root')" :value="modelValue" @input="onInput" v-bind="ptm('root', ptmParams)" data-pc-name="textarea"></textarea>
</template>
<script>
@ -44,6 +44,13 @@ export default {
computed: {
filled() {
return this.modelValue != null && this.modelValue.toString().length > 0;
},
ptmParams() {
return {
context: {
disabled: this.$attrs.disabled || this.$attrs.disabled === ''
}
};
}
}
};