mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-25 18:40:34 +00:00
Merge pull request #30795 from christianchown/react-infinite-calendar-full-api
[react-infinite-calendar] Extend typings to include the Enhanced Default Functionality
This commit is contained in:
+35
-8
@@ -6,16 +6,33 @@
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
export type DateType = Date | string | number;
|
||||
|
||||
export enum EVENT_TYPE {
|
||||
START = 1,
|
||||
HOVER,
|
||||
END
|
||||
}
|
||||
|
||||
export interface RangedSelection {
|
||||
eventType: EVENT_TYPE;
|
||||
start: Date;
|
||||
end: Date;
|
||||
}
|
||||
|
||||
export type RangedSelectFunction = (rangedDate: RangedSelection) => void;
|
||||
export type DateSelectFunction = (date: Date) => void;
|
||||
|
||||
export interface ReactInfiniteCalendarProps {
|
||||
selected?: Date | boolean;
|
||||
width?: number | 'auto';
|
||||
selected?: DateType | false | { start: DateType; end: DateType };
|
||||
width?: number | 'auto' | '100%';
|
||||
height?: number | 'auto';
|
||||
min?: Date;
|
||||
max?: Date;
|
||||
minDate?: Date;
|
||||
maxDate?: Date;
|
||||
min?: DateType;
|
||||
max?: DateType;
|
||||
minDate?: DateType;
|
||||
maxDate?: DateType;
|
||||
disabledDays?: Array<0 | 1 | 2 | 3 | 4 | 5 | 6>;
|
||||
disabledDates?: Date[];
|
||||
disabledDates?: DateType[];
|
||||
display?: 'days' | 'years';
|
||||
displayOptions?: {
|
||||
hideYearsOnSelect?: boolean;
|
||||
@@ -55,12 +72,22 @@ export interface ReactInfiniteCalendarProps {
|
||||
weekdayColor?: string;
|
||||
};
|
||||
className?: string;
|
||||
onSelect?: (date: string) => void;
|
||||
onSelect?: DateSelectFunction | RangedSelectFunction;
|
||||
onScroll?: (scrollTop: number) => void;
|
||||
onScrollEnd?: (scrollTop: number) => void;
|
||||
rowHeight?: number;
|
||||
autoFocus?: boolean;
|
||||
tabIndex?: number;
|
||||
Component?: CalendarClass;
|
||||
}
|
||||
|
||||
export class Calendar extends React.Component<ReactInfiniteCalendarProps> {}
|
||||
export type CalendarClass = React.ComponentClass<ReactInfiniteCalendarProps>;
|
||||
|
||||
export function withRange(component: CalendarClass): CalendarClass;
|
||||
export function withDateSelection(component: CalendarClass): CalendarClass;
|
||||
export function withMultipleDates(component: CalendarClass): CalendarClass;
|
||||
export function withKeyboardSupport(component: CalendarClass): CalendarClass;
|
||||
export function defaultMultipleDateInterpolation(component: CalendarClass): CalendarClass;
|
||||
|
||||
export default class ReactInfiniteCalendar extends React.Component<ReactInfiniteCalendarProps> {}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import * as React from 'react';
|
||||
import ReactInfiniteCalendar from 'react-infinite-calendar';
|
||||
import ReactInfiniteCalendar, {
|
||||
Calendar,
|
||||
withRange,
|
||||
withKeyboardSupport,
|
||||
withMultipleDates,
|
||||
withDateSelection
|
||||
} from 'react-infinite-calendar';
|
||||
|
||||
const test: React.SFC = () => (
|
||||
<ReactInfiniteCalendar
|
||||
@@ -59,3 +65,8 @@ const test: React.SFC = () => (
|
||||
tabIndex={1}
|
||||
/>
|
||||
);
|
||||
|
||||
const testWithRange = withRange(Calendar);
|
||||
const testWithDateSelection = withDateSelection(Calendar);
|
||||
const testWithKeyboardSupport = withKeyboardSupport(Calendar);
|
||||
const testWithMultipleDate = withMultipleDates(Calendar);
|
||||
|
||||
Reference in New Issue
Block a user