feat: migrate DateField and shared date input group
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
DateField,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
Label,
|
||||
Description,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { shallowRef } from "vue";
|
||||
import {
|
||||
today,
|
||||
getLocalTimeZone,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
const value = shallowRef<DateValue | null>(null);
|
||||
const todayDate = today(getLocalTimeZone());
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<DateField v-model="value" class="w-[256px]" name="date">
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
</DateFieldGroup>
|
||||
<Description>
|
||||
当前值:{{ value ? value.toString() : "(空)" }}
|
||||
</Description>
|
||||
</DateField>
|
||||
<div class="flex gap-2">
|
||||
<Button variant="tertiary" @click="value = todayDate">设为今天</Button>
|
||||
<Button variant="tertiary" @click="value = null">清空</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user