feat: migrate DateField and shared date input group
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user