/** * DateInput / DateTimeInput * * Native date pickers display in the OS/browser locale (MM/DD/YYYY on en-US). * These wrappers overlay the native input with a visible DD/MM/YYYY display * while keeping the full native picker UX (click, keyboard, mobile wheel). * * Props mirror a plain : value (YYYY-MM-DD or YYYY-MM-DDTHH:MM), * onChange (receives the same synthetic event), className. */ import { useRef } from 'react' function formatDateGR(value) { // value is "YYYY-MM-DD" if (!value) return '' const [y, m, d] = value.split('-') if (!y || !m || !d) return value return `${d}/${m}/${y}` } function formatDateTimeGR(value) { // value is "YYYY-MM-DDTHH:MM" if (!value) return '' const [datePart, timePart] = value.split('T') if (!datePart) return value const [y, m, d] = datePart.split('-') if (!y || !m || !d) return value return `${d}/${m}/${y}${timePart ? ' ' + timePart : ''}` } export function DateInput({ value, onChange, className = '', ...rest }) { const ref = useRef(null) return (
ref.current?.showPicker?.()} > {/* Visible display */}
{value ? formatDateGR(value) : ΗΗ/ΜΜ/ΕΕΕΕ}
{/* Native input — invisible but functional (provides the picker) */}
) } export function DateTimeInput({ value, onChange, className = '', ...rest }) { const ref = useRef(null) return (
ref.current?.showPicker?.()} >
{value ? formatDateTimeGR(value) : ΗΗ/ΜΜ/ΕΕΕΕ ΩΩ:ΛΛ}
) }