lowcoder-comps 0.0.29 → 0.0.31

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 (86) hide show
  1. package/README.md +120 -0
  2. package/index.html +26 -0
  3. package/index.tsx +21 -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 +633 -0
  9. package/src/comps/calendarComp/calendarConstants.tsx +1048 -0
  10. package/src/comps/calendarComp/errorBoundary.tsx +30 -0
  11. package/src/comps/chartComp/chartComp.tsx +442 -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 +9 -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 +299 -0
  20. package/src/comps/chartComp/chartPropertyView.tsx +235 -0
  21. package/src/comps/chartComp/chartUtils.ts +291 -0
  22. package/src/comps/chartComp/reactEcharts/core.tsx +194 -0
  23. package/src/comps/chartComp/reactEcharts/index.ts +21 -0
  24. package/src/comps/chartComp/reactEcharts/types.ts +76 -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 +163 -0
  34. package/src/i18n/comps/locales/enObj.tsx +198 -0
  35. package/src/i18n/comps/locales/index.ts +7 -0
  36. package/src/i18n/comps/locales/types.tsx +10 -0
  37. package/src/i18n/comps/locales/zh.ts +156 -0
  38. package/src/i18n/comps/locales/zhObj.tsx +4 -0
  39. package/src/index.ts +11 -0
  40. package/tsconfig.json +22 -0
  41. package/vite.config.js +10 -0
  42. package/2085da13.js +0 -960
  43. package/250691b5.js +0 -5
  44. package/256b619e.js +0 -92
  45. package/274f545c.js +0 -881
  46. package/289305a1.js +0 -208
  47. package/2eae45c2.js +0 -34
  48. package/2ff2c7a6.js +0 -6
  49. package/2ff7471d.js +0 -9
  50. package/335b22a2.js +0 -220
  51. package/38c826fe.js +0 -1127
  52. package/44011c1d.js +0 -818
  53. package/4fc06812.js +0 -64
  54. package/56a787cf.js +0 -915
  55. package/590941ff.js +0 -86
  56. package/6341867f.js +0 -804
  57. package/657fd065.js +0 -8
  58. package/78a5e50d.js +0 -1579
  59. package/820c3641.js +0 -25
  60. package/88b4e75a.js +0 -2967
  61. package/8d999722.js +0 -1102
  62. package/92e85b65.js +0 -65
  63. package/989caea2.js +0 -505
  64. package/99b984d1.js +0 -237
  65. package/9e5f02d6.js +0 -19104
  66. package/a40faea7.js +0 -11624
  67. package/abac9104.js +0 -1536
  68. package/af2f19b3.js +0 -819
  69. package/af5ee3de.js +0 -268
  70. package/b24707c2.js +0 -48428
  71. package/b68f8b69.js +0 -1276
  72. package/ba68ba65.js +0 -391
  73. package/bafb8599.js +0 -319
  74. package/bba60c35.js +0 -2501
  75. package/bd7c2a8e.js +0 -1089
  76. package/c71dadea.js +0 -455
  77. package/d05c1762.js +0 -933
  78. package/d073ab24.js +0 -134353
  79. package/d838cd10.js +0 -769
  80. package/dc36a6eb.js +0 -796
  81. package/ed143450.js +0 -1284
  82. package/ee8ec8f2.js +0 -2284
  83. package/f6755210.js +0 -1269
  84. package/f9637058.js +0 -16
  85. package/fba4c8e4.js +0 -447
  86. package/index.js +0 -5
@@ -0,0 +1,1048 @@
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 { default as Form } from "antd/es/form";
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) =>
209
+ props.$theme?.primary ? props.$theme.primary : props.$style.background};
210
+ color: ${(props) =>
211
+ contrastText(
212
+ props.$theme?.primary || "",
213
+ props.$theme?.textDark || "#000000",
214
+ props.$theme?.textLight || "#ffffff"
215
+ )};
216
+ }
217
+ .fc-daygrid-day-events {
218
+ padding: 1px 0 5px 0;
219
+ min-height: unset;
220
+ .fc-event {
221
+ margin: 2px 4px 2px 12px;
222
+ padding: 0;
223
+ &:hover .event {
224
+ padding-right: 20px;
225
+ }
226
+ .event {
227
+ font-size: 13px;
228
+ line-height: 18px;
229
+ padding-right: 0;
230
+ .event-time {
231
+ display: none;
232
+ }
233
+ .event-title {
234
+ margin-left: 15px;
235
+ overflow: hidden;
236
+ text-overflow: ellipsis;
237
+ white-space: nowrap;
238
+ }
239
+ &::before {
240
+ height: 14px;
241
+ }
242
+ }
243
+ }
244
+ .fc-daygrid-day-bottom {
245
+ padding: 2px 2px 0 10px;
246
+ }
247
+ }
248
+ .fc-day-other {
249
+ color: ${(props) => props.$style.text};
250
+ .fc-daygrid-day-top,
251
+ .fc-daygrid-day-events {
252
+ opacity: 0.35;
253
+ }
254
+ .event::before {
255
+ background-color: ${(props) => props.$style.text};
256
+ }
257
+ }
258
+ }
259
+ // month drag event
260
+ .fc > .fc-event {
261
+ visibility: hidden;
262
+ }
263
+
264
+ // more link
265
+ .fc-view-harness-active .fc-more-popover {
266
+ border-radius: 4px;
267
+ box-shadow: 0 0px 10px 4px rgba(0, 0, 0, 0.25);
268
+ overflow: hidden;
269
+ left: ${(props) => `min(${props.$left}px, calc(100% - 210px)) !important`};
270
+ .fc-popover-body {
271
+ padding: 4px 0;
272
+ min-width: 200px;
273
+ width: 200px;
274
+ .fc-daygrid-event-harness {
275
+ margin: 4px;
276
+ .fc-event {
277
+ margin: 0;
278
+ .event {
279
+ height: fit-content;
280
+ .event-title {
281
+ white-space: pre-wrap;
282
+ }
283
+ .event-time {
284
+ margin-top: 0;
285
+ }
286
+ }
287
+ }
288
+ }
289
+ }
290
+ .fc-popover-header,
291
+ .fc-popover-body {
292
+ background-color: ${(props) => props.$style.background};
293
+ }
294
+ .fc-popover-header .fc-popover-close {
295
+ color: #8b8fa3;
296
+ &:hover {
297
+ color: #222;
298
+ }
299
+ }
300
+ }
301
+
302
+ .fc-direction-ltr .fc-timegrid-more-link {
303
+ border: 1px solid ${(props) => props.$style.border};
304
+ border-radius: 4px;
305
+ box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.15);
306
+ font-size: 13px;
307
+ display: inline-block;
308
+ font-weight: 500;
309
+ background-color: ${(props) => lightenColor(props.$style.background, 0.1)};
310
+ }
311
+
312
+ .fc-dayGridMonth-view .fc-more-link {
313
+ margin: 0 2px 2px 2px !important;
314
+ }
315
+ .fc-timeGridWeek-view .fc-more-link,
316
+ .fc-timeGridDay-view .fc-more-link {
317
+ margin: 2px !important;
318
+ }
319
+ .fc-daygrid-day-events {
320
+ margin: 0 !important;
321
+ padding: 2px 0;
322
+ .fc-event {
323
+ margin: 2px 4px;
324
+ }
325
+ .fc-daygrid-day-bottom {
326
+ line-height: 16px;
327
+ padding: 0;
328
+ .fc-more-link {
329
+ width: calc(100% - 4px);
330
+ border: 1px solid ${(props) => props.$style.border};
331
+ border-radius: 4px;
332
+ box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.15);
333
+ font-size: 13px;
334
+ display: inline-block;
335
+ height: 20px;
336
+ padding-left: 15px;
337
+ font-weight: 500;
338
+ background-color: ${(props) =>
339
+ lightenColor(props.$style.background, 0.1)};
340
+ }
341
+ }
342
+ }
343
+
344
+ // on resize
345
+ .fc-media-screen {
346
+ height: 100% !important;
347
+ }
348
+ .fc-scroller {
349
+ overflow: hidden auto !important;
350
+ overflow: hidden overlay !important;
351
+ }
352
+ .fc-col-header,
353
+ .fc-scroller > div,
354
+ .fc-scroller > div > table,
355
+ .fc-scrollgrid-sync-table,
356
+ .fc-timegrid-cols > table,
357
+ .fc .fc-scrollgrid,
358
+ .fc .fc-scrollgrid table {
359
+ width: 100% !important;
360
+ }
361
+
362
+ // event
363
+ .fc-timegrid-event .fc-event-main {
364
+ padding: 4px 0 4px 1px;
365
+ }
366
+ .fc-event {
367
+ position: relative;
368
+ height: 100%;
369
+ background-color: unset !important;
370
+ border: none !important;
371
+ box-shadow: none !important;
372
+ .event-remove {
373
+ color: ${(props) => props.$style.text};
374
+ }
375
+ &:hover {
376
+ .event-remove {
377
+ opacity: ${(props) => (props.$editable ? 1 : undefined)};
378
+ }
379
+ }
380
+ }
381
+
382
+ // left time
383
+ .time.past {
384
+ opacity: 0.35;
385
+ }
386
+
387
+ .past .time {
388
+ opacity: 0.35;
389
+ }
390
+
391
+ .future .time {
392
+ opacity: 1;
393
+ }
394
+
395
+ .fc-scrollgrid-liquid > tbody {
396
+ & > tr:nth-of-type(2) {
397
+ display: ${(props) => props.allDay && 1};
398
+ }
399
+ }
400
+ .fc .fc-timegrid-slot-label-cushion {
401
+ padding: 0 15px;
402
+ }
403
+
404
+ // border-radius, bg
405
+ .fc-theme-standard .fc-list {
406
+ background-color: ${(props) => props.$style.background};
407
+ border-radius: ${(props) =>
408
+ `0 0 ${props.$style.radius} ${props.$style.radius}`};
409
+ border-color: ${(props) => props.$style.border};
410
+ border-top-color: ${(props) =>
411
+ toHex(props.$style.border) === "#D7D9E0"
412
+ ? "#E1E3EB"
413
+ : lightenColor(props.$style.border, 0.03)};
414
+ }
415
+ .fc-scrollgrid-liquid {
416
+ border-radius: ${(props) =>
417
+ `0 0 ${props.$style.radius} ${props.$style.radius}`};
418
+ overflow: hidden;
419
+ border-right-width: 1px;
420
+ border-bottom-width: 1px;
421
+ border-color: ${(props) => props.$style.border};
422
+ > thead,
423
+ > tbody > tr:nth-of-type(1),
424
+ .fc-scrollgrid-section-liquid > td {
425
+ background-color: ${(props) => props.$style.background};
426
+ }
427
+ }
428
+ .fc-scrollgrid-section-liquid > td,
429
+ .fc-scrollgrid-liquid .fc-scrollgrid-section-header > th {
430
+ border: none;
431
+ }
432
+ .fc-scrollgrid-liquid > tbody > tr:nth-of-type(1) > td {
433
+ border-right: none;
434
+ }
435
+ .fc-theme-standard .fc-scrollgrid {
436
+ border-color: ${(props) =>
437
+ toHex(props.$style.border) === "#D7D9E0"
438
+ ? "#E1E3EB"
439
+ : lightenColor(props.$style.border, 0.03)};
440
+ }
441
+ .fc .fc-scrollgrid {
442
+ border-bottom-width: 1px;
443
+ border-right-width: 1px;
444
+ }
445
+
446
+ .fc-day-sat,
447
+ .fc-day-sun {
448
+ &.fc-timegrid-col,
449
+ &.fc-daygrid-day {
450
+ background-color: ${(props) =>
451
+ isDarkColor(props.$style.background)
452
+ ? darkenColor(props.$style.background, 0.06)
453
+ : darkenColor(props.$style.background, 0.02)};
454
+ }
455
+ }
456
+ .fc-theme-standard td,
457
+ .fc-theme-standard th {
458
+ border-color: ${(props) =>
459
+ toHex(props.$style.border) === "#D7D9E0"
460
+ ? "#E1E3EB"
461
+ : lightenColor(props.$style.border, 0.03)};
462
+ }
463
+
464
+ // header
465
+ .fc .fc-toolbar.fc-header-toolbar {
466
+ padding: 16px;
467
+ margin-bottom: 0;
468
+ border: 1px solid ${(props) => props.$style.border};
469
+ border-bottom: none;
470
+ border-radius: ${(props) =>
471
+ `${props.$style.radius} ${props.$style.radius} 0 0`};
472
+ background-color: ${(props) => props.$style.background};
473
+ }
474
+ .fc-toolbar-title {
475
+ color: ${(props) => props.$style.title};
476
+ font-size: 24px;
477
+ line-height: 24px;
478
+ display: inline-flex;
479
+ }
480
+ .fc-toolbar-chunk {
481
+ display: inline-flex;
482
+ align-items: center;
483
+ }
484
+ .fc .fc-toolbar-chunk .fc-button.fc-button-primary {
485
+ height: 28px;
486
+ display: flex;
487
+ align-items: center;
488
+ justify-content: center;
489
+ &:not(:disabled):not(.fc-button-active) {
490
+ &:hover,
491
+ &:active {
492
+ color: ${(props) => props.$style.btnText};
493
+ background-color: ${(props) =>
494
+ toHex(props.$style.headerBtnBackground) === "#FFFFFF"
495
+ ? "#F5F5F6"
496
+ : genHoverColor(props.$style.headerBtnBackground)};
497
+ border-color: ${(props) =>
498
+ toHex(props.$style.headerBtnBackground) === "#FFFFFF"
499
+ ? "#D7D9E0"
500
+ : backgroundToBorder(
501
+ genHoverColor(props.$style.headerBtnBackground)
502
+ )};
503
+ }
504
+ }
505
+ &:not(:disabled):focus {
506
+ box-shadow: none;
507
+ }
508
+ &:disabled {
509
+ cursor: not-allowed;
510
+ opacity: 1;
511
+ &,
512
+ &:hover {
513
+ background-color: ${(props) => props.$style.headerBtnBackground};
514
+ border-color: ${(props) =>
515
+ backgroundToBorder(props.$style.headerBtnBackground)};
516
+ color: ${(props) =>
517
+ toHex(props.$style.btnText) === "#222222"
518
+ ? "#B8B9BF"
519
+ : contrastColor(props.$style.btnText)};
520
+ }
521
+ }
522
+ }
523
+ .fc .fc-button-primary:not(:disabled).fc-button-active:focus,
524
+ .fc .fc-button-primary:not(:disabled):active:focus {
525
+ box-shadow: none;
526
+ }
527
+ .fc-toolbar-chunk:nth-of-type(3) .fc-button-primary {
528
+ height: 28px;
529
+ display: inline-flex;
530
+ font-size: 14px;
531
+ margin-left: 8px;
532
+ background-color: ${(props) => props.$style.headerBtnBackground};
533
+ border-color: ${(props) =>
534
+ backgroundToBorder(props.$style.headerBtnBackground)};
535
+ color: ${(props) => props.$style.btnText};
536
+ &.fc-today-button {
537
+ min-width: 52px;
538
+ }
539
+ &.fc-prev-button,
540
+ &.fc-next-button {
541
+ padding: 0;
542
+ width: 28px;
543
+ color: ${(props) => lightenColor(props.$style.btnText, 0.4)};
544
+ }
545
+ &.fc-prev-button {
546
+ margin-left: 12px;
547
+ }
548
+ }
549
+ .fc-toolbar-chunk:nth-of-type(3) .fc-button-group {
550
+ background-color: ${(props) =>
551
+ toHex(props.$style.headerBtnBackground) === "#FFFFFF"
552
+ ? "#EFEFF1"
553
+ : isDarkColor(props.$style.headerBtnBackground)
554
+ ? props.$style.headerBtnBackground
555
+ : darkenColor(props.$style.headerBtnBackground, 0.1)};
556
+ border-radius: 4px;
557
+ margin-left: 16px;
558
+ .fc-button-primary {
559
+ background-color: transparent;
560
+ min-width: 60px;
561
+ border-radius: 4px;
562
+ margin: 2px;
563
+ border: none;
564
+ color: ${(props) =>
565
+ toHex(props.$style.btnText) === "#222222"
566
+ ? "#8B8FA3"
567
+ : lightenColor(props.$style.btnText, 0.4)};
568
+ font-weight: 500;
569
+
570
+ &.fc-button-active {
571
+ background-color: ${(props) =>
572
+ isDarkColor(props.$style.headerBtnBackground)
573
+ ? lightenColor(props.$style.headerBtnBackground, 0.1)
574
+ : props.$style.headerBtnBackground};
575
+ color: ${(props) => props.$style.btnText};
576
+ }
577
+ }
578
+ }
579
+
580
+ // week head
581
+ .fc-timeGridWeek-view {
582
+ .week-head {
583
+ display: flex;
584
+ flex-direction: column;
585
+ font-size: 14px;
586
+ font-weight: 400;
587
+ &.past span {
588
+ opacity: 0.35;
589
+ }
590
+ .week {
591
+ padding-bottom: 3px;
592
+ }
593
+ .day {
594
+ font-size: 20px;
595
+ font-weight: 500;
596
+ line-height: 22px;
597
+ }
598
+ }
599
+ .fc-day-today.fc-col-header-cell {
600
+ background-color: ${(props) =>
601
+ isDarkColor(props.$style.background)
602
+ ? "#ffffff19"
603
+ : toHex(props.$theme?.primary!) + "19"};
604
+ a {
605
+ color: ${(props) =>
606
+ !isDarkColor(props.$style.background) &&
607
+ darkenColor(props.$theme?.primary!, 0.1)};
608
+ }
609
+ }
610
+ .fc-col-header-cell-cushion {
611
+ padding: 8px 0 13px 0;
612
+ }
613
+ }
614
+
615
+ // week left
616
+ .fc .fc-timegrid-axis-cushion {
617
+ min-width: 62px;
618
+ min-height: 52px;
619
+ max-width: none;
620
+ display: inline-flex;
621
+ align-items: center;
622
+ justify-content: center;
623
+ }
624
+ .fc-direction-ltr .fc-timegrid-slot-label-frame {
625
+ text-align: center;
626
+ }
627
+ .fc .fc-timegrid-slot-label {
628
+ border: none;
629
+ }
630
+
631
+ // time can doubleClick
632
+ .fc-timegrid-bg-harness,
633
+ .fc-daygrid-day-bg {
634
+ pointer-events: none;
635
+ }
636
+ `;
637
+
638
+ export const Remove = styled.div<{ $isList: boolean }>`
639
+ position: absolute;
640
+ pointer-events: auto;
641
+ top: 0;
642
+ right: 0;
643
+ display: flex;
644
+ padding: 5px;
645
+ opacity: 0;
646
+ cursor: pointer;
647
+ &:hover {
648
+ g {
649
+ stroke: #315efb;
650
+ }
651
+ }
652
+ `;
653
+
654
+ export const Event = styled.div<{
655
+ $bg: string;
656
+ theme: Object;
657
+ $isList: boolean;
658
+ $allDay: boolean;
659
+ $style: CalendarStyleType;
660
+ }>`
661
+ height: 100%;
662
+ width: 100%;
663
+ pointer-events: none;
664
+ border-radius: 4px;
665
+ box-shadow: ${(props) => !props.$isList && "0 0 5px 0 rgba(0, 0, 0, 0.15)"};
666
+ border: 1px solid ${(props) => props.$style.border};
667
+ display: ${(props) => props.$isList && "flex"};
668
+ background-color: ${(props) =>
669
+ !props.$isList && lightenColor(props.$style.background, 0.1)};
670
+ overflow: hidden;
671
+ font-size: 13px;
672
+ line-height: 19px;
673
+ padding-right: 20px;
674
+ overflow: hidden;
675
+ position: relative;
676
+ &::before {
677
+ content: "";
678
+ position: absolute;
679
+ display: block;
680
+ width: 5px;
681
+ height: calc(100% - 4px);
682
+ left: 2px;
683
+ top: 2px;
684
+ border-radius: 3px;
685
+ background-color: ${(props) => props.$bg};
686
+ }
687
+
688
+ .event-time {
689
+ color: ${(props) =>
690
+ !props.$isList &&
691
+ (isDarkColor(props.$style.text)
692
+ ? lightenColor(props.$style.text, 0.2)
693
+ : props.$style.text)};
694
+ margin-left: 15px;
695
+ white-space: pre-wrap;
696
+ margin-top: 2px;
697
+ }
698
+ .event-title {
699
+ color: ${(props) => !props.$isList && props.$style.text};
700
+ font-weight: 500;
701
+ margin-left: 15px;
702
+ white-space: pre-wrap;
703
+ word-break: break-word;
704
+ }
705
+
706
+ &.small {
707
+ height: 20px;
708
+ .event-time {
709
+ display: none;
710
+ }
711
+ .event-title {
712
+ text-overflow: ellipsis;
713
+ overflow: hidden;
714
+ white-space: nowrap;
715
+ }
716
+ }
717
+ &.middle {
718
+ padding-top: 2px;
719
+ .event-time,
720
+ .event-title {
721
+ text-overflow: ellipsis;
722
+ overflow: hidden;
723
+ white-space: nowrap;
724
+ }
725
+ }
726
+ &.large {
727
+ .event-time {
728
+ margin-top: 13px;
729
+ }
730
+ }
731
+ &.past {
732
+ background-color: ${(props) =>
733
+ isDarkColor(props.$style.background) && props.$style.background};
734
+ &::before {
735
+ background-color: ${(props) =>
736
+ toHex(props.$style.text) === "#3C3C3C"
737
+ ? "#8B8FA3"
738
+ : isDarkColor(props.$style.text)
739
+ ? lightenColor(props.$style.text, 0.3)
740
+ : props.$style.text};
741
+ }
742
+ &::before,
743
+ .event-title,
744
+ .event-time {
745
+ opacity: 0.35;
746
+ }
747
+ }
748
+ `;
749
+
750
+ export const FormWrapper = styled(Form)`
751
+ .ant-form-item-label {
752
+ width: 100px;
753
+ text-align: left;
754
+ line-height: 18px;
755
+ label:not(.ant-form-item-required) {
756
+ margin-left: 11px;
757
+ }
758
+ label span {
759
+ ${UnderlineCss}
760
+ }
761
+ }
762
+ `;
763
+
764
+ export type EventType = {
765
+ id?: string;
766
+ resourceId?: string;
767
+ label?: string;
768
+ title?: string;
769
+ start?: string;
770
+ end?: string;
771
+ allDay?: boolean;
772
+ color?: string;
773
+ groupId?: string;
774
+ value?: string;
775
+ };
776
+
777
+ export enum ViewType {
778
+ YEAR = "multiMonthYear",
779
+ MONTH = "dayGridMonth",
780
+ WEEK = "timeGridWeek",
781
+ DAY = "timeGridDay",
782
+ DAYLIST = "dayGridDay",
783
+ LIST = "listWeek",
784
+ TIMEGRID = "timeGridDay",
785
+ }
786
+
787
+ export const DefaultWithPremiumViewOptions = [
788
+ {
789
+ label: trans("calendar.resourceTimeGridDay"),
790
+ value: "resourceTimeGridDay",
791
+ },
792
+ {
793
+ label: trans("calendar.timeline"),
794
+ value: "resourceTimelineDay",
795
+ },
796
+ {
797
+ label: trans("calendar.year"),
798
+ value: "multiMonthYear",
799
+ },
800
+ {
801
+ label: trans("calendar.month"),
802
+ value: "dayGridMonth",
803
+ },
804
+ {
805
+ label: trans("calendar.week"),
806
+ value: "timeGridWeek",
807
+ },
808
+ {
809
+ label: trans("calendar.weekdaygrid"),
810
+ value: "dayGridWeek",
811
+ },
812
+ {
813
+ label: trans("calendar.daygrid"),
814
+ value: "dayGridDay",
815
+ },
816
+ {
817
+ label: trans("calendar.day"),
818
+ value: "timeGridDay",
819
+ },
820
+ {
821
+ label: trans("calendar.list"),
822
+ value: "listWeek",
823
+ },
824
+ ] as const;
825
+
826
+ export const DefaultWithFreeViewOptions = [
827
+ {
828
+ label: trans("calendar.year"),
829
+ value: "multiMonthYear",
830
+ },
831
+ {
832
+ label: trans("calendar.month"),
833
+ value: "dayGridMonth",
834
+ },
835
+ {
836
+ label: trans("calendar.week"),
837
+ value: "timeGridWeek",
838
+ },
839
+ {
840
+ label: trans("calendar.weekdaygrid"),
841
+ value: "dayGridWeek",
842
+ },
843
+ {
844
+ label: trans("calendar.daygrid"),
845
+ value: "dayGridDay",
846
+ },
847
+ {
848
+ label: trans("calendar.day"),
849
+ value: "timeGridDay",
850
+ },
851
+ {
852
+ label: trans("calendar.list"),
853
+ value: "listWeek",
854
+ },
855
+ ] as const;
856
+
857
+ export const FirstDayOptions = [
858
+ {
859
+ label: trans("calendar.monday"),
860
+ value: "1",
861
+ },
862
+ {
863
+ label: trans("calendar.tuesday"),
864
+ value: "2",
865
+ },
866
+ {
867
+ label: trans("calendar.wednesday"),
868
+ value: "3",
869
+ },
870
+ {
871
+ label: trans("calendar.thursday"),
872
+ value: "4",
873
+ },
874
+ {
875
+ label: trans("calendar.friday"),
876
+ value: "5",
877
+ },
878
+ {
879
+ label: trans("calendar.saturday"),
880
+ value: "6",
881
+ },
882
+ {
883
+ label: trans("calendar.sunday"),
884
+ value: "0",
885
+ },
886
+ ];
887
+
888
+ export const defaultData = [
889
+ {
890
+ id: "1",
891
+ title: "Coding",
892
+ start: dayjs().hour(10).minute(0).second(0).format(DATE_TIME_FORMAT),
893
+ end: dayjs().hour(12).minute(30).second(0).format(DATE_TIME_FORMAT),
894
+ color: "#079968",
895
+ },
896
+ {
897
+ id: "2",
898
+ title: "Rest",
899
+ start: dayjs().hour(24).format(DATE_FORMAT),
900
+ end: dayjs().hour(48).format(DATE_FORMAT),
901
+ allDay: true,
902
+ },
903
+ ];
904
+ export const resourcesEventsDefaultData = [
905
+ {
906
+ id: "1",
907
+ resourceId: "d1",
908
+ title: "event 1",
909
+ start: dayjs().hour(10).minute(0).second(0).format(DATE_TIME_FORMAT),
910
+ end: dayjs().hour(17).minute(30).second(0).format(DATE_TIME_FORMAT),
911
+ color: "#079968",
912
+ },
913
+ {
914
+ id: "2",
915
+ resourceId: "b",
916
+ title: "event 5",
917
+ start: dayjs().hour(8).minute(0).second(0).format(DATE_TIME_FORMAT),
918
+ end: dayjs().hour(16).minute(30).second(0).format(DATE_TIME_FORMAT),
919
+ color: "#079968",
920
+ },
921
+ {
922
+ id: "3",
923
+ resourceId: "a",
924
+ title: "event 3",
925
+ start: dayjs().hour(12).minute(0).second(0).format(DATE_TIME_FORMAT),
926
+ end: dayjs().hour(21).minute(30).second(0).format(DATE_TIME_FORMAT),
927
+ color: "#079968",
928
+ },
929
+ ];
930
+
931
+ export const resourcesDefaultData = [
932
+ {
933
+ id: "a",
934
+ title: "Auditorium A",
935
+ },
936
+ {
937
+ id: "b",
938
+ title: "Auditorium B",
939
+ eventColor: "green",
940
+ },
941
+ {
942
+ id: "d",
943
+ title: "Auditorium D",
944
+ children: [
945
+ {
946
+ id: "d1",
947
+ title: "Room D1",
948
+ },
949
+ {
950
+ id: "d2",
951
+ title: "Room D2",
952
+ },
953
+ ],
954
+ },
955
+ ];
956
+
957
+ export const buttonText = {
958
+ today: trans("calendar.today"),
959
+ month: trans("calendar.month"),
960
+ week: trans("calendar.week"),
961
+ timeline: trans("calendar.timeline"),
962
+ day: trans("calendar.day"),
963
+ list: trans("calendar.list"),
964
+ };
965
+
966
+ export const headerToolbar = {
967
+ left: "title",
968
+ right: "prev today next dayGridMonth,timeGridWeek,timeGridDay,listWeek",
969
+ };
970
+
971
+ export const resourceTimeLineHeaderToolbar = {
972
+ left: "title",
973
+ right:
974
+ "prev today next resourceTimelineMonth,resourceTimelineWeek,resourceTimelineDay",
975
+ };
976
+ export const resourceTimeGridHeaderToolbar = {
977
+ left: "title",
978
+ right: "prev today next",
979
+ };
980
+
981
+ const weekHeadContent = (info: DayHeaderContentArg) => {
982
+ const text = info.text.split(" ");
983
+ return {
984
+ html: `<span class="week-head ${info.isPast && "past"} ${
985
+ info.isToday && "today"
986
+ }">
987
+ <span class="week">${text[0]}</span>
988
+ <span class="day">${text[1]}</span>
989
+ </span>`,
990
+ };
991
+ };
992
+
993
+ const leftTimeContent = (info: SlotLabelContentArg) => {
994
+ let isPast = false;
995
+ if (info.view.type === ViewType.WEEK) {
996
+ isPast = dayjs().isAfter(dayjs(dayjs().format("YYYY MM DD " + info.text)));
997
+ } else if (info.view.type === ViewType.DAY) {
998
+ isPast = dayjs().isAfter(
999
+ dayjs(dayjs(info.view.activeStart).format("YYYY MM DD " + info.text))
1000
+ );
1001
+ }
1002
+ return {
1003
+ html: `<span class="time ${isPast && "past"}">${info.text}</span>`,
1004
+ };
1005
+ };
1006
+
1007
+ export const views = {
1008
+ [ViewType.WEEK]: {
1009
+ dayHeaderFormat: "ddd DD",
1010
+ dayHeaderContent: (info: DayHeaderContentArg) => weekHeadContent(info),
1011
+ slotLabelContent: (info: SlotLabelContentArg) => leftTimeContent(info),
1012
+ },
1013
+ [ViewType.DAY]: {
1014
+ slotLabelContent: (info: SlotLabelContentArg) => leftTimeContent(info),
1015
+ },
1016
+ [ViewType.LIST]: {
1017
+ listDayFormat: { weekday: "short" },
1018
+ },
1019
+ } as const;
1020
+
1021
+ export const slotLabelFormat = [
1022
+ {
1023
+ hour: "2-digit",
1024
+ minute: "2-digit",
1025
+ },
1026
+ ] as FormatterInput[];
1027
+
1028
+ export const slotLabelFormatWeek = [
1029
+ { week: "short" },
1030
+ { hour: "2-digit" },
1031
+ ] as FormatterInput[];
1032
+
1033
+ export const slotLabelFormatMonth = [
1034
+ { week: "short" },
1035
+ { weekday: "short" }
1036
+ ] as FormatterInput[];
1037
+
1038
+ export const viewClassNames = (info: ViewContentArg) => {
1039
+ let className = "";
1040
+ if ([ViewType.WEEK, ViewType.DAY].includes(info.view.type as ViewType)) {
1041
+ if (dayjs().isAfter(info.view.activeEnd)) {
1042
+ className = "past";
1043
+ } else if (dayjs().isBefore(info.view.activeStart)) {
1044
+ className = "future";
1045
+ }
1046
+ }
1047
+ return className;
1048
+ };