wlw-components 0.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 +73 -0
- package/dist/cjs/Calendar/Header.d.ts +9 -0
- package/dist/cjs/Calendar/Header.js +13 -0
- package/dist/cjs/Calendar/LocaleContext.d.ts +5 -0
- package/dist/cjs/Calendar/LocaleContext.js +7 -0
- package/dist/cjs/Calendar/MonthCalendar.d.ts +8 -0
- package/dist/cjs/Calendar/MonthCalendar.js +59 -0
- package/dist/cjs/Calendar/index.css +113 -0
- package/dist/cjs/Calendar/index.css.map +1 -0
- package/dist/cjs/Calendar/index.d.ts +14 -0
- package/dist/cjs/Calendar/index.js +41 -0
- package/dist/cjs/Calendar/locale/en-US.d.ts +3 -0
- package/dist/cjs/Calendar/locale/en-US.js +31 -0
- package/dist/cjs/Calendar/locale/index.d.ts +3 -0
- package/dist/cjs/Calendar/locale/index.js +9 -0
- package/dist/cjs/Calendar/locale/interface.d.ts +28 -0
- package/dist/cjs/Calendar/locale/interface.js +2 -0
- package/dist/cjs/Calendar/locale/zh-CN.d.ts +3 -0
- package/dist/cjs/Calendar/locale/zh-CN.js +31 -0
- package/dist/cjs/Message/ConfigProvider.d.ts +8 -0
- package/dist/cjs/Message/ConfigProvider.js +13 -0
- package/dist/cjs/Message/index.css +50 -0
- package/dist/cjs/Message/index.css.map +1 -0
- package/dist/cjs/Message/index.d.ts +18 -0
- package/dist/cjs/Message/index.js +58 -0
- package/dist/cjs/Message/useMessage.d.ts +2 -0
- package/dist/cjs/Message/useMessage.js +13 -0
- package/dist/cjs/Message/useStore.d.ts +19 -0
- package/dist/cjs/Message/useStore.js +81 -0
- package/dist/cjs/Message/useTimer.d.ts +9 -0
- package/dist/cjs/Message/useTimer.js +34 -0
- package/dist/cjs/Watermark/index.d.ts +22 -0
- package/dist/cjs/Watermark/index.js +51 -0
- package/dist/cjs/Watermark/useWatermark.d.ts +7 -0
- package/dist/cjs/Watermark/useWatermark.js +211 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +11 -0
- package/dist/esm/Calendar/Header.d.ts +9 -0
- package/dist/esm/Calendar/Header.js +11 -0
- package/dist/esm/Calendar/LocaleContext.d.ts +5 -0
- package/dist/esm/Calendar/LocaleContext.js +5 -0
- package/dist/esm/Calendar/MonthCalendar.d.ts +8 -0
- package/dist/esm/Calendar/MonthCalendar.js +57 -0
- package/dist/esm/Calendar/index.css +113 -0
- package/dist/esm/Calendar/index.css.map +1 -0
- package/dist/esm/Calendar/index.d.ts +14 -0
- package/dist/esm/Calendar/index.js +39 -0
- package/dist/esm/Calendar/locale/en-US.d.ts +3 -0
- package/dist/esm/Calendar/locale/en-US.js +29 -0
- package/dist/esm/Calendar/locale/index.d.ts +3 -0
- package/dist/esm/Calendar/locale/index.js +7 -0
- package/dist/esm/Calendar/locale/interface.d.ts +28 -0
- package/dist/esm/Calendar/locale/interface.js +1 -0
- package/dist/esm/Calendar/locale/zh-CN.d.ts +3 -0
- package/dist/esm/Calendar/locale/zh-CN.js +29 -0
- package/dist/esm/Message/ConfigProvider.d.ts +8 -0
- package/dist/esm/Message/ConfigProvider.js +9 -0
- package/dist/esm/Message/index.css +50 -0
- package/dist/esm/Message/index.css.map +1 -0
- package/dist/esm/Message/index.d.ts +18 -0
- package/dist/esm/Message/index.js +55 -0
- package/dist/esm/Message/useMessage.d.ts +2 -0
- package/dist/esm/Message/useMessage.js +10 -0
- package/dist/esm/Message/useStore.d.ts +19 -0
- package/dist/esm/Message/useStore.js +76 -0
- package/dist/esm/Message/useTimer.d.ts +9 -0
- package/dist/esm/Message/useTimer.js +31 -0
- package/dist/esm/Watermark/index.d.ts +22 -0
- package/dist/esm/Watermark/index.js +49 -0
- package/dist/esm/Watermark/useWatermark.d.ts +7 -0
- package/dist/esm/Watermark/useWatermark.js +207 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +5 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dayjs } from "dayjs";
|
|
2
|
+
interface HeaderProps {
|
|
3
|
+
curMonth: Dayjs;
|
|
4
|
+
prevMonthHandler: () => void;
|
|
5
|
+
nextMonthHandler: () => void;
|
|
6
|
+
todayHandler: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare function Header(props: HeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default Header;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const LocaleContext_1 = require("./LocaleContext");
|
|
6
|
+
const locale_1 = require("./locale");
|
|
7
|
+
function Header(props) {
|
|
8
|
+
const { curMonth, prevMonthHandler, nextMonthHandler, todayHandler, } = props;
|
|
9
|
+
const localeContext = (0, react_1.useContext)(LocaleContext_1.default);
|
|
10
|
+
const CalendarContext = locale_1.default[localeContext.locale];
|
|
11
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "calendar-header", children: (0, jsx_runtime_1.jsxs)("div", { className: "calendar-header-left", children: [(0, jsx_runtime_1.jsx)("div", { className: "calendar-header-icon", onClick: prevMonthHandler, children: "<" }), (0, jsx_runtime_1.jsx)("div", { className: "calendar-header-value", children: curMonth.format(CalendarContext.formatMonth) }), (0, jsx_runtime_1.jsx)("div", { className: "calendar-header-icon", onClick: nextMonthHandler, children: ">" }), (0, jsx_runtime_1.jsx)("button", { className: "calendar-header-btn", onClick: todayHandler, children: CalendarContext.today })] }) });
|
|
12
|
+
}
|
|
13
|
+
exports.default = Header;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CalendarProps } from ".";
|
|
2
|
+
import { Dayjs } from "dayjs";
|
|
3
|
+
interface MonthCalendarProps extends CalendarProps {
|
|
4
|
+
curMonth: Dayjs;
|
|
5
|
+
selectHandler?: (date: Dayjs) => void;
|
|
6
|
+
}
|
|
7
|
+
declare function MonthCalendar(props: MonthCalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default MonthCalendar;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
// import CalendarLocale from "./locale/en-US";
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const LocaleContext_1 = require("./LocaleContext");
|
|
7
|
+
const locale_1 = require("./locale");
|
|
8
|
+
const classnames_1 = require("classnames");
|
|
9
|
+
function getAllDays(date) {
|
|
10
|
+
const daysInMonth = date.daysInMonth();
|
|
11
|
+
const startDate = date.startOf('month');
|
|
12
|
+
const day = startDate.day();
|
|
13
|
+
const daysInfo = new Array(6 * 7);
|
|
14
|
+
for (let i = 0; i < day; i++) {
|
|
15
|
+
daysInfo[i] = {
|
|
16
|
+
date: startDate.subtract(day - i, 'day'),
|
|
17
|
+
currentMonth: false
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
for (let i = day; i < daysInfo.length; i++) {
|
|
21
|
+
const calcDate = startDate.add(i - day, 'day');
|
|
22
|
+
daysInfo[i] = {
|
|
23
|
+
date: calcDate,
|
|
24
|
+
currentMonth: calcDate.month() === date.month()
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// debugger;
|
|
28
|
+
return daysInfo;
|
|
29
|
+
}
|
|
30
|
+
// function renderDays(
|
|
31
|
+
// days: Array<{date: Dayjs, currentMonth: boolean}>,
|
|
32
|
+
// dateRender: MonthCalendarProps['dateRender'],
|
|
33
|
+
// dateInnerContent: MonthCalendarProps['dateInnerContent'],
|
|
34
|
+
// value: Dayjs,
|
|
35
|
+
// selectHandler: MonthCalendarProps['selectHandler']
|
|
36
|
+
// )
|
|
37
|
+
function MonthCalendar(props) {
|
|
38
|
+
const localeContext = (0, react_1.useContext)(LocaleContext_1.default);
|
|
39
|
+
const { value, curMonth, dateRender, dateInnerContent, selectHandler, } = props;
|
|
40
|
+
const CalendarLocale = locale_1.default[localeContext.locale];
|
|
41
|
+
const weekList = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
|
42
|
+
const allDays = getAllDays(curMonth);
|
|
43
|
+
function renderDays(days) {
|
|
44
|
+
const rows = [];
|
|
45
|
+
for (let i = 0; i < 6; i++) {
|
|
46
|
+
const row = [];
|
|
47
|
+
for (let j = 0; j < 7; j++) {
|
|
48
|
+
const item = days[i * 7 + j];
|
|
49
|
+
row[j] = (0, jsx_runtime_1.jsx)("div", { className: "calendar-month-body-cell" + (item.currentMonth ? ' calendar-month-body-cell-current' : ''), onClick: () => selectHandler === null || selectHandler === void 0 ? void 0 : selectHandler(item.date), children: dateRender ? dateRender(item.date) : ((0, jsx_runtime_1.jsxs)("div", { className: "calendar-month-body-cell-date", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)("calendar-month-body-cell-date-value", (value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD')) === item.date.format('YYYY-MM-DD')
|
|
50
|
+
? "calendar-month-body-cell-date-selected"
|
|
51
|
+
: ""), children: item.date.date() }), (0, jsx_runtime_1.jsx)("div", { className: "calendar-month-body-cell-date-content", children: dateInnerContent === null || dateInnerContent === void 0 ? void 0 : dateInnerContent(item.date) })] })) });
|
|
52
|
+
}
|
|
53
|
+
rows.push(row);
|
|
54
|
+
}
|
|
55
|
+
return rows.map(row => (0, jsx_runtime_1.jsx)("div", { className: "calendar-month-body-row", children: row }));
|
|
56
|
+
}
|
|
57
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: "calendar-month", children: [(0, jsx_runtime_1.jsx)("div", { className: "calendar-month-week-list", children: weekList.map((week) => ((0, jsx_runtime_1.jsx)("div", { className: "calendar-month-week-list-item", children: CalendarLocale.week[week] }, week))) }), (0, jsx_runtime_1.jsx)("div", { className: "calendar-month-body", children: renderDays(allDays) })] });
|
|
58
|
+
}
|
|
59
|
+
exports.default = MonthCalendar;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
.calendar {
|
|
2
|
+
width: min(100%, 960px);
|
|
3
|
+
margin: 24px auto;
|
|
4
|
+
background: #fff;
|
|
5
|
+
border-radius: 12px;
|
|
6
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.calendar-header {
|
|
10
|
+
padding: 10px;
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
15
|
+
.calendar-header-left {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
height: 20px;
|
|
19
|
+
line-height: 20px;
|
|
20
|
+
}
|
|
21
|
+
.calendar-header-value {
|
|
22
|
+
font-size: 20px;
|
|
23
|
+
}
|
|
24
|
+
.calendar-header-btn {
|
|
25
|
+
background: #eee;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
border: 0;
|
|
28
|
+
padding: 0 15px;
|
|
29
|
+
line-height: 20px;
|
|
30
|
+
}
|
|
31
|
+
.calendar-header-btn:hover {
|
|
32
|
+
background: #ccc;
|
|
33
|
+
}
|
|
34
|
+
.calendar-header-icon {
|
|
35
|
+
width: 20px;
|
|
36
|
+
height: 20px;
|
|
37
|
+
line-height: 20px;
|
|
38
|
+
border-radius: 50%;
|
|
39
|
+
text-align: center;
|
|
40
|
+
font-size: 20px;
|
|
41
|
+
user-select: none;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
margin-right: 12px;
|
|
44
|
+
}
|
|
45
|
+
.calendar-header-icon:not(:first-child) {
|
|
46
|
+
margin: 0 12px;
|
|
47
|
+
}
|
|
48
|
+
.calendar-header-icon:hover {
|
|
49
|
+
background: #ccc;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.calendar-month-week-list {
|
|
53
|
+
display: flex;
|
|
54
|
+
padding: 0;
|
|
55
|
+
width: 100%;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
border-bottom: 1px solid #eee;
|
|
58
|
+
}
|
|
59
|
+
.calendar-month-week-list-item {
|
|
60
|
+
padding: 20px 16px;
|
|
61
|
+
text-align: left;
|
|
62
|
+
color: #7d7d7f;
|
|
63
|
+
flex: 1;
|
|
64
|
+
}
|
|
65
|
+
.calendar-month-body-row {
|
|
66
|
+
height: 70px;
|
|
67
|
+
display: flex;
|
|
68
|
+
border-left: 1px solid #eee;
|
|
69
|
+
border-top: 1px solid #eee;
|
|
70
|
+
}
|
|
71
|
+
.calendar-month-body-cell {
|
|
72
|
+
flex: 1;
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
text-align: left;
|
|
75
|
+
border-right: 1px solid #eee;
|
|
76
|
+
border-bottom: 1px solid #eee;
|
|
77
|
+
color: #ccc;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
padding: 5px;
|
|
80
|
+
}
|
|
81
|
+
.calendar-month-body-cell-current {
|
|
82
|
+
color: #000;
|
|
83
|
+
}
|
|
84
|
+
.calendar-month-body-cell-date {
|
|
85
|
+
padding: 5px;
|
|
86
|
+
}
|
|
87
|
+
.calendar-month-body-cell-date-selected {
|
|
88
|
+
background: blue;
|
|
89
|
+
width: 25px;
|
|
90
|
+
height: 25px;
|
|
91
|
+
line-height: 25px;
|
|
92
|
+
text-align: center;
|
|
93
|
+
color: #fff;
|
|
94
|
+
border-radius: 50%;
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
}
|
|
97
|
+
.calendar-month-body-cell-date-content {
|
|
98
|
+
font-size: 11px;
|
|
99
|
+
line-height: 16px;
|
|
100
|
+
color: #6b7280;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
text-overflow: ellipsis;
|
|
104
|
+
margin-top: 6px;
|
|
105
|
+
display: inline-block;
|
|
106
|
+
max-width: 100%;
|
|
107
|
+
background: #f3f4f6;
|
|
108
|
+
border-radius: 8px;
|
|
109
|
+
padding: 0 6px;
|
|
110
|
+
height: 16px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../../src/Calendar/index.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EAEA;EACA;;;AAIF;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAIR;EACI;EACA;EAEA;EAEA;EACA;EACA;EAEA;EACA;EAEA;;AACA;EACI;;AAGJ;EACI;;;AAMR;EACI;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAKJ;EACI;EACA;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;;AAEJ;EACI;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA","file":"index.css"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
export interface CalendarProps {
|
|
4
|
+
value?: Dayjs;
|
|
5
|
+
defaultValue?: Dayjs;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
className?: string | string[];
|
|
8
|
+
dateRender?: (currentDate: Dayjs) => ReactNode;
|
|
9
|
+
dateInnerContent?: (currentDate: Dayjs) => ReactNode;
|
|
10
|
+
locale?: string;
|
|
11
|
+
onChange?: (date: Dayjs) => void;
|
|
12
|
+
}
|
|
13
|
+
declare function Calendar(props: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default Calendar;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
// import './index.scss';
|
|
5
|
+
const MonthCalendar_1 = require("./MonthCalendar");
|
|
6
|
+
const Header_1 = require("./Header");
|
|
7
|
+
const classnames_1 = require("classnames");
|
|
8
|
+
const LocaleContext_1 = require("./LocaleContext");
|
|
9
|
+
const dayjs_1 = require("dayjs");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const ahooks_1 = require("ahooks");
|
|
12
|
+
function Calendar(props) {
|
|
13
|
+
const { value, style, className, locale, onChange } = props;
|
|
14
|
+
const [curValue, setCurValue] = (0, ahooks_1.useControllableValue)(props, {
|
|
15
|
+
defaultValue: (0, dayjs_1.default)()
|
|
16
|
+
});
|
|
17
|
+
const [curMonth, setCurMonth] = (0, react_1.useState)(curValue);
|
|
18
|
+
const classNames = (0, classnames_1.default)("calendar", className);
|
|
19
|
+
function changeDate(date) {
|
|
20
|
+
setCurValue(date);
|
|
21
|
+
setCurMonth(date);
|
|
22
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(date);
|
|
23
|
+
}
|
|
24
|
+
function selectHandler(date) {
|
|
25
|
+
changeDate(date);
|
|
26
|
+
}
|
|
27
|
+
function prevMonthHandler() {
|
|
28
|
+
setCurMonth(curMonth.subtract(1, 'month'));
|
|
29
|
+
}
|
|
30
|
+
function nextMonthHandler() {
|
|
31
|
+
setCurMonth(curMonth.add(1, 'month'));
|
|
32
|
+
}
|
|
33
|
+
function todayHandler() {
|
|
34
|
+
const date = (0, dayjs_1.default)(Date.now());
|
|
35
|
+
changeDate(date);
|
|
36
|
+
}
|
|
37
|
+
return (0, jsx_runtime_1.jsx)(LocaleContext_1.default.Provider, { value: {
|
|
38
|
+
locale: locale || navigator.language
|
|
39
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: classNames, style: style, children: (0, jsx_runtime_1.jsxs)("div", { className: 'calendar', children: [(0, jsx_runtime_1.jsx)(Header_1.default, { curMonth: curMonth, prevMonthHandler: prevMonthHandler, nextMonthHandler: nextMonthHandler, todayHandler: todayHandler }), (0, jsx_runtime_1.jsx)(MonthCalendar_1.default, Object.assign({}, props, { value: curValue, curMonth: curMonth, selectHandler: selectHandler }))] }) }) });
|
|
40
|
+
}
|
|
41
|
+
exports.default = Calendar;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const CalendarLocale = {
|
|
4
|
+
formatYear: 'YYYY',
|
|
5
|
+
formatMonth: 'MMM YYYY',
|
|
6
|
+
today: 'Today',
|
|
7
|
+
month: {
|
|
8
|
+
January: 'January',
|
|
9
|
+
February: 'February',
|
|
10
|
+
March: 'March',
|
|
11
|
+
April: 'April',
|
|
12
|
+
May: 'May',
|
|
13
|
+
June: 'June',
|
|
14
|
+
July: 'July',
|
|
15
|
+
August: 'August',
|
|
16
|
+
September: 'September',
|
|
17
|
+
October: 'October',
|
|
18
|
+
November: 'November',
|
|
19
|
+
December: 'December',
|
|
20
|
+
},
|
|
21
|
+
week: {
|
|
22
|
+
monday: 'Monday',
|
|
23
|
+
tuesday: 'Tuesday',
|
|
24
|
+
wednesday: 'Wednesday',
|
|
25
|
+
thursday: 'Thursday',
|
|
26
|
+
friday: 'Friday',
|
|
27
|
+
saturday: 'Saturday',
|
|
28
|
+
sunday: 'Sunday',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
exports.default = CalendarLocale;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const zh_CN_1 = require("./zh-CN");
|
|
4
|
+
const en_US_1 = require("./en-US");
|
|
5
|
+
const allLocales = {
|
|
6
|
+
'zh-CN': zh_CN_1.default,
|
|
7
|
+
'en-US': en_US_1.default
|
|
8
|
+
};
|
|
9
|
+
exports.default = allLocales;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface CalendarType {
|
|
2
|
+
formatYear: string;
|
|
3
|
+
formatMonth: string;
|
|
4
|
+
today: string;
|
|
5
|
+
month: {
|
|
6
|
+
January: string;
|
|
7
|
+
February: string;
|
|
8
|
+
March: string;
|
|
9
|
+
April: string;
|
|
10
|
+
May: string;
|
|
11
|
+
June: string;
|
|
12
|
+
July: string;
|
|
13
|
+
August: string;
|
|
14
|
+
September: string;
|
|
15
|
+
October: string;
|
|
16
|
+
November: string;
|
|
17
|
+
December: string;
|
|
18
|
+
} & Record<string, any>;
|
|
19
|
+
week: {
|
|
20
|
+
monday: string;
|
|
21
|
+
tuesday: string;
|
|
22
|
+
wednesday: string;
|
|
23
|
+
thursday: string;
|
|
24
|
+
friday: string;
|
|
25
|
+
saturday: string;
|
|
26
|
+
sunday: string;
|
|
27
|
+
} & Record<string, any>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const CalendarLocale = {
|
|
4
|
+
formatYear: 'YYYY 年',
|
|
5
|
+
formatMonth: 'YYYY 年 MM 月',
|
|
6
|
+
today: '今天',
|
|
7
|
+
month: {
|
|
8
|
+
January: '一月',
|
|
9
|
+
February: '二月',
|
|
10
|
+
March: '三月',
|
|
11
|
+
April: '四月',
|
|
12
|
+
May: '五月',
|
|
13
|
+
June: '六月',
|
|
14
|
+
July: '七月',
|
|
15
|
+
August: '八月',
|
|
16
|
+
September: '九月',
|
|
17
|
+
October: '十月',
|
|
18
|
+
November: '十一月',
|
|
19
|
+
December: '十二月',
|
|
20
|
+
},
|
|
21
|
+
week: {
|
|
22
|
+
monday: '周一',
|
|
23
|
+
tuesday: '周二',
|
|
24
|
+
wednesday: '周三',
|
|
25
|
+
thursday: '周四',
|
|
26
|
+
friday: '周五',
|
|
27
|
+
saturday: '周六',
|
|
28
|
+
sunday: '周日',
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.default = CalendarLocale;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren, RefObject } from "react";
|
|
2
|
+
import { MessageRef } from ".";
|
|
3
|
+
interface ConfigProviderProps {
|
|
4
|
+
messageRef?: RefObject<MessageRef | null>;
|
|
5
|
+
}
|
|
6
|
+
export declare const ConfigContext: import("react").Context<ConfigProviderProps>;
|
|
7
|
+
export declare function ConfigProvider(props: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigContext = void 0;
|
|
4
|
+
exports.ConfigProvider = ConfigProvider;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const _1 = require(".");
|
|
8
|
+
exports.ConfigContext = (0, react_1.createContext)({});
|
|
9
|
+
function ConfigProvider(props) {
|
|
10
|
+
const { children } = props;
|
|
11
|
+
const messageRef = (0, react_1.useRef)(null);
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(exports.ConfigContext.Provider, { value: { messageRef }, children: [(0, jsx_runtime_1.jsx)(_1.MessageProvider, { ref: messageRef }), children] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.message-enter {
|
|
2
|
+
opacity: 0;
|
|
3
|
+
transform: scale(1.1);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.message-enter-active {
|
|
7
|
+
opacity: 1;
|
|
8
|
+
transform: scale(1);
|
|
9
|
+
transition: opacity, transform 1s ease;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.message-exit {
|
|
13
|
+
opacity: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.message-exit-active {
|
|
17
|
+
opacity: 0;
|
|
18
|
+
transition: opacity 1s ease;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.message-wrapper {
|
|
22
|
+
position: fixed;
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
justify-content: flex-start;
|
|
29
|
+
align-items: center;
|
|
30
|
+
}
|
|
31
|
+
.message-wrapper-top {
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 20px;
|
|
34
|
+
}
|
|
35
|
+
.message-wrapper-bottom {
|
|
36
|
+
position: absolute;
|
|
37
|
+
bottom: 20px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.message-item {
|
|
41
|
+
margin-bottom: 12px;
|
|
42
|
+
padding: 10px 16px;
|
|
43
|
+
line-height: 14px;
|
|
44
|
+
font-size: 14px;
|
|
45
|
+
border: 1px solid #ccc;
|
|
46
|
+
box-shadow: 0 0 3px #ccc;
|
|
47
|
+
pointer-events: all;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../../src/Message/index.scss"],"names":[],"mappings":"AAAA;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;EAEA;EAEA;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAGF;EACE;EACA;;;AAIJ;EACE;EAEA;EACA;EACA;EAEA;EACA;EAEA","file":"index.css"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
export type Position = 'top' | 'bottom';
|
|
3
|
+
export interface MessageProps {
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
className?: string | string[];
|
|
6
|
+
content: ReactNode | string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
onClose?: (...args: any) => void;
|
|
9
|
+
id?: number;
|
|
10
|
+
position?: Position;
|
|
11
|
+
}
|
|
12
|
+
export interface MessageRef {
|
|
13
|
+
add: (messageProps: MessageProps) => number;
|
|
14
|
+
remove: (id: number) => void;
|
|
15
|
+
update: (id: number, messageProps: MessageProps) => void;
|
|
16
|
+
clearAll: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const MessageProvider: import("react").ForwardRefExoticComponent<import("react").RefAttributes<MessageRef>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useStore_1 = require("./useStore");
|
|
7
|
+
const react_transition_group_1 = require("react-transition-group");
|
|
8
|
+
const useTimer_1 = require("./useTimer");
|
|
9
|
+
// import './index.scss';
|
|
10
|
+
const react_dom_1 = require("react-dom");
|
|
11
|
+
const MessageItem = (item) => {
|
|
12
|
+
const { onMouseEnter, onMouseLeave } = (0, useTimer_1.useTimer)({
|
|
13
|
+
id: item.id,
|
|
14
|
+
duration: item.duration,
|
|
15
|
+
remove: item.onClose,
|
|
16
|
+
});
|
|
17
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "message-item", onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: item.content });
|
|
18
|
+
};
|
|
19
|
+
exports.MessageProvider = (0, react_1.forwardRef)((props, ref) => {
|
|
20
|
+
const { messageList, add, update, remove, clearAll } = (0, useStore_1.default)('top');
|
|
21
|
+
// useEffect(() => {
|
|
22
|
+
// setInterval(() => {
|
|
23
|
+
// add({
|
|
24
|
+
// content: Math.random().toString().slice(2, 8)
|
|
25
|
+
// })
|
|
26
|
+
// }, 2000);
|
|
27
|
+
// }, []);
|
|
28
|
+
if ('current' in ref) {
|
|
29
|
+
ref.current = {
|
|
30
|
+
add,
|
|
31
|
+
update,
|
|
32
|
+
remove,
|
|
33
|
+
clearAll
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// useImperativeHandle(ref, () => {
|
|
37
|
+
// debugger;
|
|
38
|
+
// return {
|
|
39
|
+
// add,
|
|
40
|
+
// update,
|
|
41
|
+
// remove,
|
|
42
|
+
// clearAll
|
|
43
|
+
// }
|
|
44
|
+
// }, []);
|
|
45
|
+
const positions = Object.keys(messageList);
|
|
46
|
+
const messageWrapper = (0, jsx_runtime_1.jsx)("div", { className: "message-wrapper", children: positions.map(direction => {
|
|
47
|
+
return (0, jsx_runtime_1.jsx)(react_transition_group_1.TransitionGroup, { className: `message-wrapper-${direction}`, children: messageList[direction].map(item => {
|
|
48
|
+
return (0, jsx_runtime_1.jsx)(react_transition_group_1.CSSTransition, { timeout: 1000, classNames: 'message', children: (0, jsx_runtime_1.jsx)(MessageItem, Object.assign({ onClose: remove }, item)) }, item.id);
|
|
49
|
+
}) }, direction);
|
|
50
|
+
}) });
|
|
51
|
+
const el = (0, react_1.useMemo)(() => {
|
|
52
|
+
const el = document.createElement('div');
|
|
53
|
+
el.className = `wrapper`;
|
|
54
|
+
document.body.appendChild(el);
|
|
55
|
+
return el;
|
|
56
|
+
}, []);
|
|
57
|
+
return (0, react_dom_1.createPortal)(messageWrapper, el);
|
|
58
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMessage = useMessage;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ConfigProvider_1 = require("./ConfigProvider");
|
|
6
|
+
function useMessage() {
|
|
7
|
+
const { messageRef } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
8
|
+
if (!messageRef) {
|
|
9
|
+
throw new Error('请在最外层添加 ConfigProvider 组件');
|
|
10
|
+
}
|
|
11
|
+
debugger;
|
|
12
|
+
return messageRef.current;
|
|
13
|
+
}
|