lowcoder-comps 0.0.18 → 0.0.19

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.
Files changed (78) hide show
  1. package/README.md +27 -0
  2. package/index.html +26 -0
  3. package/index.tsx +19 -0
  4. package/jest.config.js +6 -0
  5. package/package.json +3 -4
  6. package/src/__test__/allComp.test.tsx +61 -0
  7. package/src/app-env.d.ts +3 -0
  8. package/src/comps/calendarComp/calendarComp.tsx +443 -0
  9. package/src/comps/calendarComp/calendarConstants.tsx +898 -0
  10. package/src/comps/chartComp/chartComp.tsx +356 -0
  11. package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +51 -0
  12. package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +307 -0
  13. package/src/comps/chartComp/chartConfigs/chartUrls.tsx +9 -0
  14. package/src/comps/chartComp/chartConfigs/legendConfig.tsx +55 -0
  15. package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +96 -0
  16. package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +83 -0
  17. package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +62 -0
  18. package/src/comps/chartComp/chartConstants.tsx +288 -0
  19. package/src/comps/chartComp/chartPropertyView.tsx +218 -0
  20. package/src/comps/chartComp/chartUtils.ts +291 -0
  21. package/src/comps/chartComp/reactEcharts/core.tsx +194 -0
  22. package/src/comps/chartComp/reactEcharts/index.ts +21 -0
  23. package/src/comps/chartComp/reactEcharts/types.ts +76 -0
  24. package/src/comps/chartComp/seriesComp.tsx +119 -0
  25. package/src/comps/imageEditorComp/imageEditorClass.tsx +52 -0
  26. package/src/comps/imageEditorComp/imageEditorConstants.tsx +109 -0
  27. package/src/comps/imageEditorComp/index.tsx +184 -0
  28. package/src/comps/mermaidComp/index.tsx +44 -0
  29. package/src/comps/mermaidComp/mermaid.tsx +29 -0
  30. package/src/global.ts +1 -0
  31. package/src/i18n/comps/index.tsx +29 -0
  32. package/src/i18n/comps/locales/en.ts +150 -0
  33. package/src/i18n/comps/locales/enObj.tsx +198 -0
  34. package/src/i18n/comps/locales/index.ts +7 -0
  35. package/src/i18n/comps/locales/types.tsx +10 -0
  36. package/src/i18n/comps/locales/zh.ts +145 -0
  37. package/src/i18n/comps/locales/zhObj.tsx +4 -0
  38. package/src/index.ts +11 -0
  39. package/tsconfig.json +22 -0
  40. package/vite.config.js +10 -0
  41. package/0d763a87.js +0 -798
  42. package/1813144f.js +0 -940
  43. package/2039ece8.js +0 -91
  44. package/256b619e.js +0 -92
  45. package/2ff2c7a6.js +0 -6
  46. package/372dc2a7.js +0 -365
  47. package/3b12eb0e.js +0 -2103
  48. package/3c0b160f.js +0 -236
  49. package/401f73a2.js +0 -1602
  50. package/4137766d.js +0 -86
  51. package/4728777d.js +0 -447
  52. package/4881ced8.js +0 -943
  53. package/50cdd04e.js +0 -823
  54. package/5a46ac81.js +0 -1118
  55. package/6737b605.js +0 -985
  56. package/6a3117df.js +0 -159
  57. package/6add348f.js +0 -2456
  58. package/7aa956be.js +0 -326
  59. package/80fe4e54.js +0 -24
  60. package/847d7b9d.js +0 -7
  61. package/8c3bb161.js +0 -18619
  62. package/8edfc14c.js +0 -1246
  63. package/a96f93b1.js +0 -1032
  64. package/b680d6c7.js +0 -70
  65. package/babb4d5d.js +0 -832
  66. package/bfa09fb0.js +0 -607
  67. package/c1008714.js +0 -275
  68. package/ca536ab8.js +0 -117238
  69. package/cb157d73.js +0 -849
  70. package/ce50b2ed.js +0 -2679
  71. package/d4fa84c2.js +0 -212
  72. package/d7fee54a.js +0 -451
  73. package/e1a22e9d.js +0 -34
  74. package/e1cbc8ec.js +0 -46688
  75. package/f9637058.js +0 -16
  76. package/fbeabd79.js +0 -793
  77. package/fc3693cc.js +0 -2827
  78. package/index.js +0 -5
@@ -0,0 +1,898 @@
1
+ import { trans } from "../../i18n/comps";
2
+ import {
3
+ backgroundToBorder,
4
+ CalendarStyleType,
5
+ contrastText,
6
+ contrastColor,
7
+ handleToCalendarHeadSelectBg,
8
+ handleToCalendarToday,
9
+ genHoverColor,
10
+ DATE_FORMAT,
11
+ DATE_TIME_FORMAT,
12
+ ThemeDetail,
13
+ isDarkColor,
14
+ darkenColor,
15
+ lightenColor,
16
+ toHex,
17
+ UnderlineCss,
18
+ } from "lowcoder-sdk";
19
+ import styled from "styled-components";
20
+ import dayjs from "dayjs";
21
+ import {
22
+ DayHeaderContentArg,
23
+ FormatterInput,
24
+ SlotLabelContentArg,
25
+ ViewContentArg,
26
+ } from "@fullcalendar/core";
27
+ import { Form } from "antd";
28
+
29
+ export const Wrapper = styled.div<{
30
+ editable: boolean;
31
+ $style: CalendarStyleType;
32
+ theme?: ThemeDetail;
33
+ left?: number;
34
+ }>`
35
+ position: relative;
36
+ height: 100%;
37
+ overflow: hidden;
38
+ color: ${(props) => props.$style.text};
39
+ .fc-theme-standard .fc-list-day-cushion,
40
+ .fc .fc-timegrid-col.fc-day-today,
41
+ .fc .fc-daygrid-day.fc-day-today {
42
+ background-color: ${(props) => props.$style.background};
43
+ }
44
+ .fc .fc-highlight {
45
+ background-color: ${(props) => props.$style.selectBackground};
46
+ }
47
+ a {
48
+ color: ${(props) => props.$style.text};
49
+ }
50
+
51
+ .fc .fc-timegrid-slot {
52
+ height: 28px;
53
+ }
54
+
55
+ // day
56
+ .fc-timeGridDay-view {
57
+ .fc-col-header-cell {
58
+ font-size: 20px;
59
+ font-weight: 500;
60
+ a {
61
+ line-height: 67px;
62
+ }
63
+ }
64
+ }
65
+
66
+ // list
67
+ .fc-list {
68
+ .fc-list-table {
69
+ table-layout: fixed;
70
+ th {
71
+ background-color: ${(props) => props.$style.background};
72
+ }
73
+ }
74
+ .fc-list-event-graphic {
75
+ display: none;
76
+ }
77
+ .fc-list-day-cushion {
78
+ font-size: 16px;
79
+ font-weight: 500;
80
+ line-height: 32px;
81
+ padding: 0 24px;
82
+ }
83
+ .fc-list-day-side-text {
84
+ float: left;
85
+ margin-left: 24px;
86
+ }
87
+ .fc-list-day {
88
+ th {
89
+ padding: 8px 0 3px 0;
90
+ }
91
+ > th {
92
+ border: none;
93
+ }
94
+ &:not(:nth-of-type(1)) .fc-list-day-cushion {
95
+ border-top: 1px solid
96
+ ${(props) =>
97
+ toHex(props.$style.border) === "#D7D9E0"
98
+ ? "#E1E3EB"
99
+ : lightenColor(props.$style.border, 0.03)};
100
+ }
101
+ }
102
+ .fc-event + .fc-list-day th {
103
+ padding-top: 11px;
104
+ .fc-list-day-cushion {
105
+ padding-top: 8px;
106
+ }
107
+ }
108
+ .fc-event {
109
+ .fc-list-event-time,
110
+ .fc-list-event-title {
111
+ border: none;
112
+ }
113
+ &:hover .event {
114
+ box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.15);
115
+ border-width: 1px;
116
+ margin: 2px 5px;
117
+ height: 20px;
118
+ .event-title {
119
+ margin-left: 15px;
120
+ }
121
+ &::before {
122
+ left: 2px;
123
+ }
124
+ }
125
+ }
126
+ .fc-event {
127
+ font-size: 13px;
128
+ line-height: 20px;
129
+ display: flex;
130
+ align-items: center;
131
+ &.no-time {
132
+ padding-left: 19px;
133
+ }
134
+ }
135
+ .fc-list-event-time {
136
+ padding: 0px 16px 0 24px;
137
+ vertical-align: middle;
138
+ min-width: 87px;
139
+ width: 87px;
140
+ box-sizing: content-box;
141
+ }
142
+ .fc-list-event-title {
143
+ min-width: 266px;
144
+ overflow: hidden;
145
+ text-overflow: ellipsis;
146
+ white-space: nowrap;
147
+ padding: 0 14px 0 0;
148
+ cursor: pointer;
149
+ .event {
150
+ font-size: 13px;
151
+ height: 18px;
152
+ line-height: 18px;
153
+ margin: 3px 5px;
154
+ border-width: 0;
155
+ align-items: center;
156
+ &::before {
157
+ height: 14px;
158
+ top: 2px;
159
+ left: 3px;
160
+ }
161
+ .event-time {
162
+ display: none;
163
+ }
164
+ .event-title {
165
+ margin-left: 16px;
166
+ overflow: hidden;
167
+ text-overflow: ellipsis;
168
+ white-space: nowrap;
169
+ }
170
+ .event-remove {
171
+ background-color: inherit;
172
+ }
173
+ }
174
+ }
175
+ .fc-event:hover td {
176
+ background-color: inherit;
177
+ }
178
+ }
179
+
180
+ // month
181
+ .fc-dayGridMonth-view {
182
+ .fc-daygrid-day-frame {
183
+ min-height: 95px;
184
+ height: 100%;
185
+ }
186
+ .fc-col-header-cell {
187
+ font-size: 14px;
188
+ font-weight: 400;
189
+ text-align: left;
190
+ padding-left: 16px;
191
+ a {
192
+ padding: 0;
193
+ line-height: 39px;
194
+ }
195
+ }
196
+ .fc-daygrid-day-number {
197
+ font-size: 14px;
198
+ line-height: 22px;
199
+ font-weight: 500;
200
+ padding: 0 6px;
201
+ border-radius: 11px;
202
+ margin: 12px 0 0 10px;
203
+ }
204
+ .fc-daygrid-day-top {
205
+ flex-direction: inherit;
206
+ }
207
+ .fc-day-today .fc-daygrid-day-number {
208
+ background-color: ${(props) => props.theme.primary};
209
+ color: ${(props) =>
210
+ contrastText(props.theme.primary || "", props.theme.textDark, props.theme.textLight)};
211
+ }
212
+ .fc-daygrid-day-events {
213
+ padding: 1px 0 5px 0;
214
+ min-height: unset;
215
+ .fc-event {
216
+ margin: 2px 4px 2px 12px;
217
+ padding: 0;
218
+ &:hover .event {
219
+ padding-right: 20px;
220
+ }
221
+ .event {
222
+ font-size: 13px;
223
+ line-height: 18px;
224
+ padding-right: 0;
225
+ .event-time {
226
+ display: none;
227
+ }
228
+ .event-title {
229
+ margin-left: 15px;
230
+ overflow: hidden;
231
+ text-overflow: ellipsis;
232
+ white-space: nowrap;
233
+ }
234
+ &::before {
235
+ height: 14px;
236
+ }
237
+ }
238
+ }
239
+ .fc-daygrid-day-bottom {
240
+ padding: 2px 2px 0 10px;
241
+ }
242
+ }
243
+ .fc-day-other {
244
+ color: ${(props) => props.$style.text};
245
+ .fc-daygrid-day-top,
246
+ .fc-daygrid-day-events {
247
+ opacity: 0.35;
248
+ }
249
+ .event::before {
250
+ background-color: ${(props) => props.$style.text};
251
+ }
252
+ }
253
+ }
254
+ // month drag event
255
+ .fc > .fc-event {
256
+ visibility: hidden;
257
+ }
258
+
259
+ // more link
260
+ .fc-view-harness-active .fc-more-popover {
261
+ border-radius: 4px;
262
+ box-shadow: 0 0px 10px 4px rgba(0, 0, 0, 0.25);
263
+ overflow: hidden;
264
+ left: ${(props) => `min(${props.left}px, calc(100% - 210px)) !important`};
265
+ .fc-popover-body {
266
+ padding: 4px 0;
267
+ min-width: 200px;
268
+ width: 200px;
269
+ .fc-daygrid-event-harness {
270
+ margin: 4px;
271
+ .fc-event {
272
+ margin: 0;
273
+ .event {
274
+ height: fit-content;
275
+ .event-title {
276
+ white-space: pre-wrap;
277
+ }
278
+ .event-time {
279
+ margin-top: 0;
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ .fc-popover-header,
286
+ .fc-popover-body {
287
+ background-color: ${(props) => props.$style.background};
288
+ }
289
+ .fc-popover-header .fc-popover-close {
290
+ color: #8b8fa3;
291
+ &:hover {
292
+ color: #222;
293
+ }
294
+ }
295
+ }
296
+
297
+ .fc-direction-ltr .fc-timegrid-more-link {
298
+ border: 1px solid ${(props) => props.$style.border};
299
+ border-radius: 4px;
300
+ box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.15);
301
+ font-size: 13px;
302
+ display: inline-block;
303
+ font-weight: 500;
304
+ background-color: ${(props) => lightenColor(props.$style.background, 0.1)};
305
+ }
306
+
307
+ .fc-dayGridMonth-view .fc-more-link {
308
+ margin: 0 2px 2px 2px !important;
309
+ }
310
+ .fc-timeGridWeek-view .fc-more-link,
311
+ .fc-timeGridDay-view .fc-more-link {
312
+ margin: 2px !important;
313
+ }
314
+ .fc-daygrid-day-events {
315
+ margin: 0 !important;
316
+ padding: 2px 0;
317
+ .fc-event {
318
+ margin: 2px 4px;
319
+ }
320
+ .fc-daygrid-day-bottom {
321
+ line-height: 16px;
322
+ padding: 0;
323
+ .fc-more-link {
324
+ width: calc(100% - 4px);
325
+ border: 1px solid ${(props) => props.$style.border};
326
+ border-radius: 4px;
327
+ box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.15);
328
+ font-size: 13px;
329
+ display: inline-block;
330
+ height: 20px;
331
+ padding-left: 15px;
332
+ font-weight: 500;
333
+ background-color: ${(props) => lightenColor(props.$style.background, 0.1)};
334
+ }
335
+ }
336
+ }
337
+
338
+ // on resize
339
+ .fc-media-screen {
340
+ height: 100% !important;
341
+ }
342
+ .fc-scroller {
343
+ overflow: hidden auto !important;
344
+ overflow: hidden overlay !important;
345
+ }
346
+ .fc-col-header,
347
+ .fc-scroller > div,
348
+ .fc-scroller > div > table,
349
+ .fc-scrollgrid-sync-table,
350
+ .fc-timegrid-cols > table,
351
+ .fc .fc-scrollgrid,
352
+ .fc .fc-scrollgrid table {
353
+ width: 100% !important;
354
+ }
355
+
356
+ // event
357
+ .fc-timegrid-event .fc-event-main {
358
+ padding: 4px 0 4px 1px;
359
+ }
360
+ .fc-event {
361
+ position: relative;
362
+ height: 100%;
363
+ background-color: unset !important;
364
+ border: none !important;
365
+ box-shadow: none !important;
366
+ .event-remove {
367
+ color: ${(props) => props.$style.text};
368
+ }
369
+ &:hover {
370
+ .event-remove {
371
+ opacity: ${(props) => props.editable && 1};
372
+ }
373
+ }
374
+ }
375
+
376
+ // left time
377
+ .time.past {
378
+ opacity: 0.35;
379
+ }
380
+
381
+ .past .time {
382
+ opacity: 0.35;
383
+ }
384
+
385
+ .future .time {
386
+ opacity: 1;
387
+ }
388
+
389
+ .fc-scrollgrid-liquid > tbody {
390
+ & > tr:nth-of-type(2) {
391
+ display: ${(props) => props.allDay && 1};
392
+ }
393
+ }
394
+ .fc .fc-timegrid-slot-label-cushion {
395
+ padding: 0 15px;
396
+ }
397
+
398
+ // border-radius, bg
399
+ .fc-theme-standard .fc-list {
400
+ background-color: ${(props) => props.$style.background};
401
+ border-radius: ${(props) => `0 0 ${props.$style.radius} ${props.$style.radius}`};
402
+ border-color: ${(props) => props.$style.border};
403
+ border-top-color: ${(props) =>
404
+ toHex(props.$style.border) === "#D7D9E0"
405
+ ? "#E1E3EB"
406
+ : lightenColor(props.$style.border, 0.03)};
407
+ }
408
+ .fc-scrollgrid-liquid {
409
+ border-radius: ${(props) => `0 0 ${props.$style.radius} ${props.$style.radius}`};
410
+ overflow: hidden;
411
+ border-right-width: 1px;
412
+ border-bottom-width: 1px;
413
+ border-color: ${(props) => props.$style.border};
414
+ > thead,
415
+ > tbody > tr:nth-of-type(1),
416
+ .fc-scrollgrid-section-liquid > td {
417
+ background-color: ${(props) => props.$style.background};
418
+ }
419
+ }
420
+ .fc-scrollgrid-section-liquid > td,
421
+ .fc-scrollgrid-liquid .fc-scrollgrid-section-header > th {
422
+ border: none;
423
+ }
424
+ .fc-scrollgrid-liquid > tbody > tr:nth-of-type(1) > td {
425
+ border-right: none;
426
+ }
427
+ .fc-theme-standard .fc-scrollgrid {
428
+ border-color: ${(props) =>
429
+ toHex(props.$style.border) === "#D7D9E0"
430
+ ? "#E1E3EB"
431
+ : lightenColor(props.$style.border, 0.03)};
432
+ }
433
+ .fc .fc-scrollgrid {
434
+ border-bottom-width: 1px;
435
+ border-right-width: 1px;
436
+ }
437
+
438
+ .fc-day-sat,
439
+ .fc-day-sun {
440
+ &.fc-timegrid-col,
441
+ &.fc-daygrid-day {
442
+ background-color: ${(props) =>
443
+ isDarkColor(props.$style.background)
444
+ ? darkenColor(props.$style.background, 0.06)
445
+ : darkenColor(props.$style.background, 0.02)};
446
+ }
447
+ }
448
+ .fc-theme-standard td,
449
+ .fc-theme-standard th {
450
+ border-color: ${(props) =>
451
+ toHex(props.$style.border) === "#D7D9E0"
452
+ ? "#E1E3EB"
453
+ : lightenColor(props.$style.border, 0.03)};
454
+ }
455
+
456
+ // header
457
+ .fc .fc-toolbar.fc-header-toolbar {
458
+ padding: 16px;
459
+ margin-bottom: 0;
460
+ border: 1px solid ${(props) => props.$style.border};
461
+ border-bottom: none;
462
+ border-radius: ${(props) => `${props.$style.radius} ${props.$style.radius} 0 0`};
463
+ background-color: ${(props) => props.$style.background};
464
+ }
465
+ .fc-toolbar-title {
466
+ color: ${(props) => props.$style.title};
467
+ font-size: 24px;
468
+ line-height: 24px;
469
+ display: inline-flex;
470
+ }
471
+ .fc-toolbar-chunk {
472
+ display: inline-flex;
473
+ align-items: center;
474
+ }
475
+ .fc .fc-toolbar-chunk .fc-button.fc-button-primary {
476
+ height: 28px;
477
+ display: flex;
478
+ align-items: center;
479
+ justify-content: center;
480
+ &:not(:disabled):not(.fc-button-active) {
481
+ &:hover,
482
+ &:active {
483
+ color: ${(props) => props.$style.btnText};
484
+ background-color: ${(props) =>
485
+ toHex(props.$style.headerBtnBackground) === "#FFFFFF"
486
+ ? "#F5F5F6"
487
+ : genHoverColor(props.$style.headerBtnBackground)};
488
+ border-color: ${(props) =>
489
+ toHex(props.$style.headerBtnBackground) === "#FFFFFF"
490
+ ? "#D7D9E0"
491
+ : backgroundToBorder(genHoverColor(props.$style.headerBtnBackground))};
492
+ }
493
+ }
494
+ &:not(:disabled):focus {
495
+ box-shadow: none;
496
+ }
497
+ &:disabled {
498
+ cursor: not-allowed;
499
+ opacity: 1;
500
+ &,
501
+ &:hover {
502
+ background-color: ${(props) => props.$style.headerBtnBackground};
503
+ border-color: ${(props) => backgroundToBorder(props.$style.headerBtnBackground)};
504
+ color: ${(props) =>
505
+ toHex(props.$style.btnText) === "#222222"
506
+ ? "#B8B9BF"
507
+ : contrastColor(props.$style.btnText)};
508
+ }
509
+ }
510
+ }
511
+ .fc .fc-button-primary:not(:disabled).fc-button-active:focus,
512
+ .fc .fc-button-primary:not(:disabled):active:focus {
513
+ box-shadow: none;
514
+ }
515
+ .fc-toolbar-chunk:nth-of-type(3) .fc-button-primary {
516
+ height: 28px;
517
+ display: inline-flex;
518
+ font-size: 14px;
519
+ margin-left: 8px;
520
+ background-color: ${(props) => props.$style.headerBtnBackground};
521
+ border-color: ${(props) => backgroundToBorder(props.$style.headerBtnBackground)};
522
+ color: ${(props) => props.$style.btnText};
523
+ &.fc-today-button {
524
+ min-width: 52px;
525
+ }
526
+ &.fc-prev-button,
527
+ &.fc-next-button {
528
+ padding: 0;
529
+ width: 28px;
530
+ color: ${(props) => lightenColor(props.$style.btnText, 0.4)};
531
+ }
532
+ &.fc-prev-button {
533
+ margin-left: 12px;
534
+ }
535
+ }
536
+ .fc-toolbar-chunk:nth-of-type(3) .fc-button-group {
537
+ background-color: ${(props) =>
538
+ toHex(props.$style.headerBtnBackground) === "#FFFFFF"
539
+ ? "#EFEFF1"
540
+ : isDarkColor(props.$style.headerBtnBackground)
541
+ ? props.$style.headerBtnBackground
542
+ : darkenColor(props.$style.headerBtnBackground, 0.1)};
543
+ border-radius: 4px;
544
+ margin-left: 16px;
545
+ .fc-button-primary {
546
+ background-color: transparent;
547
+ min-width: 60px;
548
+ border-radius: 4px;
549
+ margin: 2px;
550
+ border: none;
551
+ color: ${(props) =>
552
+ toHex(props.$style.btnText) === "#222222"
553
+ ? "#8B8FA3"
554
+ : lightenColor(props.$style.btnText, 0.4)};
555
+ font-weight: 500;
556
+
557
+ &.fc-button-active {
558
+ background-color: ${(props) =>
559
+ isDarkColor(props.$style.headerBtnBackground)
560
+ ? lightenColor(props.$style.headerBtnBackground, 0.1)
561
+ : props.$style.headerBtnBackground};
562
+ color: ${(props) => props.$style.btnText};
563
+ }
564
+ }
565
+ }
566
+
567
+ // week head
568
+ .fc-timeGridWeek-view {
569
+ .week-head {
570
+ display: flex;
571
+ flex-direction: column;
572
+ font-size: 14px;
573
+ font-weight: 400;
574
+ &.past span {
575
+ opacity: 0.35;
576
+ }
577
+ .week {
578
+ padding-bottom: 3px;
579
+ }
580
+ .day {
581
+ font-size: 20px;
582
+ font-weight: 500;
583
+ line-height: 22px;
584
+ }
585
+ }
586
+ .fc-day-today.fc-col-header-cell {
587
+ background-color: ${(props) =>
588
+ isDarkColor(props.$style.background) ? "#ffffff19" : toHex(props.theme.primary!) + "19"};
589
+ a {
590
+ color: ${(props) =>
591
+ !isDarkColor(props.$style.background) && darkenColor(props.theme.primary!, 0.1)};
592
+ }
593
+ }
594
+ .fc-col-header-cell-cushion {
595
+ padding: 8px 0 13px 0;
596
+ }
597
+ }
598
+
599
+ // week left
600
+ .fc .fc-timegrid-axis-cushion {
601
+ min-width: 62px;
602
+ min-height: 52px;
603
+ max-width: none;
604
+ display: inline-flex;
605
+ align-items: center;
606
+ justify-content: center;
607
+ }
608
+ .fc-direction-ltr .fc-timegrid-slot-label-frame {
609
+ text-align: center;
610
+ }
611
+ .fc .fc-timegrid-slot-label {
612
+ border: none;
613
+ }
614
+
615
+ // time can doubleClick
616
+ .fc-timegrid-bg-harness,
617
+ .fc-daygrid-day-bg {
618
+ pointer-events: none;
619
+ }
620
+ `;
621
+
622
+ export const Remove = styled.div<{ isList: boolean }>`
623
+ position: absolute;
624
+ pointer-events: auto;
625
+ top: 0;
626
+ right: 0;
627
+ display: flex;
628
+ padding: 5px;
629
+ opacity: 0;
630
+ cursor: pointer;
631
+ &:hover {
632
+ g {
633
+ stroke: #315efb;
634
+ }
635
+ }
636
+ `;
637
+
638
+ export const Event = styled.div<{
639
+ bg: string;
640
+ theme: Object;
641
+ isList: boolean;
642
+ allDay: boolean;
643
+ $style: CalendarStyleType;
644
+ }>`
645
+ height: 100%;
646
+ width: 100%;
647
+ pointer-events: none;
648
+ border-radius: 4px;
649
+ box-shadow: ${(props) => !props.isList && "0 0 5px 0 rgba(0, 0, 0, 0.15)"};
650
+ border: 1px solid ${(props) => props.$style.border};
651
+ display: ${(props) => props.isList && "flex"};
652
+ background-color: ${(props) => !props.isList && lightenColor(props.$style.background, 0.1)};
653
+ overflow: hidden;
654
+ font-size: 13px;
655
+ line-height: 19px;
656
+ padding-right: 20px;
657
+ overflow: hidden;
658
+ position: relative;
659
+ &::before {
660
+ content: "";
661
+ position: absolute;
662
+ display: block;
663
+ width: 5px;
664
+ height: calc(100% - 4px);
665
+ left: 2px;
666
+ top: 2px;
667
+ border-radius: 3px;
668
+ background-color: ${(props) => props.bg};
669
+ }
670
+
671
+ .event-time {
672
+ color: ${(props) =>
673
+ !props.isList &&
674
+ (isDarkColor(props.$style.text) ? lightenColor(props.$style.text, 0.2) : props.$style.text)};
675
+ margin-left: 15px;
676
+ white-space: pre-wrap;
677
+ margin-top: 2px;
678
+ }
679
+ .event-title {
680
+ color: ${(props) => !props.isList && props.$style.text};
681
+ font-weight: 500;
682
+ margin-left: 15px;
683
+ white-space: pre-wrap;
684
+ word-break: break-word;
685
+ }
686
+
687
+ &.small {
688
+ height: 20px;
689
+ .event-time {
690
+ display: none;
691
+ }
692
+ .event-title {
693
+ text-overflow: ellipsis;
694
+ overflow: hidden;
695
+ white-space: nowrap;
696
+ }
697
+ }
698
+ &.middle {
699
+ padding-top: 2px;
700
+ .event-time,
701
+ .event-title {
702
+ text-overflow: ellipsis;
703
+ overflow: hidden;
704
+ white-space: nowrap;
705
+ }
706
+ }
707
+ &.large {
708
+ .event-time {
709
+ margin-top: 13px;
710
+ }
711
+ }
712
+ &.past {
713
+ background-color: ${(props) => isDarkColor(props.$style.background) && props.$style.background};
714
+ &::before {
715
+ background-color: ${(props) =>
716
+ toHex(props.$style.text) === "#3C3C3C"
717
+ ? "#8B8FA3"
718
+ : isDarkColor(props.$style.text)
719
+ ? lightenColor(props.$style.text, 0.3)
720
+ : props.$style.text};
721
+ }
722
+ &::before,
723
+ .event-title,
724
+ .event-time {
725
+ opacity: 0.35;
726
+ }
727
+ }
728
+ `;
729
+
730
+ export const FormWrapper = styled(Form)`
731
+ .ant-form-item-label {
732
+ width: 100px;
733
+ text-align: left;
734
+ line-height: 18px;
735
+ label:not(.ant-form-item-required) {
736
+ margin-left: 11px;
737
+ }
738
+ label span {
739
+ ${UnderlineCss}
740
+ }
741
+ }
742
+ `;
743
+
744
+ export type EventType = {
745
+ id?: string;
746
+ label?: string;
747
+ title?: string;
748
+ start?: string;
749
+ end?: string;
750
+ allDay?: boolean;
751
+ color?: string;
752
+ groupId?: string;
753
+ value?: string;
754
+ };
755
+
756
+ export enum ViewType {
757
+ MONTH = "dayGridMonth",
758
+ WEEK = "timeGridWeek",
759
+ DAY = "timeGridDay",
760
+ LIST = "listWeek",
761
+ }
762
+
763
+ export const DefaultViewOptions = [
764
+ {
765
+ label: trans("calendar.month"),
766
+ value: "dayGridMonth",
767
+ },
768
+ {
769
+ label: trans("calendar.week"),
770
+ value: "timeGridWeek",
771
+ },
772
+ {
773
+ label: trans("calendar.day"),
774
+ value: "timeGridDay",
775
+ },
776
+ {
777
+ label: trans("calendar.list"),
778
+ value: "listWeek",
779
+ },
780
+ ] as const;
781
+
782
+ export const FirstDayOptions = [
783
+ {
784
+ label: trans("calendar.monday"),
785
+ value: "1",
786
+ },
787
+ {
788
+ label: trans("calendar.tuesday"),
789
+ value: "2",
790
+ },
791
+ {
792
+ label: trans("calendar.wednesday"),
793
+ value: "3",
794
+ },
795
+ {
796
+ label: trans("calendar.thursday"),
797
+ value: "4",
798
+ },
799
+ {
800
+ label: trans("calendar.friday"),
801
+ value: "5",
802
+ },
803
+ {
804
+ label: trans("calendar.saturday"),
805
+ value: "6",
806
+ },
807
+ {
808
+ label: trans("calendar.sunday"),
809
+ value: "0",
810
+ },
811
+ ];
812
+
813
+ export const defaultData = [
814
+ {
815
+ id: "1",
816
+ title: "Coding",
817
+ start: dayjs().hour(10).minute(0).second(0).format(DATE_TIME_FORMAT),
818
+ end: dayjs().hour(11).minute(30).second(0).format(DATE_TIME_FORMAT),
819
+ color: "#079968",
820
+ },
821
+ {
822
+ id: "2",
823
+ title: "Rest",
824
+ start: dayjs().hour(24).format(DATE_FORMAT),
825
+ end: dayjs().hour(48).format(DATE_FORMAT),
826
+ allDay: true,
827
+ },
828
+ ];
829
+
830
+ export const buttonText = {
831
+ today: trans("calendar.today"),
832
+ month: trans("calendar.month"),
833
+ week: trans("calendar.week"),
834
+ day: trans("calendar.day"),
835
+ list: trans("calendar.list"),
836
+ };
837
+
838
+ export const headerToolbar = {
839
+ left: "title",
840
+ right: "prev today next dayGridMonth,timeGridWeek,timeGridDay,listWeek",
841
+ };
842
+
843
+ const weekHeadContent = (info: DayHeaderContentArg) => {
844
+ const text = info.text.split(" ");
845
+ return {
846
+ html: `<span class="week-head ${info.isPast && "past"} ${info.isToday && "today"}">
847
+ <span class="week">${text[0]}</span>
848
+ <span class="day">${text[1]}</span>
849
+ </span>`,
850
+ };
851
+ };
852
+
853
+ const leftTimeContent = (info: SlotLabelContentArg) => {
854
+ let isPast = false;
855
+ if (info.view.type === ViewType.WEEK) {
856
+ isPast = dayjs().isAfter(dayjs(dayjs().format("YYYY MM DD " + info.text)));
857
+ } else if (info.view.type === ViewType.DAY) {
858
+ isPast = dayjs().isAfter(
859
+ dayjs(dayjs(info.view.activeStart).format("YYYY MM DD " + info.text))
860
+ );
861
+ }
862
+ return {
863
+ html: `<span class="time ${isPast && "past"}">${info.text}</span>`,
864
+ };
865
+ };
866
+
867
+ export const views = {
868
+ [ViewType.WEEK]: {
869
+ dayHeaderFormat: "ddd DD",
870
+ dayHeaderContent: (info: DayHeaderContentArg) => weekHeadContent(info),
871
+ slotLabelContent: (info: SlotLabelContentArg) => leftTimeContent(info),
872
+ },
873
+ [ViewType.DAY]: {
874
+ slotLabelContent: (info: SlotLabelContentArg) => leftTimeContent(info),
875
+ },
876
+ [ViewType.LIST]: {
877
+ listDayFormat: { weekday: "short" },
878
+ },
879
+ } as const;
880
+
881
+ export const slotLabelFormat = [
882
+ {
883
+ hour: "2-digit",
884
+ minute: "2-digit",
885
+ },
886
+ ] as FormatterInput[];
887
+
888
+ export const viewClassNames = (info: ViewContentArg) => {
889
+ let className = "";
890
+ if ([ViewType.WEEK, ViewType.DAY].includes(info.view.type as ViewType)) {
891
+ if (dayjs().isAfter(info.view.activeEnd)) {
892
+ className = "past";
893
+ } else if (dayjs().isBefore(info.view.activeStart)) {
894
+ className = "future";
895
+ }
896
+ }
897
+ return className;
898
+ };