react-date-range icon indicating copy to clipboard operation
react-date-range copied to clipboard

Locale prop doesn't exist on Calendar

Open eschumacher-99 opened this issue 3 years ago • 4 comments

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

eschumacher-99 avatar Jul 13 '21 14:07 eschumacher-99

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

kamyar avatar Jul 13 '21 14:07 kamyar

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; /** * Calendar languages. * ('cn' - Chinese, 'jp' - Japanese, * 'fr' - French, 'it' - Italian, * 'de' - German, 'ko' - Korean, * 'es' - Spanish, 'ru' - Russian, * 'tr' - Turkish) default: none */ lang?: LanguageType; }

eschumacher-99 avatar Jul 14 '21 05:07 eschumacher-99

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

eschumacher-99 avatar Jul 14 '21 11:07 eschumacher-99

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?

kamyar avatar Jul 14 '21 13:07 kamyar