timescape
Version:
A flexible, headless date and time input library for JavaScript. Provides tools for building fully customizable date and time input fields, with support for libraries like React, Preact, Vue, Svelte and Solid.
61 lines (56 loc) • 2.02 kB
text/typescript
declare const STOP_EVENT_PROPAGATION: unique symbol;
type Callback<T> = (arg: T) => void | typeof STOP_EVENT_PROPAGATION;
declare const marry: (from: TimescapeManager, to: TimescapeManager) => void;
type DateType = "days" | "months" | "years" | "hours" | "minutes" | "seconds" | "milliseconds" | "am/pm";
declare const $NOW: "$NOW";
type $NOW = typeof $NOW;
type Options = {
date?: Date;
minDate?: Date | $NOW;
maxDate?: Date | $NOW;
hour12?: boolean;
digits?: "numeric" | "2-digit";
wrapAround?: boolean;
snapToStep?: boolean;
wheelControl?: boolean;
disallowPartial?: boolean;
};
type RangeOptions = {
from?: Options & {
date?: Date;
};
to?: Options & {
date?: Date;
};
};
type Events = {
changeDate: Date | undefined;
focusWrap: "start" | "end";
};
declare class TimescapeManager implements Options {
#private;
minDate?: Options["minDate"];
maxDate?: Options["maxDate"];
hour12?: Options["hour12"];
digits?: Options["digits"];
wrapAround?: Options["wrapAround"];
snapToStep?: Options["snapToStep"];
wheelControl?: Options["wheelControl"];
disallowPartial?: Options["disallowPartial"];
ampm?: "am" | "pm";
get date(): Date | undefined;
set date(nextDate: Date | number | string | undefined);
constructor(initialDate?: Date, options?: Options);
resync(): void;
registerRoot(element: HTMLElement): void;
registerElement(element: HTMLInputElement, type: DateType, autofocus?: boolean, domExists?: boolean): HTMLInputElement | undefined;
/**
* Returns whether all fields are filled out. Can only be false in partial mode.
* @returns {boolean}
*/
isCompleted(): boolean;
remove(): void;
focusField(which?: number): void;
on<E extends keyof Events>(event: E, callback: Callback<Events[E]>): () => void;
}
export { $NOW, type DateType, type Options, type RangeOptions, STOP_EVENT_PROPAGATION, TimescapeManager, TimescapeManager as default, marry };