lichta 1.0.0 → 1.0.1

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
@@ -65,7 +65,13 @@ const lunarChina = LichTa.toLunar(10, 2, 2024, 8); // GMT+8
65
65
  ### Sexagenary Cycle & Feng Shui (Can Chi & Phong Thủy)
66
66
 
67
67
  ```typescript
68
- import { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from 'lichta/core';
68
+ import {
69
+ getYearDetails,
70
+ getDayCanChi,
71
+ getMonthCanChi,
72
+ getHourCanChi,
73
+ getAuspiciousHours
74
+ } from 'lichta/core';
69
75
 
70
76
  // Can Chi + Element for the year
71
77
  getYearDetails(2024);
@@ -74,7 +80,7 @@ getYearDetails(2024);
74
80
 
75
81
  // Day Can Chi (requires Julian Day Number)
76
82
  const lunar = LichTa.toLunar(10, 2, 2024);
77
- getDayCanChi(lunar.jd); // → 'Giáp Tý'
83
+ getDayCanChi(lunar.jd); // → 'Giáp Tý'
78
84
 
79
85
  // Month Can Chi
80
86
  getMonthCanChi(1, 2024); // → month Giêng year Giáp Thìn
@@ -99,46 +105,42 @@ formatTraditional(lunar);
99
105
  // → 'Mùng Một tháng Giêng năm Giáp Thìn'
100
106
 
101
107
  // Pattern format
102
- formatLunarDate(lunar, 'dd/MM/yyyy'); // → '01/01/2024'
103
- formatLunarDate(lunar, 'CC'); // → 'Giáp Thìn'
104
- formatLunarDate(lunar, 'Ngày DC'); // → 'Ngày Giáp Tý'
108
+ formatLunarDate(lunar, 'dd/MM/yyyy'); // → '01/01/2024'
109
+ formatLunarDate(lunar, 'CC'); // → 'Giáp Thìn'
110
+ formatLunarDate(lunar, 'Ngày DC'); // → 'Ngày Giáp Tý'
105
111
 
106
112
  // Traditional names
107
- getMonthName(1); // → 'Giêng'
113
+ getMonthName(1); // → 'Giêng'
108
114
  getMonthName(12); // → 'Chạp'
109
- getDayName(1); // → 'Mùng Một'
110
- getDayName(15); // → 'Rằm'
111
- getDayName(30); // → 'Ba Mươi'
115
+ getDayName(1); // → 'Mùng Một'
116
+ getDayName(15); // → 'Rằm'
117
+ getDayName(30); // → 'Ba Mươi'
112
118
  ```
113
119
 
114
120
  **Format tokens:**
115
121
 
116
- | Token | Description | Example |
117
- |--------|-------------------------------|--------------|
118
- | `dd` | 2-digit day | 01, 15 |
119
- | `d` | Day | 1, 15 |
120
- | `MM` | 2-digit month | 01, 12 |
121
- | `M` | Month | 1, 12 |
122
- | `yyyy` | 4-digit year | 2024 |
123
- | `yy` | Last 2 digits of year | 24 |
124
- | `CC` | Year Can Chi | Giáp Thìn |
125
- | `DC` | Day Can Chi | Giáp Tý |
126
- | `MC` | Month Can Chi | Bính Dần |
127
- | `L` | "Nhuận" if leap month | Nhuận |
122
+ | Token | Description | Example |
123
+ | ------ | --------------------- | --------- |
124
+ | `dd` | 2-digit day | 01, 15 |
125
+ | `d` | Day | 1, 15 |
126
+ | `MM` | 2-digit month | 01, 12 |
127
+ | `M` | Month | 1, 12 |
128
+ | `yyyy` | 4-digit year | 2024 |
129
+ | `yy` | Last 2 digits of year | 24 |
130
+ | `CC` | Year Can Chi | Giáp Thìn |
131
+ | `DC` | Day Can Chi | Giáp Tý |
132
+ | `MC` | Month Can Chi | Bính Dần |
133
+ | `L` | "Nhuận" if leap month | Nhuận |
128
134
 
129
135
  ### Svelte 5 Components
130
136
 
131
137
  ```svelte
132
138
  <script>
133
- import { Calendar, Formatter } from 'lichta';
139
+ import { Calendar, Formatter } from 'lichta';
134
140
  </script>
135
141
 
136
142
  <!-- Full monthly calendar -->
137
- <Calendar
138
- showLunar={true}
139
- locale="vi"
140
- onSelect={(date, lunar) => console.log(date, lunar)}
141
- />
143
+ <Calendar showLunar={true} locale="vi" onSelect={(date, lunar) => console.log(date, lunar)} />
142
144
 
143
145
  <!-- Lunar date formatter -->
144
146
  <Formatter date={new Date()} />
@@ -146,15 +148,15 @@ getDayName(30); // → 'Ba Mươi'
146
148
 
147
149
  #### Calendar Props
148
150
 
149
- | Prop | Type | Default | Description |
150
- |----------------|-----------------------------------------------|-------------------|-------------------------------|
151
- | `month` | `number` | Current month | Displayed month (1-12) |
152
- | `year` | `number` | Current year | Displayed year |
153
- | `selectedDate` | `Date \| null` | `null` | Selected date |
154
- | `onSelect` | `(date: Date, lunar: LunarDate) => void` | — | Callback on date select |
155
- | `showLunar` | `boolean` | `true` | Show lunar dates |
156
- | `locale` | `'vi' \| 'en' \| 'ja' \| 'ko'` | `'vi'` | Language |
157
- | `dayCell` | `Snippet` | — | Custom snippet for day cell |
151
+ | Prop | Type | Default | Description |
152
+ | -------------- | ---------------------------------------- | ------------- | --------------------------- |
153
+ | `month` | `number` | Current month | Displayed month (1-12) |
154
+ | `year` | `number` | Current year | Displayed year |
155
+ | `selectedDate` | `Date \| null` | `null` | Selected date |
156
+ | `onSelect` | `(date: Date, lunar: LunarDate) => void` | — | Callback on date select |
157
+ | `showLunar` | `boolean` | `true` | Show lunar dates |
158
+ | `locale` | `'vi' \| 'en' \| 'ja' \| 'ko'` | `'vi'` | Language |
159
+ | `dayCell` | `Snippet` | — | Custom snippet for day cell |
158
160
 
159
161
  #### Theming
160
162
 
@@ -162,14 +164,14 @@ The Calendar supports CSS custom properties:
162
164
 
163
165
  ```css
164
166
  :root {
165
- --lichta-primary: #d4a373;
166
- --lichta-bg: #fffcf7;
167
- --lichta-text: #2c1810;
168
- --lichta-today-bg: #d4a373;
169
- --lichta-selected-bg: #a0522d;
170
- --lichta-lunar-text: #b08968;
171
- --lichta-radius: 8px;
172
- --lichta-font: 'Inter', sans-serif;
167
+ --lichta-primary: #d4a373;
168
+ --lichta-bg: #fffcf7;
169
+ --lichta-text: #2c1810;
170
+ --lichta-today-bg: #d4a373;
171
+ --lichta-selected-bg: #a0522d;
172
+ --lichta-lunar-text: #b08968;
173
+ --lichta-radius: 8px;
174
+ --lichta-font: 'Inter', sans-serif;
173
175
  }
174
176
  ```
175
177
 
@@ -180,20 +182,20 @@ import { t, getZodiacAnimal } from 'lichta';
180
182
 
181
183
  // Get dictionary
182
184
  const vi = t('vi');
183
- vi.heavenlyStems; // ['Giáp', 'Ất', ...]
185
+ vi.heavenlyStems; // ['Giáp', 'Ất', ...]
184
186
  vi.earthlyBranches; // ['Tý', 'Sửu', ...]
185
- vi.fiveElements; // ['Kim', 'Mộc', 'Thủy', 'Hỏa', 'Thổ']
186
- vi.monthNames; // ['Giêng', 'Hai', ..., 'Chạp']
187
+ vi.fiveElements; // ['Kim', 'Mộc', 'Thủy', 'Hỏa', 'Thổ']
188
+ vi.monthNames; // ['Giêng', 'Hai', ..., 'Chạp']
187
189
 
188
190
  const en = t('en');
189
- en.fiveElements; // ['Metal', 'Wood', 'Water', 'Fire', 'Earth']
190
- en.zodiacAnimals; // ['Rat', 'Ox', 'Tiger', ...]
191
+ en.fiveElements; // ['Metal', 'Wood', 'Water', 'Fire', 'Earth']
192
+ en.zodiacAnimals; // ['Rat', 'Ox', 'Tiger', ...]
191
193
 
192
194
  const ja = t('ja');
193
- ja.weekDays; // ['日', '月', '火', '水', '木', '金', '土']
195
+ ja.weekDays; // ['日', '月', '火', '水', '木', '金', '土']
194
196
 
195
197
  const ko = t('ko');
196
- ko.fiveElements; // ['금', '목', '수', '화', '토']
198
+ ko.fiveElements; // ['금', '목', '수', '화', '토']
197
199
 
198
200
  // Zodiac animal by year
199
201
  getZodiacAnimal(0, 'vi'); // → 'Chuột'
@@ -205,11 +207,11 @@ getZodiacAnimal(0, 'ja'); // → '鼠'
205
207
 
206
208
  ## 📁 Import Paths
207
209
 
208
- | Path | Content | Used for |
209
- |-----------------|-----------------------------------|-------------------------------|
210
- | `lichta` | Full API + Svelte components | Svelte 5 projects |
211
- | `lichta/core` | Pure TypeScript logic | React, Vue, Angular, vanilla |
212
- | `lichta/utils` | Format utilities | Any framework |
210
+ | Path | Content | Used for |
211
+ | -------------- | ---------------------------- | ---------------------------- |
212
+ | `lichta` | Full API + Svelte components | Svelte 5 projects |
213
+ | `lichta/core` | Pure TypeScript logic | React, Vue, Angular, vanilla |
214
+ | `lichta/utils` | Format utilities | Any framework |
213
215
 
214
216
  ```typescript
215
217
  // Svelte 5 — import everything
@@ -246,4 +248,4 @@ See details in [docs/ALGORITHM.md](./docs/ALGORITHM.md).
246
248
  ## 🙏 Credits
247
249
 
248
250
  - **Ho Ngoc Duc** — Original algorithm ([informatik.uni-leipzig.de](http://www.informatik.uni-leipzig.de/~duc/amlich/))
249
- - **Jean Meeus** — *Astronomical Algorithms* (1998)
251
+ - **Jean Meeus** — _Astronomical Algorithms_ (1998)
@@ -1,57 +1,57 @@
1
1
  <script lang="ts">
2
- import { LichTa } from '../core/lunar.js';
3
- import type { LunarDate } from '../core/types.js';
4
- import type { Snippet } from 'svelte';
2
+ import { LichTa } from '../core/lunar.js';
3
+ import type { LunarDate } from '../core/types.js';
4
+ import type { Snippet } from 'svelte';
5
5
 
6
- // Props nhận vào từ consumer ứng dụng
7
- interface Props {
8
- date?: Date;
9
- children?: Snippet;
10
- }
11
- let { date = new Date(), children }: Props = $props();
6
+ // Props nhận vào từ consumer ứng dụng
7
+ interface Props {
8
+ date?: Date;
9
+ children?: Snippet;
10
+ }
11
+ let { date = new Date(), children }: Props = $props();
12
12
 
13
- // Khai báo biến reactive tự động tính toán lại khi `date` thay đổi
14
- let lunar: LunarDate = $derived.by(() => {
15
- const d = date.getDate();
16
- const m = date.getMonth() + 1; // Tháng trong JS tính từ 0
17
- const y = date.getFullYear();
18
- return LichTa.toLunar(d, m, y);
19
- });
13
+ // Khai báo biến reactive tự động tính toán lại khi `date` thay đổi
14
+ let lunar: LunarDate = $derived.by(() => {
15
+ const d = date.getDate();
16
+ const m = date.getMonth() + 1; // Tháng trong JS tính từ 0
17
+ const y = date.getFullYear();
18
+ return LichTa.toLunar(d, m, y);
19
+ });
20
20
  </script>
21
21
 
22
22
  <div class="lich-ta-formatter">
23
- <div class="lunar-display-banner">
24
- <span class="lunar-date">Ngày {lunar.day} tháng {lunar.month} (Âm lịch)</span>
25
- <span class="can-chi-details">Năm {lunar.yearCanChi}</span>
26
- </div>
23
+ <div class="lunar-display-banner">
24
+ <span class="lunar-date">Ngày {lunar.day} tháng {lunar.month} (Âm lịch)</span>
25
+ <span class="can-chi-details">Năm {lunar.yearCanChi}</span>
26
+ </div>
27
27
 
28
- <div class="control-slot-wrapper">
29
- {@render children?.()}
30
- </div>
28
+ <div class="control-slot-wrapper">
29
+ {@render children?.()}
30
+ </div>
31
31
  </div>
32
32
 
33
33
  <style>
34
- .lich-ta-formatter {
35
- display: block;
36
- width: 100%;
37
- box-sizing: border-box;
38
- }
39
- .lunar-display-banner {
40
- padding: 12px;
41
- background-color: #fcfaf7;
42
- border-left: 4px solid #d4a373;
43
- margin-bottom: 16px;
44
- }
45
- .lunar-date {
46
- display: block;
47
- font-weight: bold;
48
- font-size: 1.1rem;
49
- color: #1a1a1a;
50
- }
51
- .can-chi-details {
52
- display: block;
53
- font-size: 0.9rem;
54
- color: #666666;
55
- margin-top: 4px;
56
- }
57
- </style>
34
+ .lich-ta-formatter {
35
+ display: block;
36
+ width: 100%;
37
+ box-sizing: border-box;
38
+ }
39
+ .lunar-display-banner {
40
+ padding: 12px;
41
+ background-color: #fcfaf7;
42
+ border-left: 4px solid #d4a373;
43
+ margin-bottom: 16px;
44
+ }
45
+ .lunar-date {
46
+ display: block;
47
+ font-weight: bold;
48
+ font-size: 1.1rem;
49
+ color: #1a1a1a;
50
+ }
51
+ .can-chi-details {
52
+ display: block;
53
+ font-size: 0.9rem;
54
+ color: #666666;
55
+ margin-top: 4px;
56
+ }
57
+ </style>
@@ -1,3 +1,3 @@
1
1
  export { LichTa, jdFromDate, jdToDate, getNewMoonDay, getSunLongitude } from './lunar.js';
2
- export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours, } from './feng-shui.js';
2
+ export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from './feng-shui.js';
3
3
  export type { LunarDate, SolarDate } from './types.js';
@@ -1,4 +1,4 @@
1
1
  // Xuất bản phần lõi TypeScript — KHÔNG có Svelte dependencies
2
2
  // Dành cho React, Vue, Angular, vanilla JS consumers
3
3
  export { LichTa, jdFromDate, jdToDate, getNewMoonDay, getSunLongitude } from './lunar.js';
4
- export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours, } from './feng-shui.js';
4
+ export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from './feng-shui.js';
@@ -279,7 +279,7 @@ export class LichTa {
279
279
  jd: dayNumber,
280
280
  dayCanChi,
281
281
  monthCanChi,
282
- yearCanChi,
282
+ yearCanChi
283
283
  };
284
284
  }
285
285
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { LichTa, jdFromDate, jdToDate } from './core/lunar.js';
2
2
  export type { LunarDate, SolarDate } from './core/types.js';
3
- export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours, } from './core/feng-shui.js';
3
+ export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from './core/feng-shui.js';
4
4
  export { formatLunarDate, formatTraditional, getMonthName, getDayName } from './utils/format.js';
5
5
  export { t, getZodiacAnimal } from './constants/i18n.js';
6
6
  export type { Locale } from './constants/i18n.js';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // Xuất bản phần lõi TypeScript (Cho những ai chỉ muốn dùng logic toán học)
5
5
  export { LichTa, jdFromDate, jdToDate } from './core/lunar.js';
6
6
  // Xuất bản phần phong thủy
7
- export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours, } from './core/feng-shui.js';
7
+ export { getYearDetails, getDayCanChi, getMonthCanChi, getHourCanChi, getAuspiciousHours } from './core/feng-shui.js';
8
8
  // Xuất bản phần format/tiện ích
9
9
  export { formatLunarDate, formatTraditional, getMonthName, getDayName } from './utils/format.js';
10
10
  // Xuất bản phần i18n
@@ -3,13 +3,32 @@
3
3
  // ============================================================
4
4
  /** Tên tháng âm lịch truyền thống */
5
5
  const MONTH_NAMES = [
6
- 'Giêng', 'Hai', 'Ba', 'Tư', 'Năm', 'Sáu',
7
- 'Bảy', 'Tám', 'Chín', 'Mười', 'Một', 'Chạp',
6
+ 'Giêng',
7
+ 'Hai',
8
+ 'Ba',
9
+ 'Tư',
10
+ 'Năm',
11
+ 'Sáu',
12
+ 'Bảy',
13
+ 'Tám',
14
+ 'Chín',
15
+ 'Mười',
16
+ 'Một',
17
+ 'Chạp'
8
18
  ];
9
19
  /** Tên số đếm truyền thống */
10
20
  const DAY_UNITS = [
11
- '', 'Một', 'Hai', 'Ba', 'Bốn', 'Năm',
12
- 'Sáu', 'Bảy', 'Tám', 'Chín', 'Mười',
21
+ '',
22
+ 'Một',
23
+ 'Hai',
24
+ 'Ba',
25
+ 'Bốn',
26
+ 'Năm',
27
+ 'Sáu',
28
+ 'Bảy',
29
+ 'Tám',
30
+ 'Chín',
31
+ 'Mười'
13
32
  ];
14
33
  /**
15
34
  * Lấy tên tháng âm lịch dạng chữ truyền thống.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lichta",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Thư viện chuyển đổi Dương lịch ↔ Âm lịch Việt Nam. Vietnamese lunar calendar conversion library with Svelte 5 components.",
5
5
  "author": "Zeforc | Stridev",
6
6
  "license": "MIT",
@@ -58,6 +58,11 @@
58
58
  "@sveltejs/package": "^2.5.8",
59
59
  "@sveltejs/vite-plugin-svelte": "^7.1.2",
60
60
  "@types/node": "^22",
61
+ "@event-calendar/core": "^5.7.1",
62
+ "@event-calendar/day-grid": "^3.12.0",
63
+ "@fullcalendar/core": "^6.1.20",
64
+ "@fullcalendar/daygrid": "^6.1.20",
65
+ "moment": "^2.30.1",
61
66
  "eslint": "^10.4.1",
62
67
  "eslint-config-prettier": "^10.1.8",
63
68
  "eslint-plugin-svelte": "^3.19.0",
@@ -68,6 +73,9 @@
68
73
  "prettier": "^3.8.3",
69
74
  "prettier-plugin-svelte": "^4.1.0",
70
75
  "publint": "^0.3.21",
76
+ "react": "^19.2.7",
77
+ "react-big-calendar": "^1.20.0",
78
+ "react-dom": "^19.2.7",
71
79
  "svelte": "^5.56.1",
72
80
  "svelte-check": "^4.6.0",
73
81
  "typescript": "^6.0.3",
@@ -93,15 +101,5 @@
93
101
  "bugs": {
94
102
  "url": "https://github.com/zeforc/lichta/issues"
95
103
  },
96
- "homepage": "https://github.com/zeforc/lichta#readme",
97
- "dependencies": {
98
- "@event-calendar/core": "^5.7.1",
99
- "@event-calendar/day-grid": "^3.12.0",
100
- "@fullcalendar/core": "^6.1.20",
101
- "@fullcalendar/daygrid": "^6.1.20",
102
- "moment": "^2.30.1",
103
- "react": "^19.2.7",
104
- "react-big-calendar": "^1.20.0",
105
- "react-dom": "^19.2.7"
106
- }
104
+ "homepage": "https://github.com/zeforc/lichta#readme"
107
105
  }