lowcoder-comps 0.0.7 → 0.0.9

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 (40) hide show
  1. package/icons/icon-chart.svg +15 -0
  2. package/icons/icon-comp-calendar.svg +22 -0
  3. package/index.html +26 -0
  4. package/index.tsx +19 -0
  5. package/jest.config.js +5 -0
  6. package/package.json +1 -4
  7. package/src/__test__/allComp.test.tsx +61 -0
  8. package/src/app-env.d.ts +3 -0
  9. package/src/comps/calendarComp/calendarComp.tsx +442 -0
  10. package/src/comps/calendarComp/calendarConstants.tsx +897 -0
  11. package/src/comps/chartComp/chartComp.tsx +249 -0
  12. package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +51 -0
  13. package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +307 -0
  14. package/src/comps/chartComp/chartConfigs/chartUrls.tsx +6 -0
  15. package/src/comps/chartComp/chartConfigs/legendConfig.tsx +55 -0
  16. package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +96 -0
  17. package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +83 -0
  18. package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +62 -0
  19. package/src/comps/chartComp/chartConstants.tsx +243 -0
  20. package/src/comps/chartComp/chartPropertyView.tsx +161 -0
  21. package/src/comps/chartComp/chartUtils.ts +240 -0
  22. package/src/comps/chartComp/reactEcharts/core.tsx +187 -0
  23. package/src/comps/chartComp/reactEcharts/index.ts +20 -0
  24. package/src/comps/chartComp/reactEcharts/types.ts +70 -0
  25. package/src/comps/chartComp/seriesComp.tsx +119 -0
  26. package/src/comps/imageEditorComp/imageEditorClass.tsx +52 -0
  27. package/src/comps/imageEditorComp/imageEditorConstants.tsx +109 -0
  28. package/src/comps/imageEditorComp/index.tsx +184 -0
  29. package/src/comps/mermaidComp/index.tsx +44 -0
  30. package/src/comps/mermaidComp/mermaid.tsx +29 -0
  31. package/src/global.ts +1 -0
  32. package/src/i18n/comps/index.tsx +29 -0
  33. package/src/i18n/comps/locales/en.ts +142 -0
  34. package/src/i18n/comps/locales/enObj.tsx +120 -0
  35. package/src/i18n/comps/locales/index.ts +7 -0
  36. package/src/i18n/comps/locales/types.tsx +9 -0
  37. package/src/i18n/comps/locales/zh.ts +4 -0
  38. package/src/i18n/comps/locales/zhObj.tsx +4 -0
  39. package/src/index.ts +11 -0
  40. package/vite.config.js +10 -0
@@ -0,0 +1,897 @@
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 moment from "moment";
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: none;
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
+ $style: CalendarStyleType;
643
+ }>`
644
+ height: 100%;
645
+ width: 100%;
646
+ pointer-events: none;
647
+ border-radius: 4px;
648
+ box-shadow: ${(props) => !props.isList && "0 0 5px 0 rgba(0, 0, 0, 0.15)"};
649
+ border: 1px solid ${(props) => props.$style.border};
650
+ display: ${(props) => props.isList && "flex"};
651
+ background-color: ${(props) => !props.isList && lightenColor(props.$style.background, 0.1)};
652
+ overflow: hidden;
653
+ font-size: 13px;
654
+ line-height: 19px;
655
+ padding-right: 20px;
656
+ overflow: hidden;
657
+ position: relative;
658
+ &::before {
659
+ content: "";
660
+ position: absolute;
661
+ display: block;
662
+ width: 5px;
663
+ height: calc(100% - 4px);
664
+ left: 2px;
665
+ top: 2px;
666
+ border-radius: 3px;
667
+ background-color: ${(props) => props.bg};
668
+ }
669
+
670
+ .event-time {
671
+ color: ${(props) =>
672
+ !props.isList &&
673
+ (isDarkColor(props.$style.text) ? lightenColor(props.$style.text, 0.2) : props.$style.text)};
674
+ margin-left: 15px;
675
+ white-space: pre-wrap;
676
+ margin-top: 2px;
677
+ }
678
+ .event-title {
679
+ color: ${(props) => !props.isList && props.$style.text};
680
+ font-weight: 500;
681
+ margin-left: 15px;
682
+ white-space: pre-wrap;
683
+ word-break: break-word;
684
+ }
685
+
686
+ &.small {
687
+ height: 20px;
688
+ .event-time {
689
+ display: none;
690
+ }
691
+ .event-title {
692
+ text-overflow: ellipsis;
693
+ overflow: hidden;
694
+ white-space: nowrap;
695
+ }
696
+ }
697
+ &.middle {
698
+ padding-top: 2px;
699
+ .event-time,
700
+ .event-title {
701
+ text-overflow: ellipsis;
702
+ overflow: hidden;
703
+ white-space: nowrap;
704
+ }
705
+ }
706
+ &.large {
707
+ .event-time {
708
+ margin-top: 13px;
709
+ }
710
+ }
711
+ &.past {
712
+ background-color: ${(props) => isDarkColor(props.$style.background) && props.$style.background};
713
+ &::before {
714
+ background-color: ${(props) =>
715
+ toHex(props.$style.text) === "#3C3C3C"
716
+ ? "#8B8FA3"
717
+ : isDarkColor(props.$style.text)
718
+ ? lightenColor(props.$style.text, 0.3)
719
+ : props.$style.text};
720
+ }
721
+ &::before,
722
+ .event-title,
723
+ .event-time {
724
+ opacity: 0.35;
725
+ }
726
+ }
727
+ `;
728
+
729
+ export const FormWrapper = styled(Form)`
730
+ .ant-form-item-label {
731
+ width: 100px;
732
+ text-align: left;
733
+ line-height: 18px;
734
+ label:not(.ant-form-item-required) {
735
+ margin-left: 11px;
736
+ }
737
+ label span {
738
+ ${UnderlineCss}
739
+ }
740
+ }
741
+ `;
742
+
743
+ export type EventType = {
744
+ id?: string;
745
+ label?: string;
746
+ title?: string;
747
+ start?: string;
748
+ end?: string;
749
+ allDay?: boolean;
750
+ color?: string;
751
+ groupId?: string;
752
+ value?: string;
753
+ };
754
+
755
+ export enum ViewType {
756
+ MONTH = "dayGridMonth",
757
+ WEEK = "timeGridWeek",
758
+ DAY = "timeGridDay",
759
+ LIST = "listWeek",
760
+ }
761
+
762
+ export const DefaultViewOptions = [
763
+ {
764
+ label: trans("calendar.month"),
765
+ value: "dayGridMonth",
766
+ },
767
+ {
768
+ label: trans("calendar.week"),
769
+ value: "timeGridWeek",
770
+ },
771
+ {
772
+ label: trans("calendar.day"),
773
+ value: "timeGridDay",
774
+ },
775
+ {
776
+ label: trans("calendar.list"),
777
+ value: "listWeek",
778
+ },
779
+ ] as const;
780
+
781
+ export const FirstDayOptions = [
782
+ {
783
+ label: trans("calendar.monday"),
784
+ value: "1",
785
+ },
786
+ {
787
+ label: trans("calendar.tuesday"),
788
+ value: "2",
789
+ },
790
+ {
791
+ label: trans("calendar.wednesday"),
792
+ value: "3",
793
+ },
794
+ {
795
+ label: trans("calendar.thursday"),
796
+ value: "4",
797
+ },
798
+ {
799
+ label: trans("calendar.friday"),
800
+ value: "5",
801
+ },
802
+ {
803
+ label: trans("calendar.saturday"),
804
+ value: "6",
805
+ },
806
+ {
807
+ label: trans("calendar.sunday"),
808
+ value: "0",
809
+ },
810
+ ];
811
+
812
+ export const defaultData = [
813
+ {
814
+ id: "1",
815
+ title: "Coding",
816
+ start: moment().hours(10).minutes(0).second(0).format(DATE_TIME_FORMAT),
817
+ end: moment().hours(11).minutes(30).second(0).format(DATE_TIME_FORMAT),
818
+ color: "#079968",
819
+ },
820
+ {
821
+ id: "2",
822
+ title: "Rest",
823
+ start: moment().hours(24).format(DATE_FORMAT),
824
+ end: moment().hours(48).format(DATE_FORMAT),
825
+ allDay: true,
826
+ },
827
+ ];
828
+
829
+ export const buttonText = {
830
+ today: trans("calendar.today"),
831
+ month: trans("calendar.month"),
832
+ week: trans("calendar.week"),
833
+ day: trans("calendar.day"),
834
+ list: trans("calendar.list"),
835
+ };
836
+
837
+ export const headerToolbar = {
838
+ left: "title",
839
+ right: "prev today next dayGridMonth,timeGridWeek,timeGridDay,listWeek",
840
+ };
841
+
842
+ const weekHeadContent = (info: DayHeaderContentArg) => {
843
+ const text = info.text.split(" ");
844
+ return {
845
+ html: `<span class="week-head ${info.isPast && "past"} ${info.isToday && "today"}">
846
+ <span class="week">${text[0]}</span>
847
+ <span class="day">${text[1]}</span>
848
+ </span>`,
849
+ };
850
+ };
851
+
852
+ const leftTimeContent = (info: SlotLabelContentArg) => {
853
+ let isPast = false;
854
+ if (info.view.type === ViewType.WEEK) {
855
+ isPast = moment().isAfter(moment(moment().format("YYYY MM DD " + info.text)));
856
+ } else if (info.view.type === ViewType.DAY) {
857
+ isPast = moment().isAfter(
858
+ moment(moment(info.view.activeStart).format("YYYY MM DD " + info.text))
859
+ );
860
+ }
861
+ return {
862
+ html: `<span class="time ${isPast && "past"}">${info.text}</span>`,
863
+ };
864
+ };
865
+
866
+ export const views = {
867
+ [ViewType.WEEK]: {
868
+ dayHeaderFormat: "ddd DD",
869
+ dayHeaderContent: (info: DayHeaderContentArg) => weekHeadContent(info),
870
+ slotLabelContent: (info: SlotLabelContentArg) => leftTimeContent(info),
871
+ },
872
+ [ViewType.DAY]: {
873
+ slotLabelContent: (info: SlotLabelContentArg) => leftTimeContent(info),
874
+ },
875
+ [ViewType.LIST]: {
876
+ listDayFormat: { weekday: "short" },
877
+ },
878
+ } as const;
879
+
880
+ export const slotLabelFormat = [
881
+ {
882
+ hour: "2-digit",
883
+ minute: "2-digit",
884
+ },
885
+ ] as FormatterInput[];
886
+
887
+ export const viewClassNames = (info: ViewContentArg) => {
888
+ let className = "";
889
+ if ([ViewType.WEEK, ViewType.DAY].includes(info.view.type as ViewType)) {
890
+ if (moment().isAfter(info.view.activeEnd)) {
891
+ className = "past";
892
+ } else if (moment().isBefore(info.view.activeStart)) {
893
+ className = "future";
894
+ }
895
+ }
896
+ return className;
897
+ };