Files
KArtSell.Aegis/frontend/src/shared/ui/components/KsDateField.vue
T
kjh2064 d79edae546
deploy / deploy (push) Failing after 51s
deploy / notify (push) Successful in 1s
V13-FE-005: restore direct UI components and harden grid provider
2026-08-13 02:39:48 +09:00

15 lines
1.3 KiB
Vue

<script setup lang="ts">
import DatePicker from 'primevue/datepicker'
import { computed } from 'vue'
import FieldShell from './FieldShell.vue'
const props = defineProps<{ modelValue: string | Date | null; label: string; inputId?: string; disabled?: boolean; required?: boolean; error?: string; help?: string; min?: Date; max?: Date }>()
const emit = defineEmits<{ 'update:modelValue': [value: string | Date | null]; blur: [event: FocusEvent] }>()
const dateValue = computed(() => typeof props.modelValue === 'string' ? new Date(props.modelValue) : props.modelValue)
function handleDateChange(value: Date | Date[] | (Date | null)[] | null | undefined): void {
if (value instanceof Date) emit('update:modelValue', value)
else if (value == null) emit('update:modelValue', null)
else emit('update:modelValue', value[0] ?? null)
}
</script>
<template><FieldShell :label="label" :input-id="inputId" :required="required" :error="error" :help="help" v-slot="field"><DatePicker :input-id="field.inputId" :model-value="dateValue" :disabled="disabled" :invalid="field.invalid" :min-date="min" :max-date="max" date-format="yy-mm-dd" show-icon :aria-describedby="field.describedBy" :aria-required="field.required || undefined" @update:model-value="handleDateChange" @blur="emit('blur', $event as unknown as FocusEvent)" /></FieldShell></template>