Update definitions to support react-big-calendar Event object properties for OnSelectEvent (Version 0.15.0) (#19832)

* Update definitions to support react-big-calendar Event object properties

* Update version number
This commit is contained in:
Gavin Draper
2017-09-25 16:12:15 -07:00
committed by Mohamed Hegazy
parent 8d952056e7
commit a88944d8e3
2 changed files with 41 additions and 72 deletions
+10 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for react-big-calendar 0.14.0
// Type definitions for react-big-calendar 0.15.0
// Project: https://github.com/intljusticemission/react-big-calendar
// Definitions by: Piotr Witek <http://piotrwitek.github.io>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -9,6 +9,14 @@ declare module 'react-big-calendar' {
type stringOrDate = string | Date;
interface CalendarEvent {
title: string;
allDay: boolean;
start: Date;
end: Date;
desc: string;
}
interface BigCalendarProps extends React.Props<BigCalendar> {
date?: stringOrDate;
view?: string;
@@ -16,7 +24,7 @@ declare module 'react-big-calendar' {
onNavigate?: Function;
onView?: Function;
onSelectSlot?: (slotInfo: { start: stringOrDate, end: stringOrDate, slots: Date[] | string[] }) => void;
onSelectEvent?: (event: Object) => void;
onSelectEvent?: (event: CalendarEvent) => void;
onSelecting?: (slotInfo: { start: stringOrDate, end: stringOrDate }) => boolean;
views?: Object;
toolbar?: boolean;
@@ -12,6 +12,22 @@ BigCalendar.momentLocalizer(moment);
// Testing examples from demos page
// http://intljusticemission.github.io/react-big-calendar/examples/index.html
class CalendarEvent {
public title: string;
public allDay: boolean;
public start: Date;
public end: Date;
public desc: string;
public constructor(_title: string, _start: Date, _end: Date, _allDay?: boolean, _desc?: string) {
this.title = _title;
this.allDay = _allDay || false;
this.start = _start;
this.end = _end;
this.desc = _desc || '';
}
}
// Basic Example Test
const BasicExample = React.createClass({
render() {
@@ -81,75 +97,20 @@ const fullApiExampleHtml = ReactDOMServer.renderToString(<FullAPIExample />);
console.log('Test Results -> FullAPIExample', fullApiExampleHtml);
// Test fixtures
function getEvents(): Object[] {
return [
{
'title': 'All Day Event',
'allDay': true,
'start': new Date(2015, 3, 0),
'end': new Date(2015, 3, 0)
},
{
'title': 'Long Event',
'start': new Date(2015, 3, 7),
'end': new Date(2015, 3, 10)
},
{
'title': 'DTS STARTS',
'start': new Date(2016, 2, 13, 0, 0, 0),
'end': new Date(2016, 2, 20, 0, 0, 0)
},
{
'title': 'DTS ENDS',
'start': new Date(2016, 10, 6, 0, 0, 0),
'end': new Date(2016, 10, 13, 0, 0, 0)
},
{
'title': 'Some Event',
'start': new Date(2015, 3, 9, 0, 0, 0),
'end': new Date(2015, 3, 9, 0, 0, 0)
},
{
'title': 'Conference',
'start': new Date(2015, 3, 11),
'end': new Date(2015, 3, 13),
desc: 'Big conference for important people'
},
{
'title': 'Meeting',
'start': new Date(2015, 3, 12, 10, 30, 0, 0),
'end': new Date(2015, 3, 12, 12, 30, 0, 0),
desc: 'Pre-meeting meeting, to prepare for the meeting'
},
{
'title': 'Lunch',
'start': new Date(2015, 3, 12, 12, 0, 0, 0),
'end': new Date(2015, 3, 12, 13, 0, 0, 0),
desc: 'Power lunch'
},
{
'title': 'Meeting',
'start': new Date(2015, 3, 12, 14, 0, 0, 0),
'end': new Date(2015, 3, 12, 15, 0, 0, 0)
},
{
'title': 'Happy Hour',
'start': new Date(2015, 3, 12, 17, 0, 0, 0),
'end': new Date(2015, 3, 12, 17, 30, 0, 0),
desc: 'Most important meal of the day'
},
{
'title': 'Dinner',
'start': new Date(2015, 3, 12, 20, 0, 0, 0),
'end': new Date(2015, 3, 12, 21, 0, 0, 0)
},
{
'title': 'Birthday Party',
'start': new Date(2015, 3, 13, 7, 0, 0),
'end': new Date(2015, 3, 13, 10, 30, 0)
}
function getEvents(): CalendarEvent[] {
var events: CalendarEvent[] = [
new CalendarEvent('All Day Event', new Date(2015, 3, 0), new Date(2015, 3, 0), true),
new CalendarEvent('Long Event', new Date(2015, 3, 7), new Date(2015, 3, 10)),
new CalendarEvent('DTS STARTS', new Date(2016, 2, 13, 0, 0, 0), new Date(2016, 2, 20, 0, 0, 0)),
new CalendarEvent('DTS ENDS', new Date(2016, 10, 6, 0, 0, 0), new Date(2016, 10, 13, 0, 0, 0)),
new CalendarEvent('Some Event', new Date(2015, 3, 9, 0, 0, 0), new Date(2015, 3, 9, 0, 0, 0)),
new CalendarEvent('Conference', new Date(2015, 3, 11), new Date(2015, 3, 13), undefined, 'Big conference for important people'),
new CalendarEvent('Meeting', new Date(2015, 3, 12, 10, 30, 0, 0),new Date(2015, 3, 12, 12, 30, 0, 0), undefined, 'Pre-meeting meeting, to prepare for the meeting'),
new CalendarEvent('Lunch', new Date(2015, 3, 12, 12, 0, 0, 0),new Date(2015, 3, 12, 13, 0, 0, 0), undefined, 'Power lunch'),
new CalendarEvent('Meeting', new Date(2015, 3, 12, 14, 0, 0, 0),new Date(2015, 3, 12, 15, 0, 0, 0)),
new CalendarEvent('Happy Hour', new Date(2015, 3, 12, 17, 0, 0, 0),new Date(2015, 3, 12, 17, 30, 0, 0),undefined,'Most important meal of the day'),
new CalendarEvent('Dinner', new Date(2015, 3, 12, 20, 0, 0, 0),new Date(2015, 3, 12, 21, 0, 0, 0)),
new CalendarEvent('Birthday Party', new Date(2015, 3, 13, 7, 0, 0),new Date(2015, 3, 13, 10, 30, 0)),
];
return events;
};