2025-12-10 20:52:44 +08:00
|
|
|
<template>
|
|
|
|
|
<input
|
|
|
|
|
:class="inputClass"
|
|
|
|
|
:value="modelValue"
|
|
|
|
|
:autocomplete="autocompleteAttr"
|
2026-01-01 02:10:19 +08:00
|
|
|
:data-lpignore="disableAutofill ? 'true' : undefined"
|
|
|
|
|
:data-1p-ignore="disableAutofill ? 'true' : undefined"
|
|
|
|
|
:data-form-type="disableAutofill ? 'other' : undefined"
|
2025-12-10 20:52:44 +08:00
|
|
|
v-bind="$attrs"
|
|
|
|
|
@input="handleInput"
|
2025-12-12 16:15:07 +08:00
|
|
|
>
|
2025-12-10 20:52:44 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed } from 'vue'
|
|
|
|
|
import { cn } from '@/lib/utils'
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
modelValue?: string | number
|
|
|
|
|
class?: string
|
|
|
|
|
autocomplete?: string
|
2026-01-01 02:10:19 +08:00
|
|
|
disableAutofill?: boolean
|
2025-12-10 20:52:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const props = defineProps<Props>()
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
'update:modelValue': [value: string]
|
|
|
|
|
}>()
|
|
|
|
|
|
2026-01-01 02:10:19 +08:00
|
|
|
const autocompleteAttr = computed(() => {
|
|
|
|
|
if (props.disableAutofill) {
|
|
|
|
|
return 'one-time-code'
|
|
|
|
|
}
|
|
|
|
|
return props.autocomplete ?? 'off'
|
|
|
|
|
})
|
2025-12-10 20:52:44 +08:00
|
|
|
|
|
|
|
|
const inputClass = computed(() =>
|
|
|
|
|
cn(
|
|
|
|
|
'flex h-11 w-full rounded-2xl border border-border/60 bg-card/80 px-4 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:border-primary/60 text-foreground backdrop-blur transition-all',
|
|
|
|
|
props.class
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
function handleInput(event: Event) {
|
|
|
|
|
const target = event.target as HTMLInputElement
|
|
|
|
|
emit('update:modelValue', target.value)
|
|
|
|
|
}
|
|
|
|
|
</script>
|