@lichta/core 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # @lichta/core
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@lichta/core.svg)](https://www.npmjs.com/package/@lichta/core)
4
+ [![npm version](https://img.shields.io/npm/v/@lichta/react.svg)](https://www.npmjs.com/package/@lichta/react)
5
+ [![npm version](https://img.shields.io/npm/v/@lichta/vue.svg)](https://www.npmjs.com/package/@lichta/vue)
6
+ [![npm version](https://img.shields.io/npm/v/@lichta/svelte.svg)](https://www.npmjs.com/package/@lichta/svelte)
7
+ [![npm version](https://img.shields.io/npm/v/@lichta/full-calendar.svg)](https://www.npmjs.com/package/@lichta/full-calendar)
8
+ [![npm version](https://img.shields.io/npm/v/@lichta/event-calendar.svg)](https://www.npmjs.com/package/@lichta/event-calendar)
9
+ [![npm version](https://img.shields.io/npm/v/@lichta/react-big-calendar.svg)](https://www.npmjs.com/package/@lichta/react-big-calendar)
10
+
11
+ 🚀 **[Demo trực tiếp](https://lichta.zeneo.app/)**
4
12
 
5
13
  Thư viện lõi tính toán chuyển đổi **Dương lịch ↔ Âm lịch Việt Nam** cho JavaScript/TypeScript. Thuần TypeScript, **0 dependency**, không phụ thuộc framework nào — dùng được ở Node.js, trình duyệt, hoặc làm nền cho các binding framework khác ([`@lichta/react`](https://www.npmjs.com/package/@lichta/react), [`@lichta/vue`](https://www.npmjs.com/package/@lichta/vue), [`@lichta/svelte`](https://www.npmjs.com/package/@lichta/svelte)).
6
14
 
@@ -34,16 +42,23 @@ const lunarGmt8 = LichTa.toLunar(10, 2, 2024, 8);
34
42
  ## Can Chi & Phong Thủy
35
43
 
36
44
  ```typescript
37
- import { LichTa, getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from '@lichta/core';
45
+ import { LichTa, getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours, getAuspiciousHourIndices } from '@lichta/core';
38
46
 
39
47
  getYearDetails(2024);
40
48
  // → { can: 'Giáp', chi: 'Thìn', menh: 'Thủy', fullString: 'Giáp Thìn - Mệnh Thủy' }
49
+ // getYearDetails() nhận mọi số năm nguyên (kể cả 0 hoặc âm) — chu kỳ Can Chi 60 năm lặp vô hạn.
41
50
 
42
51
  const lunar = LichTa.toLunar(10, 2, 2024);
43
52
  getDayCanChi(lunar.jd); // 'Giáp Thìn'
44
53
  getMonthCanChi(lunar.month, lunar.year); // 'Bính Dần'
45
54
  getHourCanChi(8, lunar.jd); // giờ Thìn (7h-9h)
46
- getAuspiciousHours(lunar.jd); // 6 giờ Hoàng Đạo trong ngày
55
+ getAuspiciousHours(lunar.jd); // 6 giờ Hoàng Đạo trong ngày (tên Địa Chi)
56
+
57
+ // Mỗi hàm trên đều nhận thêm tham số `locale` tùy chọn (mặc định 'vi', không đổi hành vi cũ)
58
+ getDayCanChi(lunar.jd, 'ja'); // Can Chi bằng chữ Nhật
59
+
60
+ // Cần index Địa Chi thay vì tên (ví dụ để tự map sang UI riêng)?
61
+ getAuspiciousHourIndices(lunar.jd); // [0, 2, 3, 6, 8, 10] — index 0-11 (0 = Tý)
47
62
  ```
48
63
 
49
64
  ## Format & Hiển thị
@@ -57,10 +72,24 @@ formatLunarDate(lunar, 'Ngày d tháng M năm CC'); // 'Ngày 1 tháng 1 năm Gi
57
72
 
58
73
  getMonthName(1); // 'Giêng'
59
74
  getDayName(15); // 'Rằm'
75
+
76
+ // formatLunarDate nhận thêm `locale` tùy chọn (mặc định 'vi', chỉ ảnh hưởng token L)
77
+ formatLunarDate(lunar, 'dd/MM/yyyy', 'en');
60
78
  ```
61
79
 
62
80
  **Format tokens:** `dd`/`d` (ngày), `MM`/`M` (tháng), `yyyy`/`yy` (năm), `CC`/`MC`/`DC` (Can Chi năm/tháng/ngày), `L` ("Nhuận" nếu là tháng nhuận).
63
81
 
82
+ ## Lưới lịch tháng (dựng UI Calendar riêng)
83
+
84
+ Nếu bạn muốn tự dựng UI lịch tháng thay vì dùng component `Calendar` có sẵn (xem [`@lichta/react`](https://www.npmjs.com/package/@lichta/react)/[`@lichta/vue`](https://www.npmjs.com/package/@lichta/vue)/[`@lichta/svelte`](https://www.npmjs.com/package/@lichta/svelte)), `getCalendarGrid()` dựng sẵn lưới 42 ô (6 tuần) cho 1 tháng, gồm cả ngày tràn từ tháng trước/sau và ngày âm lịch tương ứng cho mỗi ô — đây cũng chính là hàm mà `Calendar` và `DatePicker` ở các package binding dùng nội bộ.
85
+
86
+ ```typescript
87
+ import { getCalendarGrid } from '@lichta/core';
88
+
89
+ const grid = getCalendarGrid(2, 2024, null); // tháng, năm, ngày đang chọn (hoặc null)
90
+ // → CalendarDayCell[42], mỗi ô: { solar: Date, lunar: LunarDate, isToday, isSelected, isCurrentMonth }
91
+ ```
92
+
64
93
  ## i18n
65
94
 
66
95
  Hỗ trợ 4 ngôn ngữ cho tên Can Chi, Ngũ Hành, con giáp, tên tháng, thứ trong tuần: `vi`, `en`, `ja`, `ko`.
@@ -68,31 +97,38 @@ Hỗ trợ 4 ngôn ngữ cho tên Can Chi, Ngũ Hành, con giáp, tên tháng, t
68
97
  ```typescript
69
98
  import { t, getZodiacAnimal } from '@lichta/core';
70
99
 
71
- t('en').fiveElements; // ['Metal', 'Wood', 'Water', 'Fire', 'Earth']
72
- t('ja').weekDays; // ['日', '月', '火', '水', '木', '金', '土']
73
- getZodiacAnimal(0, 'vi'); // 'Chuột'
100
+ t('en').fiveElements; // ['Metal', 'Wood', 'Water', 'Fire', 'Earth']
101
+ t('ja').weekDays; // ['日', '月', '火', '水', '木', '金', '土']
102
+ t('vi').lunarMonthNames; // ['Giêng', 'Hai', ..., 'Chạp'] — tên tháng ÂM lịch
103
+ t('vi').solarMonthNames; // ['Tháng 1', 'Tháng 2', ..., 'Tháng 12'] — tên tháng DƯƠNG lịch
104
+ getZodiacAnimal(0, 'vi'); // 'Chuột'
74
105
  ```
75
106
 
107
+ > `t(locale).monthNames` vẫn còn nhưng đã `@deprecated` — ngữ nghĩa của nó không nhất quán giữa các locale (với `'vi'` là tên tháng âm, với `'en'/'ja'/'ko'` lại là tên tháng dương). Luôn dùng `lunarMonthNames` hoặc `solarMonthNames` tùy ngữ cảnh cho code mới.
108
+
76
109
  ## API đầy đủ
77
110
 
78
111
  | Nhóm | Hàm/Class |
79
112
  |---|---|
80
113
  | Solar ↔ Lunar | `LichTa.toLunar()`, `LichTa.toSolar()` |
81
114
  | Julian Day Number | `jdFromDate()`, `jdToDate()` |
82
- | Can Chi & Phong Thủy | `getYearDetails()`, `getDayCanChi()`, `getMonthCanChi()`, `getHourCanChi()`, `getAuspiciousHours()` |
115
+ | Can Chi & Phong Thủy | `getYearDetails()`, `getDayCanChi()`, `getMonthCanChi()`, `getHourCanChi()`, `getAuspiciousHours()`, `getAuspiciousHourIndices()` |
83
116
  | Format & Hiển thị | `formatLunarDate()`, `formatTraditional()`, `getMonthName()`, `getDayName()` |
117
+ | Lưới lịch | `getCalendarGrid()` |
84
118
  | i18n | `t()`, `getZodiacAnimal()` |
85
- | Types | `LunarDate`, `SolarDate`, `Locale` |
119
+ | Types | `LunarDate`, `SolarDate`, `Locale`, `YearDetails`, `CalendarDayCell` |
86
120
 
87
121
  Xem chi tiết đầy đủ (tham số, kiểu trả về, ví dụ đã chạy thật) tại trang [API Reference](https://lichta.zeneo.app/api).
88
122
 
89
- ## Styles (dùng chung cho Calendar component)
123
+ ## Styles (dùng chung cho Calendar/DatePicker component)
90
124
 
91
- Package này cũng export sẵn CSS cho component `Calendar` ở các package binding framework — không cần thiết nếu bạn chỉ dùng logic tính toán:
125
+ Package này cũng export sẵn CSS cho component `Calendar`/`DatePicker` ở các package binding framework — không cần thiết nếu bạn chỉ dùng logic tính toán:
92
126
 
93
127
  ```typescript
94
128
  import '@lichta/core/styles/calendar-base.css';
95
- import '@lichta/core/styles/calendar-glass.css'; // theme kính mờ (tùy chọn)
129
+ import '@lichta/core/styles/calendar-glass.css'; // theme kính mờ cho Calendar (tùy chọn)
130
+ import '@lichta/core/styles/datepicker-base.css'; // chỉ cần nếu dùng component DatePicker
131
+ import '@lichta/core/styles/datepicker-glass.css'; // theme kính mờ cho DatePicker (tùy chọn)
96
132
  ```
97
133
 
98
134
  ## Thuật toán
package/dist/index.d.mts CHANGED
@@ -73,22 +73,106 @@ declare class LichTa {
73
73
  }
74
74
 
75
75
  /**
76
- * Lấy ra chuỗi tả toàn bộ Can, Chi và Mệnh dựa vào số năm (Ví dụ: 2024)
77
- * Theo quy ước: Năm 4 (sau CN) là năm Giáp Tý (Can index 0, Chi index 0)
76
+ * Internationalization Hỗ trợ song ngữ Việt-Anh
78
77
  */
79
- declare function getYearDetails(year: number): {
80
- can: "Giáp" | "Ất" | "Bính" | "Đinh" | "Mậu" | "Kỷ" | "Canh" | "Tân" | "Nhâm" | "Quý";
81
- chi: "Tý" | "Sửu" | "Dần" | "Mão" | "Thìn" | "Tỵ" | "Ngọ" | "Mùi" | "Thân" | "Dậu" | "Tuất" | "Hợi";
78
+ type Locale = 'vi' | 'en' | 'ja' | 'ko';
79
+ /**
80
+ * Lấy bộ dịch theo locale
81
+ * @param locale - Ngôn ngữ ('vi' | 'en' | 'ja' | 'ko')
82
+ */
83
+ declare function t(locale: Locale): {
84
+ readonly heavenlyStems: readonly ["Giáp", "Ất", "Bính", "Đinh", "Mậu", "Kỷ", "Canh", "Tân", "Nhâm", "Quý"];
85
+ readonly earthlyBranches: readonly ["Tý", "Sửu", "Dần", "Mão", "Thìn", "Tỵ", "Ngọ", "Mùi", "Thân", "Dậu", "Tuất", "Hợi"];
86
+ readonly fiveElements: readonly ["Kim", "Mộc", "Thủy", "Hỏa", "Thổ"];
87
+ readonly zodiacAnimals: readonly ["Chuột", "Trâu", "Cọp", "Thỏ", "Rồng", "Rắn", "Ngựa", "Dê", "Khỉ", "Gà", "Chó", "Heo"];
88
+ readonly monthNames: readonly ["Giêng", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy", "Tám", "Chín", "Mười", "Một", "Chạp"];
89
+ readonly lunarMonthNames: readonly ["Giêng", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy", "Tám", "Chín", "Mười", "Một", "Chạp"];
90
+ readonly solarMonthNames: readonly ["Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"];
91
+ readonly weekDays: readonly ["CN", "T2", "T3", "T4", "T5", "T6", "T7"];
92
+ readonly leapLabel: "Nhuận";
93
+ readonly yearLabel: "Năm";
94
+ readonly monthLabel: "Tháng";
95
+ readonly destiny: "Mệnh";
96
+ } | {
97
+ readonly heavenlyStems: readonly ["Giáp", "Ất", "Bính", "Đinh", "Mậu", "Kỷ", "Canh", "Tân", "Nhâm", "Quý"];
98
+ readonly earthlyBranches: readonly ["Tý", "Sửu", "Dần", "Mão", "Thìn", "Tỵ", "Ngọ", "Mùi", "Thân", "Dậu", "Tuất", "Hợi"];
99
+ readonly fiveElements: readonly ["Metal", "Wood", "Water", "Fire", "Earth"];
100
+ readonly zodiacAnimals: readonly ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"];
101
+ readonly monthNames: readonly ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
102
+ readonly lunarMonthNames: readonly ["Month 1", "Month 2", "Month 3", "Month 4", "Month 5", "Month 6", "Month 7", "Month 8", "Month 9", "Month 10", "Month 11", "Month 12"];
103
+ readonly solarMonthNames: readonly ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
104
+ readonly weekDays: readonly ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
105
+ readonly leapLabel: "Leap";
106
+ readonly yearLabel: "Year";
107
+ readonly monthLabel: "Month";
108
+ readonly destiny: "Destiny";
109
+ } | {
110
+ readonly heavenlyStems: readonly ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"];
111
+ readonly earthlyBranches: readonly ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"];
112
+ readonly fiveElements: readonly ["金", "木", "水", "火", "土"];
113
+ readonly zodiacAnimals: readonly ["鼠", "牛", "虎", "兎", "竜", "蛇", "馬", "羊", "猿", "鶏", "犬", "猪"];
114
+ readonly monthNames: readonly ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
115
+ readonly lunarMonthNames: readonly ["旧暦1月", "旧暦2月", "旧暦3月", "旧暦4月", "旧暦5月", "旧暦6月", "旧暦7月", "旧暦8月", "旧暦9月", "旧暦10月", "旧暦11月", "旧暦12月"];
116
+ readonly solarMonthNames: readonly ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
117
+ readonly weekDays: readonly ["日", "月", "火", "水", "木", "金", "土"];
118
+ readonly leapLabel: "閏";
119
+ readonly yearLabel: "年";
120
+ readonly monthLabel: "月";
121
+ readonly destiny: "命";
122
+ } | {
123
+ readonly heavenlyStems: readonly ["갑", "을", "병", "정", "무", "기", "경", "신", "임", "계"];
124
+ readonly earthlyBranches: readonly ["자", "축", "인", "묘", "진", "사", "오", "미", "신", "유", "술", "해"];
125
+ readonly fiveElements: readonly ["금", "목", "수", "화", "토"];
126
+ readonly zodiacAnimals: readonly ["쥐", "소", "호랑이", "토끼", "용", "뱀", "말", "양", "원숭이", "닭", "개", "돼지"];
127
+ readonly monthNames: readonly ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"];
128
+ readonly lunarMonthNames: readonly ["음력 1월", "음력 2월", "음력 3월", "음력 4월", "음력 5월", "음력 6월", "음력 7월", "음력 8월", "음력 9월", "음력 10월", "음력 11월", "음력 12월"];
129
+ readonly solarMonthNames: readonly ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"];
130
+ readonly weekDays: readonly ["일", "월", "화", "수", "목", "금", "토"];
131
+ readonly leapLabel: "윤";
132
+ readonly yearLabel: "년";
133
+ readonly monthLabel: "월";
134
+ readonly destiny: "명";
135
+ };
136
+ /**
137
+ * Lấy tên con giáp theo locale
138
+ * @param branchIndex - Index Địa Chi (0-11)
139
+ * @param locale - Ngôn ngữ
140
+ */
141
+ declare function getZodiacAnimal(branchIndex: number, locale?: Locale): string;
142
+
143
+ /** Kết quả trả về của {@link getYearDetails}. */
144
+ interface YearDetails {
145
+ can: string;
146
+ chi: string;
82
147
  menh: string;
83
148
  fullString: string;
84
- };
149
+ }
150
+ /**
151
+ * Lấy ra chuỗi mô tả toàn bộ Can, Chi và Mệnh dựa vào số năm (Ví dụ: 2024)
152
+ * Theo quy ước: Năm 4 (sau CN) là năm Giáp Tý (Can index 0, Chi index 0)
153
+ *
154
+ * Công thức Can Chi là chu kỳ 60 năm lặp lại vô hạn nên nhận mọi số năm nguyên,
155
+ * kể cả năm 0 hoặc âm (trước Công Nguyên) — không giới hạn phạm vi như
156
+ * {@link LichTa.toLunar} (phạm vi đó là do thuật toán tìm Điểm Sóc, không áp
157
+ * dụng cho công thức Can Chi thuần).
158
+ *
159
+ * @param year - Năm (số nguyên bất kỳ, kể cả 0 hoặc âm)
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * getYearDetails(2024);
164
+ * // → { can: 'Giáp', chi: 'Thìn', menh: 'Thủy', fullString: 'Giáp Thìn - Mệnh Thủy' }
165
+ * ```
166
+ */
167
+ declare function getYearDetails(year: number): YearDetails;
85
168
  /**
86
169
  * Tính Can Chi ngày từ Julian Day Number.
87
170
  *
88
171
  * @param jd - Julian Day Number
172
+ * @param locale - Ngôn ngữ hiển thị (mặc định: 'vi', giữ nguyên hành vi cũ)
89
173
  * @returns Chuỗi Can Chi (ví dụ: "Giáp Tý")
90
174
  */
91
- declare function getDayCanChi(jd: number): string;
175
+ declare function getDayCanChi(jd: number, locale?: Locale): string;
92
176
  /**
93
177
  * Tính Can Chi tháng từ tháng và năm âm lịch.
94
178
  * Can tháng phụ thuộc vào Can của năm (quy tắc Ngũ Hổ Độn):
@@ -100,8 +184,9 @@ declare function getDayCanChi(jd: number): string;
100
184
  *
101
185
  * @param lunarMonth - Tháng âm lịch (1-12)
102
186
  * @param lunarYear - Năm âm lịch
187
+ * @param locale - Ngôn ngữ hiển thị (mặc định: 'vi', giữ nguyên hành vi cũ)
103
188
  */
104
- declare function getMonthCanChi(lunarMonth: number, lunarYear: number): string;
189
+ declare function getMonthCanChi(lunarMonth: number, lunarYear: number, locale?: Locale): string;
105
190
  /**
106
191
  * Tính Can Chi giờ từ giờ (0-23) và Julian Day Number của ngày.
107
192
  *
@@ -117,16 +202,30 @@ declare function getMonthCanChi(lunarMonth: number, lunarYear: number): string;
117
202
  *
118
203
  * @param hour - Giờ (0-23)
119
204
  * @param dayJd - Julian Day Number của ngày
205
+ * @param locale - Ngôn ngữ hiển thị (mặc định: 'vi', giữ nguyên hành vi cũ)
120
206
  */
121
- declare function getHourCanChi(hour: number, dayJd: number): string;
207
+ declare function getHourCanChi(hour: number, dayJd: number, locale?: Locale): string;
122
208
  /**
123
209
  * Lấy danh sách 6 giờ Hoàng Đạo trong ngày.
124
210
  * Giờ Hoàng Đạo phụ thuộc vào Địa Chi của ngày.
125
211
  *
126
212
  * @param dayJd - Julian Day Number của ngày
213
+ * @param locale - Ngôn ngữ hiển thị (mặc định: 'vi', giữ nguyên hành vi cũ)
127
214
  * @returns Mảng 6 chuỗi tên Địa Chi (ví dụ: ["Tý", "Sửu", "Mão", "Ngọ", "Mùi", "Dậu"])
128
215
  */
129
- declare function getAuspiciousHours(dayJd: number): string[];
216
+ declare function getAuspiciousHours(dayJd: number, locale?: Locale): string[];
217
+ /**
218
+ * Lấy index (0-11, theo thứ tự Địa Chi Tý→Hợi) của 6 giờ Hoàng Đạo trong ngày.
219
+ *
220
+ * Dùng khi cần một khoá ổn định, không phụ thuộc ngôn ngữ — ví dụ để map sang
221
+ * icon riêng, hoặc tự tra bảng dịch của bạn thay vì dùng chuỗi tên có sẵn từ
222
+ * {@link getAuspiciousHours}. Cả hai hàm dùng chung thứ tự dữ liệu nên
223
+ * `getAuspiciousHourIndices(jd)[i]` luôn tương ứng với `getAuspiciousHours(jd)[i]`.
224
+ *
225
+ * @param dayJd - Julian Day Number của ngày
226
+ * @returns Mảng 6 index Địa Chi (ví dụ: [0, 1, 3, 6, 7, 9])
227
+ */
228
+ declare function getAuspiciousHourIndices(dayJd: number): number[];
130
229
 
131
230
  /**
132
231
  * Lấy tên tháng âm lịch dạng chữ truyền thống.
@@ -170,13 +269,14 @@ declare function getDayName(day: number): string;
170
269
  * | `M` | Tháng | 1, 12 |
171
270
  * | `yyyy`| Năm 4 chữ số | 2024 |
172
271
  * | `yy` | Năm 2 chữ số cuối | 24 |
173
- * | `L` | "Nhuận" nếu tháng nhuận, "" nếu không | Nhuận |
272
+ * | `L` | Nhãn tháng nhuận theo `locale` (xem tham số `locale`), "" nếu không phải tháng nhuận | Nhuận |
174
273
  * | `CC` | Can Chi năm | Giáp Thìn |
175
274
  * | `DC` | Can Chi ngày | Giáp Tý |
176
275
  * | `MC` | Can Chi tháng | Bính Dần |
177
276
  *
178
277
  * @param lunar - Đối tượng LunarDate
179
278
  * @param pattern - Chuỗi pattern
279
+ * @param locale - Ngôn ngữ cho token `L` (mặc định: 'vi', giữ nguyên hành vi cũ — "Nhuận")
180
280
  *
181
281
  * @example
182
282
  * ```typescript
@@ -187,7 +287,7 @@ declare function getDayName(day: number): string;
187
287
  * // → "Ngày 1 tháng 1 năm Giáp Thìn"
188
288
  * ```
189
289
  */
190
- declare function formatLunarDate(lunar: LunarDate, pattern: string): string;
290
+ declare function formatLunarDate(lunar: LunarDate, pattern: string, locale?: Locale): string;
191
291
  /**
192
292
  * Format ngày âm lịch theo kiểu truyền thống Việt Nam.
193
293
  *
@@ -202,64 +302,26 @@ declare function formatLunarDate(lunar: LunarDate, pattern: string): string;
202
302
  */
203
303
  declare function formatTraditional(lunar: LunarDate): string;
204
304
 
305
+ /** Một ô ngày trong lưới lịch tháng. */
306
+ interface CalendarDayCell {
307
+ solar: Date;
308
+ lunar: LunarDate;
309
+ isToday: boolean;
310
+ isSelected: boolean;
311
+ isCurrentMonth: boolean;
312
+ }
205
313
  /**
206
- * Internationalization Hỗ trợ song ngữ Việt-Anh
207
- */
208
- type Locale = 'vi' | 'en' | 'ja' | 'ko';
209
- /**
210
- * Lấy bộ dịch theo locale
211
- * @param locale - Ngôn ngữ ('vi' | 'en' | 'ja' | 'ko')
212
- */
213
- declare function t(locale: Locale): {
214
- readonly heavenlyStems: readonly ["Giáp", "Ất", "Bính", "Đinh", "Mậu", "Kỷ", "Canh", "Tân", "Nhâm", "Quý"];
215
- readonly earthlyBranches: readonly ["Tý", "Sửu", "Dần", "Mão", "Thìn", "Tỵ", "Ngọ", "Mùi", "Thân", "Dậu", "Tuất", "Hợi"];
216
- readonly fiveElements: readonly ["Kim", "Mộc", "Thủy", "Hỏa", "Thổ"];
217
- readonly zodiacAnimals: readonly ["Chuột", "Trâu", "Cọp", "Thỏ", "Rồng", "Rắn", "Ngựa", "Dê", "Khỉ", "Gà", "Chó", "Heo"];
218
- readonly monthNames: readonly ["Giêng", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy", "Tám", "Chín", "Mười", "Một", "Chạp"];
219
- readonly weekDays: readonly ["CN", "T2", "T3", "T4", "T5", "T6", "T7"];
220
- readonly leapLabel: "Nhuận";
221
- readonly yearLabel: "Năm";
222
- readonly monthLabel: "Tháng";
223
- readonly destiny: "Mệnh";
224
- } | {
225
- readonly heavenlyStems: readonly ["Giáp", "Ất", "Bính", "Đinh", "Mậu", "Kỷ", "Canh", "Tân", "Nhâm", "Quý"];
226
- readonly earthlyBranches: readonly ["Tý", "Sửu", "Dần", "Mão", "Thìn", "Tỵ", "Ngọ", "Mùi", "Thân", "Dậu", "Tuất", "Hợi"];
227
- readonly fiveElements: readonly ["Metal", "Wood", "Water", "Fire", "Earth"];
228
- readonly zodiacAnimals: readonly ["Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"];
229
- readonly monthNames: readonly ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
230
- readonly weekDays: readonly ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
231
- readonly leapLabel: "Leap";
232
- readonly yearLabel: "Year";
233
- readonly monthLabel: "Month";
234
- readonly destiny: "Destiny";
235
- } | {
236
- readonly heavenlyStems: readonly ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"];
237
- readonly earthlyBranches: readonly ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"];
238
- readonly fiveElements: readonly ["金", "木", "水", "火", "土"];
239
- readonly zodiacAnimals: readonly ["鼠", "牛", "虎", "兎", "竜", "蛇", "馬", "羊", "猿", "鶏", "犬", "猪"];
240
- readonly monthNames: readonly ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"];
241
- readonly weekDays: readonly ["日", "月", "火", "水", "木", "金", "土"];
242
- readonly leapLabel: "閏";
243
- readonly yearLabel: "年";
244
- readonly monthLabel: "月";
245
- readonly destiny: "命";
246
- } | {
247
- readonly heavenlyStems: readonly ["갑", "을", "병", "정", "무", "기", "경", "신", "임", "계"];
248
- readonly earthlyBranches: readonly ["자", "축", "인", "묘", "진", "사", "오", "미", "신", "유", "술", "해"];
249
- readonly fiveElements: readonly ["금", "목", "수", "화", "토"];
250
- readonly zodiacAnimals: readonly ["쥐", "소", "호랑이", "토끼", "용", "뱀", "말", "양", "원숭이", "닭", "개", "돼지"];
251
- readonly monthNames: readonly ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"];
252
- readonly weekDays: readonly ["일", "월", "화", "수", "목", "금", "토"];
253
- readonly leapLabel: "윤";
254
- readonly yearLabel: "년";
255
- readonly monthLabel: "월";
256
- readonly destiny: "명";
257
- };
258
- /**
259
- * Lấy tên con giáp theo locale
260
- * @param branchIndex - Index Địa Chi (0-11)
261
- * @param locale - Ngôn ngữ
314
+ * Dựng lưới 42 ô (6 tuần x 7 ngày) cho 1 tháng dương lịch, gồm ngày tràn từ
315
+ * tháng trước/sau để lấp đầy tuần đầu/cuối, mỗi ô kèm ngày âm tương ứng.
316
+ *
317
+ * Logic này trước đây bị lặp lại độc lập ở Calendar.tsx/vue/svelte — tách ra
318
+ * đây để 1 nguồn tính toán duy nhất (tránh 3 bản có thể lệch nhau khi sửa
319
+ * riêng lẻ), dùng chung cho cả Calendar DatePicker mọi framework.
320
+ *
321
+ * @param month - Tháng dương lịch (1-12)
322
+ * @param year - Năm dương lịch
323
+ * @param selectedDate - Ngày đang được chọn (nếu có), dùng để đánh dấu `isSelected`
262
324
  */
263
- declare function getZodiacAnimal(branchIndex: number, locale?: Locale): string;
325
+ declare function getCalendarGrid(month: number, year: number, selectedDate?: Date | null): CalendarDayCell[];
264
326
 
265
- export { LichTa, type Locale, type LunarDate, type SolarDate, formatLunarDate, formatTraditional, getAuspiciousHours, getDayCanChi, getDayName, getHourCanChi, getMonthCanChi, getMonthName, getYearDetails, getZodiacAnimal, jdFromDate, jdToDate, t };
327
+ export { type CalendarDayCell, LichTa, type Locale, type LunarDate, type SolarDate, type YearDetails, formatLunarDate, formatTraditional, getAuspiciousHourIndices, getAuspiciousHours, getCalendarGrid, getDayCanChi, getDayName, getHourCanChi, getMonthCanChi, getMonthName, getYearDetails, getZodiacAnimal, jdFromDate, jdToDate, t };