Skip to content

Commit 318b1d3

Browse files
committed
🚀 release v1.1.0
1 parent 8ac2065 commit 318b1d3

File tree

7 files changed

+805
-235
lines changed

7 files changed

+805
-235
lines changed

README.md

Lines changed: 114 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11

2-
3-
4-
52
<h1 align="center">📅 React Material Scheduler</h1>
63
<p align="center">developed with <a target="_blank" href="https://mui.com">@mui</a> </p>
74

@@ -17,80 +14,124 @@
1714

1815
React mui scheduler is a react component based on @mui v5 that allows you to manage data in a calendar.
1916

20-
## 🗣️ Installation
17+
## 🚀 Installation
2118
```nodejs
2219
npm install react-mui-scheduler
2320
```
2421

2522
## 💻 Usage
2623
```javascript
27-
import React from 'react'
28-
import ReactDOM from 'react-dom'
29-
import Scheduler from "react-mui-scheduler"
30-
31-
function App() {
32-
const events = [
33-
{
34-
id: "event-1",
35-
label: "Consultation médicale",
36-
title: "Dr Shaun Murphy",
37-
color: "#f28f6a",
38-
startHour: "9 AM",
39-
endHour: "10 AM",
40-
date: "2021-09-09",
41-
createdAt: new Date(),
42-
createdBy: "Kristina Mayer"
43-
},
44-
{
45-
id: "event-2",
46-
label: "Consultation médicale",
47-
title: "Dr Claire Brown",
48-
color: "#099ce5",
49-
startHour: "9 AM",
50-
endHour: "10 AM",
51-
date: "2021-09-09",
52-
createdAt: new Date(),
53-
createdBy: "Kristina Mayer"
54-
},
55-
{
56-
id: "event-3",
57-
label: "Consultation médicale",
58-
title: "Dr Menlendez Hary",
59-
color: "#263686",
60-
startHour: "13 AM",
61-
endHour: "14 AM",
62-
date: "2021-09-12",
63-
createdAt: new Date(),
64-
createdBy: "Kristina Mayer"
65-
},
66-
]
67-
68-
const onCellClick = (event, row, day) => {
69-
// Do something...
70-
}
71-
72-
const onEventClick = (event, task) => {
73-
// Do something...
24+
import React, {useState} from 'react'
25+
import ReactDOM from 'react-dom'
26+
import Scheduler from "react-mui-scheduler"
27+
28+
function App() {
29+
const [state, setState] = useState({
30+
options: {
31+
transitionMode: "zoom",
32+
startWeekOn: "Mon",
33+
defaultMode: "week"
34+
},
35+
alertProps: {
36+
open: true,
37+
color: "info",
38+
severity: "info",
39+
message: "🚀 Let's start with awesome react-mui-scheduler 🔥 🔥 🔥" ,
40+
showActionButton: true,
41+
},
42+
toolbarProps: {
43+
showSearchBar: true,
44+
showSwitchModeButtons: true,
45+
showDatePicker: true
7446
}
75-
76-
const onEventsChange = (item) => {
77-
// Do something...
47+
})
48+
49+
const events = [
50+
{
51+
id: "event-1",
52+
label: "Consultation médicale",
53+
groupLabel: "Dr Shaun Murphy",
54+
user: "Dr Shaun Murphy",
55+
color: "#f28f6a",
56+
startHour: "04:00 AM",
57+
endHour: "05:00 AM",
58+
date: "2021-09-28",
59+
createdAt: new Date(),
60+
createdBy: "Kristina Mayer"
61+
},
62+
{
63+
id: "event-2",
64+
label: "Consultation médicale",
65+
groupLabel: "Dr Claire Brown",
66+
user: "Dr Claire Brown",
67+
color: "#099ce5",
68+
startHour: "09:00 AM",
69+
endHour: "10:00 AM",
70+
date: "2021-09-29",
71+
createdAt: new Date(),
72+
createdBy: "Kristina Mayer"
73+
},
74+
{
75+
id: "event-3",
76+
label: "Consultation médicale",
77+
groupLabel: "Dr Menlendez Hary",
78+
user: "Dr Menlendez Hary",
79+
color: "#263686",
80+
startHour: "13 AM",
81+
endHour: "14 AM",
82+
date: "2021-09-30",
83+
createdAt: new Date(),
84+
createdBy: "Kristina Mayer"
85+
},
86+
{
87+
id: "event-4",
88+
label: "Consultation prénatale",
89+
groupLabel: "Dr Shaun Murphy",
90+
user: "Dr Shaun Murphy",
91+
color: "#f28f6a",
92+
startHour: "08:00 AM",
93+
endHour: "09:00 AM",
94+
date: "2021-10-01",
95+
createdAt: new Date(),
96+
createdBy: "Kristina Mayer"
7897
}
98+
]
7999

80-
return (
81-
<Scheduler
82-
events={events}
83-
openAlert={false}
84-
alertMessage={'This is a scheduler alert'}
85-
alertProps={{color: 'info', severity: 'success'}}
86-
onEventsChange={onEventsChange}
87-
onCellClick={onCellClick}
88-
onTaskClick={onEventClick}
89-
/>
90-
)
100+
const handleCellClick = (event, row, day) => {
101+
// Do something...
91102
}
92-
93-
ReactDOM.render(<App />, document.querySelector('#app'))
103+
104+
const handleEventClick = (event, task) => {
105+
// Do something...
106+
}
107+
108+
const handleEventsChange = (item) => {
109+
// Do something...
110+
}
111+
112+
const handleAlertCloseButtonClicked = (item) => {
113+
// Do something...
114+
setState({
115+
...state,
116+
alertProps: {...state.alertProps, open: false}
117+
})
118+
}
119+
120+
return (
121+
<Scheduler
122+
events={events}
123+
options={state?.options}
124+
alertProps={state?.alertProps}
125+
toolbarProps={state?.toolbarProps}
126+
onEventsChange={handleEventsChange}
127+
onCellClick={handleCellClick}
128+
onTaskClick={handleEventClick}
129+
onAlertCloseButtonClicked={handleAlertCloseButtonClicked}
130+
/>
131+
)
132+
}
133+
134+
ReactDOM.render(<App />, document.querySelector('#yourComponentRootId'))
94135
```
95136
96137
@@ -109,16 +150,18 @@ React mui scheduler is a react component based on @mui v5 that allows you to man
109150
110151
## 🙇‍♂️ Extra
111152
112-
😊 Do you like this library ? Buy me a coffee
153+
Do you like this library ? Buy me a coffee
113154
114-
* Btc address: `1A2VNHSLGDyYsKWniJBe8cCqYWC52NvNZx`
155+
* Btc address: `bc1qettgagenn9nc8ks7ghntjfme96yvvkfhntk774`
115156
116-
* Eth address: `0xFe444a01D9494Ec04f61797e15193C8016D666A5`
157+
* Eth address: `0xB0413d8D0336E263e289A915c383e152155881E0`
117158
118159
119160
## 🔥 Some features to add in next releases
120161
121-
- 👉 Week and day mode switch view
162+
- ✅ Week mode switch view
163+
164+
- 👉 Day mode switch view
122165
123166
- 👉 Option menu
124167

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-mui-scheduler",
3-
"version": "1.0.4",
3+
"version": "1.1.0",
44
"description": "\uD83D\uDCC5 React mui scheduler is a react component based on @mui v5 that allows you to manage data in a calendar",
55
"main": "dist/index.esm.js",
66
"directories": {
@@ -18,6 +18,10 @@
1818
],
1919
"author": "rouftom",
2020
"license": "MIT",
21+
"repository": {
22+
"type": "git",
23+
"url": "https://github.com/rouftom/react-mui-scheduler.git"
24+
},
2125
"peerDependencies": {
2226
"react": "^17.0.2",
2327
"react-dom": "^17.0.2"

src/MonthModeView.jsx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ const StyledTableCell = styled(TableCell)(({ theme }) => ({
1515
borderTop: `1px solid #ccc !important`,
1616
borderBottom: `1px solid #ccc !important`,
1717
borderLeft: `1px solid #ccc !important`,
18-
'&:nth-child(1)': {
18+
'&:nth-of-type(1)': {
1919
borderLeft: `0px !important`
2020
}
2121
},
2222
[`&.${tableCellClasses.body}`]: {
2323
fontSize: 14,
2424
height: 96,
2525
width: 64,
26+
maxWidth: 64,
2627
cursor: 'pointer',
2728
borderLeft: `1px solid #ccc`,
28-
'&:nth-child(7n+1)': {
29+
'&:nth-of-type(7n+1)': {
2930
borderLeft: 0
3031
},
31-
'&:nth-child(even)': {
32+
'&:nth-of-type(even)': {
3233
backgroundColor: theme.palette.action.hover
3334
},
3435
},
@@ -73,7 +74,19 @@ function MonthModeView (props) {
7374
*/
7475
const onCellDragStart = (e, item, rowIndex) => {
7576
setState({...state, itemTransfert: {item, rowIndex}})
76-
//e.dataTransfer.setData('text/plain', `${item.id}_${rowIndex}`)
77+
}
78+
79+
/**
80+
* @name onCellDragEnter
81+
* @description
82+
* @param e
83+
* @param elementId
84+
* @param rowIndex
85+
* @return void
86+
*/
87+
const onCellDragEnter = (e, elementId, rowIndex) => {
88+
e.preventDefault()
89+
setState({...state, transfertTarget: {elementId, rowIndex}})
7790
}
7891

7992
/**
@@ -98,47 +111,35 @@ function MonthModeView (props) {
98111
let splittedDate = transfert?.item?.date?.split('-')
99112

100113
if (!transfert?.item?.day) {
101-
// Jour de la date du début du mois en chiffre
114+
// Get day of the date (DD)
102115
transfert.item.day = parseInt(splittedDate[2])
103116
}
104117

105118
if (transfert.item.day !== day?.day) {
106119
let itemCheck = day.data.findIndex(item => (
107-
item.day === transfert.item.day && item.title === transfert.item.title
120+
item.day === transfert.item.day && item.label === transfert.item.label
108121
))
109122

110123
if (itemCheck === -1) {
111124
let prevDayEvents = rowsCopy[transfert.rowIndex].days.find(d => d.day === transfert.item.day)
112125
let itemIndexToRemove = prevDayEvents?.data?.findIndex(i => i.id === transfert.item.id)
113-
126+
114127
if (itemIndexToRemove === undefined || itemIndexToRemove === -1) {
128+
console.log(prevDayEvents)
115129
return console.log("item to remove is not found")
116130
}
117131

118132
prevDayEvents?.data?.splice(itemIndexToRemove, 1)
119133
transfert.item.day = day?.day
120134
transfert.item.date = format(day?.date, 'yyyy-MM-dd')
121135
day.data.push(transfert.item)
122-
setState({...state, rows: rowsCopy})
136+
setState({...state, rows: rowsCopy, itemTransfert: null, transfertTarget: null})
123137
}
124138
}
125139
}
126140
}
127141
}
128142

129-
/**
130-
* @name onCellDragEnter
131-
* @description
132-
* @param e
133-
* @param elementId
134-
* @param rowIndex
135-
* @return void
136-
*/
137-
const onCellDragEnter = (e, elementId, rowIndex) => {
138-
e.preventDefault()
139-
setState({...state, transfertTarget: {elementId, rowIndex}})
140-
}
141-
142143
/**
143144
* @name handleCellClick
144145
* @description
@@ -164,7 +165,13 @@ function MonthModeView (props) {
164165
*/
165166
const renderTask = (tasks = [], rowId) => {
166167
return tasks?.map((task, index) => (
167-
((searchResult && task?.title === searchResult?.title) || !searchResult) && (
168+
(
169+
(
170+
searchResult &&
171+
(task?.groupLabel === searchResult?.groupLabel || task?.user === searchResult?.user)
172+
) || !searchResult
173+
) &&
174+
(
168175
<Paper
169176
draggable
170177
onClick={(e) => handleTaskClick(e, task)}
@@ -181,7 +188,7 @@ function MonthModeView (props) {
181188
onDragStart={e => onCellDragStart(e, task, rowId)}
182189
>
183190
<Box sx={{px: 0.5}}>
184-
<Typography variant="caption">{task?.title}</Typography>
191+
<Typography variant="caption">{task?.label}</Typography>
185192
</Box>
186193
</Paper>
187194
)
@@ -205,6 +212,7 @@ function MonthModeView (props) {
205212
if (state?.rows) {
206213
onEventsChange(Object.assign({}, state?.itemTransfert?.item))
207214
}
215+
// eslint-disable-next-line
208216
}, [state?.rows, state?.itemTransfert])
209217

210218
return (

0 commit comments

Comments
 (0)