diff --git a/components/src/stories/Textarea.stories.js b/components/src/stories/Textarea.stories.js index 14e38094..3fed6c32 100644 --- a/components/src/stories/Textarea.stories.js +++ b/components/src/stories/Textarea.stories.js @@ -9,13 +9,31 @@ export const Basic = { setup() { return { args }; }, - template: '', + template: '', }), args: { + label: 'Simple textarea', + hint: 'This is a hint for the text area input', value: '', placeholder: 'Placeholder text', - label: 'Label', + }, +}; + +export const Validation = { + name: 'Input validation', + render: Basic.render, + + args: { + label: 'Text area with validation', + hint: 'This is a text area with validation. The text should be < 30 characters.', + value: '', + placeholder: 'Lorem ipsum dolor sit amet', + required: true, + rules: [ + (value) => !!value || 'This field is required', + (value) => value.length < 30 || 'The value must be less than 30 characters', + ], }, }; @@ -28,10 +46,12 @@ export default { argTypes: { value: 'text', readonly: 'boolean', + hint: 'text', placeholder: 'text', required: 'boolean', autoGrow: 'boolean', noBorder: 'boolean', + monospace: 'boolean', rows: 'number', label: 'string', }, diff --git a/components/src/widgets/menu/widget.vue b/components/src/widgets/menu/widget.vue index 9e58d2fb..69063d7a 100644 --- a/components/src/widgets/menu/widget.vue +++ b/components/src/widgets/menu/widget.vue @@ -91,7 +91,7 @@ onUnmounted(() => { .menu-content { position: absolute; - top: 0; + top: 2px; width: max-content; &_align-right { diff --git a/components/src/widgets/textarea/widget.vue b/components/src/widgets/textarea/widget.vue index 6b804bd7..edcbc525 100644 --- a/components/src/widgets/textarea/widget.vue +++ b/components/src/widgets/textarea/widget.vue @@ -8,7 +8,7 @@ {{ props.label }} @@ -18,14 +18,12 @@ ref="txtarea" v-model="localValue" class="textarea-field__input" - :class="{ - 'textarea-field__input_no-resize': autoGrow, - 'textarea-field__input_no-border': noBorder, - }" + :class="inputClasses" :placeholder="placeholder" :readonly="props.readonly" :rows="rows" name="textarea" + @focus="setFocus" @input.stop > [], @@ -125,6 +127,12 @@ const computedClasses = computed(() => ({ 'textarea-field_optional': !props.required, })); +const inputClasses = computed(() => ({ + 'textarea-field__input_no-resize': props.autoGrow, + 'textarea-field__input_no-border': props.noBorder, + 'textarea-field__input_monospace': props.monospace, +})); + onMounted(() => { if (props.autoGrow) calculateInputHeight(); }); @@ -166,6 +174,7 @@ watch(localValue, async (newValue) => { border-radius: 2px; padding: 11px; resize: vertical; + font-family: inherit; &_no-resize { resize: none; @@ -175,6 +184,10 @@ watch(localValue, async (newValue) => { border: none; outline: none; } + + &_monospace { + font-family: monospace; + } } &__label { diff --git a/components/src/widgets/textfield/widget.vue b/components/src/widgets/textfield/widget.vue index b2b6c659..500a71ff 100644 --- a/components/src/widgets/textfield/widget.vue +++ b/components/src/widgets/textfield/widget.vue @@ -2,6 +2,7 @@ @@ -24,6 +24,7 @@ :placeholder="placeholder" name="textfield" type="text" + @focus="setFocus" @input.stop />