From d71d71fee8d13d71eea3d6b44afbd36abcc38210 Mon Sep 17 00:00:00 2001 From: Jason Killian Date: Fri, 4 Dec 2015 11:23:26 -0500 Subject: [PATCH] Update react-day-picker typings for version 1.2.0 --- react-day-picker/react-day-picker-tests.tsx | 14 ++++++++++ react-day-picker/react-day-picker.d.ts | 30 ++++++++++++++------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/react-day-picker/react-day-picker-tests.tsx b/react-day-picker/react-day-picker-tests.tsx index 984834dfd6..3afdf07343 100644 --- a/react-day-picker/react-day-picker-tests.tsx +++ b/react-day-picker/react-day-picker-tests.tsx @@ -20,3 +20,17 @@ function MyComponent() { } DayPicker2.DateUtils.clone(new Date()); DayPicker2.DateUtils.isDayInRange(new Date(), { from: new Date() }); + +// test interface for captionElement prop +interface MyCaptionProps extends ReactDayPicker.CaptionElementProps { } +class Caption extends React.Component { + render() { + const { date, locale, localeUtils, onClick } = this.props; + return ( +
+ { localeUtils.formatMonthTitle(date, locale) } +
+ ); + } +} +}/> diff --git a/react-day-picker/react-day-picker.d.ts b/react-day-picker/react-day-picker.d.ts index 94214ec455..921add78c9 100644 --- a/react-day-picker/react-day-picker.d.ts +++ b/react-day-picker/react-day-picker.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-day-picker v1.1.4 +// Type definitions for react-day-picker v1.2.0 // Project: https://github.com/gpbl/react-day-picker // Definitions by: Giampaolo Bellavite , Jason Killian // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -13,18 +13,28 @@ declare module "react-day-picker" { declare var DayPicker: typeof ReactDayPicker.DayPicker; declare namespace ReactDayPicker { + import React = __React; + interface LocaleUtils { formatMonthTitle: (month: Date, locale: string) => string; formatWeekdayShort: (weekday: number, locale: string) => string; formatWeekdayLong: (weekday: number, locale: string) => string; getFirstDayOfWeek: (locale: string) => number; + getMonths: (locale: string) => string[]; } interface Modifiers { [name: string]: (date: Date) => boolean; } - interface Props extends __React.Props{ + interface CaptionElementProps extends React.Props { + date?: Date; + localeUtils?: LocaleUtils; + locale?: string; + onClick?: React.MouseEventHandler; + } + + interface Props extends React.Props{ modifiers?: Modifiers; initialMonth?: Date; numberOfMonths?: number; @@ -35,18 +45,19 @@ declare namespace ReactDayPicker { toMonth?: Date; localeUtils?: LocaleUtils; locale?: string; - onDayClick?: (e: __React.SyntheticEvent, day: Date, modifiers: string[]) => any; - onDayTouchTap?: (e: __React.SyntheticEvent, day: Date, modifiers: string[]) => any; - onDayMouseEnter?: (e: __React.SyntheticEvent, day: Date, modifiers: string[]) => any; - onDayMouseLeave?: (e: __React.SyntheticEvent, day: Date, modifiers: string[]) => any; + captionElement?: React.ReactElement; + onDayClick?: (e: React.SyntheticEvent, day: Date, modifiers: string[]) => any; + onDayTouchTap?: (e: React.SyntheticEvent, day: Date, modifiers: string[]) => any; + onDayMouseEnter?: (e: React.SyntheticEvent, day: Date, modifiers: string[]) => any; + onDayMouseLeave?: (e: React.SyntheticEvent, day: Date, modifiers: string[]) => any; onMonthChange?: (month: Date) => any; - onCaptionClick?: (e: __React.SyntheticEvent, month: Date) => any; + onCaptionClick?: (e: React.SyntheticEvent, month: Date) => any; className?: string; - style?: __React.CSSProperties; + style?: React.CSSProperties; tabIndex?: number; } - class DayPicker extends __React.Component { + class DayPicker extends React.Component { showMonth(month: Date): void; showPreviousMonth(): void; showNextMonth(): void; @@ -55,6 +66,7 @@ declare namespace ReactDayPicker { namespace DayPicker { var LocaleUtils: LocaleUtils; namespace DateUtils { + function addMonths(d: Date, n: number): Date; function clone(d: Date): Date; function isSameDay(d1?: Date, d2?: Date): boolean; function isPastDay(d: Date): boolean;