Skip to content

Commit

Permalink
feat(BaseTextarea): add .lazy v-model modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Oct 14, 2023
1 parent b18930d commit 6d68fa5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
12 changes: 10 additions & 2 deletions components/form/BaseInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ const props = withDefaults(
*
* @modifiers
* `v-model.trim="value"`
*
* @modifiers
* `v-model.lazy="value"`
*/
modelValue?: string | number
/**
* Used internaly to allow v-model.number and v-model.trim
* Used internaly to allow .number, .trim
* and .lazy v-model modifiers.
*/
modelModifiers?: any
modelModifiers?: {
number?: boolean
trim?: boolean
lazy?: boolean
}
/**
* The form input identifier.
Expand Down
29 changes: 27 additions & 2 deletions components/form/BaseTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ export interface TextareaProps {
*
* @example
* `v-model.trim="value"`
*
* @modifiers
* `v-model.lazy="value"`
*/
modelValue?: string
/**
* Used internaly to allow v-model.trim
* Used internaly to allow .trim
* and .lazy v-model modifiers.
*/
modelModifiers?: any
modelModifiers?: {
trim?: boolean
lazy?: boolean
}
/**
* The form input identifier.
Expand Down Expand Up @@ -249,6 +256,24 @@ const id = useNinjaId(() => props.id)
</label>
<div class="nui-textarea-outer">
<textarea
v-if="props.modelModifiers.lazy"
:id="id"
ref="textareaRef"
v-model.lazy="value"
v-bind="$attrs"
class="nui-textarea"
:class="[
props.colorFocus && 'nui-textarea-focus',
props.classes.textarea,
]"
:name="props.name"
:placeholder="props.placeholder"
:readonly="props.readonly"
:disabled="props.disabled"
:rows="props.rows"
></textarea>
<textarea
v-else
:id="id"
ref="textareaRef"
v-model="value"
Expand Down

0 comments on commit 6d68fa5

Please sign in to comment.