@lichta/react-big-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 +94 -0
- package/dist/index.cjs +83 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -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,94 @@
|
|
|
1
|
+
# @lichta/react-big-calendar
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@lichta/react-big-calendar)
|
|
4
|
+
|
|
5
|
+
Plugin/Adapter tích hợp lịch âm Việt Nam (LichTa) vào thư viện [React Big Calendar](https://github.com/jquense/react-big-calendar).
|
|
6
|
+
|
|
7
|
+
## Cài đặt
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @lichta/react-big-calendar react-big-calendar
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Cách sử dụng cơ bản
|
|
14
|
+
|
|
15
|
+
React Big Calendar cho phép tùy chỉnh giao diện thông qua props `components`. Hàm `injectLunarDates` sẽ nhận vào object components hiện tại của bạn và tự động gắn thêm phần hiển thị ngày âm lịch.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import { Calendar, momentLocalizer } from 'react-big-calendar';
|
|
20
|
+
import moment from 'moment';
|
|
21
|
+
import { injectLunarDates } from '@lichta/react-big-calendar';
|
|
22
|
+
import 'react-big-calendar/lib/css/react-big-calendar.css';
|
|
23
|
+
|
|
24
|
+
const localizer = momentLocalizer(moment);
|
|
25
|
+
|
|
26
|
+
const MyCalendar = (props) => {
|
|
27
|
+
// Tạo components được tích hợp sẵn LichTa
|
|
28
|
+
const customComponents = injectLunarDates();
|
|
29
|
+
|
|
30
|
+
// Nếu bạn đã có components custom trước đó, bạn có thể truyền nó vào:
|
|
31
|
+
// const customComponents = injectLunarDates({ ...yourComponents });
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div>
|
|
35
|
+
<Calendar
|
|
36
|
+
localizer={localizer}
|
|
37
|
+
events={[]}
|
|
38
|
+
startAccessor="start"
|
|
39
|
+
endAccessor="end"
|
|
40
|
+
style={{ height: 500 }}
|
|
41
|
+
components={customComponents}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Tùy chọn giao diện (Options)
|
|
49
|
+
|
|
50
|
+
Hàm `injectLunarDates(components, pluginOptions)` nhận đối số thứ hai để cấu hình giao diện cho ngày âm lịch:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const customComponents = injectLunarDates({}, {
|
|
54
|
+
// Chỉ hiển thị tháng khi là mùng 1 (vd: "1/4" thay vì "1")
|
|
55
|
+
monthOnFirstDayOnly: false,
|
|
56
|
+
|
|
57
|
+
// Hiển thị "(Nhuận)" cho các tháng nhuận âm lịch
|
|
58
|
+
showLeapMonth: true,
|
|
59
|
+
|
|
60
|
+
// Hiển thị Can Chi khi hover chuột vào (Tooltip)
|
|
61
|
+
showTooltip: true,
|
|
62
|
+
|
|
63
|
+
// Tùy chỉnh màu chữ
|
|
64
|
+
color: '#888',
|
|
65
|
+
|
|
66
|
+
// Tùy chỉnh class CSS (hữu ích khi dùng Tailwind)
|
|
67
|
+
className: 'lichta-rbc-lunar',
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Tùy chỉnh hoàn toàn bằng hàm `render`
|
|
72
|
+
|
|
73
|
+
Nếu bạn muốn kiểm soát hoàn toàn mã React Node của phần hiển thị ngày âm lịch, hãy sử dụng thuộc tính `render`:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
const customComponents = injectLunarDates({}, {
|
|
77
|
+
render: (lunarDate) => {
|
|
78
|
+
return (
|
|
79
|
+
<div className="custom-lunar" style={{ fontStyle: 'italic' }}>
|
|
80
|
+
🌙 {lunarDate.day}/{lunarDate.month}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Phụ thuộc (Dependencies)
|
|
88
|
+
- **@lichta/core**: workspace dependency (tự động cài kèm)
|
|
89
|
+
- **react-big-calendar**: ^1.0.0 (peer dependency)
|
|
90
|
+
- **react**: ^17 || ^18 || ^19 (peer dependency)
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
[MIT](./LICENSE)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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.tsx
|
|
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
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
function injectLunarDates(originalComponents = {}, pluginOptions = {}) {
|
|
29
|
+
const {
|
|
30
|
+
monthOnFirstDayOnly = false,
|
|
31
|
+
showLeapMonth = true,
|
|
32
|
+
showTooltip = true,
|
|
33
|
+
color = "#888",
|
|
34
|
+
className = "lichta-rbc-lunar",
|
|
35
|
+
render
|
|
36
|
+
} = pluginOptions;
|
|
37
|
+
const OriginalDateHeader = originalComponents?.month?.dateHeader;
|
|
38
|
+
const LunarDateHeader = (props) => {
|
|
39
|
+
const { date, label } = props;
|
|
40
|
+
const day = date.getDate();
|
|
41
|
+
const month = date.getMonth() + 1;
|
|
42
|
+
const year = date.getFullYear();
|
|
43
|
+
const lunar = import_core.LichTa.toLunar(day, month, year);
|
|
44
|
+
let customLunarNode = null;
|
|
45
|
+
if (render) {
|
|
46
|
+
customLunarNode = render(lunar);
|
|
47
|
+
} else {
|
|
48
|
+
let lunarText = `${lunar.day}`;
|
|
49
|
+
if (!monthOnFirstDayOnly || lunar.day === 1) {
|
|
50
|
+
lunarText = `${lunar.day}/${lunar.month}`;
|
|
51
|
+
}
|
|
52
|
+
if (showLeapMonth && lunar.isLeap) {
|
|
53
|
+
lunarText += " (Nhu\u1EADn)";
|
|
54
|
+
}
|
|
55
|
+
let tooltipAttr = showTooltip ? `Ng\xE0y ${(0, import_core.getDayCanChi)(lunar.jd)}` : void 0;
|
|
56
|
+
customLunarNode = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
className,
|
|
60
|
+
style: { fontSize: "0.8em", color, marginTop: "2px" },
|
|
61
|
+
title: tooltipAttr,
|
|
62
|
+
children: lunarText
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "lichta-rbc-cell", style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
|
|
67
|
+
OriginalDateHeader ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OriginalDateHeader, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rbc-button-link", children: label }),
|
|
68
|
+
customLunarNode
|
|
69
|
+
] });
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
...originalComponents,
|
|
73
|
+
month: {
|
|
74
|
+
...originalComponents?.month || {},
|
|
75
|
+
dateHeader: LunarDateHeader
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
injectLunarDates
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport { 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 React Node nâng cao.\n */\n render?: (lunar: LunarDate) => React.ReactNode;\n}\n\n/**\n * Attaches LichTa lunar dates to React Big Calendar components object.\n */\nexport function injectLunarDates(originalComponents: any = {}, pluginOptions: LichTaOptions = {}) {\n const {\n monthOnFirstDayOnly = false,\n showLeapMonth = true,\n showTooltip = true,\n color = '#888',\n className = 'lichta-rbc-lunar',\n render\n } = pluginOptions;\n\n const OriginalDateHeader = originalComponents?.month?.dateHeader;\n\n const LunarDateHeader = (props: any) => {\n const { date, label } = props;\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 customLunarNode: React.ReactNode = null;\n\n if (render) {\n customLunarNode = 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 = showTooltip ? `Ngày ${getDayCanChi(lunar.jd)}` : undefined;\n\n customLunarNode = (\n <div \n className={className} \n style={{ fontSize: '0.8em', color: color, marginTop: '2px' }} \n title={tooltipAttr}\n >\n {lunarText}\n </div>\n );\n }\n\n return (\n <div className=\"lichta-rbc-cell\" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n {OriginalDateHeader ? (\n <OriginalDateHeader {...props} />\n ) : (\n <span className=\"rbc-button-link\">{label}</span>\n )}\n {customLunarNode}\n </div>\n );\n };\n\n return {\n ...originalComponents,\n month: {\n ...(originalComponents?.month || {}),\n dateHeader: LunarDateHeader\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAqC;AAgF7B;AAtCD,SAAS,iBAAiB,qBAA0B,CAAC,GAAG,gBAA+B,CAAC,GAAG;AAChG,QAAM;AAAA,IACJ,sBAAsB;AAAA,IACtB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ;AAAA,EACF,IAAI;AAEJ,QAAM,qBAAqB,oBAAoB,OAAO;AAEtD,QAAM,kBAAkB,CAAC,UAAe;AACtC,UAAM,EAAE,MAAM,MAAM,IAAI;AACxB,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,kBAAmC;AAEvC,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,cAAc,eAAQ,0BAAa,MAAM,EAAE,CAAC,KAAK;AAEnE,wBACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,OAAO,EAAE,UAAU,SAAS,OAAc,WAAW,MAAM;AAAA,UAC3D,OAAO;AAAA,UAEN;AAAA;AAAA,MACH;AAAA,IAEJ;AAEA,WACE,6CAAC,SAAI,WAAU,mBAAkB,OAAO,EAAE,SAAS,QAAQ,eAAe,UAAU,YAAY,SAAS,GACtG;AAAA,2BACC,4CAAC,sBAAoB,GAAG,OAAO,IAE/B,4CAAC,UAAK,WAAU,mBAAmB,iBAAM;AAAA,MAE1C;AAAA,OACH;AAAA,EAEJ;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAI,oBAAoB,SAAS,CAAC;AAAA,MAClC,YAAY;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LunarDate } from '@lichta/core';
|
|
3
|
+
|
|
4
|
+
interface LichTaOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Chỉ hiển thị tháng khi là mùng 1 âm lịch (ví dụ: "1/4" thay vì "1").
|
|
7
|
+
* Mặc định: false
|
|
8
|
+
*/
|
|
9
|
+
monthOnFirstDayOnly?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Hiển thị chữ "Nhuận" nếu rơi vào tháng nhuận âm lịch.
|
|
12
|
+
* Mặc định: true
|
|
13
|
+
*/
|
|
14
|
+
showLeapMonth?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Hiển thị Can Chi của ngày khi hover chuột vào (Tooltip).
|
|
17
|
+
* Mặc định: true
|
|
18
|
+
*/
|
|
19
|
+
showTooltip?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Màu chữ tùy chỉnh cho ngày âm lịch.
|
|
22
|
+
* Mặc định: '#888'
|
|
23
|
+
*/
|
|
24
|
+
color?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Class CSS tùy chỉnh cho thẻ div chứa ngày âm lịch.
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Tùy chọn render React Node nâng cao.
|
|
31
|
+
*/
|
|
32
|
+
render?: (lunar: LunarDate) => React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Attaches LichTa lunar dates to React Big Calendar components object.
|
|
36
|
+
*/
|
|
37
|
+
declare function injectLunarDates(originalComponents?: any, pluginOptions?: LichTaOptions): any;
|
|
38
|
+
|
|
39
|
+
export { type LichTaOptions, injectLunarDates };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LunarDate } from '@lichta/core';
|
|
3
|
+
|
|
4
|
+
interface LichTaOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Chỉ hiển thị tháng khi là mùng 1 âm lịch (ví dụ: "1/4" thay vì "1").
|
|
7
|
+
* Mặc định: false
|
|
8
|
+
*/
|
|
9
|
+
monthOnFirstDayOnly?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Hiển thị chữ "Nhuận" nếu rơi vào tháng nhuận âm lịch.
|
|
12
|
+
* Mặc định: true
|
|
13
|
+
*/
|
|
14
|
+
showLeapMonth?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Hiển thị Can Chi của ngày khi hover chuột vào (Tooltip).
|
|
17
|
+
* Mặc định: true
|
|
18
|
+
*/
|
|
19
|
+
showTooltip?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Màu chữ tùy chỉnh cho ngày âm lịch.
|
|
22
|
+
* Mặc định: '#888'
|
|
23
|
+
*/
|
|
24
|
+
color?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Class CSS tùy chỉnh cho thẻ div chứa ngày âm lịch.
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Tùy chọn render React Node nâng cao.
|
|
31
|
+
*/
|
|
32
|
+
render?: (lunar: LunarDate) => React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Attaches LichTa lunar dates to React Big Calendar components object.
|
|
36
|
+
*/
|
|
37
|
+
declare function injectLunarDates(originalComponents?: any, pluginOptions?: LichTaOptions): any;
|
|
38
|
+
|
|
39
|
+
export { type LichTaOptions, injectLunarDates };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import { LichTa, getDayCanChi } from "@lichta/core";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
function injectLunarDates(originalComponents = {}, pluginOptions = {}) {
|
|
5
|
+
const {
|
|
6
|
+
monthOnFirstDayOnly = false,
|
|
7
|
+
showLeapMonth = true,
|
|
8
|
+
showTooltip = true,
|
|
9
|
+
color = "#888",
|
|
10
|
+
className = "lichta-rbc-lunar",
|
|
11
|
+
render
|
|
12
|
+
} = pluginOptions;
|
|
13
|
+
const OriginalDateHeader = originalComponents?.month?.dateHeader;
|
|
14
|
+
const LunarDateHeader = (props) => {
|
|
15
|
+
const { date, label } = props;
|
|
16
|
+
const day = date.getDate();
|
|
17
|
+
const month = date.getMonth() + 1;
|
|
18
|
+
const year = date.getFullYear();
|
|
19
|
+
const lunar = LichTa.toLunar(day, month, year);
|
|
20
|
+
let customLunarNode = null;
|
|
21
|
+
if (render) {
|
|
22
|
+
customLunarNode = render(lunar);
|
|
23
|
+
} else {
|
|
24
|
+
let lunarText = `${lunar.day}`;
|
|
25
|
+
if (!monthOnFirstDayOnly || lunar.day === 1) {
|
|
26
|
+
lunarText = `${lunar.day}/${lunar.month}`;
|
|
27
|
+
}
|
|
28
|
+
if (showLeapMonth && lunar.isLeap) {
|
|
29
|
+
lunarText += " (Nhu\u1EADn)";
|
|
30
|
+
}
|
|
31
|
+
let tooltipAttr = showTooltip ? `Ng\xE0y ${getDayCanChi(lunar.jd)}` : void 0;
|
|
32
|
+
customLunarNode = /* @__PURE__ */ jsx(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
className,
|
|
36
|
+
style: { fontSize: "0.8em", color, marginTop: "2px" },
|
|
37
|
+
title: tooltipAttr,
|
|
38
|
+
children: lunarText
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", { className: "lichta-rbc-cell", style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
|
|
43
|
+
OriginalDateHeader ? /* @__PURE__ */ jsx(OriginalDateHeader, { ...props }) : /* @__PURE__ */ jsx("span", { className: "rbc-button-link", children: label }),
|
|
44
|
+
customLunarNode
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
...originalComponents,
|
|
49
|
+
month: {
|
|
50
|
+
...originalComponents?.month || {},
|
|
51
|
+
dateHeader: LunarDateHeader
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
injectLunarDates
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport { 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 React Node nâng cao.\n */\n render?: (lunar: LunarDate) => React.ReactNode;\n}\n\n/**\n * Attaches LichTa lunar dates to React Big Calendar components object.\n */\nexport function injectLunarDates(originalComponents: any = {}, pluginOptions: LichTaOptions = {}) {\n const {\n monthOnFirstDayOnly = false,\n showLeapMonth = true,\n showTooltip = true,\n color = '#888',\n className = 'lichta-rbc-lunar',\n render\n } = pluginOptions;\n\n const OriginalDateHeader = originalComponents?.month?.dateHeader;\n\n const LunarDateHeader = (props: any) => {\n const { date, label } = props;\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 customLunarNode: React.ReactNode = null;\n\n if (render) {\n customLunarNode = 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 = showTooltip ? `Ngày ${getDayCanChi(lunar.jd)}` : undefined;\n\n customLunarNode = (\n <div \n className={className} \n style={{ fontSize: '0.8em', color: color, marginTop: '2px' }} \n title={tooltipAttr}\n >\n {lunarText}\n </div>\n );\n }\n\n return (\n <div className=\"lichta-rbc-cell\" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>\n {OriginalDateHeader ? (\n <OriginalDateHeader {...props} />\n ) : (\n <span className=\"rbc-button-link\">{label}</span>\n )}\n {customLunarNode}\n </div>\n );\n };\n\n return {\n ...originalComponents,\n month: {\n ...(originalComponents?.month || {}),\n dateHeader: LunarDateHeader\n }\n };\n}\n"],"mappings":";AACA,SAAS,QAAQ,oBAAoB;AAgF7B,cAWF,YAXE;AAtCD,SAAS,iBAAiB,qBAA0B,CAAC,GAAG,gBAA+B,CAAC,GAAG;AAChG,QAAM;AAAA,IACJ,sBAAsB;AAAA,IACtB,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ;AAAA,EACF,IAAI;AAEJ,QAAM,qBAAqB,oBAAoB,OAAO;AAEtD,QAAM,kBAAkB,CAAC,UAAe;AACtC,UAAM,EAAE,MAAM,MAAM,IAAI;AACxB,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,kBAAmC;AAEvC,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,cAAc,WAAQ,aAAa,MAAM,EAAE,CAAC,KAAK;AAEnE,wBACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,OAAO,EAAE,UAAU,SAAS,OAAc,WAAW,MAAM;AAAA,UAC3D,OAAO;AAAA,UAEN;AAAA;AAAA,MACH;AAAA,IAEJ;AAEA,WACE,qBAAC,SAAI,WAAU,mBAAkB,OAAO,EAAE,SAAS,QAAQ,eAAe,UAAU,YAAY,SAAS,GACtG;AAAA,2BACC,oBAAC,sBAAoB,GAAG,OAAO,IAE/B,oBAAC,UAAK,WAAU,mBAAmB,iBAAM;AAAA,MAE1C;AAAA,OACH;AAAA,EAEJ;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAI,oBAAoB,SAAS,CAAC;AAAA,MAClC,YAAY;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lichta/react-big-calendar",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "React Big Calendar 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
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
27
|
+
"react-big-calendar": "^1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "^18.0.0",
|
|
31
|
+
"@types/react-dom": "^18.0.0",
|
|
32
|
+
"@types/react-big-calendar": "^1.0.0",
|
|
33
|
+
"react": "^18.0.0",
|
|
34
|
+
"react-dom": "^18.0.0",
|
|
35
|
+
"react-big-calendar": "^1.13.1",
|
|
36
|
+
"typescript": "^6.0.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup"
|
|
40
|
+
}
|
|
41
|
+
}
|