@cloudbase/weda-ui 0.2.15 → 1.0.21
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 +41 -169
- package/package.json +28 -15
- package/src/configs/components/calendar.json +78 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +379 -0
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +154 -0
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +410 -0
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +20 -4
- package/src/configs/components/listView.json +277 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +362 -0
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +6 -3
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +34 -0
- package/src/mp/components/button/index.js +12 -13
- package/src/mp/components/button/index.wxml +1 -1
- package/src/mp/components/calendar/arrowright--line.svg +11 -0
- package/src/mp/components/calendar/index.js +238 -0
- package/src/mp/components/calendar/index.json +4 -0
- package/src/mp/components/calendar/index.wxml +37 -0
- package/src/mp/components/calendar/index.wxss +178 -0
- package/src/mp/components/carousel/index.js +88 -0
- package/src/mp/components/carousel/index.json +7 -0
- package/src/mp/components/carousel/index.wxml +6 -0
- package/src/mp/components/chart/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +253 -0
- package/src/mp/components/chart/statisticsCard/index.json +4 -0
- package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
- package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
- package/src/mp/components/dataView/index.js +34 -0
- package/src/mp/components/dataView/index.json +7 -0
- package/src/mp/components/dataView/index.wxml +15 -0
- package/src/mp/components/dataView/index.wxss +0 -0
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
- package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
- package/src/mp/components/form/location/index.js +382 -0
- package/src/mp/components/form/location/index.json +6 -0
- package/src/mp/components/form/location/index.wxml +25 -0
- package/src/mp/components/form/location/index.wxss +91 -0
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +84 -48
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +106 -27
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +203 -0
- package/src/mp/components/graphicCard/index.json +4 -0
- package/src/mp/components/graphicCard/index.wxml +29 -0
- package/src/mp/components/graphicCard/index.wxss +157 -0
- package/src/mp/components/image/index.js +0 -1
- package/src/mp/components/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/listView/index.js +285 -0
- package/src/mp/components/listView/index.json +4 -0
- package/src/mp/components/listView/index.wxml +40 -0
- package/src/mp/components/listView/index.wxss +155 -0
- package/src/mp/components/listView/more-line.svg +3 -0
- package/src/mp/components/navLayout/index.js +123 -0
- package/src/mp/components/navLayout/index.json +7 -0
- package/src/mp/components/navLayout/index.wxml +25 -0
- package/src/mp/components/navLayout/index.wxss +1193 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/swiper/index.wxml +2 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +18 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
- package/src/mp/utils/spark-md5.js +776 -0
- package/src/mp/utils/tcb.js +62 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/calendar/index.css +382 -0
- package/src/web/components/calendar/index.jsx +312 -0
- package/src/web/components/calendar/util.js +90 -0
- package/src/web/components/carousel/index.css +119 -0
- package/src/web/components/carousel/index.tsx +417 -0
- package/src/web/components/chart/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/chart/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +307 -0
- package/src/web/components/chart/statisticsCard/interface.ts +14 -0
- package/src/web/components/dataView/index.tsx +20 -0
- package/src/web/components/dataView/interface.ts +6 -0
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/location/common/mapChoose.css +178 -0
- package/src/web/components/form/location/common/mapChoose.jsx +343 -0
- package/src/web/components/form/location/common/mapView.jsx +190 -0
- package/src/web/components/form/location/common/propsConfig.js +54 -0
- package/src/web/components/form/location/common/selectModal.css +44 -0
- package/src/web/components/form/location/common/selectModal.jsx +82 -0
- package/src/web/components/form/location/common/useLocationInfo.js +100 -0
- package/src/web/components/form/location/components/LocationH5/index.css +243 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
- package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
- package/src/web/components/form/location/components/LocationPC/index.css +44 -0
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
- package/src/web/components/form/location/constants.js +4 -0
- package/src/web/components/form/location/index.css +0 -0
- package/src/web/components/form/location/index.jsx +25 -0
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +389 -71
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +404 -144
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
- package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
- package/src/web/components/graphicCard/index.css +159 -0
- package/src/web/components/graphicCard/index.tsx +310 -0
- package/src/web/components/image/image.tsx +1 -2
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +24 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +143 -0
- package/src/web/components/listView/index.tsx +359 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +4 -2
- package/src/web/components/tabs/tabs.h5.tsx +50 -37
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +40 -0
- package/src/web/utils/tcb.js +49 -0
- package/src/web/utils/tmap.js +4 -0
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { usePlatform } from '../../utils/platform';
|
|
3
|
+
import { ConfigProvider, Select } from 'tea-component';
|
|
4
|
+
import * as PropTypes from 'prop-types';
|
|
5
|
+
import classNames from '../../utils/classnames';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import { createDateList } from './util';
|
|
8
|
+
import './index.css';
|
|
9
|
+
|
|
10
|
+
// 抽取配置常量
|
|
11
|
+
const blockName = 'weda-calendar'; // 类名前缀
|
|
12
|
+
const minYear = 1970; // 最早选择年份
|
|
13
|
+
const firstDayOfWeek = 1; // 日历从周一开始
|
|
14
|
+
const format = 'YYYY-MM-DD';
|
|
15
|
+
const controlSectionSize = 'auto'; // 操作栏控件尺寸
|
|
16
|
+
const week = ['一', '二', '三', '四', '五', '六', '日']; // 表头日历星期展示方式
|
|
17
|
+
const isShowWeekend = true; // 是否显示周末
|
|
18
|
+
|
|
19
|
+
export default function Calendar({
|
|
20
|
+
className,
|
|
21
|
+
style,
|
|
22
|
+
initVisible = true,
|
|
23
|
+
initValue,
|
|
24
|
+
configData = [],
|
|
25
|
+
}) {
|
|
26
|
+
// 'h5' || 'pc'
|
|
27
|
+
const platform = usePlatform();
|
|
28
|
+
const visible = typeof initVisible === 'boolean' ? initVisible : true;
|
|
29
|
+
// dayjs.Dayjs
|
|
30
|
+
const [value, setValue] = useState(dayjs());
|
|
31
|
+
// number
|
|
32
|
+
const [year, setYear] = useState(dayjs().year());
|
|
33
|
+
const [month, setMonth] = useState(parseInt(dayjs().format('M'), 10));
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (initValue !== null && initValue !== '') {
|
|
37
|
+
setValue(dayjs(initValue));
|
|
38
|
+
setYear(dayjs(initValue).year());
|
|
39
|
+
setMonth(parseInt(dayjs(initValue).format('M'), 10));
|
|
40
|
+
}
|
|
41
|
+
}, [initValue]);
|
|
42
|
+
|
|
43
|
+
// 年份、月份 Select 选择框选项
|
|
44
|
+
const [yearSelectList, monthSelectList] = useMemo(() => {
|
|
45
|
+
const yearList = [];
|
|
46
|
+
const monthList = [];
|
|
47
|
+
|
|
48
|
+
// 年列表
|
|
49
|
+
const yearBegin = Math.min(minYear, year - 50);
|
|
50
|
+
const yearEnd = Math.max(minYear, year + 50); // parseInt(dayjs().format('YYYY-MM-DD'));
|
|
51
|
+
|
|
52
|
+
for (let i = yearBegin; i <= yearEnd; i++) {
|
|
53
|
+
yearList.push({
|
|
54
|
+
value: i,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// 月列表
|
|
58
|
+
for (let i = 1; i <= 12; i++) {
|
|
59
|
+
monthList.push({
|
|
60
|
+
value: i,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return [yearList, monthList];
|
|
65
|
+
}, [year, month]);
|
|
66
|
+
|
|
67
|
+
// 匹配数据
|
|
68
|
+
const _dateList = (configList) => {
|
|
69
|
+
const _map = new Map();
|
|
70
|
+
const configArr = JSON.parse(JSON.stringify(configData));
|
|
71
|
+
// 补日期的零
|
|
72
|
+
configArr &&
|
|
73
|
+
configArr.length &&
|
|
74
|
+
configArr.map((item) => {
|
|
75
|
+
if (item.matchDate === '' || item.matchDate === undefined) return;
|
|
76
|
+
const date = item.matchDate.split('-');
|
|
77
|
+
const day = date[2].split('');
|
|
78
|
+
if (day.length === 1) {
|
|
79
|
+
date[2] = `0${date[2]}`;
|
|
80
|
+
item.matchDate = date.join('-');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
for (const item of configArr) {
|
|
84
|
+
_map.set(item.matchDate, item);
|
|
85
|
+
}
|
|
86
|
+
return configList.map((item) => {
|
|
87
|
+
return item.reduce((res, i) => {
|
|
88
|
+
if (_map.has(i.formattedDate)) {
|
|
89
|
+
const _disabled = _map.get(i.formattedDate)['disabled'];
|
|
90
|
+
const _marked = _map.get(i.formattedDate)['marked'];
|
|
91
|
+
i['disabled'] =
|
|
92
|
+
_disabled !== undefined ? JSON.parse(_disabled) : false;
|
|
93
|
+
i['marked'] = _marked;
|
|
94
|
+
}
|
|
95
|
+
res.push(i);
|
|
96
|
+
return res;
|
|
97
|
+
}, []);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// 日历单元格数据
|
|
102
|
+
const dateList = useMemo(
|
|
103
|
+
() => _dateList(createDateList(year, month, firstDayOfWeek, value, format)),
|
|
104
|
+
[year, month, firstDayOfWeek, format, value, configData]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// 表头数组
|
|
108
|
+
const colHeaderList = useMemo(() => {
|
|
109
|
+
const weekTextArr = week;
|
|
110
|
+
const list = [];
|
|
111
|
+
for (let i = firstDayOfWeek; i <= 7; i++) {
|
|
112
|
+
if (!isShowWeekend && i > 5) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
list.push({
|
|
116
|
+
day: i,
|
|
117
|
+
text: weekTextArr[i - 1],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (firstDayOfWeek > 1) {
|
|
121
|
+
for (let i = 1; i < firstDayOfWeek; i++) {
|
|
122
|
+
if (!isShowWeekend && i > 5) {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
list.push({
|
|
126
|
+
day: i,
|
|
127
|
+
text: weekTextArr[i - 1],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return list;
|
|
132
|
+
}, [firstDayOfWeek, isShowWeekend, week]);
|
|
133
|
+
|
|
134
|
+
// 补零
|
|
135
|
+
// const fix0 = (num) => {
|
|
136
|
+
// return num < 10 ? `0${num}` : num;
|
|
137
|
+
// };
|
|
138
|
+
const yearSelectOptions = () => {
|
|
139
|
+
return yearSelectList.map((item) => ({
|
|
140
|
+
text: `${item.value} 年`,
|
|
141
|
+
value: `${item.value}`,
|
|
142
|
+
}));
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const monthSelectOptions = () => {
|
|
146
|
+
return monthSelectList.map((item) => ({
|
|
147
|
+
text: `${item.value} 月`,
|
|
148
|
+
value: `${item.value}`,
|
|
149
|
+
}));
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<div
|
|
154
|
+
data-testid="weda-calendar"
|
|
155
|
+
className={classNames(
|
|
156
|
+
blockName,
|
|
157
|
+
'weda-ui',
|
|
158
|
+
platform === 'h5' ? `${blockName}-h5` : `${blockName}-pc`,
|
|
159
|
+
{
|
|
160
|
+
[className]: className,
|
|
161
|
+
}
|
|
162
|
+
)}
|
|
163
|
+
style={style}
|
|
164
|
+
>
|
|
165
|
+
{/* 操作部分 PC*/}
|
|
166
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
167
|
+
<div
|
|
168
|
+
className={blockName + '__control_pc'}
|
|
169
|
+
data-testid="weda-calendar-control-pc"
|
|
170
|
+
>
|
|
171
|
+
{visible ? (
|
|
172
|
+
<div className={blockName + '__control-section'}>
|
|
173
|
+
{/* 年份选择框 */}
|
|
174
|
+
<div className={blockName + '__control-section-cell'}>
|
|
175
|
+
<Select
|
|
176
|
+
appearance="button"
|
|
177
|
+
size={controlSectionSize}
|
|
178
|
+
value={String(year)}
|
|
179
|
+
options={yearSelectOptions()}
|
|
180
|
+
onChange={(selectYear) => setYear(parseInt(selectYear))}
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
{/* 月份选择框 */}
|
|
184
|
+
<div className={blockName + '__control-section-cell'}>
|
|
185
|
+
<Select
|
|
186
|
+
appearance="button"
|
|
187
|
+
size={controlSectionSize}
|
|
188
|
+
value={String(month)}
|
|
189
|
+
options={monthSelectOptions()}
|
|
190
|
+
onChange={(selectMonth) => setMonth(parseInt(selectMonth))}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
) : (
|
|
195
|
+
<div
|
|
196
|
+
className={`${blockName}__current-date`}
|
|
197
|
+
>{`${year} 年 ${month} 月`}</div>
|
|
198
|
+
)}
|
|
199
|
+
</div>
|
|
200
|
+
</ConfigProvider>
|
|
201
|
+
|
|
202
|
+
{/* H5 */}
|
|
203
|
+
<div
|
|
204
|
+
className={blockName + '__control_h5'}
|
|
205
|
+
data-testid="weda-calendar-control-h5"
|
|
206
|
+
>
|
|
207
|
+
{visible && (
|
|
208
|
+
<div
|
|
209
|
+
className={blockName + '_prevMonth wedatea2td-icon-arrowleft--line'}
|
|
210
|
+
onClick={() => {
|
|
211
|
+
// 上一个月
|
|
212
|
+
setYear(month === 1 ? year - 1 : year);
|
|
213
|
+
setMonth(month === 1 ? 12 : month - 1);
|
|
214
|
+
}}
|
|
215
|
+
></div>
|
|
216
|
+
)}
|
|
217
|
+
<div
|
|
218
|
+
className={`${blockName}__current-date`}
|
|
219
|
+
>{`${year}年${month}月`}</div>
|
|
220
|
+
{visible && (
|
|
221
|
+
<div
|
|
222
|
+
className={
|
|
223
|
+
blockName + '_nextMonth wedatea2td-icon-arrowright--line'
|
|
224
|
+
}
|
|
225
|
+
onClick={() => {
|
|
226
|
+
// 下一个月
|
|
227
|
+
setYear(month === 12 ? year + 1 : year);
|
|
228
|
+
setMonth(month === 12 ? 1 : month + 1);
|
|
229
|
+
}}
|
|
230
|
+
></div>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
{/* 主体部分 */}
|
|
235
|
+
<div className={blockName + '__panel'}>
|
|
236
|
+
<table className={blockName + '__table'}>
|
|
237
|
+
{/* 表头部分 */}
|
|
238
|
+
{colHeaderList.length > 0 && (
|
|
239
|
+
<thead className={blockName + '__table-head'}>
|
|
240
|
+
<tr className={blockName + '__table-head-row'}>
|
|
241
|
+
{colHeaderList.map((item) => (
|
|
242
|
+
<th
|
|
243
|
+
key={item.day}
|
|
244
|
+
className={blockName + '__table-head-cell'}
|
|
245
|
+
>
|
|
246
|
+
{item.text}
|
|
247
|
+
</th>
|
|
248
|
+
))}
|
|
249
|
+
</tr>
|
|
250
|
+
</thead>
|
|
251
|
+
)}
|
|
252
|
+
<tbody className={blockName + '__table-body'}>
|
|
253
|
+
{dateList.map((dateRow, dateRowIndex) => (
|
|
254
|
+
<tr
|
|
255
|
+
key={String(dateRowIndex)}
|
|
256
|
+
className={blockName + '__table-body-row'}
|
|
257
|
+
>
|
|
258
|
+
{dateRow.map((dateCell, dateCellIndex) => {
|
|
259
|
+
if (!isShowWeekend && [6, 7].indexOf(dateCell.day) >= 0)
|
|
260
|
+
return null;
|
|
261
|
+
const isNow =
|
|
262
|
+
(dateCell.formattedDate === dayjs().format('YYYY-MM-DD') &&
|
|
263
|
+
'is-now') ||
|
|
264
|
+
'';
|
|
265
|
+
return (
|
|
266
|
+
<td
|
|
267
|
+
key={String(dateCellIndex)}
|
|
268
|
+
className={classNames(
|
|
269
|
+
`${blockName}__table-body-cell`,
|
|
270
|
+
isNow,
|
|
271
|
+
dateCell.isCurrent ? 'is-checked' : '',
|
|
272
|
+
dateCell.belongTo !== 0 ? 'is-disabled' : '',
|
|
273
|
+
dateCell.disabled ? 'is-invalid' : ''
|
|
274
|
+
)}
|
|
275
|
+
>
|
|
276
|
+
<div className={blockName + '__table-body-cell-value'}>
|
|
277
|
+
{dateCell.date.getDate()}
|
|
278
|
+
<div
|
|
279
|
+
className={`${blockName}__table-body-cell-bg`}
|
|
280
|
+
></div>
|
|
281
|
+
{dateCell.marked && dateCell.marked !== '' && (
|
|
282
|
+
<div
|
|
283
|
+
style={{ backgroundColor: `${dateCell.marked}` }}
|
|
284
|
+
className={blockName + '__table-body-cell-marked'}
|
|
285
|
+
data-testid="weda-calendar-cell-marked"
|
|
286
|
+
></div>
|
|
287
|
+
)}
|
|
288
|
+
</div>
|
|
289
|
+
</td>
|
|
290
|
+
);
|
|
291
|
+
})}
|
|
292
|
+
</tr>
|
|
293
|
+
))}
|
|
294
|
+
</tbody>
|
|
295
|
+
</table>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
Calendar.propTypes = {
|
|
302
|
+
className: PropTypes.string,
|
|
303
|
+
style: PropTypes.object,
|
|
304
|
+
/** 传入日期 '2021-01-01' */
|
|
305
|
+
initValue: PropTypes.string,
|
|
306
|
+
/** 平台 'h5' || 'pc'*/
|
|
307
|
+
platform: PropTypes.string,
|
|
308
|
+
/** 时间控制器 */
|
|
309
|
+
initVisible: PropTypes.bool,
|
|
310
|
+
/** 展示配置 */
|
|
311
|
+
configData: PropTypes.array,
|
|
312
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取一个日期是周几(1~7)
|
|
5
|
+
*/
|
|
6
|
+
export const getDay = (dt) => {
|
|
7
|
+
let day = dayjs(dt).day();
|
|
8
|
+
if (day === 0) {
|
|
9
|
+
day = 7;
|
|
10
|
+
}
|
|
11
|
+
return day;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 创建日历单元格数据
|
|
16
|
+
* @param year 日历年份
|
|
17
|
+
* @param month 日历月份
|
|
18
|
+
* @param firstDayOfWeek 周起始日(1~7)
|
|
19
|
+
* @param currentValue 当前日期
|
|
20
|
+
* @param format 日期格式
|
|
21
|
+
*/
|
|
22
|
+
export const createDateList = (
|
|
23
|
+
year,
|
|
24
|
+
month,
|
|
25
|
+
firstDayOfWeek,
|
|
26
|
+
currentValue,
|
|
27
|
+
format
|
|
28
|
+
) => {
|
|
29
|
+
const createCellData = (belongTo, isCurrent, date, weekOrder) => {
|
|
30
|
+
const day = getDay(date);
|
|
31
|
+
return {
|
|
32
|
+
mode: 'month',
|
|
33
|
+
belongTo,
|
|
34
|
+
isCurrent,
|
|
35
|
+
day,
|
|
36
|
+
weekOrder,
|
|
37
|
+
date,
|
|
38
|
+
formattedDate: dayjs(date).format(format),
|
|
39
|
+
filterDate: null,
|
|
40
|
+
formattedFilterDate: null,
|
|
41
|
+
isShowWeekend: true,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const monthFirstDay = dayjs(`${year}-${month}`);
|
|
46
|
+
const rowList = [];
|
|
47
|
+
let list = [];
|
|
48
|
+
let weekCount = 1;
|
|
49
|
+
|
|
50
|
+
// 添加上个月中会在本月显示的最后几天日期
|
|
51
|
+
// getDay(monthFirstDay.toDate()) 获取每月第一天是周几
|
|
52
|
+
const lastMonthDaysCount =
|
|
53
|
+
(getDay(monthFirstDay.toDate()) - firstDayOfWeek + 7) % 7;
|
|
54
|
+
for (let i = 0; i < lastMonthDaysCount; i++) {
|
|
55
|
+
// 获取显示在当前月的日历中,上月日期数据
|
|
56
|
+
// monthFirstDay.subtract(num, 'day' | 'month' | 'year') 表示以当月第一天日期为基准,在 日|月|年 数字上减去num
|
|
57
|
+
const dayObj = monthFirstDay.subtract(i + 1, 'day');
|
|
58
|
+
list.unshift(createCellData(-1, false, dayObj.toDate(), weekCount));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 添加本月日期
|
|
62
|
+
// 获取本月最后一天是几号
|
|
63
|
+
const monthDaysCount = monthFirstDay.endOf('month').daysInMonth();
|
|
64
|
+
for (let i = 0; i < monthDaysCount; i++) {
|
|
65
|
+
const dayObj = monthFirstDay.add(i, 'day');
|
|
66
|
+
list.push(
|
|
67
|
+
createCellData(0, currentValue.isSame(dayObj), dayObj.toDate(), weekCount)
|
|
68
|
+
);
|
|
69
|
+
if (list.length === 7) {
|
|
70
|
+
rowList.push(list);
|
|
71
|
+
list = [];
|
|
72
|
+
weekCount += 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 添加下月日期
|
|
77
|
+
if (list.length) {
|
|
78
|
+
// 获取当月最后一天
|
|
79
|
+
const monthLastDay = dayjs(`${year}-${month}`).endOf('month');
|
|
80
|
+
// 获取下月在当月日历中的天数
|
|
81
|
+
const nextMonthDaysCount = 7 - list.length;
|
|
82
|
+
for (let i = 0; i < nextMonthDaysCount; i++) {
|
|
83
|
+
const dayObj = monthLastDay.add(i + 1, 'day');
|
|
84
|
+
list.push(createCellData(1, false, dayObj.toDate(), weekCount));
|
|
85
|
+
}
|
|
86
|
+
rowList.push(list);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return rowList;
|
|
90
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.g-swiper {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
margin: auto;
|
|
4
|
+
width: 100%;
|
|
5
|
+
transition: height 0.15s ease-in;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.g-carousel {
|
|
10
|
+
height: 320px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.g-swiper-list {
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.g-swiper-item {
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
flex-flow: column;
|
|
24
|
+
min-width: 100%;
|
|
25
|
+
max-height: 100%;
|
|
26
|
+
margin: 0;
|
|
27
|
+
text-align: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.g-swiper.vertical {
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.g-swiper.vertical .g-swiper-list {
|
|
35
|
+
display: block;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.g-swiper.vertical .g-swiper-item {
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.g-swiper-item > div > * {
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: auto;
|
|
45
|
+
max-width: 100%;
|
|
46
|
+
max-height: 100%;
|
|
47
|
+
object-fit: cover;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* .g-swiper-item > div,
|
|
51
|
+
.g-swiper-item > div > .weda-image {
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
max-height: 100%;
|
|
56
|
+
} */
|
|
57
|
+
|
|
58
|
+
.g-swiper__pagination {
|
|
59
|
+
position: absolute;
|
|
60
|
+
bottom: 0;
|
|
61
|
+
margin: 10px 0;
|
|
62
|
+
padding: 0;
|
|
63
|
+
text-align: center;
|
|
64
|
+
width: 100%;
|
|
65
|
+
z-index: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.g-swiper__pagination-bulletm {
|
|
69
|
+
background: #fff;
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
box-shadow: 1px 1px 2px rgb(0 0 0 / 70%);
|
|
72
|
+
width: 8px;
|
|
73
|
+
height: 8px;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
margin: 0 8px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (max-width: 1024px) {
|
|
79
|
+
.g-swiper .g-swiper__turn-pre,
|
|
80
|
+
.g-swiper .g-swiper__turn-next {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.g-swiper__turn-pre,
|
|
86
|
+
.g-swiper__turn-next {
|
|
87
|
+
position: absolute;
|
|
88
|
+
box-sizing: content-box;
|
|
89
|
+
display: block;
|
|
90
|
+
top: 50%;
|
|
91
|
+
transform: translate3d(0, -50%, 0);
|
|
92
|
+
font-size: 0;
|
|
93
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
94
|
+
padding: 20px 10px;
|
|
95
|
+
width: 23px;
|
|
96
|
+
height: 41px;
|
|
97
|
+
background-position: center;
|
|
98
|
+
background-repeat: no-repeat;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.g-swiper__turn-pre {
|
|
102
|
+
left: 20px;
|
|
103
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAApCAYAAADeWrJ9AAAABGdBTUEAALGPC/xhBQAAAbpJREFUSA2t178rxHEcx/E7p/MrP9KRRbFcMZHBIBkMSjYyKEpXJIMkww3KcIOkxKAsBmWQDEQSgyRJUkKZFANJRBLy4+v51udT/oDXp569660e32933X1PKCQ8QRCEaZa6hWwo5OAZpp05GQ5mdzxtKmeBIkp88o8NgkU1POHgJTU85uBlZlT5UqQcvKKGRx28roZHHLzBzFC+FEkHbzKzlPCwg7eZ2Up40ME7angA8Id2KUd5x/0O3mPmKuFeB+8z85VwwsGHargb8JuOqEB5x12AX3RMhUq4w8EnzJgSbnfwKbNICbcBftI5FctgoDRqpXSyR5PuiwjMHqxRWiU7l1Rme9kBtAv00AddUVyGewi0md7ohir8XjZBG+mV7qhKBnsItJ6e6YFq/F42QWvpkZ6oTgZ7CLSa7umFGvxeNkEr6ZbsfWiSwR4CjdM1vVOL38smaDnZh8w+C20y2EOgpXRB9rXc4feyCVpCZ+4CCRnsIeAY2QPFfhX0+b1sghbQgbvAkAz2EHAe2e8ZO0m/l03QbNoynZOSwR4CzaQ10znjFPZ/k0xAeybYfxh2piTofwQ0QvPUaftfzME87zp8MlQAAAAASUVORK5CYII=);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.g-swiper__turn-next {
|
|
107
|
+
right: 20px;
|
|
108
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAApCAYAAADeWrJ9AAAABGdBTUEAALGPC/xhBQAAAZpJREFUSA21l7ErhHEYgO9cznUR6ZTBcAvFRMpCGQxKxstwJV1XlJQkyw0y3CJJLDJYZJEMSCKDJEmSQpkUA0lEEko+z3u9/oP3fevp1y3P87uv7/t+d6EQEwRBBhYgLJ9NB+kiyMyDbQBhBJZBZg5cAisFfRDMmF4akSGWb7CqgWmPQDHyNQ1MegSiyNc1kPcKbGlgwiuwrYFxj0AM+Y4Gch6BOPI9DYx5BfY1MOIVONDAsEegFPkh/MKQR6Ac8ZEGBrwCJxrIegVONZDxCFQiP4Mf6PMIJBCfayDtEahCfqGBHq/AlQZSRcaFEnwRJWXmZrdJuAGZDYiayBHVwi18Qz+YieuR3cMndJnsViTIGuERPqDDUtyM8BneoM1S3IrwFV6gxVLcjvAdnqDJUtyJUK7vAzRYirsRfsEd1FmKUwjlHpaHJGkpTiOU1+k11FiKsyq+ZK22FA8ilENYDoKEpXhUxcesFZbiHEIZ+X1SZinOF7RBsMsaNxEjCsOUijdZYyZikSCbVbH8o7B5F//vDmEvLIEcUWbzB99VPOowvSXGAAAAAElFTkSuQmCC);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.g-swiper__turn-pre:hover,
|
|
112
|
+
.g-swiper__turn-next:hover {
|
|
113
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
._editor-iframe
|
|
117
|
+
._wa-comp-container-empty-children:not(._wa-comp-slot-wrapper):after {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|