From 4c8e12692cba83a0d507660778a7f506e30956ff Mon Sep 17 00:00:00 2001 From: Warsono Date: Thu, 30 Jun 2022 16:07:35 +0700 Subject: [PATCH] fix(textarea): add new props: `wrapperClass` and `inputClass` --- .../forms/src/textarea/Textarea.stories.ts | 28 ++++++++++--------- packages/forms/src/textarea/Textarea.vue | 15 ++++++++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/forms/src/textarea/Textarea.stories.ts b/packages/forms/src/textarea/Textarea.stories.ts index 74c15f6f8..b385e786b 100644 --- a/packages/forms/src/textarea/Textarea.stories.ts +++ b/packages/forms/src/textarea/Textarea.stories.ts @@ -30,24 +30,13 @@ export default { } as Meta; const Template: Story = (args) => ({ - // Components used in your story `template` are defined in the `components` object components: {VTextarea}, - // The story's `args` need to be mapped into the template through the `setup()` method setup() { return {args}; }, - // And then the `args` are bound to your component with `v-bind="args"` template: ``, }); -// export const Textarea: Story = (args) => ({ -// components: { VTextarea }, -// setup() { -// return { args }; -// }, -// template: '', -// }); - export const Default = Template.bind({}); Default.args = {}; Default.parameters = { @@ -96,10 +85,11 @@ Error.parameters = { }, }; -export const Validation: Story<{}> = (args) => ({ +export const Validation: Story<{}> = () => ({ components: {VTextarea, VBtn}, setup() { const schema = object({ + bio: string().required().label('Bio'), message: string().required().label('Message'), }); @@ -115,7 +105,19 @@ export const Validation: Story<{}> = (args) => ({ }, template: `
- + + Submit Reset diff --git a/packages/forms/src/textarea/Textarea.vue b/packages/forms/src/textarea/Textarea.vue index 98c4668fc..ac55c1ea3 100644 --- a/packages/forms/src/textarea/Textarea.vue +++ b/packages/forms/src/textarea/Textarea.vue @@ -60,6 +60,14 @@ const props = defineProps({ type: String, default: '', }, + wrapperClass: { + type: String, + default: '', + }, + inputClass: { + type: String, + default: '', + }, }); const {error, size} = toRefs(props); @@ -71,19 +79,20 @@ const {value, errorMessage} = useField(props.name, props.rules, { }); const {class: sizeClass} = useTextSize(size.value); -const inputClass = computed(() => +const inputClasses = computed(() => useInputClasses(error.value || !!errorMessage.value), ); const classes = computed(() => [ - inputClass.value, + inputClasses.value, sizeClass.value, {shadow: props.shadow}, + props.inputClass, ]);