Files
heroui-vue/packages/vue/tests/fixtures/AcceptedDateFieldFoundation.vue
T
2026-10-23 23:56:18 +08:00

49 lines
1.6 KiB
Vue

<script setup lang="ts">
import { computed, ref } from "vue";
import type { DateValue } from "@internationalized/date";
import EmptyDateBridge from "../../src/components/date/EmptyDateBridge";
import DateFieldFoundation from "./DateFieldFoundation.vue";
import { useAcceptedDateValue } from "../../src/components/date/model";
import { serializeDateValue } from "../../src/components/date/value";
import { useChoiceForm } from "../../src/components/choice/shared";
const props = defineProps<{
modelValue?: DateValue | null;
defaultValue?: DateValue;
defaultPlaceholder?: DateValue;
name?: string;
disabled?: boolean;
readonly?: boolean;
}>();
const emit = defineEmits<{ "update:modelValue": [value: DateValue | null] }>();
const accepted = useAcceptedDateValue({
value: () => props.modelValue,
defaultValue: () => props.defaultValue,
onChange: (value) => emit("update:modelValue", value),
disabled: () => !!props.disabled,
readOnly: () => !!props.readonly,
});
const native = ref<HTMLInputElement>();
const serialized = computed(() => serializeDateValue(accepted.value.value));
useChoiceForm(native, accepted.reset, () => {});
</script>
<template>
<div>
<DateFieldFoundation
:model-value="accepted.wire.value"
:default-placeholder="defaultPlaceholder"
:disabled="disabled"
:readonly="readonly"
@update:model-value="accepted.request"
>
<EmptyDateBridge :revision="accepted.emptyRevision.value" />
</DateFieldFoundation>
<input
ref="native"
type="hidden"
:name="name"
:value="serialized"
:disabled="disabled"
/>
</div>
</template>