instance.d.ts 4.11 KB
Newer Older
Joe TS Dell's avatar
Joe TS Dell committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { DateOption, Options, ParsedOptions } from "./options";
import { Locale, CustomLocale, key as LocaleKey } from "./locale";
import { RevFormat, Formats, TokenRegex } from "../utils/formatting";
export interface Elements {
    element: HTMLElement;
    input: HTMLInputElement;
    altInput?: HTMLInputElement;
    _input: HTMLInputElement;
    mobileInput?: HTMLInputElement;
    mobileFormatStr?: string;
    selectedDateElem?: DayElement;
    todayDateElem?: DayElement;
    _positionElement: HTMLElement;
    weekdayContainer: HTMLDivElement;
    calendarContainer: HTMLDivElement;
    innerContainer?: HTMLDivElement;
    rContainer?: HTMLDivElement;
    daysContainer?: HTMLDivElement;
    days: HTMLDivElement;
    weekWrapper?: HTMLDivElement;
    weekNumbers?: HTMLDivElement;
    monthNav: HTMLDivElement;
    monthsDropdownContainer: HTMLSelectElement;
    yearElements: HTMLInputElement[];
    monthElements: HTMLSpanElement[];
    currentYearElement: HTMLInputElement;
    currentMonthElement: HTMLSpanElement;
    _hidePrevMonthArrow: boolean;
    _hideNextMonthArrow: boolean;
    prevMonthNav: HTMLElement;
    nextMonthNav: HTMLElement;
    timeContainer?: HTMLDivElement;
    hourElement?: HTMLInputElement;
    minuteElement?: HTMLInputElement;
    secondElement?: HTMLInputElement;
    amPM?: HTMLSpanElement;
    pluginElements: Node[];
}
export interface Formatting {
    revFormat: RevFormat;
    formats: Formats;
    tokenRegex: TokenRegex;
}
export declare type Instance = Elements & Formatting & {
    minRangeDate?: Date;
    maxRangeDate?: Date;
    now: Date;
    latestSelectedDateObj?: Date;
    _selectedDateObj?: Date;
    selectedDates: Date[];
    _initialDate: Date;
    config: ParsedOptions;
    loadedPlugins: string[];
    l10n: Locale;
    currentYear: number;
    currentMonth: number;
    isOpen: boolean;
    isMobile: boolean;
    minDateHasTime: boolean;
    maxDateHasTime: boolean;
    changeMonth: (value: number, isOffset?: boolean, fromKeyboard?: boolean) => void;
    changeYear: (year: number) => void;
    clear: (emitChangeEvent?: boolean, toInitial?: boolean) => void;
    close: () => void;
    destroy: () => void;
    isEnabled: (date: DateOption, timeless?: boolean) => boolean;
    jumpToDate: (date?: DateOption, triggerChange?: boolean) => void;
    open: (e?: FocusEvent | MouseEvent, positionElement?: HTMLElement) => void;
    redraw: () => void;
    set: (option: keyof Options | {
        [k in keyof Options]?: Options[k];
    }, value?: any) => void;
    setDate: (date: DateOption | DateOption[], triggerChange?: boolean, format?: string) => void;
    toggle: () => void;
    pad: (num: string | number) => string;
    parseDate: (date: Date | string | number, givenFormat?: string, timeless?: boolean) => Date | undefined;
    formatDate: (dateObj: Date, frmt: string) => string;
    _handlers: {
        remove: () => void;
    }[];
    _bind: <E extends Element>(element: E | E[], event: string | string[], handler: (e?: any) => void) => void;
    _createElement: <E extends HTMLElement>(tag: keyof HTMLElementTagNameMap, className: string, content?: string) => E;
    _setHoursFromDate: (date: Date) => void;
    _debouncedChange: () => void;
    __hideNextMonthArrow: boolean;
    __hidePrevMonthArrow: boolean;
    _positionCalendar: (customPositionElement?: HTMLElement) => void;
    utils: {
        getDaysInMonth: (month?: number, year?: number) => number;
    };
};
export interface FlatpickrFn {
    (selector: Node, config?: Options): Instance;
    (selector: ArrayLike<Node>, config?: Options): Instance[];
    (selector: string, config?: Options): Instance | Instance[];
    defaultConfig: Partial<ParsedOptions>;
    l10ns: {
        [k in LocaleKey]?: CustomLocale;
    } & {
        default: Locale;
    };
    localize: (l10n: CustomLocale) => void;
    setDefaults: (config: Options) => void;
    parseDate: (date: DateOption, format?: string, timeless?: boolean) => Date | undefined;
    formatDate: (date: Date, format: string) => string;
    compareDates: (date1: Date, date2: Date, timeless?: boolean) => number;
}
export declare type DayElement = HTMLSpanElement & {
    dateObj: Date;
    $i: number;
};