Merge pull request #17176 from rowellx68/master

Updated flatpickr to include changes brought in for v3
This commit is contained in:
Mine Starks
2017-06-16 11:10:19 -07:00
committed by GitHub
5 changed files with 122 additions and 7 deletions
+13 -7
View File
@@ -1,22 +1,25 @@
// Type definitions for flatpickr 2.2
// Type definitions for flatpickr 3.0
// Project: https://github.com/chmln/flatpickr
// Definitions by: James Birtles <https://github.com/UnwrittenFun>
// Rowell Heria <https://github.com/rowellx68>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Flatpickr {
constructor(element: string | Element, options?: Flatpickr.Options);
declare function flatpickr(element: string | Element | HTMLElement, options?: Flatpickr.Options): Flatpickr;
changeMonth(month: number, isOffset: boolean): void;
declare class Flatpickr {
constructor(element: string | Element | HTMLElement, options?: Flatpickr.Options);
changeMonth(month: number, isOffset?: boolean): void;
clear(): void;
close(): void;
destroy(): void;
formatDate(format: string, date: Date): string;
formatDate(date: Date, format: string): string;
jumpToDate(date?: Flatpickr.DateString): void;
open(): void;
parseDate(date: string): Date;
parseDate(date: string, format: string): Date;
redraw(): void;
set(option: string, value: any): void;
setDate(date: Flatpickr.DateString | Flatpickr.DateString[]): void;
setDate(date: Flatpickr.DateString | Flatpickr.DateString[], triggerChange?: boolean, dateFormat?: string): void;
toggle(): void;
}
@@ -29,7 +32,10 @@ declare namespace Flatpickr {
clickOpens?: boolean;
dateFormat?: string | null;
defaultDate?: DateString | DateString[];
defaultHour?: number;
defaultMinute?: number;
disable?: DateRange[];
disableMobile?: boolean;
enable?: DateRange[];
enableTime?: boolean;
enableSeconds?: boolean;
+14
View File
@@ -0,0 +1,14 @@
import * as Flatpickr from 'flatpickr';
const picker1 = new Flatpickr('input');
const input = document.querySelector('input');
if (input != null) {
const picker2 = new Flatpickr(input, {
mode: 'range',
onChange: dates => null
});
picker2.setDate(['2016-11-15T00:00:00.000Z', new Date()]);
}
picker1.destroy();
+68
View File
@@ -0,0 +1,68 @@
// Type definitions for flatpickr 2.2
// Project: https://github.com/chmln/flatpickr
// Definitions by: James Birtles <https://github.com/UnwrittenFun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Flatpickr {
constructor(element: string | Element, options?: Flatpickr.Options);
changeMonth(month: number, isOffset: boolean): void;
clear(): void;
close(): void;
destroy(): void;
formatDate(format: string, date: Date): string;
jumpToDate(date?: Flatpickr.DateString): void;
open(): void;
parseDate(date: string): Date;
redraw(): void;
set(option: string, value: any): void;
setDate(date: Flatpickr.DateString | Flatpickr.DateString[]): void;
toggle(): void;
}
declare namespace Flatpickr {
interface Options {
altFormat?: string;
altInput?: boolean;
altInputClass?: string;
allowInput?: boolean;
clickOpens?: boolean;
dateFormat?: string | null;
defaultDate?: DateString | DateString[];
disable?: DateRange[];
enable?: DateRange[];
enableTime?: boolean;
enableSeconds?: boolean;
hourIncrement?: number;
inline?: boolean;
maxDate?: DateString;
minDate?: DateString;
minuteIncrement?: number;
mode?: Mode;
nextArrow?: string;
noCalendar?: boolean;
onChange?: EventCallback | EventCallback[];
onClose?: EventCallback | EventCallback[];
onOpen?: EventCallback | EventCallback[];
onReady?: EventCallback | EventCallback[];
onMonthChange?: EventCallback | EventCallback[];
onYearChange?: EventCallback | EventCallback[];
onValueUpdate?: EventCallback | EventCallback[];
onDayCreate?: EventCallback | EventCallback[];
parseDate?(date: string): Date;
prevArrow?: string;
shorthandCurrentMonth?: boolean;
static?: boolean;
time_24hr?: boolean;
utc?: boolean;
weekNumbers?: boolean;
wrap?: boolean;
}
type DateString = Date | string;
type DateRange = DateString | { from: DateString, to: DateString } | ((date: Date) => boolean);
type Mode = 'single' | 'multiple' | 'range';
type EventCallback = (selectedDates: Date[], dateStr: string, instance: Flatpickr, elem: HTMLElement) => void;
}
export = Flatpickr;
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"flatpickr": [ "flatpickr/v2" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"flatpickr-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }