mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-29 11:12:23 +08:00
Merge pull request #6825 from JKillian/react-day-picker
Initial commit for react-day-picker typings
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/// <reference path="react-day-picker.d.ts" />
|
||||
/// <reference path="../react/react-global.d.ts" />
|
||||
|
||||
import DayPicker2 from 'react-day-picker';
|
||||
|
||||
function isSunday(day: Date) {
|
||||
return day.getDay() === 0;
|
||||
}
|
||||
|
||||
// make sure global variable version works
|
||||
function MyComponent2() {
|
||||
return <DayPicker initialMonth={ new Date(2016, 1) } modifiers={{ isSunday }} />
|
||||
}
|
||||
|
||||
// make sure imported version works
|
||||
function MyComponent() {
|
||||
return <DayPicker2 initialMonth={ new Date(2016, 1) } 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 }} />
|
||||
@@ -0,0 +1 @@
|
||||
--target es5 --noImplicitAny --jsx react
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// Type definitions for react-day-picker
|
||||
// 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
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "react-day-picker" {
|
||||
export default ReactDayPicker.DayPicker;
|
||||
}
|
||||
|
||||
declare var DayPicker: typeof ReactDayPicker.DayPicker;
|
||||
|
||||
declare namespace ReactDayPicker {
|
||||
interface LocaleUtils {
|
||||
formatMonthTitle: (month: Date, locale: string) => string;
|
||||
formatWeekdayShort: (weekday: number, locale: string) => string;
|
||||
formatWeekdayLong: (weekday: number, locale: string) => string;
|
||||
getFirstDayOfWeek: (locale: string) => number;
|
||||
}
|
||||
|
||||
interface Modifiers {
|
||||
[name: string]: (date: Date) => boolean;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modifiers?: Modifiers;
|
||||
initialMonth?: Date;
|
||||
numberOfMonths?: number;
|
||||
renderDay?: (date: Date) => number | string | JSX.Element;
|
||||
enableOutsideDays?: boolean;
|
||||
canChangeMonth?: boolean;
|
||||
fromMonth?: Date;
|
||||
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;
|
||||
onMonthChange?: (month: Date) => any;
|
||||
onCaptionClick?: (e: __React.SyntheticEvent, month: Date) => any;
|
||||
className?: string;
|
||||
style?: __React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
}
|
||||
|
||||
export class DayPicker extends __React.Component<Props, {}> {
|
||||
showMonth(month: Date): void;
|
||||
showPreviousMonth(): void;
|
||||
showNextMonth(): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user