nepali-date-selector
Version:
Nepali Date Selector
73 lines (72 loc) • 2.5 kB
TypeScript
import { HTMLAttributes } from "react";
export declare type voidFunction = () => void;
export declare const ENGLISH = "en";
export declare const NEPALI = "ne";
export declare const BS = "BS";
export declare const AD = "AD";
export declare type localeType = "en" | "ne";
export interface NepaliDateSelectorOptions {
closeOnSelect: boolean;
calenderLocale: localeType;
valueLocale: localeType;
}
export interface IContextProviderProps {
minYear?: number;
children: React.ReactNode;
maxYear?: number;
}
export interface INepaliDateSelector {
value: string;
className: HTMLAttributes<HTMLDivElement>["className"];
inputClassName: HTMLAttributes<HTMLInputElement>["className"];
onChange: (date: string) => void;
onSelect?: (value: string) => void;
options: NepaliDateSelectorOptions;
minYear?: number;
maxYear?: number;
todayIfEmpty?: boolean;
}
export interface NepaliDateSelectorProps {
value?: INepaliDateSelector["value"];
className?: INepaliDateSelector["className"];
inputClassName?: INepaliDateSelector["inputClassName"];
onChange?: INepaliDateSelector["onChange"];
onSelect?: INepaliDateSelector["onSelect"];
options?: {
closeOnSelect?: NepaliDateSelectorOptions["closeOnSelect"];
calenderLocale?: NepaliDateSelectorOptions["calenderLocale"];
valueLocale?: NepaliDateSelectorOptions["valueLocale"];
};
minYear?: INepaliDateSelector["minYear"];
maxYear?: INepaliDateSelector["maxYear"];
todayIfEmpty?: boolean;
}
export interface NepaliDateSelectorEvents {
change: (value: string) => void;
yearSelect?: (year: number) => void;
monthSelect?: ({ year, month }: YearMonth) => void;
daySelect?: ({ year, month, day }: YearMonthDate) => void;
previousMonthSelect?: ({ month, year }: YearMonth) => void;
nextMonthSelect?: ({ year, month }: YearMonth) => void;
todaySelect?: ({ year, month, day }: YearMonthDate) => void;
}
export interface ParsedDate {
bsYear: number;
bsMonth: number;
bsDay: number;
weekDay: number;
adDate: Date;
numberOfDaysInBSMonth: number;
firstAdDayInBSMonth: Date;
}
export declare const parsedDateInitialValue: ParsedDate;
export interface SplittedDate {
year: number;
month: number;
day: number;
}
export declare type YearMonthDate = SplittedDate;
export interface YearMonth {
year: number;
month: number;
}