@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,84 +0,0 @@
1
- import { useMemo } from "react";
2
- import { format, isSameMonth, getDaysInMonth, isToday } from "date-fns";
3
- import { AgendaDiv } from "../styles/styles";
4
- import { DefaultResource, ProcessedEvent } from "../types";
5
- import useStore from "../hooks/useStore";
6
- import { Typography } from "@mui/material";
7
- import { filterTodayAgendaEvents, isTimeZonedToday } from "../helpers/generals";
8
- import AgendaEventsList from "../components/events/AgendaEventsList";
9
- import EmptyAgenda from "../components/events/EmptyAgenda";
10
-
11
- type Props = {
12
- events: ProcessedEvent[];
13
- resource?: DefaultResource;
14
- };
15
- const MonthAgenda = ({ events, resource }: Props) => {
16
- const {
17
- month,
18
- handleGotoDay,
19
- locale,
20
- timeZone,
21
- selectedDate,
22
- translations,
23
- alwaysShowAgendaDays,
24
- stickyNavigationOffset,
25
- stickyNavigationHeight,
26
- } = useStore();
27
- const { disableGoToDay, headRenderer } = month!;
28
- const daysOfMonth = getDaysInMonth(selectedDate);
29
- const daysList = Array.from({ length: daysOfMonth }, (_, i) => i + 1);
30
-
31
- const monthEvents = useMemo(() => {
32
- return events.filter((event) => isSameMonth(event.start, selectedDate));
33
- }, [events, selectedDate]);
34
-
35
- if (!alwaysShowAgendaDays && !monthEvents.length) {
36
- return <EmptyAgenda />;
37
- }
38
-
39
- return (
40
- <AgendaDiv stickyOffset={stickyNavigationOffset} stickyHeight={stickyNavigationHeight}>
41
- {daysList.map((i) => {
42
- const day = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
43
- const today = isTimeZonedToday({ dateLeft: day, timeZone });
44
- const dayEvents = filterTodayAgendaEvents(events, day);
45
-
46
- if (!alwaysShowAgendaDays && !dayEvents.length) return null;
47
-
48
- return (
49
- <div key={i} className={`rs__agenda_row ${isToday(day) ? "rs__today_cell" : ""}`}>
50
- <div className="rs__cell rs__agenda__cell">
51
- {typeof headRenderer === "function" ? (
52
- <div>{headRenderer({ day, events, resource })}</div>
53
- ) : (
54
- <Typography
55
- sx={{ fontWeight: today ? "bold" : "inherit" }}
56
- color={today ? "primary" : "inherit"}
57
- variant="body2"
58
- className={!disableGoToDay ? "rs__hover__op" : ""}
59
- onClick={(e) => {
60
- e.stopPropagation();
61
- if (!disableGoToDay) {
62
- handleGotoDay(day);
63
- }
64
- }}
65
- >
66
- {format(day, "dd E", { locale })}
67
- </Typography>
68
- )}
69
- </div>
70
- <div className="rs__cell rs__agenda_items">
71
- {dayEvents.length > 0 ? (
72
- <AgendaEventsList day={day} events={dayEvents} />
73
- ) : (
74
- <Typography sx={{ padding: 1 }}>{translations.noDataToDisplay}</Typography>
75
- )}
76
- </div>
77
- </div>
78
- );
79
- })}
80
- </AgendaDiv>
81
- );
82
- };
83
-
84
- export { MonthAgenda };
@@ -1,92 +0,0 @@
1
- import { useEffect, useCallback } from "react";
2
- import { startOfWeek, addDays, eachMinuteOfInterval, endOfDay, startOfDay, set } from "date-fns";
3
- import { DefaultResource } from "../types";
4
- import { calcCellHeight, calcMinuteHeight, getResourcedEvents } from "../helpers/generals";
5
- import { WithResources } from "../components/common/WithResources";
6
- import useStore from "../hooks/useStore";
7
- import { WeekAgenda } from "./WeekAgenda";
8
- import WeekTable from "../components/week/WeekTable";
9
-
10
- const Week = () => {
11
- const {
12
- week,
13
- selectedDate,
14
- height,
15
- events,
16
- getRemoteEvents,
17
- triggerLoading,
18
- handleState,
19
- resources,
20
- resourceFields,
21
- fields,
22
- agenda,
23
- } = useStore();
24
- const { weekStartOn, weekDays, startHour, endHour, step } = week!;
25
- const _weekStart = startOfWeek(selectedDate, { weekStartsOn: weekStartOn });
26
- const daysList = weekDays.map((d) => addDays(_weekStart, d));
27
- const weekStart = startOfDay(daysList[0]);
28
- const weekEnd = endOfDay(daysList[daysList.length - 1]);
29
- const START_TIME = set(selectedDate, { hours: startHour, minutes: 0, seconds: 0 });
30
- const END_TIME = set(selectedDate, { hours: endHour, minutes: -step, seconds: 0 });
31
- const hours = eachMinuteOfInterval(
32
- {
33
- start: START_TIME,
34
- end: END_TIME,
35
- },
36
- { step }
37
- );
38
- const CELL_HEIGHT = calcCellHeight(height, hours.length);
39
- const MINUTE_HEIGHT = calcMinuteHeight(CELL_HEIGHT, step);
40
-
41
- const fetchEvents = useCallback(async () => {
42
- try {
43
- triggerLoading(true);
44
-
45
- const events = await getRemoteEvents!({
46
- start: weekStart,
47
- end: weekEnd,
48
- view: "week",
49
- });
50
- if (Array.isArray(events)) {
51
- handleState(events, "events");
52
- }
53
- } catch (error) {
54
- throw error;
55
- } finally {
56
- triggerLoading(false);
57
- }
58
- // eslint-disable-next-line react-hooks/exhaustive-deps
59
- }, [getRemoteEvents]);
60
-
61
- useEffect(() => {
62
- if (getRemoteEvents instanceof Function) {
63
- fetchEvents();
64
- }
65
- }, [fetchEvents, getRemoteEvents]);
66
-
67
- const renderTable = (resource?: DefaultResource) => {
68
- let resourcedEvents = events;
69
- if (resource) {
70
- resourcedEvents = getResourcedEvents(events, resource, resourceFields, fields);
71
- }
72
-
73
- if (agenda) {
74
- return <WeekAgenda daysList={daysList} resource={resource} events={resourcedEvents} />;
75
- }
76
-
77
- return (
78
- <WeekTable
79
- resourcedEvents={resourcedEvents}
80
- resource={resource}
81
- hours={hours}
82
- cellHeight={CELL_HEIGHT}
83
- minutesHeight={MINUTE_HEIGHT}
84
- daysList={daysList}
85
- />
86
- );
87
- };
88
-
89
- return resources.length ? <WithResources renderChildren={renderTable} /> : renderTable();
90
- };
91
-
92
- export { Week };
@@ -1,81 +0,0 @@
1
- import { useMemo } from "react";
2
- import { format, isToday } from "date-fns";
3
- import { AgendaDiv } from "../styles/styles";
4
- import { DefaultResource, ProcessedEvent } from "../types";
5
- import useStore from "../hooks/useStore";
6
- import { Typography } from "@mui/material";
7
- import { filterTodayAgendaEvents, isTimeZonedToday } from "../helpers/generals";
8
- import AgendaEventsList from "../components/events/AgendaEventsList";
9
- import EmptyAgenda from "../components/events/EmptyAgenda";
10
-
11
- type Props = {
12
- daysList: Date[];
13
- resource?: DefaultResource;
14
- events: ProcessedEvent[];
15
- };
16
- const WeekAgenda = ({ daysList, resource, events }: Props) => {
17
- const {
18
- week,
19
- handleGotoDay,
20
- locale,
21
- timeZone,
22
- translations,
23
- alwaysShowAgendaDays,
24
- stickyNavigationOffset,
25
- stickyNavigationHeight,
26
- } = useStore();
27
- const { disableGoToDay, headRenderer } = week!;
28
-
29
- const hasEvents = useMemo(() => {
30
- return daysList.some((day) => filterTodayAgendaEvents(events, day).length > 0);
31
- }, [daysList, events]);
32
-
33
- if (!alwaysShowAgendaDays && !hasEvents) {
34
- return <EmptyAgenda />;
35
- }
36
-
37
- return (
38
- <AgendaDiv stickyOffset={stickyNavigationOffset} stickyHeight={stickyNavigationHeight}>
39
- {daysList.map((day, i) => {
40
- const today = isTimeZonedToday({ dateLeft: day, timeZone });
41
- const dayEvents = filterTodayAgendaEvents(events, day);
42
-
43
- if (!alwaysShowAgendaDays && !dayEvents.length) return null;
44
-
45
- return (
46
- <div key={i} className={`rs__agenda_row ${isToday(day) ? "rs__today_cell" : ""}`}>
47
- <div className="rs__cell rs__agenda__cell">
48
- {typeof headRenderer === "function" ? (
49
- <div>{headRenderer({ day, events, resource })}</div>
50
- ) : (
51
- <Typography
52
- sx={{ fontWeight: today ? "bold" : "inherit" }}
53
- color={today ? "primary" : "inherit"}
54
- variant="body2"
55
- className={!disableGoToDay ? "rs__hover__op" : ""}
56
- onClick={(e) => {
57
- e.stopPropagation();
58
- if (!disableGoToDay) {
59
- handleGotoDay(day);
60
- }
61
- }}
62
- >
63
- {format(day, "dd E", { locale })}
64
- </Typography>
65
- )}
66
- </div>
67
- <div className="rs__cell rs__agenda_items">
68
- {dayEvents.length > 0 ? (
69
- <AgendaEventsList day={day} events={dayEvents} />
70
- ) : (
71
- <Typography sx={{ padding: 1 }}>{translations.noDataToDisplay}</Typography>
72
- )}
73
- </div>
74
- </div>
75
- );
76
- })}
77
- </AgendaDiv>
78
- );
79
- };
80
-
81
- export { WeekAgenda };
package/src/vite-env.d.ts DELETED
@@ -1,3 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- /// <reference types="vite-plugin-svgr/client" />
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["src/lib/**/*"],
4
- "exclude": ["node_modules", "**/__tests__/**"]
5
- }
package/tsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "incremental": true,
5
- "target": "ES2022",
6
- "useDefineForClassFields": true,
7
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
8
- "module": "ESNext",
9
- "skipLibCheck": true,
10
- "esModuleInterop": true,
11
-
12
- /* Bundler mode */
13
- "moduleResolution": "bundler",
14
- "allowImportingTsExtensions": true,
15
- "isolatedModules": true,
16
- "moduleDetection": "force",
17
- "noEmit": true,
18
- "jsx": "react-jsx",
19
-
20
- /* Linting */
21
- "strict": true,
22
- "noUnusedLocals": true,
23
- "noUnusedParameters": true,
24
- "noFallthroughCasesInSwitch": true
25
- },
26
- "include": ["src"]
27
- }
package/vite.config.js DELETED
@@ -1,40 +0,0 @@
1
- import { dirname, resolve } from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { defineConfig } from "vite";
4
- import react from "@vitejs/plugin-react";
5
- import dts from "vite-plugin-dts";
6
- import tsconfigPaths from "vite-tsconfig-paths";
7
- import peerDepsExternal from "rollup-plugin-peer-deps-external";
8
-
9
- const __dirname = dirname(fileURLToPath(import.meta.url));
10
-
11
- export default defineConfig(() => ({
12
- plugins: [
13
- react(),
14
- tsconfigPaths({
15
- configNames: ["tsconfig.json"],
16
- }),
17
- dts({ tsconfigPath: "./tsconfig.build.json" }),
18
- peerDepsExternal(),
19
- ],
20
- server: {
21
- port: 3000,
22
- host: true,
23
- },
24
- preview: {
25
- port: 3000,
26
- },
27
- build: {
28
- lib: {
29
- entry: {
30
- index: resolve(__dirname, "src/lib/index.tsx"),
31
- },
32
- name: "Scheduler",
33
- formats: ["es"],
34
- },
35
- copyPublicDir: false,
36
- },
37
- resolve: {
38
- extensions: [".js", ".ts", ".tsx", ".jsx"],
39
- },
40
- }));
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes