From 55421afb90b7eacef9e8fc79f54a1d279cc54d27 Mon Sep 17 00:00:00 2001 From: Christian Chown Date: Tue, 20 Mar 2018 23:18:23 +0000 Subject: [PATCH 1/3] Initial typings for react-infinite-calendar --- types/react-infinite-calendar/index.d.ts | 66 +++++++++++++++++++ .../react-infinite-calendar-tests.tsx | 61 +++++++++++++++++ types/react-infinite-calendar/tsconfig.json | 25 +++++++ types/react-infinite-calendar/tslint.json | 1 + 4 files changed, 153 insertions(+) create mode 100644 types/react-infinite-calendar/index.d.ts create mode 100644 types/react-infinite-calendar/react-infinite-calendar-tests.tsx create mode 100644 types/react-infinite-calendar/tsconfig.json create mode 100644 types/react-infinite-calendar/tslint.json diff --git a/types/react-infinite-calendar/index.d.ts b/types/react-infinite-calendar/index.d.ts new file mode 100644 index 0000000000..8a1adbff14 --- /dev/null +++ b/types/react-infinite-calendar/index.d.ts @@ -0,0 +1,66 @@ +// Type definitions for react-infinite-calendar 2.3 +// Project: https://github.com/clauderic/react-infinite-calendar +// Definitions by: Christian Chown +// 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 {} diff --git a/types/react-infinite-calendar/react-infinite-calendar-tests.tsx b/types/react-infinite-calendar/react-infinite-calendar-tests.tsx new file mode 100644 index 0000000000..ff1918d539 --- /dev/null +++ b/types/react-infinite-calendar/react-infinite-calendar-tests.tsx @@ -0,0 +1,61 @@ +import * as React from 'react'; +import ReactInfiniteCalendar from 'react-infinite-calendar'; + +const test: React.SFC = () => ( + {}} + onScroll={(scrollTop: number) => { console.log(scrollTop); }} + onScrollEnd={(scrollTop: number) => { console.log(scrollTop); }} + rowHeight={40} + autoFocus={false} + tabIndex={1} + /> +); diff --git a/types/react-infinite-calendar/tsconfig.json b/types/react-infinite-calendar/tsconfig.json new file mode 100644 index 0000000000..bf57e148ca --- /dev/null +++ b/types/react-infinite-calendar/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/types/react-infinite-calendar/tslint.json b/types/react-infinite-calendar/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/react-infinite-calendar/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From 1ad2b822af67c1d88a80f35e895260dcbe738eb9 Mon Sep 17 00:00:00 2001 From: Christian Chown Date: Wed, 21 Mar 2018 00:19:09 +0000 Subject: [PATCH 2/3] Allow auto width/height, floatingNav is optional, onSelect takes a string --- types/react-infinite-calendar/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-infinite-calendar/index.d.ts b/types/react-infinite-calendar/index.d.ts index 8a1adbff14..0264c70d91 100644 --- a/types/react-infinite-calendar/index.d.ts +++ b/types/react-infinite-calendar/index.d.ts @@ -8,8 +8,8 @@ import * as React from 'react'; export interface ReactInfiniteCalendarProps { selected?: Date | boolean; - width?: number; - height?: number; + width?: number | 'auto'; + height?: number | 'auto'; min?: Date; max?: Date; minDate?: Date; @@ -40,7 +40,7 @@ export interface ReactInfiniteCalendarProps { }; theme?: { accentColor?: string; - floatingNav: { + floatingNav?: { background?: string; chevron?: string; color?: string; @@ -55,7 +55,7 @@ export interface ReactInfiniteCalendarProps { weekdayColor?: string; }; className?: string; - onSelect?: () => void; + onSelect?: (date: string) => void; onScroll?: (scrollTop: number) => void; onScrollEnd?: (scrollTop: number) => void; rowHeight?: number; From ea9dfd9bddd1ed8102d9dfc86eeaef46cdad7d52 Mon Sep 17 00:00:00 2001 From: Christian Chown Date: Wed, 21 Mar 2018 12:27:59 +0000 Subject: [PATCH 3/3] strictNullChecks = true --- types/react-infinite-calendar/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-infinite-calendar/tsconfig.json b/types/react-infinite-calendar/tsconfig.json index bf57e148ca..dab62fb64c 100644 --- a/types/react-infinite-calendar/tsconfig.json +++ b/types/react-infinite-calendar/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "jsx": "react",