mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
40 lines
2.0 KiB
Vue
40 lines
2.0 KiB
Vue
<script setup lang="ts">
|
|
import type { HTMLAttributes } from 'vue'
|
|
import { cn } from '@/lib/utils'
|
|
import { useVModel } from '@vueuse/core'
|
|
import { EyeIcon, EyeOffIcon } from 'lucide-vue-next';
|
|
|
|
const props = defineProps<{
|
|
defaultValue?: string | number
|
|
modelValue?: string | number
|
|
class?: HTMLAttributes['class']
|
|
}>()
|
|
|
|
const emits = defineEmits<{
|
|
(e: 'update:modelValue', payload: string | number): void
|
|
}>()
|
|
|
|
const modelValue = useVModel(props, 'modelValue', emits, {
|
|
passive: true,
|
|
defaultValue: props.defaultValue,
|
|
})
|
|
|
|
const showInputText = ref<boolean>(false);
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<div class="relative">
|
|
<div class="absolute right-4 h-full flex items-center text-white">
|
|
<EyeIcon @click="showInputText = true" v-if="!showInputText" class="size-5 cursor-pointer"></EyeIcon>
|
|
<EyeOffIcon @click="showInputText = false" v-else class="size-5 cursor-pointer"></EyeOffIcon>
|
|
</div>
|
|
<input class="pr-12" v-model="modelValue" data-slot="input" :type="showInputText ? 'text' : 'password'" :class="cn(
|
|
'file:text-gray-950 placeholder:text-gray-500 selection:bg-gray-900 selection:text-gray-50 dark:bg-gray-200/30 border-border 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 dark:file:text-gray-50 dark:placeholder:text-gray-400 dark:selection:bg-gray-50 dark:selection:text-gray-900 dark:dark:bg-background dark:border-border',
|
|
'focus-visible:border-gray-950 focus-visible:ring-gray-950/50 focus-visible:ring-[1px] dark:focus-visible:border-gray-800 dark:focus-visible:ring-gray-300/50',
|
|
'aria-invalid:ring-red-500/20 dark:aria-invalid:ring-red-500/40 aria-invalid:border-red-500 dark:dark:aria-invalid:ring-red-900/40 dark:aria-invalid:border-red-900',
|
|
props.class,
|
|
)">
|
|
</div>
|
|
</template>
|