mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-13 08:57:26 +08:00
Update react-day-picker typings for version 1.2.0
This commit is contained in:
@@ -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<MyCaptionProps, {}> {
|
||||
render() {
|
||||
const { date, locale, localeUtils, onClick } = this.props;
|
||||
return (
|
||||
<div className="DayPicker-Caption" onClick={ onClick }>
|
||||
{ localeUtils.formatMonthTitle(date, locale) }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
<DayPicker captionElement={<Caption/>}/>
|
||||
|
||||
30
react-day-picker/react-day-picker.d.ts
vendored
30
react-day-picker/react-day-picker.d.ts
vendored
@@ -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 <https://github.com/gpbl>, Jason Killian <https://github.com/jkillian>
|
||||
// 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<DayPicker>{
|
||||
interface CaptionElementProps extends React.Props<any> {
|
||||
date?: Date;
|
||||
localeUtils?: LocaleUtils;
|
||||
locale?: string;
|
||||
onClick?: React.MouseEventHandler;
|
||||
}
|
||||
|
||||
interface Props extends React.Props<DayPicker>{
|
||||
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<CaptionElementProps>;
|
||||
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<Props, {}> {
|
||||
class DayPicker extends React.Component<Props, {}> {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user