fix: new-york input props are not reactive

This commit is contained in:
parasSolanki 2023-12-29 20:26:31 +05:30
parent fa0cae16b6
commit 8cbb7899f9

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { useAttrs } from 'vue'
import { computed, useAttrs } from 'vue'
import { useVModel } from '@vueuse/core'
import { cn } from '@/lib/utils'
@ -16,7 +16,13 @@ const emits = defineEmits<{
(e: 'update:modelValue', payload: string | number): void
}>()
const { class: className, ...rest } = useAttrs()
const rawAttrs = useAttrs()
const attrs = computed(() => {
const { class: className, ...rest } = rawAttrs
return { className, rest }
})
const modelValue = useVModel(props, 'modelValue', emits, {
passive: true,
@ -25,5 +31,5 @@ const modelValue = useVModel(props, 'modelValue', emits, {
</script>
<template>
<input v-model="modelValue" :class="cn('flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50', className ?? '')" v-bind="rest">
<input v-model="modelValue" :class="cn('flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50', attrs.className ?? '')" v-bind="attrs.rest">
</template>