@isma91/react-scheduler 4.0.0 → 4.0.2

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 (132) hide show
  1. package/{dist/index.js → index.js} +218 -203
  2. package/package.json +4 -76
  3. package/.github/workflows/publish.yml +0 -29
  4. package/.github/workflows/tests.yml +0 -35
  5. package/.gitignore +0 -32
  6. package/.husky/pre-commit +0 -2
  7. package/.prettierignore +0 -1
  8. package/.prettierrc.json +0 -7
  9. package/.yarnrc.yml +0 -1
  10. package/dist/LICENSE +0 -24
  11. package/dist/README.md +0 -172
  12. package/dist/package.json +0 -65
  13. package/eslint.config.js +0 -79
  14. package/index.html +0 -41
  15. package/jest.config.ts +0 -194
  16. package/public/favicon.ico +0 -0
  17. package/public/logo192.png +0 -0
  18. package/public/logo512.png +0 -0
  19. package/public/manifest.json +0 -25
  20. package/public/robots.txt +0 -3
  21. package/scripts/post-pack.js +0 -34
  22. package/src/App.tsx +0 -25
  23. package/src/Page1.tsx +0 -67
  24. package/src/events.tsx +0 -227
  25. package/src/index.tsx +0 -21
  26. package/src/lib/SchedulerComponent.tsx +0 -78
  27. package/src/lib/__tests__/index.test.tsx +0 -24
  28. package/src/lib/components/common/Cell.tsx +0 -52
  29. package/src/lib/components/common/LocaleArrow.tsx +0 -38
  30. package/src/lib/components/common/ResourceHeader.tsx +0 -73
  31. package/src/lib/components/common/Tabs.tsx +0 -119
  32. package/src/lib/components/common/TodayTypo.tsx +0 -44
  33. package/src/lib/components/common/WithResources.tsx +0 -98
  34. package/src/lib/components/events/Actions.tsx +0 -65
  35. package/src/lib/components/events/AgendaEventsList.tsx +0 -115
  36. package/src/lib/components/events/CurrentTimeBar.tsx +0 -59
  37. package/src/lib/components/events/EmptyAgenda.tsx +0 -27
  38. package/src/lib/components/events/EventItem.tsx +0 -180
  39. package/src/lib/components/events/EventItemPopover.tsx +0 -179
  40. package/src/lib/components/events/MonthEvents.tsx +0 -141
  41. package/src/lib/components/events/TodayEvents.tsx +0 -99
  42. package/src/lib/components/hoc/DateProvider.tsx +0 -19
  43. package/src/lib/components/inputs/DatePicker.tsx +0 -95
  44. package/src/lib/components/inputs/Input.tsx +0 -113
  45. package/src/lib/components/inputs/SelectInput.tsx +0 -164
  46. package/src/lib/components/month/MonthTable.tsx +0 -207
  47. package/src/lib/components/nav/DayDateBtn.tsx +0 -77
  48. package/src/lib/components/nav/MonthDateBtn.tsx +0 -80
  49. package/src/lib/components/nav/Navigation.tsx +0 -201
  50. package/src/lib/components/nav/WeekDateBtn.tsx +0 -89
  51. package/src/lib/components/week/WeekTable.tsx +0 -229
  52. package/src/lib/helpers/constants.ts +0 -4
  53. package/src/lib/helpers/generals.tsx +0 -354
  54. package/src/lib/hooks/useArrowDisable.ts +0 -26
  55. package/src/lib/hooks/useCellAttributes.ts +0 -67
  56. package/src/lib/hooks/useDragAttributes.ts +0 -31
  57. package/src/lib/hooks/useEventPermissions.ts +0 -42
  58. package/src/lib/hooks/useStore.ts +0 -8
  59. package/src/lib/hooks/useSyncScroll.ts +0 -31
  60. package/src/lib/hooks/useWindowResize.ts +0 -37
  61. package/src/lib/index.tsx +0 -14
  62. package/src/lib/positionManger/context.ts +0 -14
  63. package/src/lib/positionManger/provider.tsx +0 -113
  64. package/src/lib/positionManger/usePosition.ts +0 -8
  65. package/src/lib/store/context.ts +0 -5
  66. package/src/lib/store/default.ts +0 -157
  67. package/src/lib/store/provider.tsx +0 -211
  68. package/src/lib/store/types.ts +0 -33
  69. package/src/lib/styles/styles.ts +0 -256
  70. package/src/lib/types.ts +0 -423
  71. package/src/lib/views/Day.tsx +0 -265
  72. package/src/lib/views/DayAgenda.tsx +0 -57
  73. package/src/lib/views/Editor.tsx +0 -258
  74. package/src/lib/views/Month.tsx +0 -82
  75. package/src/lib/views/MonthAgenda.tsx +0 -84
  76. package/src/lib/views/Week.tsx +0 -92
  77. package/src/lib/views/WeekAgenda.tsx +0 -81
  78. package/src/vite-env.d.ts +0 -3
  79. package/tsconfig.build.json +0 -5
  80. package/tsconfig.json +0 -27
  81. package/vite.config.js +0 -40
  82. /package/{dist/SchedulerComponent.d.ts → SchedulerComponent.d.ts} +0 -0
  83. /package/{dist/components → components}/common/Cell.d.ts +0 -0
  84. /package/{dist/components → components}/common/LocaleArrow.d.ts +0 -0
  85. /package/{dist/components → components}/common/ResourceHeader.d.ts +0 -0
  86. /package/{dist/components → components}/common/Tabs.d.ts +0 -0
  87. /package/{dist/components → components}/common/TodayTypo.d.ts +0 -0
  88. /package/{dist/components → components}/common/WithResources.d.ts +0 -0
  89. /package/{dist/components → components}/events/Actions.d.ts +0 -0
  90. /package/{dist/components → components}/events/AgendaEventsList.d.ts +0 -0
  91. /package/{dist/components → components}/events/CurrentTimeBar.d.ts +0 -0
  92. /package/{dist/components → components}/events/EmptyAgenda.d.ts +0 -0
  93. /package/{dist/components → components}/events/EventItem.d.ts +0 -0
  94. /package/{dist/components → components}/events/EventItemPopover.d.ts +0 -0
  95. /package/{dist/components → components}/events/MonthEvents.d.ts +0 -0
  96. /package/{dist/components → components}/events/TodayEvents.d.ts +0 -0
  97. /package/{dist/components → components}/hoc/DateProvider.d.ts +0 -0
  98. /package/{dist/components → components}/inputs/DatePicker.d.ts +0 -0
  99. /package/{dist/components → components}/inputs/Input.d.ts +0 -0
  100. /package/{dist/components → components}/inputs/SelectInput.d.ts +0 -0
  101. /package/{dist/components → components}/month/MonthTable.d.ts +0 -0
  102. /package/{dist/components → components}/nav/DayDateBtn.d.ts +0 -0
  103. /package/{dist/components → components}/nav/MonthDateBtn.d.ts +0 -0
  104. /package/{dist/components → components}/nav/Navigation.d.ts +0 -0
  105. /package/{dist/components → components}/nav/WeekDateBtn.d.ts +0 -0
  106. /package/{dist/components → components}/week/WeekTable.d.ts +0 -0
  107. /package/{dist/helpers → helpers}/constants.d.ts +0 -0
  108. /package/{dist/helpers → helpers}/generals.d.ts +0 -0
  109. /package/{dist/hooks → hooks}/useArrowDisable.d.ts +0 -0
  110. /package/{dist/hooks → hooks}/useCellAttributes.d.ts +0 -0
  111. /package/{dist/hooks → hooks}/useDragAttributes.d.ts +0 -0
  112. /package/{dist/hooks → hooks}/useEventPermissions.d.ts +0 -0
  113. /package/{dist/hooks → hooks}/useStore.d.ts +0 -0
  114. /package/{dist/hooks → hooks}/useSyncScroll.d.ts +0 -0
  115. /package/{dist/hooks → hooks}/useWindowResize.d.ts +0 -0
  116. /package/{dist/index.d.ts → index.d.ts} +0 -0
  117. /package/{dist/positionManger → positionManger}/context.d.ts +0 -0
  118. /package/{dist/positionManger → positionManger}/provider.d.ts +0 -0
  119. /package/{dist/positionManger → positionManger}/usePosition.d.ts +0 -0
  120. /package/{dist/store → store}/context.d.ts +0 -0
  121. /package/{dist/store → store}/default.d.ts +0 -0
  122. /package/{dist/store → store}/provider.d.ts +0 -0
  123. /package/{dist/store → store}/types.d.ts +0 -0
  124. /package/{dist/styles → styles}/styles.d.ts +0 -0
  125. /package/{dist/types.d.ts → types.d.ts} +0 -0
  126. /package/{dist/views → views}/Day.d.ts +0 -0
  127. /package/{dist/views → views}/DayAgenda.d.ts +0 -0
  128. /package/{dist/views → views}/Editor.d.ts +0 -0
  129. /package/{dist/views → views}/Month.d.ts +0 -0
  130. /package/{dist/views → views}/MonthAgenda.d.ts +0 -0
  131. /package/{dist/views → views}/Week.d.ts +0 -0
  132. /package/{dist/views → views}/WeekAgenda.d.ts +0 -0
@@ -1,95 +0,0 @@
1
- import { useCallback, useEffect, useState } from "react";
2
- import DateProvider from "../hoc/DateProvider";
3
- import { DatePicker } from "@mui/x-date-pickers/DatePicker";
4
- import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
5
- import useStore from "../../hooks/useStore";
6
-
7
- interface EditorDatePickerProps {
8
- type?: "date" | "datetime";
9
- label?: string;
10
- variant?: "standard" | "filled" | "outlined";
11
- value: Date | string;
12
- name: string;
13
- onChange(name: string, date: Date): void;
14
- error?: boolean;
15
- errMsg?: string;
16
- touched?: boolean;
17
- required?: boolean;
18
- }
19
-
20
- const EditorDatePicker = ({
21
- type = "datetime",
22
- value,
23
- label,
24
- name,
25
- onChange,
26
- variant = "outlined",
27
- error,
28
- errMsg,
29
- touched,
30
- required,
31
- }: EditorDatePickerProps) => {
32
- const { translations } = useStore();
33
- const [state, setState] = useState({
34
- touched: false,
35
- valid: !!value,
36
- errorMsg: errMsg
37
- ? errMsg
38
- : required
39
- ? translations?.validation?.required || "Required"
40
- : undefined,
41
- });
42
-
43
- const Picker = type === "date" ? DatePicker : DateTimePicker;
44
-
45
- const hasError = state.touched && (error || !state.valid);
46
-
47
- const handleChange = useCallback(
48
- (value: string | Date) => {
49
- const isValidDate = !isNaN(Date.parse(value as string));
50
- const val = typeof value === "string" && isValidDate ? new Date(value) : value;
51
- let isValid = true;
52
- let errorMsg = errMsg;
53
- if (required && !val) {
54
- isValid = false;
55
- errorMsg = errMsg || translations?.validation?.required || "Required";
56
- }
57
-
58
- setState((prev) => {
59
- return { ...prev, touched: true, valid: isValid, errorMsg: errorMsg };
60
- });
61
-
62
- onChange(name, val as Date);
63
- },
64
- [errMsg, name, onChange, required, translations?.validation?.required]
65
- );
66
-
67
- useEffect(() => {
68
- if (touched) {
69
- handleChange(value);
70
- }
71
- }, [handleChange, touched, value]);
72
-
73
- return (
74
- <DateProvider>
75
- <Picker
76
- value={value instanceof Date ? value : new Date(value)}
77
- label={label}
78
- onChange={(e) => {
79
- handleChange(e as Date);
80
- }}
81
- minutesStep={5}
82
- slotProps={{
83
- textField: {
84
- variant,
85
- helperText: hasError && state.errorMsg,
86
- error: hasError,
87
- fullWidth: true,
88
- },
89
- }}
90
- />
91
- </DateProvider>
92
- );
93
- };
94
-
95
- export { EditorDatePicker };
@@ -1,113 +0,0 @@
1
- import { useState, useEffect, useCallback } from "react";
2
- import { TextField, Typography } from "@mui/material";
3
- import useStore from "../../hooks/useStore";
4
-
5
- interface EditorInputProps {
6
- variant?: "standard" | "filled" | "outlined";
7
- label?: string;
8
- placeholder?: string;
9
- required?: boolean;
10
- min?: number;
11
- max?: number;
12
- email?: boolean;
13
- decimal?: boolean;
14
- disabled?: boolean;
15
- multiline?: boolean;
16
- rows?: number;
17
- value: string;
18
- name: string;
19
- onChange(name: string, value: string, isValid: boolean): void;
20
- touched?: boolean;
21
- }
22
-
23
- const EditorInput = ({
24
- variant = "outlined",
25
- label,
26
- placeholder,
27
- value,
28
- name,
29
- required,
30
- min,
31
- max,
32
- email,
33
- decimal,
34
- onChange,
35
- disabled,
36
- multiline,
37
- rows,
38
- touched,
39
- }: EditorInputProps) => {
40
- const [state, setState] = useState({
41
- touched: false,
42
- valid: false,
43
- errorMsg: "",
44
- });
45
- const { translations } = useStore();
46
-
47
- const handleChange = useCallback(
48
- (value: string) => {
49
- const val = value;
50
- let isValid = true;
51
- let errorMsg = "";
52
- if (email) {
53
- const reg =
54
- /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
55
- isValid = reg.test(val) && isValid;
56
- errorMsg = translations?.validation?.invalidEmail || "Invalid Email";
57
- }
58
- if (decimal) {
59
- const reg = /^[0-9]+(\.[0-9]*)?$/;
60
- isValid = reg.test(val) && isValid;
61
- errorMsg = translations?.validation?.onlyNumbers || "Only Numbers Allowed";
62
- }
63
- if (min && `${val}`.trim().length < min) {
64
- isValid = false;
65
- errorMsg =
66
- typeof translations?.validation?.min === "function"
67
- ? translations?.validation?.min(min)
68
- : translations?.validation?.min || `Minimum ${min} letters`;
69
- }
70
- if (max && `${val}`.trim().length > max) {
71
- isValid = false;
72
- errorMsg =
73
- typeof translations?.validation?.max === "function"
74
- ? translations?.validation?.max(max)
75
- : translations?.validation?.max || `Maximum ${max} letters`;
76
- }
77
- if (required && `${val}`.trim().length <= 0) {
78
- isValid = false;
79
- errorMsg = translations?.validation?.required || "Required";
80
- }
81
- setState({ touched: true, valid: isValid, errorMsg: errorMsg });
82
- onChange(name, val, isValid);
83
- },
84
- [decimal, email, max, min, name, onChange, required, translations?.validation]
85
- );
86
-
87
- useEffect(() => {
88
- if (touched) {
89
- handleChange(value);
90
- }
91
- }, [handleChange, touched, value]);
92
-
93
- return (
94
- <TextField
95
- variant={variant}
96
- label={label && <Typography variant="body2">{`${label} ${required ? "*" : ""}`}</Typography>}
97
- value={value}
98
- name={name}
99
- onChange={(e) => handleChange(e.target.value)}
100
- disabled={disabled}
101
- error={state.touched && !state.valid}
102
- helperText={state.touched && !state.valid && state.errorMsg}
103
- multiline={multiline}
104
- rows={rows}
105
- style={{ width: "100%" }}
106
- InputProps={{
107
- placeholder: placeholder || "",
108
- }}
109
- />
110
- );
111
- };
112
-
113
- export { EditorInput };
@@ -1,164 +0,0 @@
1
- import { useState, useEffect, useCallback } from "react";
2
- import {
3
- FormControl,
4
- FormHelperText,
5
- MenuItem,
6
- Checkbox,
7
- useTheme,
8
- Chip,
9
- Typography,
10
- CircularProgress,
11
- InputLabel,
12
- Select,
13
- } from "@mui/material";
14
- import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
15
- import useStore from "../../hooks/useStore";
16
-
17
- export type SelectOption = {
18
- id: string | number;
19
- text: string;
20
- value: any;
21
- };
22
- interface EditorSelectProps {
23
- options: Array<SelectOption>;
24
- value: string;
25
- name: string;
26
- onChange(name: string, value: string, isValid: boolean): void;
27
- variant?: "standard" | "filled" | "outlined";
28
- label?: string;
29
- placeholder?: string;
30
- required?: boolean;
31
- disabled?: boolean;
32
- touched?: boolean;
33
- loading?: boolean;
34
- multiple?: "default" | "chips";
35
- errMsg?: string;
36
- }
37
-
38
- const EditorSelect = ({
39
- options,
40
- value,
41
- name,
42
- required,
43
- onChange,
44
- label,
45
- disabled,
46
- touched,
47
- variant = "outlined",
48
- loading,
49
- multiple,
50
- placeholder,
51
- errMsg,
52
- }: EditorSelectProps) => {
53
- const theme = useTheme();
54
- const { translations } = useStore();
55
- const [state, setState] = useState({
56
- touched: false,
57
- valid: !!value,
58
- errorMsg: errMsg
59
- ? errMsg
60
- : required
61
- ? translations?.validation?.required || "Required"
62
- : undefined,
63
- });
64
- const handleTouched = useCallback(() => {
65
- if (!state.touched) {
66
- setState((prev) => {
67
- return { ...prev, touched: true, errorMsg: errMsg || prev.errorMsg };
68
- });
69
- }
70
- }, [errMsg, state.touched]);
71
- const handleChange = useCallback(
72
- (value: string | any) => {
73
- const val = value;
74
- let isValid = true;
75
- let errorMsg = errMsg;
76
- if (required && (multiple ? !val.length : !val)) {
77
- isValid = false;
78
- errorMsg = errMsg || translations?.validation?.required || "Required";
79
- }
80
- setState((prev) => {
81
- return { ...prev, touched: true, valid: isValid, errorMsg: errorMsg };
82
- });
83
- onChange(name, val, isValid);
84
- },
85
- [errMsg, multiple, name, onChange, required, translations?.validation?.required]
86
- );
87
-
88
- useEffect(() => {
89
- if (touched) {
90
- handleChange(value);
91
- }
92
- }, [handleChange, touched, value]);
93
- return (
94
- <>
95
- <FormControl
96
- variant={variant || "outlined"}
97
- fullWidth
98
- error={required && state.touched && !state.valid}
99
- // style={{ minWidth: 230 }}
100
- disabled={disabled}
101
- >
102
- {label && (
103
- <InputLabel id={`input_${name}`}>
104
- <Typography variant="body2">{`${label} ${required ? "*" : ""}`}</Typography>
105
- </InputLabel>
106
- )}
107
- <Select
108
- label={label}
109
- labelId={`input_${name}`}
110
- value={value}
111
- onBlur={handleTouched}
112
- onChange={(e) => handleChange(e.target.value)}
113
- IconComponent={loading ? () => <CircularProgress size={5} /> : ExpandMoreIcon}
114
- multiple={!!multiple}
115
- classes={{
116
- select: multiple === "chips" ? "flex__wrap" : undefined,
117
- }}
118
- renderValue={(selected: string | Array<any> | any) => {
119
- if (!selected || selected.length === 0) {
120
- return <em>{label}</em>;
121
- }
122
- const text = [];
123
- if (multiple) {
124
- for (const opt of options) {
125
- if (selected.includes(opt.value)) {
126
- text.push([opt.text]);
127
- }
128
- }
129
- if (multiple === "chips") {
130
- return text.map((t, i) => (
131
- <Chip key={`${t}_${i}`} label={t} style={{ margin: "0 2px" }} color="primary" />
132
- ));
133
- } else {
134
- return text.join(",");
135
- }
136
- } else {
137
- for (const opt of options) {
138
- if (selected === opt.value) text.push([opt.text]);
139
- }
140
- return text.join(",");
141
- }
142
- }}
143
- >
144
- {placeholder && (
145
- <MenuItem value="">
146
- <em>{placeholder}</em>
147
- </MenuItem>
148
- )}
149
- {options.map((op) => (
150
- <MenuItem value={op.value} key={op.id || op.value}>
151
- {multiple && <Checkbox checked={value.indexOf(op.value) > -1} color="primary" />}
152
- {op.text}
153
- </MenuItem>
154
- ))}
155
- </Select>
156
- </FormControl>
157
- <FormHelperText style={{ color: theme.palette.error.main }}>
158
- {state.touched && !state.valid && state.errorMsg}
159
- </FormHelperText>
160
- </>
161
- );
162
- };
163
-
164
- export { EditorSelect };
@@ -1,207 +0,0 @@
1
- import { Avatar, Typography, useTheme } from "@mui/material";
2
- import {
3
- addDays,
4
- endOfDay,
5
- format,
6
- isSameDay,
7
- isSameMonth,
8
- isWithinInterval,
9
- setHours,
10
- startOfDay,
11
- startOfMonth,
12
- } from "date-fns";
13
- import { Fragment, useCallback } from "react";
14
- import {
15
- getHourFormat,
16
- getRecurrencesForDate,
17
- getResourcedEvents,
18
- isTimeZonedToday,
19
- sortEventsByTheEarliest,
20
- } from "../../helpers/generals";
21
- import useStore from "../../hooks/useStore";
22
- import useSyncScroll from "../../hooks/useSyncScroll";
23
- import { TableGrid } from "../../styles/styles";
24
- import { DefaultResource } from "../../types";
25
- import Cell from "../common/Cell";
26
- import MonthEvents from "../events/MonthEvents";
27
-
28
- type Props = {
29
- daysList: Date[];
30
- resource?: DefaultResource;
31
- eachWeekStart: Date[];
32
- };
33
-
34
- const MonthTable = ({ daysList, resource, eachWeekStart }: Props) => {
35
- const {
36
- height,
37
- month,
38
- selectedDate,
39
- events,
40
- handleGotoDay,
41
- resourceFields,
42
- fields,
43
- locale,
44
- hourFormat,
45
- stickyNavigation,
46
- timeZone,
47
- onClickMore,
48
- stickyNavigationOffset,
49
- stickyNavigationHeight,
50
- } = useStore();
51
- const { weekDays, startHour, endHour, cellRenderer, headRenderer, disableGoToDay } = month!;
52
- const { headersRef, bodyRef } = useSyncScroll();
53
-
54
- const theme = useTheme();
55
- const monthStart = startOfMonth(selectedDate);
56
- const hFormat = getHourFormat(hourFormat);
57
- const CELL_HEIGHT = height / eachWeekStart.length;
58
-
59
- const renderCells = useCallback(
60
- (resource?: DefaultResource) => {
61
- let resourcedEvents = sortEventsByTheEarliest(events);
62
- if (resource) {
63
- resourcedEvents = getResourcedEvents(events, resource, resourceFields, fields);
64
- }
65
- const rows: React.ReactNode[] = [];
66
-
67
- for (const startDay of eachWeekStart) {
68
- const cells = weekDays.map((d) => {
69
- const today = addDays(startDay, d);
70
- const start = new Date(`${format(setHours(today, startHour), `yyyy/MM/dd ${hFormat}`)}`);
71
- const end = new Date(`${format(setHours(today, endHour), `yyyy/MM/dd ${hFormat}`)}`);
72
- const field = resourceFields.idField;
73
- const eachFirstDayInCalcRow = isSameDay(startDay, today) ? today : null;
74
- const todayEvents = resourcedEvents
75
- .flatMap((e) => getRecurrencesForDate(e, today))
76
- .filter((e) => {
77
- if (isSameDay(e.start, today)) return true;
78
- const dayInterval = { start: startOfDay(e.start), end: endOfDay(e.end) };
79
- if (eachFirstDayInCalcRow && isWithinInterval(eachFirstDayInCalcRow, dayInterval))
80
- return true;
81
- return false;
82
- });
83
- const isToday = isTimeZonedToday({ dateLeft: today, timeZone });
84
- return (
85
- <span style={{ height: CELL_HEIGHT }} key={d.toString()} className="rs__cell">
86
- <Cell
87
- start={start}
88
- end={end}
89
- day={selectedDate}
90
- height={CELL_HEIGHT}
91
- resourceKey={field}
92
- resourceVal={resource ? resource[field] : null}
93
- cellRenderer={cellRenderer}
94
- />
95
- <Fragment>
96
- {typeof headRenderer === "function" ? (
97
- <div style={{ position: "absolute", top: 0 }}>
98
- {headRenderer({ day: today, events: resourcedEvents, resource })}
99
- </div>
100
- ) : (
101
- <Avatar
102
- style={{
103
- width: 27,
104
- height: 27,
105
- position: "absolute",
106
- top: 0,
107
- background: isToday ? theme.palette.secondary.main : "transparent",
108
- color: isToday ? theme.palette.secondary.contrastText : "",
109
- marginBottom: 2,
110
- }}
111
- >
112
- <Typography
113
- color={!isSameMonth(today, monthStart) ? "#ccc" : "textPrimary"}
114
- className={!disableGoToDay ? "rs__hover__op" : ""}
115
- onClick={(e) => {
116
- e.stopPropagation();
117
- if (!disableGoToDay) {
118
- handleGotoDay(today);
119
- }
120
- }}
121
- >
122
- {format(today, "dd")}
123
- </Typography>
124
- </Avatar>
125
- )}
126
-
127
- <MonthEvents
128
- events={todayEvents}
129
- resourceId={resource?.[field]}
130
- today={today}
131
- eachWeekStart={eachWeekStart}
132
- eachFirstDayInCalcRow={eachFirstDayInCalcRow}
133
- daysList={daysList}
134
- onViewMore={(e) => {
135
- if (onClickMore && typeof onClickMore === "function") {
136
- onClickMore(e, handleGotoDay);
137
- } else {
138
- handleGotoDay(e);
139
- }
140
- }}
141
- cellHeight={CELL_HEIGHT}
142
- />
143
- </Fragment>
144
- </span>
145
- );
146
- });
147
-
148
- rows.push(<Fragment key={startDay.toString()}>{cells}</Fragment>);
149
- }
150
- return rows;
151
- },
152
- [
153
- CELL_HEIGHT,
154
- cellRenderer,
155
- daysList,
156
- disableGoToDay,
157
- eachWeekStart,
158
- endHour,
159
- events,
160
- fields,
161
- hFormat,
162
- handleGotoDay,
163
- headRenderer,
164
- monthStart,
165
- onClickMore,
166
- resourceFields,
167
- selectedDate,
168
- startHour,
169
- theme.palette.secondary.contrastText,
170
- theme.palette.secondary.main,
171
- timeZone,
172
- weekDays,
173
- ]
174
- );
175
-
176
- return (
177
- <>
178
- {/* Header Days */}
179
- <TableGrid
180
- days={daysList.length}
181
- ref={headersRef}
182
- indent="0"
183
- sticky="1"
184
- stickyNavigation={stickyNavigation}
185
- stickyOffset={stickyNavigationOffset}
186
- stickyHeight={stickyNavigationHeight}
187
- >
188
- {daysList.map((date, i) => (
189
- <Typography
190
- key={i}
191
- className="rs__cell rs__header rs__header__center"
192
- align="center"
193
- variant="body2"
194
- >
195
- {format(date, "EE", { locale })}
196
- </Typography>
197
- ))}
198
- </TableGrid>
199
- {/* Time Cells */}
200
- <TableGrid days={daysList.length} ref={bodyRef} indent="0">
201
- {renderCells(resource)}
202
- </TableGrid>
203
- </>
204
- );
205
- };
206
-
207
- export default MonthTable;
@@ -1,77 +0,0 @@
1
- import { useState } from "react";
2
- import DateProvider from "../hoc/DateProvider";
3
- import { DateCalendar } from "@mui/x-date-pickers";
4
- import { Button, Popover } from "@mui/material";
5
- import { format, addDays } from "date-fns";
6
- import { LocaleArrow } from "../common/LocaleArrow";
7
- import useStore from "../../hooks/useStore";
8
- import useArrowDisable from "../../hooks/useArrowDisable";
9
-
10
- interface DayDateBtnProps {
11
- selectedDate: Date;
12
- onChange(value: Date): void;
13
- }
14
-
15
- const DayDateBtn = ({ selectedDate, onChange }: DayDateBtnProps) => {
16
- const { locale, navigationPickerProps } = useStore();
17
- const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
18
- const { prevDisabled, nextDisabled } = useArrowDisable();
19
-
20
- const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
21
- setAnchorEl(event.currentTarget);
22
- };
23
- const handleClose = () => {
24
- setAnchorEl(null);
25
- };
26
-
27
- const handleChange = (e: Date | null) => {
28
- onChange(e || new Date());
29
- handleClose();
30
- };
31
-
32
- const handlePrev = () => {
33
- const prevDay = addDays(selectedDate, -1);
34
- onChange(prevDay);
35
- };
36
-
37
- const handleNext = () => {
38
- const nexDay = addDays(selectedDate, 1);
39
- onChange(nexDay);
40
- };
41
-
42
- return (
43
- <>
44
- <LocaleArrow
45
- type="prev"
46
- onClick={handlePrev}
47
- disabled={prevDisabled}
48
- aria-label="previous day"
49
- />
50
- <Button style={{ padding: 4 }} onClick={handleOpen} aria-label="selected date">
51
- {format(selectedDate, "dd MMMM yyyy", { locale })}
52
- </Button>
53
- <Popover
54
- open={Boolean(anchorEl)}
55
- anchorEl={anchorEl}
56
- onClose={handleClose}
57
- anchorOrigin={{
58
- vertical: "bottom",
59
- horizontal: "left",
60
- }}
61
- >
62
- <DateProvider>
63
- <DateCalendar
64
- {...navigationPickerProps}
65
- openTo="day"
66
- views={["month", "day"]}
67
- value={selectedDate}
68
- onChange={handleChange}
69
- />
70
- </DateProvider>
71
- </Popover>
72
- <LocaleArrow type="next" onClick={handleNext} disabled={nextDisabled} aria-label="next day" />
73
- </>
74
- );
75
- };
76
-
77
- export { DayDateBtn };