Skip to content

Commit a3b8a7a

Browse files
committed
feat(app): add lazy mode in VInput
1 parent 04f77af commit a3b8a7a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/app/components/VInput.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const props = defineProps({
1414
type: [String, Number],
1515
default: '',
1616
},
17+
modelModifiers: {
18+
type: Object,
19+
default: () => ({}),
20+
},
1721
label: {
1822
type: String,
1923
default: '',
@@ -122,6 +126,18 @@ function onBlur() {
122126
emit('blur')
123127
}
124128
129+
function onInput(e: Event) {
130+
if (props.modelModifiers.lazy) return
131+
132+
model.value = (e.target as HTMLInputElement).value
133+
}
134+
135+
function onChange(e: Event) {
136+
if (!props.modelModifiers.lazy) return
137+
138+
model.value = (e.target as HTMLInputElement).value
139+
}
140+
125141
const classes = computed(() => {
126142
const result: string[] = ['transition-all bg-transparent w-full flex']
127143
@@ -194,7 +210,7 @@ const ui = computed(() => (props.disabled ? 'disabled' : ''))
194210
<input
195211
:id="label"
196212
ref="inputRef"
197-
v-model="model"
213+
:value="modelValue"
198214
:type="type"
199215
:placeholder="placeholder"
200216
:readonly="readonly"
@@ -203,6 +219,8 @@ const ui = computed(() => (props.disabled ? 'disabled' : ''))
203219
class="bg-transparent outline-none grow w-full placeholder:text-t-secondary/50"
204220
@focus="onFocus"
205221
@blur="onBlur"
222+
@input="onInput"
223+
@change="onChange"
206224
/>
207225
<slot name="append" />
208226
</div>

packages/app/modules/item/components/IValueText.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ const editModel = useModelOrInnerValue(props, 'edit', emit)
4242
{{ payload }}
4343
</div>
4444

45-
<v-input v-else v-model="payload" @update:model-value="save" @blur="editModel = false" />
45+
<v-input v-else v-model.lazy="payload" @update:model-value="save" @blur="editModel = false" />
4646
</template>

0 commit comments

Comments
 (0)