next-helios-fe 1.8.24 → 1.8.25
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/dist/components/calendar/big-calendar/event.d.ts +7 -2
- package/dist/components/calendar/big-calendar/index.d.ts +16 -8
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/calendar/big-calendar/event.tsx +8 -3
- package/src/components/calendar/big-calendar/index.tsx +79 -55
package/package.json
CHANGED
@@ -3,8 +3,13 @@ import React from "react";
|
|
3
3
|
import { Form } from "../../../components";
|
4
4
|
|
5
5
|
export interface EventProps {
|
6
|
-
title
|
7
|
-
eventList:
|
6
|
+
title?: string;
|
7
|
+
eventList: {
|
8
|
+
id: number | string;
|
9
|
+
title: string;
|
10
|
+
color?: string;
|
11
|
+
[key: string]: any;
|
12
|
+
}[];
|
8
13
|
hiddenEvent: any[];
|
9
14
|
setHiddenEvent: (event: any) => void;
|
10
15
|
}
|
@@ -38,7 +43,7 @@ export const Event: React.FC<EventProps> = ({
|
|
38
43
|
return (
|
39
44
|
eventList.length !== 0 && (
|
40
45
|
<div className="flex-1 flex flex-col gap-4 h-full px-6 py-6 overflow-hidden">
|
41
|
-
<span className="text-lg">{title || "Event
|
46
|
+
<span className="text-lg">{title || "Event List"}</span>
|
42
47
|
<div className="flex flex-col gap-2 h-full overflow-auto">
|
43
48
|
{eventArr}
|
44
49
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import React, { useState, useEffect } from "react";
|
3
3
|
import { Toolbar } from "./toolbar";
|
4
|
-
import { Event
|
4
|
+
import { Event } from "./event";
|
5
5
|
import { Calendar as Bc, dayjsLocalizer } from "react-big-calendar";
|
6
6
|
import dayjs from "dayjs";
|
7
7
|
import "../../../styles";
|
@@ -9,23 +9,34 @@ import "../../../styles";
|
|
9
9
|
const localizer = dayjsLocalizer(dayjs);
|
10
10
|
|
11
11
|
interface BigCalendarProps {
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
title?: string;
|
13
|
+
options?: {
|
14
|
+
eventListFilter?: boolean;
|
15
|
+
};
|
16
|
+
eventList: {
|
17
|
+
id: number | string;
|
18
|
+
title: string;
|
19
|
+
start: Date;
|
20
|
+
end: Date;
|
21
|
+
desc?: string;
|
22
|
+
allDay?: boolean;
|
23
|
+
color?: string;
|
24
|
+
[key: string]: any;
|
25
|
+
}[];
|
26
|
+
sideBarComponent?: React.ReactNode;
|
15
27
|
onSelectEvent?: (event: any) => void;
|
16
28
|
}
|
17
29
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
export const BigCalendar: BigCalendarComponent = ({
|
30
|
+
export const BigCalendar: React.FC<BigCalendarProps> = ({
|
31
|
+
title,
|
32
|
+
options,
|
23
33
|
eventList,
|
24
|
-
|
25
|
-
hiddenEvent,
|
34
|
+
sideBarComponent,
|
26
35
|
onSelectEvent,
|
27
36
|
}) => {
|
28
37
|
const [active, setActive] = useState<string>("month");
|
38
|
+
const [modifiedEventList, setModifiedEventList] = useState<any[]>([]);
|
39
|
+
const [hiddenEvent, setHiddenEvent] = useState<any[]>([]);
|
29
40
|
|
30
41
|
const colorList = [
|
31
42
|
{ id: 1, label: "Blue", value: "#2196f3" },
|
@@ -40,21 +51,19 @@ export const BigCalendar: BigCalendarComponent = ({
|
|
40
51
|
];
|
41
52
|
|
42
53
|
useEffect(() => {
|
43
|
-
const tempEvent = eventList
|
54
|
+
const tempEvent = eventList.map((item) => {
|
55
|
+
return {
|
56
|
+
...item,
|
57
|
+
color: colorList[Math.floor(Math.random() * colorList.length)].value,
|
58
|
+
};
|
59
|
+
});
|
44
60
|
|
45
|
-
|
46
|
-
|
47
|
-
return {
|
48
|
-
...item,
|
49
|
-
color: colorList[Math.floor(Math.random() * colorList.length)].value,
|
50
|
-
};
|
51
|
-
})
|
52
|
-
);
|
53
|
-
}, []);
|
61
|
+
setModifiedEventList(tempEvent);
|
62
|
+
}, [eventList]);
|
54
63
|
|
55
64
|
const eventPropGetter = (item: any) => {
|
56
65
|
var custStyle = {
|
57
|
-
backgroundColor: item.color,
|
66
|
+
backgroundColor: item.color || "var(--color-primary)",
|
58
67
|
opacity: 0.8,
|
59
68
|
color: "white",
|
60
69
|
};
|
@@ -64,39 +73,54 @@ export const BigCalendar: BigCalendarComponent = ({
|
|
64
73
|
};
|
65
74
|
|
66
75
|
return (
|
67
|
-
<div className="flex-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
76
|
+
<div className="flex w-full h-full lg:divide-x">
|
77
|
+
{(sideBarComponent || options?.eventListFilter) && (
|
78
|
+
<div className="hidden lg:flex flex-col w-72 h-full divide-y">
|
79
|
+
{sideBarComponent}
|
80
|
+
{options?.eventListFilter && (
|
81
|
+
<Event
|
82
|
+
title={title}
|
83
|
+
eventList={modifiedEventList}
|
84
|
+
hiddenEvent={hiddenEvent}
|
85
|
+
setHiddenEvent={(item) => {
|
86
|
+
setHiddenEvent(item);
|
87
|
+
}}
|
88
|
+
/>
|
89
|
+
)}
|
90
|
+
</div>
|
91
|
+
)}
|
92
|
+
<div className="flex-1 overflow-hidden">
|
93
|
+
<Bc
|
94
|
+
localizer={localizer}
|
95
|
+
events={modifiedEventList.filter((item) => {
|
96
|
+
return !hiddenEvent.includes(item.id);
|
97
|
+
})}
|
98
|
+
startAccessor="start"
|
99
|
+
endAccessor="end"
|
100
|
+
components={{
|
101
|
+
toolbar: (toolbar: any) => {
|
102
|
+
return (
|
103
|
+
<Toolbar
|
104
|
+
toolbar={toolbar}
|
105
|
+
active={active}
|
106
|
+
setActive={setActive}
|
107
|
+
/>
|
108
|
+
);
|
109
|
+
},
|
110
|
+
}}
|
111
|
+
onView={(view: any) => {
|
112
|
+
setActive(view);
|
113
|
+
}}
|
114
|
+
// onRangeChange={(range) => console.log(range)}
|
115
|
+
popup
|
116
|
+
tooltipAccessor={(event: any) => event.desc}
|
117
|
+
eventPropGetter={eventPropGetter}
|
118
|
+
// selected={selected}
|
119
|
+
onSelectEvent={(event: any) => {
|
120
|
+
onSelectEvent && onSelectEvent(event);
|
121
|
+
}}
|
122
|
+
/>
|
123
|
+
</div>
|
98
124
|
</div>
|
99
125
|
);
|
100
126
|
};
|
101
|
-
|
102
|
-
BigCalendar.Event = Event;
|