react-nepali-datepicker-bs
Version:
Nepali Datepicker (Bikram Sambat) as a ReactJS component
82 lines (81 loc) • 3.24 kB
TypeScript
/// <reference types="react" />
import { ConfigState } from "./Config/ConfigTypes";
export declare type voidFunction = () => void;
export declare const ENGLISH: TLocaleType;
export declare const NEPALI: TLocaleType;
export declare const BS = "BS";
export declare const AD = "AD";
export declare type TLocaleType = "en" | "ne";
export interface NepaliDatePickerOptions {
closeOnSelect?: boolean;
calenderLocale?: TLocaleType;
valueLocale?: TLocaleType;
}
export declare type Themes = "dark" | "light" | "forest";
export declare type WeekDayLabelSize = "sm" | "md" | "lg";
export interface IContextProviderProps extends ConfigState {
children: React.ReactNode;
}
export declare type TDateSeparatorDash = "-";
export declare type TDateSeparatorSlash = "/";
export declare type TDateSeparatorDot = ".";
export declare type TDateFormatDash = "YYYY-MM-DD" | "DD-MM-YYYY" | "MM-DD-YYYY";
export declare type TDateFormatSlash = "YYYY/MM/DD" | "DD/MM/YYYY" | "MM/DD/YYYY";
export declare type TDateFormatDot = "YYYY.MM.DD" | "DD.MM.YYYY" | "MM.DD.YYYY";
export declare type TDateSeparator = TDateSeparatorDash | TDateSeparatorSlash | TDateSeparatorDot;
export declare type TDateFormatOptions<GDateSeparator extends TDateSeparator> = GDateSeparator extends TDateSeparatorDash ? {
separator: GDateSeparator;
format: TDateFormatDash;
} : GDateSeparator extends TDateSeparatorSlash ? {
separator: GDateSeparator;
format: TDateFormatSlash;
} : GDateSeparator extends TDateSeparatorDot ? {
separator: GDateSeparator;
format: TDateFormatDot;
} : never;
export declare type TNepaliDatePicker<GDateSeparator extends TDateSeparator> = {
value?: string;
onChange: (date: string) => void;
onSelect?: (value: string) => void;
options?: NepaliDatePickerOptions;
minYear?: number;
maxYear?: number;
todayIfEmpty?: boolean;
placeholder?: string;
style?: React.CSSProperties;
inputStyle?: React.CSSProperties;
className?: React.HTMLAttributes<HTMLDivElement>["className"];
inputClassName?: React.HTMLAttributes<HTMLInputElement>["className"];
theme?: Themes;
weekDayLabelSize?: WeekDayLabelSize;
formatOptions?: TDateFormatOptions<GDateSeparator extends TDateSeparator ? GDateSeparator : never>;
};
export interface NepaliDatepickerEvents {
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;
}