Update typings to reflect added fields in version 1.1.4

This commit is contained in:
Jason Killian
2015-11-19 15:18:48 -05:00
parent 16134c168d
commit afbc2247fb
2 changed files with 24 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
/// <reference path="react-day-picker.d.ts" />
/// <reference path="../react/react-global.d.ts" />
import DayPicker2 from 'react-day-picker';
import * as DayPicker2 from "react-day-picker";
function isSunday(day: Date) {
return day.getDay() === 0;
@@ -9,19 +9,14 @@ function isSunday(day: Date) {
// make sure global variable version works
function MyComponent2() {
return <DayPicker initialMonth={ new Date(2016, 1) } modifiers={{ isSunday }} />
return <DayPicker ref="foo" initialMonth={ new Date(2016, 1) } localeUtils={DayPicker.LocaleUtils} modifiers={{ isSunday }} />
}
DayPicker.DateUtils.clone(new Date());
DayPicker.DateUtils.isDayInRange(new Date(), {from: new Date()});
// make sure imported version works
function MyComponent() {
return <DayPicker2 initialMonth={ new Date(2016, 1) } modifiers={{ isSunday }} />
return <DayPicker2 ref="foo" initialMonth={ new Date(2016, 1) } localeUtils={DayPicker2.LocaleUtils} modifiers={{ isSunday }} />
}
const localeUtils = {
formatMonthTitle: (d: Date) => 'month_title',
formatWeekdayShort: (i: number) => 'weekday_short',
formatWeekdayLong: (i: number) => 'weekday_long',
getFirstDayOfWeek: () => 0
};
let element = <DayPicker2 initialMonth= { new Date(2016, 1) } localeUtils={localeUtils} modifiers= {{ isSunday }} />
DayPicker2.DateUtils.clone(new Date());
DayPicker2.DateUtils.isDayInRange(new Date(), { from: new Date() });

View File

@@ -1,4 +1,4 @@
// Type definitions for react-day-picker
// Type definitions for react-day-picker v1.1.4
// Project: https://github.com/gpbl/react-day-picker
// Definitions by: Giampaolo Bellavite <https://github.com/gpbl>, Jason Killian <https://github.com/jkillian>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -6,7 +6,8 @@
/// <reference path="../react/react.d.ts" />
declare module "react-day-picker" {
export default ReactDayPicker.DayPicker;
import DayPicker = ReactDayPicker.DayPicker;
export = DayPicker;
}
declare var DayPicker: typeof ReactDayPicker.DayPicker;
@@ -23,7 +24,7 @@ declare namespace ReactDayPicker {
[name: string]: (date: Date) => boolean;
}
interface Props {
interface Props extends __React.Props<DayPicker>{
modifiers?: Modifiers;
initialMonth?: Date;
numberOfMonths?: number;
@@ -45,9 +46,21 @@ declare namespace ReactDayPicker {
tabIndex?: number;
}
export class DayPicker extends __React.Component<Props, {}> {
class DayPicker extends __React.Component<Props, {}> {
showMonth(month: Date): void;
showPreviousMonth(): void;
showNextMonth(): void;
}
namespace DayPicker {
var LocaleUtils: LocaleUtils;
namespace DateUtils {
function clone(d: Date): Date;
function isSameDay(d1?: Date, d2?: Date): boolean;
function isPastDay(d: Date): boolean;
function isDayBetween(day: Date, startDate: Date, endDate: Date): boolean;
function addDayToRange(day: Date, range: { from?: Date, to?: Date }): { from?: Date, to?: Date };
function isDayInRange(day: Date, range: { from?: Date, to?: Date }): boolean;
}
}
}