feat: migrate public TimeField with shared date input parts

This commit is contained in:
maoyingjie
2026-10-26 17:56:41 +08:00
parent d74ad1b711
commit 97263d82e1
45 changed files with 2415 additions and 61 deletions
+38
View File
@@ -0,0 +1,38 @@
<script setup lang="ts">
import {
TimeField,
TimeFieldGroup,
TimeFieldInput,
TimeFieldSegment,
Label,
Description,
Button,
} from "@heroui-vue/components";
import { shallowRef } from "vue";
import { Time, getLocalTimeZone, now } from "@internationalized/date";
import type { TimeValue } from "@heroui-vue/components";
const value = shallowRef<TimeValue | null>(null);
function setCurrent() {
const current = now(getLocalTimeZone());
value.value = new Time(current.hour, current.minute, current.second);
}
</script>
<template>
<div class="flex flex-col gap-4">
<TimeField class="w-[256px]" name="time" v-model="value">
<Label>时间</Label>
<TimeFieldGroup>
<TimeFieldInput v-slot="{ segment }">
<TimeFieldSegment :segment="segment" />
</TimeFieldInput>
</TimeFieldGroup>
<Description>
当前值:{{ value ? value.toString() : "(空)" }}
</Description>
</TimeField>
<div class="flex gap-2">
<Button variant="tertiary" @click="setCurrent">设为当前时间</Button>
<Button variant="tertiary" @click="value = null">清空</Button>
</div>
</div>
</template>