@lichta/full-calendar 2.0.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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/index.cjs +87 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zeforc Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @lichta/full-calendar
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@lichta/full-calendar)
|
|
4
|
+
|
|
5
|
+
Plugin/Adapter tích hợp lịch âm Việt Nam (LichTa) vào thư viện [FullCalendar](https://fullcalendar.io/).
|
|
6
|
+
|
|
7
|
+
## Cài đặt
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @lichta/full-calendar @fullcalendar/core @fullcalendar/daygrid
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Cách sử dụng cơ bản
|
|
14
|
+
|
|
15
|
+
Bạn chỉ cần bọc cấu hình gốc của FullCalendar bằng hàm `injectLunarDates`. Adapter sẽ tự động tính toán và tiêm (inject) ngày âm lịch vào các ô ngày trên giao diện lịch.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Calendar } from '@fullcalendar/core';
|
|
19
|
+
import dayGridPlugin from '@fullcalendar/daygrid';
|
|
20
|
+
import { injectLunarDates } from '@lichta/full-calendar';
|
|
21
|
+
|
|
22
|
+
const calendarEl = document.getElementById('calendar');
|
|
23
|
+
|
|
24
|
+
const calendarOptions = injectLunarDates({
|
|
25
|
+
plugins: [dayGridPlugin],
|
|
26
|
+
initialView: 'dayGridMonth'
|
|
27
|
+
// ... các options gốc của FullCalendar
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
let calendar = new Calendar(calendarEl, calendarOptions);
|
|
31
|
+
calendar.render();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Tùy chọn giao diện (Options)
|
|
35
|
+
|
|
36
|
+
Hàm `injectLunarDates(options, pluginOptions)` nhận đối số thứ hai để cấu hình giao diện cho ngày âm lịch:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const calendarOptions = injectLunarDates(baseOptions, {
|
|
40
|
+
// Chỉ hiển thị tháng khi là mùng 1 (vd: "1/4" thay vì "1")
|
|
41
|
+
monthOnFirstDayOnly: false,
|
|
42
|
+
|
|
43
|
+
// Hiển thị "(Nhuận)" cho các tháng nhuận âm lịch
|
|
44
|
+
showLeapMonth: true,
|
|
45
|
+
|
|
46
|
+
// Hiển thị Can Chi khi hover chuột vào (Tooltip)
|
|
47
|
+
showTooltip: true,
|
|
48
|
+
|
|
49
|
+
// Tùy chỉnh màu chữ
|
|
50
|
+
color: '#888',
|
|
51
|
+
|
|
52
|
+
// Tùy chỉnh class CSS (hữu ích khi dùng Tailwind)
|
|
53
|
+
className: 'lichta-fc-lunar',
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Tùy chỉnh hoàn toàn bằng hàm `render`
|
|
58
|
+
|
|
59
|
+
Nếu bạn muốn kiểm soát hoàn toàn mã HTML của phần hiển thị ngày âm lịch, hãy sử dụng thuộc tính `render`:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const calendarOptions = injectLunarDates(baseOptions, {
|
|
63
|
+
render: (lunarDate) => {
|
|
64
|
+
return `<div class="custom-lunar">
|
|
65
|
+
🌙 ${lunarDate.day}/${lunarDate.month}
|
|
66
|
+
</div>`;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Phụ thuộc (Dependencies)
|
|
72
|
+
- **@lichta/core**: workspace dependency (tự động cài kèm)
|
|
73
|
+
- **@fullcalendar/core**: ^6.0.0 (peer dependency)
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
[MIT](./LICENSE)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
injectLunarDates: () => injectLunarDates
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_core = require("@lichta/core");
|
|
27
|
+
function injectLunarDates(options, pluginOptions = {}) {
|
|
28
|
+
const originalDayCellContent = options.dayCellContent;
|
|
29
|
+
const {
|
|
30
|
+
monthOnFirstDayOnly = false,
|
|
31
|
+
showLeapMonth = true,
|
|
32
|
+
showTooltip = true,
|
|
33
|
+
color = "#888",
|
|
34
|
+
className = "lichta-fc-lunar",
|
|
35
|
+
render
|
|
36
|
+
} = pluginOptions;
|
|
37
|
+
options.dayCellContent = function(arg) {
|
|
38
|
+
const date = arg.date;
|
|
39
|
+
const day = date.getDate();
|
|
40
|
+
const month = date.getMonth() + 1;
|
|
41
|
+
const year = date.getFullYear();
|
|
42
|
+
const lunar = import_core.LichTa.toLunar(day, month, year);
|
|
43
|
+
let customLunarHtml = "";
|
|
44
|
+
if (render) {
|
|
45
|
+
customLunarHtml = render(lunar);
|
|
46
|
+
} else {
|
|
47
|
+
let lunarText = `${lunar.day}`;
|
|
48
|
+
if (!monthOnFirstDayOnly || lunar.day === 1) {
|
|
49
|
+
lunarText = `${lunar.day}/${lunar.month}`;
|
|
50
|
+
}
|
|
51
|
+
if (showLeapMonth && lunar.isLeap) {
|
|
52
|
+
lunarText += " (Nhu\u1EADn)";
|
|
53
|
+
}
|
|
54
|
+
let tooltipAttr = "";
|
|
55
|
+
if (showTooltip) {
|
|
56
|
+
const canChi = (0, import_core.getDayCanChi)(lunar.jd);
|
|
57
|
+
tooltipAttr = `title="Ng\xE0y ${canChi}"`;
|
|
58
|
+
}
|
|
59
|
+
customLunarHtml = `<div class="${className}" style="font-size: 0.8em; color: ${color}; margin-top: 2px;" ${tooltipAttr}>${lunarText}</div>`;
|
|
60
|
+
}
|
|
61
|
+
let originalContent = "";
|
|
62
|
+
if (originalDayCellContent) {
|
|
63
|
+
const orig = typeof originalDayCellContent === "function" ? originalDayCellContent(arg) : originalDayCellContent;
|
|
64
|
+
if (orig?.html) {
|
|
65
|
+
originalContent = orig.html;
|
|
66
|
+
} else if (typeof orig === "string") {
|
|
67
|
+
originalContent = orig;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
originalContent = `<div class="lichta-fc-day-text" style="padding: 0; text-decoration: none;">${day}</div>`;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
html: `
|
|
74
|
+
<div class="lichta-fc-cell" style="display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
|
75
|
+
${originalContent}
|
|
76
|
+
${customLunarHtml}
|
|
77
|
+
</div>
|
|
78
|
+
`
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
return options;
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
injectLunarDates
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { LichTa, getDayCanChi } from '@lichta/core';\nimport type { LunarDate } from '@lichta/core';\n\nexport interface LichTaOptions {\n /**\n * Chỉ hiển thị tháng khi là mùng 1 âm lịch (ví dụ: \"1/4\" thay vì \"1\").\n * Mặc định: false\n */\n monthOnFirstDayOnly?: boolean;\n\n /**\n * Hiển thị chữ \"Nhuận\" nếu rơi vào tháng nhuận âm lịch.\n * Mặc định: true\n */\n showLeapMonth?: boolean;\n\n /**\n * Hiển thị Can Chi của ngày khi hover chuột vào (Tooltip).\n * Mặc định: true\n */\n showTooltip?: boolean;\n\n /**\n * Màu chữ tùy chỉnh cho ngày âm lịch.\n * Mặc định: '#888'\n */\n color?: string;\n\n /**\n * Class CSS tùy chỉnh cho thẻ div chứa ngày âm lịch.\n */\n className?: string;\n\n /**\n * Tùy chọn render HTML nâng cao.\n */\n render?: (lunar: LunarDate) => string;\n}\n\n/**\n * Attaches LichTa lunar dates to FullCalendar options.\n */\nexport function injectLunarDates(options: any, pluginOptions: LichTaOptions = {}) {\n const originalDayCellContent = options.dayCellContent;\n\n const {\n monthOnFirstDayOnly = false,\n showLeapMonth = true,\n showTooltip = true,\n color = '#888',\n className = 'lichta-fc-lunar',\n render\n } = pluginOptions;\n\n options.dayCellContent = function (arg: any) {\n const date = arg.date;\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n\n const lunar = LichTa.toLunar(day, month, year);\n\n let customLunarHtml = '';\n\n if (render) {\n customLunarHtml = render(lunar);\n } else {\n let lunarText = `${lunar.day}`;\n \n if (!monthOnFirstDayOnly || lunar.day === 1) {\n lunarText = `${lunar.day}/${lunar.month}`;\n }\n\n if (showLeapMonth && lunar.isLeap) {\n lunarText += ' (Nhuận)';\n }\n\n let tooltipAttr = '';\n if (showTooltip) {\n const canChi = getDayCanChi(lunar.jd);\n tooltipAttr = `title=\"Ngày ${canChi}\"`;\n }\n\n customLunarHtml = `<div class=\"${className}\" style=\"font-size: 0.8em; color: ${color}; margin-top: 2px;\" ${tooltipAttr}>${lunarText}</div>`;\n }\n\n let originalContent = '';\n if (originalDayCellContent) {\n const orig = typeof originalDayCellContent === 'function' ? originalDayCellContent(arg) : originalDayCellContent;\n if (orig?.html) {\n originalContent = orig.html;\n } else if (typeof orig === 'string') {\n originalContent = orig; \n }\n } else {\n // Thẻ HTML mặc định của ô ngày trong FullCalendar\n originalContent = `<div class=\"lichta-fc-day-text\" style=\"padding: 0; text-decoration: none;\">${day}</div>`;\n }\n\n // Gói lại để hiển thị cho đẹp\n return {\n html: `\n <div class=\"lichta-fc-cell\" style=\"display: flex; flex-direction: column; align-items: center; justify-content: center;\">\n ${originalContent}\n ${customLunarHtml}\n </div>\n `\n };\n };\n\n return options;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqC;AA0C9B,SAAS,iBAAiB,SAAc,gBAA+B,CAAC,GAAG;AAChF,QAAM,yBAAyB,QAAQ;AAEvC,QAAM;AAAA,IACJ,sBAAsB;AAAA,IACtB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ;AAAA,EACF,IAAI;AAEJ,UAAQ,iBAAiB,SAAU,KAAU;AAC3C,UAAM,OAAO,IAAI;AACjB,UAAM,MAAM,KAAK,QAAQ;AACzB,UAAM,QAAQ,KAAK,SAAS,IAAI;AAChC,UAAM,OAAO,KAAK,YAAY;AAE9B,UAAM,QAAQ,mBAAO,QAAQ,KAAK,OAAO,IAAI;AAE7C,QAAI,kBAAkB;AAEtB,QAAI,QAAQ;AACV,wBAAkB,OAAO,KAAK;AAAA,IAChC,OAAO;AACL,UAAI,YAAY,GAAG,MAAM,GAAG;AAE5B,UAAI,CAAC,uBAAuB,MAAM,QAAQ,GAAG;AAC3C,oBAAY,GAAG,MAAM,GAAG,IAAI,MAAM,KAAK;AAAA,MACzC;AAEA,UAAI,iBAAiB,MAAM,QAAQ;AACjC,qBAAa;AAAA,MACf;AAEA,UAAI,cAAc;AAClB,UAAI,aAAa;AACf,cAAM,aAAS,0BAAa,MAAM,EAAE;AACpC,sBAAc,kBAAe,MAAM;AAAA,MACrC;AAEA,wBAAkB,eAAe,SAAS,qCAAqC,KAAK,uBAAuB,WAAW,IAAI,SAAS;AAAA,IACrI;AAEA,QAAI,kBAAkB;AACtB,QAAI,wBAAwB;AAC1B,YAAM,OAAO,OAAO,2BAA2B,aAAa,uBAAuB,GAAG,IAAI;AAC1F,UAAI,MAAM,MAAM;AACd,0BAAkB,KAAK;AAAA,MACzB,WAAW,OAAO,SAAS,UAAU;AACnC,0BAAkB;AAAA,MACpB;AAAA,IACF,OAAO;AAEJ,wBAAkB,8EAA8E,GAAG;AAAA,IACtG;AAGA,WAAO;AAAA,MACL,MAAM;AAAA;AAAA,YAEA,eAAe;AAAA,YACf,eAAe;AAAA;AAAA;AAAA,IAGvB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LunarDate } from '@lichta/core';
|
|
2
|
+
|
|
3
|
+
interface LichTaOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Chỉ hiển thị tháng khi là mùng 1 âm lịch (ví dụ: "1/4" thay vì "1").
|
|
6
|
+
* Mặc định: false
|
|
7
|
+
*/
|
|
8
|
+
monthOnFirstDayOnly?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Hiển thị chữ "Nhuận" nếu rơi vào tháng nhuận âm lịch.
|
|
11
|
+
* Mặc định: true
|
|
12
|
+
*/
|
|
13
|
+
showLeapMonth?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Hiển thị Can Chi của ngày khi hover chuột vào (Tooltip).
|
|
16
|
+
* Mặc định: true
|
|
17
|
+
*/
|
|
18
|
+
showTooltip?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Màu chữ tùy chỉnh cho ngày âm lịch.
|
|
21
|
+
* Mặc định: '#888'
|
|
22
|
+
*/
|
|
23
|
+
color?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Class CSS tùy chỉnh cho thẻ div chứa ngày âm lịch.
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Tùy chọn render HTML nâng cao.
|
|
30
|
+
*/
|
|
31
|
+
render?: (lunar: LunarDate) => string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Attaches LichTa lunar dates to FullCalendar options.
|
|
35
|
+
*/
|
|
36
|
+
declare function injectLunarDates(options: any, pluginOptions?: LichTaOptions): any;
|
|
37
|
+
|
|
38
|
+
export { type LichTaOptions, injectLunarDates };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LunarDate } from '@lichta/core';
|
|
2
|
+
|
|
3
|
+
interface LichTaOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Chỉ hiển thị tháng khi là mùng 1 âm lịch (ví dụ: "1/4" thay vì "1").
|
|
6
|
+
* Mặc định: false
|
|
7
|
+
*/
|
|
8
|
+
monthOnFirstDayOnly?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Hiển thị chữ "Nhuận" nếu rơi vào tháng nhuận âm lịch.
|
|
11
|
+
* Mặc định: true
|
|
12
|
+
*/
|
|
13
|
+
showLeapMonth?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Hiển thị Can Chi của ngày khi hover chuột vào (Tooltip).
|
|
16
|
+
* Mặc định: true
|
|
17
|
+
*/
|
|
18
|
+
showTooltip?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Màu chữ tùy chỉnh cho ngày âm lịch.
|
|
21
|
+
* Mặc định: '#888'
|
|
22
|
+
*/
|
|
23
|
+
color?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Class CSS tùy chỉnh cho thẻ div chứa ngày âm lịch.
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Tùy chọn render HTML nâng cao.
|
|
30
|
+
*/
|
|
31
|
+
render?: (lunar: LunarDate) => string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Attaches LichTa lunar dates to FullCalendar options.
|
|
35
|
+
*/
|
|
36
|
+
declare function injectLunarDates(options: any, pluginOptions?: LichTaOptions): any;
|
|
37
|
+
|
|
38
|
+
export { type LichTaOptions, injectLunarDates };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { LichTa, getDayCanChi } from "@lichta/core";
|
|
3
|
+
function injectLunarDates(options, pluginOptions = {}) {
|
|
4
|
+
const originalDayCellContent = options.dayCellContent;
|
|
5
|
+
const {
|
|
6
|
+
monthOnFirstDayOnly = false,
|
|
7
|
+
showLeapMonth = true,
|
|
8
|
+
showTooltip = true,
|
|
9
|
+
color = "#888",
|
|
10
|
+
className = "lichta-fc-lunar",
|
|
11
|
+
render
|
|
12
|
+
} = pluginOptions;
|
|
13
|
+
options.dayCellContent = function(arg) {
|
|
14
|
+
const date = arg.date;
|
|
15
|
+
const day = date.getDate();
|
|
16
|
+
const month = date.getMonth() + 1;
|
|
17
|
+
const year = date.getFullYear();
|
|
18
|
+
const lunar = LichTa.toLunar(day, month, year);
|
|
19
|
+
let customLunarHtml = "";
|
|
20
|
+
if (render) {
|
|
21
|
+
customLunarHtml = render(lunar);
|
|
22
|
+
} else {
|
|
23
|
+
let lunarText = `${lunar.day}`;
|
|
24
|
+
if (!monthOnFirstDayOnly || lunar.day === 1) {
|
|
25
|
+
lunarText = `${lunar.day}/${lunar.month}`;
|
|
26
|
+
}
|
|
27
|
+
if (showLeapMonth && lunar.isLeap) {
|
|
28
|
+
lunarText += " (Nhu\u1EADn)";
|
|
29
|
+
}
|
|
30
|
+
let tooltipAttr = "";
|
|
31
|
+
if (showTooltip) {
|
|
32
|
+
const canChi = getDayCanChi(lunar.jd);
|
|
33
|
+
tooltipAttr = `title="Ng\xE0y ${canChi}"`;
|
|
34
|
+
}
|
|
35
|
+
customLunarHtml = `<div class="${className}" style="font-size: 0.8em; color: ${color}; margin-top: 2px;" ${tooltipAttr}>${lunarText}</div>`;
|
|
36
|
+
}
|
|
37
|
+
let originalContent = "";
|
|
38
|
+
if (originalDayCellContent) {
|
|
39
|
+
const orig = typeof originalDayCellContent === "function" ? originalDayCellContent(arg) : originalDayCellContent;
|
|
40
|
+
if (orig?.html) {
|
|
41
|
+
originalContent = orig.html;
|
|
42
|
+
} else if (typeof orig === "string") {
|
|
43
|
+
originalContent = orig;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
originalContent = `<div class="lichta-fc-day-text" style="padding: 0; text-decoration: none;">${day}</div>`;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
html: `
|
|
50
|
+
<div class="lichta-fc-cell" style="display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
|
51
|
+
${originalContent}
|
|
52
|
+
${customLunarHtml}
|
|
53
|
+
</div>
|
|
54
|
+
`
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
return options;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
injectLunarDates
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { LichTa, getDayCanChi } from '@lichta/core';\nimport type { LunarDate } from '@lichta/core';\n\nexport interface LichTaOptions {\n /**\n * Chỉ hiển thị tháng khi là mùng 1 âm lịch (ví dụ: \"1/4\" thay vì \"1\").\n * Mặc định: false\n */\n monthOnFirstDayOnly?: boolean;\n\n /**\n * Hiển thị chữ \"Nhuận\" nếu rơi vào tháng nhuận âm lịch.\n * Mặc định: true\n */\n showLeapMonth?: boolean;\n\n /**\n * Hiển thị Can Chi của ngày khi hover chuột vào (Tooltip).\n * Mặc định: true\n */\n showTooltip?: boolean;\n\n /**\n * Màu chữ tùy chỉnh cho ngày âm lịch.\n * Mặc định: '#888'\n */\n color?: string;\n\n /**\n * Class CSS tùy chỉnh cho thẻ div chứa ngày âm lịch.\n */\n className?: string;\n\n /**\n * Tùy chọn render HTML nâng cao.\n */\n render?: (lunar: LunarDate) => string;\n}\n\n/**\n * Attaches LichTa lunar dates to FullCalendar options.\n */\nexport function injectLunarDates(options: any, pluginOptions: LichTaOptions = {}) {\n const originalDayCellContent = options.dayCellContent;\n\n const {\n monthOnFirstDayOnly = false,\n showLeapMonth = true,\n showTooltip = true,\n color = '#888',\n className = 'lichta-fc-lunar',\n render\n } = pluginOptions;\n\n options.dayCellContent = function (arg: any) {\n const date = arg.date;\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n\n const lunar = LichTa.toLunar(day, month, year);\n\n let customLunarHtml = '';\n\n if (render) {\n customLunarHtml = render(lunar);\n } else {\n let lunarText = `${lunar.day}`;\n \n if (!monthOnFirstDayOnly || lunar.day === 1) {\n lunarText = `${lunar.day}/${lunar.month}`;\n }\n\n if (showLeapMonth && lunar.isLeap) {\n lunarText += ' (Nhuận)';\n }\n\n let tooltipAttr = '';\n if (showTooltip) {\n const canChi = getDayCanChi(lunar.jd);\n tooltipAttr = `title=\"Ngày ${canChi}\"`;\n }\n\n customLunarHtml = `<div class=\"${className}\" style=\"font-size: 0.8em; color: ${color}; margin-top: 2px;\" ${tooltipAttr}>${lunarText}</div>`;\n }\n\n let originalContent = '';\n if (originalDayCellContent) {\n const orig = typeof originalDayCellContent === 'function' ? originalDayCellContent(arg) : originalDayCellContent;\n if (orig?.html) {\n originalContent = orig.html;\n } else if (typeof orig === 'string') {\n originalContent = orig; \n }\n } else {\n // Thẻ HTML mặc định của ô ngày trong FullCalendar\n originalContent = `<div class=\"lichta-fc-day-text\" style=\"padding: 0; text-decoration: none;\">${day}</div>`;\n }\n\n // Gói lại để hiển thị cho đẹp\n return {\n html: `\n <div class=\"lichta-fc-cell\" style=\"display: flex; flex-direction: column; align-items: center; justify-content: center;\">\n ${originalContent}\n ${customLunarHtml}\n </div>\n `\n };\n };\n\n return options;\n}\n"],"mappings":";AAAA,SAAS,QAAQ,oBAAoB;AA0C9B,SAAS,iBAAiB,SAAc,gBAA+B,CAAC,GAAG;AAChF,QAAM,yBAAyB,QAAQ;AAEvC,QAAM;AAAA,IACJ,sBAAsB;AAAA,IACtB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ;AAAA,EACF,IAAI;AAEJ,UAAQ,iBAAiB,SAAU,KAAU;AAC3C,UAAM,OAAO,IAAI;AACjB,UAAM,MAAM,KAAK,QAAQ;AACzB,UAAM,QAAQ,KAAK,SAAS,IAAI;AAChC,UAAM,OAAO,KAAK,YAAY;AAE9B,UAAM,QAAQ,OAAO,QAAQ,KAAK,OAAO,IAAI;AAE7C,QAAI,kBAAkB;AAEtB,QAAI,QAAQ;AACV,wBAAkB,OAAO,KAAK;AAAA,IAChC,OAAO;AACL,UAAI,YAAY,GAAG,MAAM,GAAG;AAE5B,UAAI,CAAC,uBAAuB,MAAM,QAAQ,GAAG;AAC3C,oBAAY,GAAG,MAAM,GAAG,IAAI,MAAM,KAAK;AAAA,MACzC;AAEA,UAAI,iBAAiB,MAAM,QAAQ;AACjC,qBAAa;AAAA,MACf;AAEA,UAAI,cAAc;AAClB,UAAI,aAAa;AACf,cAAM,SAAS,aAAa,MAAM,EAAE;AACpC,sBAAc,kBAAe,MAAM;AAAA,MACrC;AAEA,wBAAkB,eAAe,SAAS,qCAAqC,KAAK,uBAAuB,WAAW,IAAI,SAAS;AAAA,IACrI;AAEA,QAAI,kBAAkB;AACtB,QAAI,wBAAwB;AAC1B,YAAM,OAAO,OAAO,2BAA2B,aAAa,uBAAuB,GAAG,IAAI;AAC1F,UAAI,MAAM,MAAM;AACd,0BAAkB,KAAK;AAAA,MACzB,WAAW,OAAO,SAAS,UAAU;AACnC,0BAAkB;AAAA,MACpB;AAAA,IACF,OAAO;AAEJ,wBAAkB,8EAA8E,GAAG;AAAA,IACtG;AAGA,WAAO;AAAA,MACL,MAAM;AAAA;AAAA,YAEA,eAAe;AAAA,YACf,eAAe;AAAA;AAAA;AAAA,IAGvB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lichta/full-calendar",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "FullCalendar adapter for LichTa",
|
|
5
|
+
"author": "Zeforc Labs | Stridev",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@lichta/core": "2.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@fullcalendar/core": "^6.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@fullcalendar/core": "^6.0.0",
|
|
30
|
+
"typescript": "^6.0.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup"
|
|
34
|
+
}
|
|
35
|
+
}
|