Initial typings for react-infinite-calendar

This commit is contained in:
Christian Chown
2018-03-20 23:18:23 +00:00
parent 9f4c751261
commit 55421afb90
4 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
// Type definitions for react-infinite-calendar 2.3
// Project: https://github.com/clauderic/react-infinite-calendar
// Definitions by: Christian Chown <https://github.com/christianchown>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from 'react';
export interface ReactInfiniteCalendarProps {
selected?: Date | boolean;
width?: number;
height?: number;
min?: Date;
max?: Date;
minDate?: Date;
maxDate?: Date;
disabledDays?: Array<0 | 1 | 2 | 3 | 4 | 5 | 6>;
disabledDates?: Date[];
display?: 'days' | 'years';
displayOptions?: {
hideYearsOnSelect?: boolean;
layout?: 'portrait' | 'landscape';
overscanMonthCount?: number;
shouldHeaderAnimate?: boolean;
showHeader?: boolean;
showMonthsForYears?: boolean;
showOverlay?: boolean;
showTodayHelper?: boolean;
showWeekdays?: boolean;
todayHelperRowOffset?: number;
};
locale?: {
blank?: string;
headerFormat?: string;
todayLabel?: {
long: string;
};
weekdays?: string[];
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
};
theme?: {
accentColor?: string;
floatingNav: {
background?: string;
chevron?: string;
color?: string;
};
headerColor?: string;
selectionColor?: string;
textColor?: {
active?: string;
default?: string;
};
todayColor?: string;
weekdayColor?: string;
};
className?: string;
onSelect?: () => void;
onScroll?: (scrollTop: number) => void;
onScrollEnd?: (scrollTop: number) => void;
rowHeight?: number;
autoFocus?: boolean;
tabIndex?: number;
}
export default class ReactInfiniteCalendar extends React.Component<ReactInfiniteCalendarProps> {}

View File

@@ -0,0 +1,61 @@
import * as React from 'react';
import ReactInfiniteCalendar from 'react-infinite-calendar';
const test: React.SFC = () => (
<ReactInfiniteCalendar
selected={new Date()}
width={500}
height={500}
min={new Date()}
max={new Date()}
minDate={new Date()}
maxDate={new Date()}
disabledDays={[0, 6]}
disabledDates={[new Date()]}
display="years"
displayOptions={{
hideYearsOnSelect: true,
layout: 'portrait',
overscanMonthCount: 2,
shouldHeaderAnimate: true,
showHeader: true,
showMonthsForYears: true,
showOverlay: true,
showTodayHelper: true,
showWeekdays: true,
todayHelperRowOffset: 4,
}}
locale={{
blank: 'Select a date...',
headerFormat: 'ddd, MMM Do',
todayLabel: {
long: 'Today',
},
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
weekStartsOn: 0,
}}
theme={{
accentColor: '#448AFF',
floatingNav: {
background: 'rgba(56, 87, 138, 0.94)',
chevron: '#FFA726',
color: '#FFF',
},
headerColor: '#448AFF',
selectionColor: '#559FFF',
textColor: {
active: '#FFF',
default: '#333',
},
todayColor: '#FFA726',
weekdayColor: '#559FFF',
}}
className="className"
onSelect={() => {}}
onScroll={(scrollTop: number) => { console.log(scrollTop); }}
onScrollEnd={(scrollTop: number) => { console.log(scrollTop); }}
rowHeight={40}
autoFocus={false}
tabIndex={1}
/>
);

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-infinite-calendar-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }