@cloudbase/weda-ui 0.2.15 → 0.2.16
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/package.json +10 -7
- package/src/configs/components/calendar.json +75 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/statisticsCard.json +331 -0
- package/src/configs/components/dataView.json +139 -0
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +399 -0
- package/src/configs/components/link.json +2 -2
- package/src/configs/components/listView.json +230 -0
- package/src/configs/components/navLayout.json +350 -0
- package/src/configs/components/swiper.json +3 -3
- package/src/configs/index.js +16 -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/statisticsCard/index.js +226 -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/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 +341 -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/uploader/index.js +39 -35
- package/src/mp/components/form/uploaderFile/index.js +61 -14
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +205 -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 +286 -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 +150 -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/swiper/index.wxml +2 -0
- package/src/mp/index.json +9 -1
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/dr_square_point.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 +18 -0
- 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/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +286 -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/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/uploader/uploader.h5.tsx +16 -10
- package/src/web/components/form/uploader/uploader.pc.tsx +15 -11
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +122 -107
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +22 -19
- package/src/web/components/graphicCard/index.css +163 -0
- package/src/web/components/graphicCard/index.tsx +309 -0
- package/src/web/components/image/image.tsx +0 -1
- package/src/web/components/index.js +12 -0
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +139 -0
- package/src/web/components/listView/index.tsx +354 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- package/src/web/components/tabs/index.tsx +2 -2
- package/src/web/components/tabs/tabs.h5.tsx +7 -4
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +31 -0
- package/src/web/utils/tcb.js +35 -0
- package/src/web/utils/tmap.js +4 -0
package/src/mp/utils/tcb.js
CHANGED
|
@@ -12,3 +12,21 @@ export async function getTempFileURL(data) {
|
|
|
12
12
|
return await getApp().app.cloud.getTempFileURL(data);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 调用微搭后端API服务
|
|
18
|
+
*/
|
|
19
|
+
export async function callWedaApi(param) {
|
|
20
|
+
if (getApp().app.cloud.callWedaApi) {
|
|
21
|
+
return await getApp().app.cloud.callWedaApi(param);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 云函数获取数据
|
|
27
|
+
*/
|
|
28
|
+
export async function callDataSource(param) {
|
|
29
|
+
if (getApp().app.cloud.callDataSource) {
|
|
30
|
+
return await getApp().app.cloud.callDataSource(param);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/* weda_calendar */
|
|
2
|
+
|
|
3
|
+
/* pc 日历样式 start */
|
|
4
|
+
.weda-calendar.weda-calendar-pc {
|
|
5
|
+
background: #FFFFFF;
|
|
6
|
+
border: 0.5px solid #DCDCDC;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
box-shadow: 0px 3px 14px 2px rgba(0, 0, 0, 0.05), 0px 8px 10px 1px rgba(0, 0, 0, 0.06), 0px 5px 5px -3px rgba(0, 0, 0, 0.1);
|
|
9
|
+
border-radius: 3px;
|
|
10
|
+
min-width: 560px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.weda-calendar-pc .weda-calendar__control_h5 {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.weda-calendar-pc .weda-calendar__control_pc {
|
|
18
|
+
padding: 32px;
|
|
19
|
+
display: flex;
|
|
20
|
+
display: -webkit-box;
|
|
21
|
+
display: -ms-flexbox;
|
|
22
|
+
-webkit-box-pack: end;
|
|
23
|
+
-ms-flex-pack: end;
|
|
24
|
+
justify-content: flex-end;
|
|
25
|
+
-webkit-box-align: center;
|
|
26
|
+
-ms-flex-align: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.weda-calendar-pc .weda-calendar__control-section {
|
|
31
|
+
display: flex;
|
|
32
|
+
display: -webkit-box;
|
|
33
|
+
display: -ms-flexbox;
|
|
34
|
+
-webkit-box-pack: end;
|
|
35
|
+
-ms-flex-pack: end;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
-webkit-box-align: center;
|
|
38
|
+
-ms-flex-align: center;
|
|
39
|
+
align-items: center;
|
|
40
|
+
height: 100%;
|
|
41
|
+
margin-right: 16px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.weda-calendar-pc .weda-calendar__control-section:last-child {
|
|
45
|
+
margin-right: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.weda-calendar-pc .weda-calendar__control-section .weda-calendar__control-section-cell {
|
|
49
|
+
height: 100%;
|
|
50
|
+
margin-right: 8px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.weda-calendar-pc .weda-calendar__control-section .weda-calendar__control-section-cell:last-child {
|
|
54
|
+
margin-right: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.weda-calendar-pc .weda-calendar__control-section .tea-dropdown .tea-dropdown__header {
|
|
58
|
+
background: #E7E7E7;
|
|
59
|
+
border-radius: 3px;
|
|
60
|
+
padding: 5px 32px 5px 12px;
|
|
61
|
+
height: 32px;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.weda-calendar-pc .weda-calendar__control-section .tea-dropdown .tea-dropdown__value {
|
|
66
|
+
font-size: 14px;
|
|
67
|
+
line-height: 22px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.weda-calendar-pc .weda-calendar__control_pc .weda-calendar__current-date {
|
|
71
|
+
font-size: 14px;
|
|
72
|
+
line-height: 22px;
|
|
73
|
+
color: rgba(0, 0, 0, 0.9);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.weda-calendar-pc .weda-calendar__panel {
|
|
77
|
+
position: relative;
|
|
78
|
+
padding: 0 32px 32px 32px;
|
|
79
|
+
width: 100%;
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.weda-calendar .weda-calendar__table {
|
|
84
|
+
border-collapse: collapse;
|
|
85
|
+
border-spacing: 0;
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 100%;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-head {
|
|
91
|
+
display: block;
|
|
92
|
+
width: 100%;
|
|
93
|
+
margin-bottom: 8px;
|
|
94
|
+
box-sizing: border-box;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-head-row,
|
|
98
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-row {
|
|
99
|
+
display: flex;
|
|
100
|
+
display: -webkit-box;
|
|
101
|
+
display: -ms-flexbox;
|
|
102
|
+
width: 100%;
|
|
103
|
+
padding-bottom: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-head-cell {
|
|
107
|
+
cursor: default;
|
|
108
|
+
-webkit-box-flex: 1;
|
|
109
|
+
-ms-flex: 1;
|
|
110
|
+
flex: 1;
|
|
111
|
+
display: -webkit-box;
|
|
112
|
+
display: -ms-flexbox;
|
|
113
|
+
display: flex;
|
|
114
|
+
-webkit-box-pack: end;
|
|
115
|
+
-ms-flex-pack: end;
|
|
116
|
+
justify-content: flex-end;
|
|
117
|
+
height: 100%;
|
|
118
|
+
padding: 0;
|
|
119
|
+
font-size: 14px;
|
|
120
|
+
line-height: 22px;
|
|
121
|
+
color: rgba(0, 0, 0, 0.6);
|
|
122
|
+
margin-right: 12px;
|
|
123
|
+
position: relative;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-head-cell:last-child,
|
|
127
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell:last-child {
|
|
128
|
+
margin-right: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body {
|
|
132
|
+
width: 100%;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell {
|
|
136
|
+
flex: 1;
|
|
137
|
+
-webkit-box-flex: 1;
|
|
138
|
+
-ms-flex: 1;
|
|
139
|
+
border-top: 1px solid #E7E7E7;
|
|
140
|
+
padding: 0;
|
|
141
|
+
height: 87.4px;
|
|
142
|
+
display: flex;
|
|
143
|
+
display: -webkit-box;
|
|
144
|
+
display: -ms-flexbox;
|
|
145
|
+
-webkit-box-orient: vertical;
|
|
146
|
+
-webkit-box-direction: normal;
|
|
147
|
+
-ms-flex-direction: column;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
-webkit-box-align: end;
|
|
150
|
+
-ms-flex-align: end;
|
|
151
|
+
align-items: flex-end;
|
|
152
|
+
margin-left: 0;
|
|
153
|
+
margin-right: 12px;
|
|
154
|
+
position: relative;
|
|
155
|
+
justify-content: flex-start;
|
|
156
|
+
color: rgba(0, 0, 0, 0.26);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell.is-disabled,
|
|
160
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell.is-invalid {
|
|
161
|
+
cursor: not-allowed;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell.is-invalid {
|
|
165
|
+
background: #F3F3F3;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell.is-now {
|
|
169
|
+
border-top-color: #0052D9;
|
|
170
|
+
background: #ECF2FE;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell-value {
|
|
174
|
+
font-size: 14px;
|
|
175
|
+
font-weight: 400;
|
|
176
|
+
line-height: 22px;
|
|
177
|
+
color: rgba(0, 0, 0, 0.9);
|
|
178
|
+
margin-top: 3px;
|
|
179
|
+
position: relative;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell.is-disabled .weda-calendar__table-body-cell-value {
|
|
183
|
+
color: rgba(0, 0, 0, 0.26);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.weda-calendar .weda-calendar__table .weda-calendar__table-body-cell .weda-calendar__table-body-cell-marked {
|
|
187
|
+
position: absolute;
|
|
188
|
+
width: 6px;
|
|
189
|
+
height: 6px;
|
|
190
|
+
border-radius: 50%;
|
|
191
|
+
left: 50%;
|
|
192
|
+
transform: translate(-50%);
|
|
193
|
+
bottom: -10px;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* pc 日历样式 end */
|
|
197
|
+
|
|
198
|
+
/* h5 日历样式 start */
|
|
199
|
+
|
|
200
|
+
.weda-calendar.weda-calendar-h5 {
|
|
201
|
+
background: #FFFFFF;
|
|
202
|
+
width: 100%;
|
|
203
|
+
opacity: 0.9;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.weda-calendar-h5 .weda-calendar__control_pc {
|
|
207
|
+
display: none;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.weda-calendar__control_h5 {
|
|
211
|
+
width: 100%;
|
|
212
|
+
box-sizing: border-box;
|
|
213
|
+
padding: 16px 16px 0 16px;
|
|
214
|
+
position: relative;
|
|
215
|
+
text-align: center;
|
|
216
|
+
}
|
|
217
|
+
.weda-calendar__control_h5 .wedatea2td-icon-arrowleft--line,
|
|
218
|
+
.weda-calendar__control_h5 .wedatea2td-icon-arrowright--line {
|
|
219
|
+
vertical-align: middle;
|
|
220
|
+
background-repeat: no-repeat;
|
|
221
|
+
background-size: contain;
|
|
222
|
+
background-position: center;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.weda-calendar__control_h5 .weda-calendar_prevMonth.wedatea2td-icon-arrowleft--line,
|
|
226
|
+
.weda-calendar__control_h5 .weda-calendar_nextMonth.wedatea2td-icon-arrowright--line {
|
|
227
|
+
position: absolute;
|
|
228
|
+
top: 17px;
|
|
229
|
+
width: 20px;
|
|
230
|
+
height: 20px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.weda-calendar__control_h5 .weda-calendar_prevMonth.wedatea2td-icon-arrowleft--line {
|
|
234
|
+
left: 16px;
|
|
235
|
+
}
|
|
236
|
+
.weda-calendar__control_h5 .weda-calendar_nextMonth.wedatea2td-icon-arrowright--line {
|
|
237
|
+
right: 16px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.weda-calendar__control_h5 .weda-calendar__current-date {
|
|
241
|
+
font-size: 14px;
|
|
242
|
+
line-height: 22px;
|
|
243
|
+
font-weight: bold;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.weda-calendar-h5 .weda-calendar__panel {
|
|
247
|
+
height: 306px;
|
|
248
|
+
padding: 20px 16px 16px 16px;
|
|
249
|
+
width: 100%;
|
|
250
|
+
box-sizing: border-box;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.weda-calendar-h5 .weda-calendar__table {
|
|
254
|
+
width: 100%;
|
|
255
|
+
height: 100%;
|
|
256
|
+
display: -webkit-box;
|
|
257
|
+
display: -ms-flexbox;
|
|
258
|
+
display: flex;
|
|
259
|
+
-webkit-box-orient: vertical;
|
|
260
|
+
-webkit-box-direction: normal;
|
|
261
|
+
-ms-flex-direction: column;
|
|
262
|
+
flex-direction: column;
|
|
263
|
+
justify-self: start;
|
|
264
|
+
-webkit-box-align: start;
|
|
265
|
+
-ms-flex-align: start;
|
|
266
|
+
align-items: flex-start;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-head {
|
|
270
|
+
margin-bottom: 0;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-head-cell {
|
|
274
|
+
font-size: 12px;
|
|
275
|
+
line-height: 20px;
|
|
276
|
+
width: 100%;
|
|
277
|
+
height: 100%;
|
|
278
|
+
margin: 0;
|
|
279
|
+
-webkit-box-pack: center;
|
|
280
|
+
-ms-flex-pack: center;
|
|
281
|
+
justify-content: center;
|
|
282
|
+
font-size: 12px;
|
|
283
|
+
line-height: 20px;
|
|
284
|
+
-webkit-box-sizing: border-box;
|
|
285
|
+
box-sizing: border-box;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.weda-calendar-h5 .weda-calendar__table-body {
|
|
289
|
+
display: -webkit-box;
|
|
290
|
+
display: -ms-flexbox;
|
|
291
|
+
display: flex;
|
|
292
|
+
-webkit-box-orient: vertical;
|
|
293
|
+
-webkit-box-direction: normal;
|
|
294
|
+
-ms-flex-direction: column;
|
|
295
|
+
flex-direction: column;
|
|
296
|
+
justify-self: center;
|
|
297
|
+
-webkit-box-align: center;
|
|
298
|
+
-ms-flex-align: center;
|
|
299
|
+
align-items: center;
|
|
300
|
+
-webkit-box-flex: 1;
|
|
301
|
+
-ms-flex: 1;
|
|
302
|
+
flex: 1;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.weda-calendar-h5 .weda-calendar__table-body .weda-calendar__table-body-row {
|
|
306
|
+
width: 100%;
|
|
307
|
+
display: -webkit-box;
|
|
308
|
+
display: -ms-flexbox;
|
|
309
|
+
display: flex;
|
|
310
|
+
flex: 1;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.weda-calendar-h5 .weda-calendar__table-body .weda-calendar__table-body-cell {
|
|
314
|
+
width: 100%;
|
|
315
|
+
height: 100%;
|
|
316
|
+
margin: 0;
|
|
317
|
+
border: none;
|
|
318
|
+
-webkit-box-pack: center;
|
|
319
|
+
-ms-flex-pack: center;
|
|
320
|
+
justify-content: center;
|
|
321
|
+
font-size: 12px;
|
|
322
|
+
line-height: 20px;
|
|
323
|
+
-webkit-box-sizing: border-box;
|
|
324
|
+
box-sizing: border-box;
|
|
325
|
+
-webkit-box-pack: center;
|
|
326
|
+
-ms-flex-pack: center;
|
|
327
|
+
justify-content: center;
|
|
328
|
+
-webkit-box-align: center;
|
|
329
|
+
-ms-flex-align: center;
|
|
330
|
+
align-items: center;
|
|
331
|
+
flex-direction: row;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell.is-now {
|
|
335
|
+
border: none;
|
|
336
|
+
background: transparent;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.weda-calendar-h5 .weda-calendar__table-body .weda-calendar__table-body-cell-value {
|
|
340
|
+
font-size: 14px;
|
|
341
|
+
text-align: center;
|
|
342
|
+
border-radius: 50%;
|
|
343
|
+
width: 40px;
|
|
344
|
+
line-height: 40px;
|
|
345
|
+
margin: 0;
|
|
346
|
+
box-sizing: border-box;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell.is-now .weda-calendar__table-body-cell-value {
|
|
350
|
+
color: #fff;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell.is-now .weda-calendar__table-body-cell-bg {
|
|
354
|
+
position: absolute;
|
|
355
|
+
width: 24px;
|
|
356
|
+
height: 24px;
|
|
357
|
+
background: #0052D9;
|
|
358
|
+
border-radius: 100%;
|
|
359
|
+
left: calc(50% - 12px);
|
|
360
|
+
top: calc(50% - 12px);
|
|
361
|
+
z-index: -1;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell .weda-calendar__table-body-cell-marked {
|
|
365
|
+
width: 4px;
|
|
366
|
+
height: 4px;
|
|
367
|
+
top: calc(50% + 14px);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell.is-disabled .weda-calendar__table-body-cell-value {
|
|
371
|
+
color: rgba(0, 0, 0, 0.6);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell.is-invalid {
|
|
375
|
+
background: transparent;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.weda-calendar-h5 .weda-calendar__table .weda-calendar__table-body-cell.is-invalid .weda-calendar__table-body-cell-value {
|
|
379
|
+
color: #c5c5c5;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* h5 日历样式 end */
|
|
@@ -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
|
+
};
|