@datacomvn/lunar-date-picker
Version:
A powerful React Native lunar date picker with timezone support, lazy loading, and native performance built on Nitro Modules
101 lines • 3.2 kB
TypeScript
export interface LDP_Range {
from: string;
to?: string;
}
export type LDP_PickerMode = 'range' | 'single';
export type LDP_PriceData = {
date: string;
price: number;
isCheapest?: boolean;
};
/**
* Hiện tại chỉ cần làm trường hợp update cho từng tháng
*/
export type LDP_PriceUpdateParams = {
month: string;
prices: LDP_PriceData[];
};
export type LDP_PresentParams = {
theme: string;
language: string;
title: string;
textCancel: string;
mode: LDP_PickerMode;
onDone: (result: LDP_Range) => void;
minimumDate?: string;
maximumDate?: string;
initialValue?: LDP_Range;
/**
* Prices data for calendar dates
* - undefined/not provided: Price labels will be completely hidden
* - empty array []: Price labels will be shown but with empty text for dates without data
* - array with data: Price labels will be shown with actual price data
*/
prices?: LDP_PriceData[];
/**
* Callback được gọi khi một tháng mới được hiển thị trên màn hình
* @param month - Tháng theo format "YYYY-MM" (ví dụ: "2024-01")
*
* Use case: Dùng để lazy load prices cho tháng đó khi user scroll
*
* Note: Callback này được debounce với delay 600ms để tránh gọi quá nhiều API
* khi người dùng scroll nhanh. Chỉ những tháng mà người dùng dừng lại và xem
* thực sự mới trigger callback này.
*
* @example
* ```typescript
* onMonthVisible: async (month) => {
* const prices = await fetchPricesForMonth(month);
* updatePrices({
* mode: 'merge',
* monthData: { month, prices }
* });
* }
* ```
*/
onMonthVisible?: (month: string) => void;
/**
* Callback được gọi khi user chọn ngày từ
* @param date dạng YYYY-MM-DD
* @param currentlyVisibleMonths các tháng đang hiển thị trên màn hình
* @returns
* @example
* ```typescript
* onSelectFromDate: (date, currentlyVisibleMonths) => {
* console.log('Selected from date:', date);
* console.log('Currently visible months:', currentlyVisibleMonths);
* }
*/
onSelectFromDate?: (date: string, currentlyVisibleMonths: string[]) => void;
};
/**
* màu hex nhé
*/
export type LDP_CustomStyle = {
titleColor: string;
cancelColor: string;
dateLabelColor: string;
lunarDateLabelColor: string;
selectedTextColor: string;
weekendLabelColor: string;
specialDayLabelColor: string;
priceLabelColor: string;
cheapestPriceLabelColor: string;
monthLabelColor: string;
backgroundColor: string;
weekViewBackgroundColor: string;
selectedBackgroundColor: string;
rangeBackgroundColor: string;
};
export type LDP_CustomLanguage = {
weekdayNames: string[];
monthNames: string[];
};
export type LDP_ConfigParams = {
themes: Record<string, LDP_CustomStyle>;
languages: Record<string, LDP_CustomLanguage>;
yearRangeOffset: number;
timeZoneOffset: number;
monthVisibleDebounceDelaySeconds?: number;
};
//# sourceMappingURL=type.d.ts.map