gpbl / react-day-picker

DayPicker is a customizable date picker component for React. Add date pickers, calendars, and date inputs to your web applications.
https://daypicker.dev
MIT License
6.09k stars 732 forks source link

Labels/Formatters: dateLib and options should not be undefined #2556

Open gpbl opened 3 weeks ago

gpbl commented 3 weeks ago

Inspired by https://github.com/gpbl/react-day-picker/discussions/2541, we should make label* functions type to allow the use of dateLib:

labels={{
    labelDayButton: (date, { today, selected }, options, dateLib) => {
      let label = dateLib.format(date, "PPPP"); // this is not possible as `dateLib` is marked as `undefined` in the types
      if (today) label = `Oggi, ${label}`;
      if (selected) label = `${label}, selezionato`;
      return label;
    }
}