Input.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. <script setup lang="ts">
  2. import type { HTMLAttributes } from "vue"
  3. import { useVModel } from "@vueuse/core"
  4. import { cn } from '@/Packages/Shadcn/Lib/utils'
  5. const props = defineProps<{
  6. defaultValue?: string | number
  7. modelValue?: string | number
  8. class?: HTMLAttributes["class"]
  9. }>()
  10. const emits = defineEmits<{
  11. (e: "update:modelValue", payload: string | number): void
  12. }>()
  13. const modelValue = useVModel(props, "modelValue", emits, {
  14. passive: true,
  15. defaultValue: props.defaultValue,
  16. })
  17. </script>
  18. <template>
  19. <input
  20. v-model="modelValue"
  21. data-slot="input"
  22. :class="cn(
  23. 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
  24. 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
  25. 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
  26. props.class,
  27. )"
  28. >
  29. </template>