feat: migrate DateField and shared date input group
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
DateField,
|
||||
DateFieldGroup,
|
||||
DateFieldInput,
|
||||
DateFieldSegment,
|
||||
Label,
|
||||
Description,
|
||||
FieldError,
|
||||
} from "@heroui-vue/components";
|
||||
import { shallowRef, computed } from "vue";
|
||||
import {
|
||||
today,
|
||||
getLocalTimeZone,
|
||||
type DateValue,
|
||||
} from "@internationalized/date";
|
||||
const value = shallowRef<DateValue | null>(null);
|
||||
const todayDate = today(getLocalTimeZone());
|
||||
const isInvalid = computed(
|
||||
() => value.value !== null && value.value.compare(todayDate) < 0,
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<DateField
|
||||
v-model="value"
|
||||
is-required
|
||||
:is-invalid="isInvalid"
|
||||
:min-value="todayDate"
|
||||
class="w-[256px]"
|
||||
name="date"
|
||||
>
|
||||
<Label>日期</Label>
|
||||
<DateFieldGroup>
|
||||
<DateFieldInput v-slot="{ segment }">
|
||||
<DateFieldSegment :segment="segment" />
|
||||
</DateFieldInput>
|
||||
</DateFieldGroup>
|
||||
<FieldError v-if="isInvalid">日期须为今天或将来</FieldError>
|
||||
<Description v-else>输入日期 from today onwards</Description>
|
||||
</DateField>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user