File size: 801 Bytes
fe12e06 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import React from "react";
// Shim simples baseado em <input type="date">.
// Props compatíveis: mode, selected (Date), onSelect(date), disabled(date)=>bool, locale (ignorado).
export function Calendar({ selected, onSelect, disabled }) {
const toInput = (d) => (d ? new Date(d).toISOString().slice(0, 10) : "");
const fromInput = (s) => (s ? new Date(s + "T00:00:00") : null);
const today = new Date();
const min = disabled ? today.toISOString().slice(0, 10) : undefined;
return (
<div className="p-3">
<input
type="date"
className="rounded-xl border px-3 py-2 outline-none focus:ring-2 focus:ring-black/20"
value={toInput(selected)}
min={min}
onChange={(e) => onSelect && onSelect(fromInput(e.target.value))}
/>
</div>
);
}
|