From 7d55759e192e42ff871ee148a95b8707fd79c3a6 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Wed, 8 Mar 2017 00:35:03 -0500 Subject: [PATCH] react-day-picker merge types into namespace for export = syntax --- react-day-picker/index.d.ts | 270 ++++++++++++++++++------------------ 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index e50ff542b0..3f166a0c84 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -6,139 +6,143 @@ import * as React from 'react'; -interface LocaleUtils { - formatDay(day: Date, locale: string): string; - formatMonthTitle(month: Date, locale: string): string; - formatWeekdayLong(weekday: number, locale: string): string; - formatWeekdayShort(weekday: number, locale: string): string; - getFirstDayOfWeek(locale: string): number; - getMonths(locale: string): [string, string, string, string, string, string, string, string, string, string, string, string]; +declare namespace DayPicker { + export interface LocaleUtils { + formatDay(day: Date, locale: string): string; + formatMonthTitle(month: Date, locale: string): string; + formatWeekdayLong(weekday: number, locale: string): string; + formatWeekdayShort(weekday: number, locale: string): string; + getFirstDayOfWeek(locale: string): number; + getMonths(locale: string): [string, string, string, string, string, string, string, string, string, string, string, string]; + } + + export interface DateUtils { + addMonths(d: Date, n: number): Date; + clone(d: Date): Date; + isSameDay(d1: Date, d2: Date): Date; + isPastDay(d: Date): boolean; + isFutureDay(d: Date): boolean; + isDayBetween(day: Date, begin: Date, end: Date): boolean; + addDayToRange(day: Date, range: RangeModifier): RangeModifier; + isDayInRange(day: Date, range: RangeModifier): boolean; + } + + export interface CaptionElementProps { + date?: Date; + localeUtils?: LocaleUtils; + locale?: string; + onClick?(month: Date, e: React.MouseEvent): void; + } + + export interface NavbarElementProps { + className?: string; + previousMonth?: Date; + nextMonth?: Date; + showPreviousButton?: boolean; + showNextButton?: boolean; + onPreviousClick?(): void; + onNextClick?(): void; + dir?: string; + localeUtils?: LocaleUtils; + locale?: string; + } + + export interface WeekdayElementProps { + weekday?: number; + className?: string; + localeUtils?: LocaleUtils; + locale?: string; + } + + export interface ClassNames { + container: string; + interactionDisabled: string; + navBar: string; + navButtonPrev: string; + navButtonNext: string; + + month: string; + caption: string; + weekdays: string; + weekdaysRow: string; + weekday: string; + body: string; + week: string; + day: string; + + today: string; + selected: string; + disabled: string; + outside: string; + } + + export interface RangeModifier { + from: Date; + to: Date; + } + export interface BeforeModifier { + before: Date; + } + export interface AfterModifier { + after: Date; + } + export interface FunctionModifier { + (date: Date): boolean; + } + export type Modifier = RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; + + export interface Modifiers { + today: Modifier | Modifier[]; + outside: Modifier | Modifier[]; + [other: string]: Modifier | Modifier[] | undefined; + } + + export interface Props { + canChangeMonth?: boolean; + captionElement?: React.ReactElement; + className?: string; + classNames?: ClassNames; + containerProps?: React.HTMLAttributes; + disabledDays?: Modifier | Modifier[]; + enableOutsideDays?: boolean; + firstDayOfWeek?: number; + fixedWeeks?: boolean; + fromMonth?: Date; + initialMonth?: Date; + labels?: { previousMonth: string; nextMonth: string; }; + locale?: string; + localeUtils?: LocaleUtils; + modifiers?: Partial; + month?: Date; + months?: [string, string, string, string, string, string, string, string, string, string, string, string]; + navbarElement?: React.ReactElement; + numberOfMonths?: number; + onBlur?(e: React.FocusEvent): void; + onCaptionClick?(month: Date, e: React.MouseEvent): void; + onDayClick?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayKeyDown?(day: Date, modifiers: Modifiers, e: React.KeyboardEvent): void; + onDayMouseEnter?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayMouseLeave?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayTouchEnd?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; + onDayTouchStart?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; + onFocus?(e: React.FocusEvent): void; + onKeyDown?(e: React.KeyboardEvent): void; + onMonthChange?(month: Date): void; + pagedNavigation?: boolean; + renderDay?(date: Date, modifiers: Modifiers): React.ReactNode; + reverseMonths?: boolean; + selectedDays?: Modifier | Modifier[]; + toMonth?: Date; + weekdayElement?: React.ReactElement; + weekdaysLong?: [string, string, string, string, string, string, string]; + weekdaysShort?: [string, string, string, string, string, string, string]; + } + const VERSION: string; + const LocaleUtils: DayPicker.LocaleUtils; + const DateUtils: DayPicker.DateUtils; } -interface DateUtils { - addMonths(d: Date, n: number): Date; - clone(d: Date): Date; - isSameDay(d1: Date, d2: Date): Date; - isPastDay(d: Date): boolean; - isFutureDay(d: Date): boolean; - isDayBetween(day: Date, begin: Date, end: Date): boolean; - addDayToRange(day: Date, range: RangeModifier): RangeModifier; - isDayInRange(day: Date, range: RangeModifier): boolean; -} - -interface CaptionElementProps { - date: Date; - localeUtils: LocaleUtils; - locale: string; - onClick: typeof Props.onCaptionClick; -} - -interface NavbarElementProps { - className: string; - previousMonth: Date; - nextMonth: Date; - showPreviousButton: boolean; - showNextButton: boolean; - onPreviousClick(): void; - onNextClick(): void; - dir: string; - localeUtils: LocaleUtils; - locale: string; -} - -interface WeekdayElementProps { - weekday: number; - className: string; - localeUtils: LocaleUtils; - locale: string; -} - -interface ClassNames { - container: string; - interactionDisabled: string; - navBar: string; - navButtonPrev: string; - navButtonNext: string; - - month: string; - caption: string; - weekdays: string; - weekdaysRow: string; - weekday: string; - body: string; - week: string; - day: string; - - today: string; - selected: string; - disabled: string; - outside: string; -} - -interface RangeModifier { - from: Date; - to: Date; -} -interface BeforeModifier { - before: Date; -} -interface AfterModifier { - after: Date; -} -interface FunctionModifier { - (date: Date): boolean; -} -type Modifier = RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; - -interface Modifiers { - today: Modifier | Modifier[]; - outside: Modifier | Modifier[]; - [other: string]: Modifier | Modifier[] | undefined; -} - -interface Props { - canChangeMonth?: boolean; - captionElement?: React.SFC; - className?: string; - classNames?: ClassNames; - containerProps?: React.HTMLAttributes; - disabledDays?: Modifier | Modifier[]; - enableOutsideDays?: boolean; - firstDayOfWeek?: number; - fixedWeeks?: boolean; - fromMonth?: Date; - initialMonth?: Date; - labels?: { previousMonth: string; nextMonth: string; }; - locale?: string; - localeUtils?: LocaleUtils; - modifiers?: Modifiers; - month?: Date; - months?: [string, string, string, string, string, string, string, string, string, string, string, string]; - navbarElement?: React.SFC | React.ComponentClass; - numberOfMonths?: number; - onBlur?(e: React.FocusEvent): void; - onCaptionClick?(month: Date, e: React.MouseEvent): void; - onDayClick?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; - onDayKeyDown?(day: Date, modifiers: Modifiers, e: React.KeyboardEvent): void; - onDayMouseEnter?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; - onDayMouseLeave?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; - onDayTouchEnd?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; - onDayTouchStart?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; - onFocus?(e: React.FocusEvent): void; - onKeyDown?(e: React.KeyboardEvent): void; - onMonthChange?(month: Date): void; - pagedNavigation?: boolean; - renderDay?(date: Date, modifiers: Modifiers): React.ReactNode; - reverseMonths?: boolean; - selectedDays?: Modifier | Modifier[]; - toMonth?: Date; - weekdayElement?: React.SFC | React.ComponentClass; - weekdaysLong?: [string, string, string, string, string, string, string]; - weekdaysShort?: [string, string, string, string, string, string, string]; -} - - -class DayPicker extends React.Component { +declare class DayPicker extends React.Component { showMonth(month: Date): void; showPreviousMonth(): void; @@ -148,10 +152,6 @@ class DayPicker extends React.Component { showPreviousYear(): void; showNextYear(): void; - - static readonly VERSION: string; - static readonly LocaleUtils: LocaleUtils; - static readonly DateUtils: DateUtils; } export = DayPicker;