mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-06 04:19:20 +00:00
49 lines
1.5 KiB
Vue
49 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import { DateFormatter } from "@internationalized/date";
|
|
import type { FieldProps } from "./interface";
|
|
|
|
defineProps<FieldProps>();
|
|
|
|
const df = new DateFormatter("en-US", {
|
|
dateStyle: "long",
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<FormField v-slot="slotProps" :name="fieldName">
|
|
<FormItem>
|
|
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
</AutoFormLabel>
|
|
<FormControl>
|
|
<slot v-bind="slotProps">
|
|
<div>
|
|
<Popover>
|
|
<PopoverTrigger as-child :disabled="disabled">
|
|
<Button
|
|
variant="outline"
|
|
:class="cn(
|
|
'w-full justify-start text-left font-normal',
|
|
!slotProps.componentField.modelValue && 'text-muted-foreground',
|
|
)"
|
|
>
|
|
<CalendarIcon class="mr-2 h-4 w-4" />
|
|
{{ slotProps.componentField.modelValue ? df.format(slotProps.componentField.modelValue.toDate(getLocalTimeZone())) : "Pick a date" }}
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent class="w-auto p-0">
|
|
<Calendar initial-focus v-bind="slotProps.componentField" />
|
|
</PopoverContent>
|
|
</Popover>
|
|
</div>
|
|
</slot>
|
|
</FormControl>
|
|
|
|
<FormDescription v-if="config?.description">
|
|
{{ config.description }}
|
|
</FormDescription>
|
|
<FormMessage />
|
|
</FormItem>
|
|
</FormField>
|
|
</template>
|