mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
react-day-picker typing tests passing
This commit is contained in:
@@ -1,37 +1,33 @@
|
||||
import * as React from 'react';
|
||||
import * as DayPicker2 from "react-day-picker";
|
||||
import DayPicker = require('react-day-picker');
|
||||
|
||||
function isSunday(day: Date) {
|
||||
return day.getDay() === 0;
|
||||
}
|
||||
|
||||
// make sure global variable version works
|
||||
function MyComponent2() {
|
||||
return <DayPicker ref="foo" initialMonth={ new Date(2016, 1) } localeUtils={DayPicker.LocaleUtils} modifiers={{ isSunday }} />
|
||||
function MyComponent() {
|
||||
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()});
|
||||
DayPicker.DateUtils.isDayInRange(new Date(), { from: new Date(), to: new Date(2050) });
|
||||
|
||||
// make sure imported version works
|
||||
function MyComponent() {
|
||||
return <DayPicker2 ref="foo" initialMonth={ new Date(2016, 1) } localeUtils={DayPicker2.LocaleUtils} modifiers={{ isSunday }} />
|
||||
interface MyCaptionProps extends DayPicker.CaptionElementProps {
|
||||
}
|
||||
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;
|
||||
|
||||
if (!date || !localeUtils || typeof locale === 'undefined') {
|
||||
return null
|
||||
if (!date || !localeUtils || !onClick || typeof locale === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="DayPicker-Caption" onClick={ onClick }>
|
||||
{ localeUtils.formatMonthTitle(date, locale) }
|
||||
<div className="DayPicker-Caption" onClick={ (e) => onClick(date, e) }>
|
||||
{ localeUtils.formatMonthTitle(date, locale) }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user