hypeserver / react-date-range

A React component for choosing dates and date ranges.
MIT License
2.57k stars 658 forks source link

Locale prop doesn't exist on Calendar #503

Open eschumacher-99 opened 2 years ago

eschumacher-99 commented 2 years ago

Subject of the issue

The locale prop doesn't exist on the Calendar using typescript. There's only the lang-prop with about 5 different languages but the documentation says otherwise.

[BUG] Bug Reproduce Steps

import * as dateFnsLocales from "date-fns/locale";
export default function () {

return 
<Calendar locale={dateFnsLocales["de"]}/>
}

[BUG] Expected behaviour

Calendar should use locale-prop like DateRangePicker instead of lang-prop when using typescript.

Environment

Using Typescript Package Version: 1.3.0 Types Version: 1.1.5

kamyar commented 2 years ago

Are you sure, it seems right to me: https://github.com/hypeserver/react-date-range/blob/master/src/components/Calendar/index.js#L35-L37

eschumacher-99 commented 2 years ago

Are you sure, it seems right to me: https://github.com/hypeserver/react-date-range/blob/master/src/components/Calendar/index.js#L35-L37

Yes, I think it's a problem with @types/react-date-range missing the locale in the Calendar Props interface as I am using typescript:

`export interface CommonCalendarProps {
/ default: DD/MM/YYY */
format?: string;
firstDayOfWeek?: number;
theme?: CalendarTheme;
/* default: none /
onInit?: (range: Range) => void;
/
default: none */
onChange?: (range: Range) => void;
/ default: none */
minDate?: DateInputType;
/* default: none /
maxDate?: DateInputType;
/

eschumacher-99 commented 2 years ago

I've opened a pull request on DefinitelyTyped that should fix this issue.

kamyar commented 2 years ago

DefinitelyTyped is unfortunately very outdated. I have started a Pr to hopefully add full TS support: https://github.com/hypeserver/react-date-range/pull/499 If you have time would appreciate if you could take a look and even better try it?