@schedule-x/react 1.4.0 → 1.6.0
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/CHANGELOG.md +19 -10
- package/development/next-app/app/page.tsx +17 -2
- package/development/next-app/package-lock.json +6 -6
- package/dist/index.cjs.js +12 -0
- package/dist/index.js +12 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/schedule-x-calendar.d.ts +1 -1
- package/dist/types/use-calendar-app.d.ts +3 -2
- package/package.json +2 -2
- package/src/index.tsx +1 -1
- package/src/schedule-x-calendar.tsx +3 -1
- package/src/use-calendar-app.tsx +18 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,40 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
# [1.
|
|
5
|
+
# [1.6.0](https://github.com/schedule-x/react/compare/v1.5.0...v1.6.0) (2024-01-17)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
### Features
|
|
9
9
|
|
|
10
|
-
* update schedule-x monorepo packages to v1.
|
|
10
|
+
* update schedule-x monorepo packages to v1.9.0 ([#34](https://github.com/schedule-x/react/issues/34)) ([7dccabb](https://github.com/schedule-x/react/commit/7dccabb57e7ca8d6c2bd4e71dd496fa85ef89306))
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
# [1.5.0](https://github.com/schedule-x/react/compare/v1.4.0...v1.5.0) (2024-01-15)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add useNextCalendarApp hook ([#32](https://github.com/schedule-x/react/issues/32)) ([2d3c561](https://github.com/schedule-x/react/commit/2d3c561c479eeea38011588842484e140416644c))
|
|
13
18
|
|
|
19
|
+
# [1.4.0](https://github.com/schedule-x/react/compare/v1.3.2...v1.4.0) (2024-01-13)
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
- update schedule-x monorepo packages to v1.6.0 ([#29](https://github.com/schedule-x/react/issues/29)) ([02fb337](https://github.com/schedule-x/react/commit/02fb3378b9957abcd50f0f5e066bc2744620c53f))
|
|
24
|
+
|
|
25
|
+
## [1.3.2](https://github.com/schedule-x/react/compare/v1.3.1...v1.3.2) (2024-01-11)
|
|
14
26
|
|
|
15
27
|
### Bug Fixes
|
|
16
28
|
|
|
17
|
-
|
|
29
|
+
- **deps:** update schedule-x monorepo packages to v1.5.1 ([#27](https://github.com/schedule-x/react/issues/27)) ([437ec00](https://github.com/schedule-x/react/commit/437ec004959beb80cf482b60a5824bdc53258f69))
|
|
18
30
|
|
|
19
31
|
## [1.3.1](https://github.com/schedule-x/react/compare/v1.3.0...v1.3.1) (2024-01-08)
|
|
20
32
|
|
|
21
|
-
|
|
22
33
|
### Bug Fixes
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
- **deps:** update schedule-x monorepo packages to v1.4.1 ([#25](https://github.com/schedule-x/react/issues/25)) ([f123728](https://github.com/schedule-x/react/commit/f1237289df77e0cbe2e632a9f9580275cca136f7))
|
|
25
36
|
|
|
26
37
|
# [1.3.0](https://github.com/schedule-x/react/compare/v1.2.1...v1.3.0) (2024-01-05)
|
|
27
38
|
|
|
28
|
-
|
|
29
39
|
### Features
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
- **deps:** update schedule-x monorepo packages to v1.4.0 ([#18](https://github.com/schedule-x/react/issues/18)) ([6ac8ac4](https://github.com/schedule-x/react/commit/6ac8ac4db022e7e792a512e5db0f2f06d8373871))
|
|
32
42
|
|
|
33
43
|
## [1.2.1](https://github.com/schedule-x/react/compare/v1.2.0...v1.2.1) (2024-01-04)
|
|
34
44
|
|
|
35
|
-
|
|
36
45
|
### Bug Fixes
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
- usage in nextjs ([#22](https://github.com/schedule-x/react/issues/22)) ([70f81df](https://github.com/schedule-x/react/commit/70f81dff94c7c3334cf69ed5935aa4b0fdf6966d))
|
|
39
48
|
|
|
40
49
|
# [1.2.0](https://github.com/schedule-x/react/compare/v1.1.1...v1.2.0) (2024-01-04)
|
|
41
50
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import styles from './page.module.css'
|
|
3
3
|
// import { Calendar, useCalendarApp } from '../../../..'
|
|
4
|
-
import {
|
|
4
|
+
import { useNextCalendarApp, ScheduleXCalendar } from '../../..'
|
|
5
5
|
import {
|
|
6
6
|
viewDay,
|
|
7
7
|
viewMonthAgenda,
|
|
@@ -12,7 +12,7 @@ import '@schedule-x/theme-default/dist/index.css'
|
|
|
12
12
|
import { createDragAndDropPlugin } from '@schedule-x/drag-and-drop'
|
|
13
13
|
|
|
14
14
|
export default function Home() {
|
|
15
|
-
const calendarApp =
|
|
15
|
+
const calendarApp = useNextCalendarApp({
|
|
16
16
|
views: [viewWeek, viewMonthGrid, viewDay, viewMonthAgenda],
|
|
17
17
|
defaultView: viewWeek.name,
|
|
18
18
|
events: [
|
|
@@ -25,6 +25,21 @@ export default function Home() {
|
|
|
25
25
|
],
|
|
26
26
|
selectedDate: '2023-12-15',
|
|
27
27
|
plugins: [createDragAndDropPlugin()],
|
|
28
|
+
calendars: {
|
|
29
|
+
school: {
|
|
30
|
+
colorName: 'school',
|
|
31
|
+
lightColors: {
|
|
32
|
+
main: '#1c7df9',
|
|
33
|
+
container: '#d2e7ff',
|
|
34
|
+
onContainer: '#002859',
|
|
35
|
+
},
|
|
36
|
+
darkColors: {
|
|
37
|
+
main: '#c0dfff',
|
|
38
|
+
onContainer: '#dee6ff',
|
|
39
|
+
container: '#426aa2',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
28
43
|
})
|
|
29
44
|
|
|
30
45
|
return (
|
|
@@ -168,9 +168,9 @@
|
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
170
|
"node_modules/@types/node": {
|
|
171
|
-
"version": "20.11.
|
|
172
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.
|
|
173
|
-
"integrity": "sha512-
|
|
171
|
+
"version": "20.11.3",
|
|
172
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.3.tgz",
|
|
173
|
+
"integrity": "sha512-nrlmbvGPNGaj84IJZXMPhQuCMEVTT/hXZMJJG/aIqVL9fKxqk814sGGtJA4GI6hpJSLQjpi6cn0Qx9eOf9SDVg==",
|
|
174
174
|
"dev": true,
|
|
175
175
|
"dependencies": {
|
|
176
176
|
"undici-types": "~5.26.4"
|
|
@@ -183,9 +183,9 @@
|
|
|
183
183
|
"dev": true
|
|
184
184
|
},
|
|
185
185
|
"node_modules/@types/react": {
|
|
186
|
-
"version": "18.2.
|
|
187
|
-
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.
|
|
188
|
-
"integrity": "sha512-
|
|
186
|
+
"version": "18.2.48",
|
|
187
|
+
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.48.tgz",
|
|
188
|
+
"integrity": "sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w==",
|
|
189
189
|
"dev": true,
|
|
190
190
|
"dependencies": {
|
|
191
191
|
"@types/prop-types": "*",
|
package/dist/index.cjs.js
CHANGED
|
@@ -29,6 +29,8 @@ function ScheduleXCalendar({ calendarApp, customComponents }) {
|
|
|
29
29
|
setRandomId('sx' + Math.random().toString(36).substring(2, 11));
|
|
30
30
|
}, []);
|
|
31
31
|
react.useEffect(() => {
|
|
32
|
+
if (!calendarApp)
|
|
33
|
+
return; // in SSR, calendarApp will be undefined
|
|
32
34
|
for (const [componentName, Component] of Object.entries(customComponents || {})) {
|
|
33
35
|
calendarApp._setCustomComponentFn(componentName, createCustomComponentFn(setComponent, Component));
|
|
34
36
|
}
|
|
@@ -46,7 +48,17 @@ function useCalendarApp(config) {
|
|
|
46
48
|
const [calendarApp] = react.useState(calendar.createCalendar(config));
|
|
47
49
|
return calendarApp;
|
|
48
50
|
}
|
|
51
|
+
function useNextCalendarApp(config) {
|
|
52
|
+
const [calendarApp, setCalendarApp] = react.useState();
|
|
53
|
+
react.useEffect(() => {
|
|
54
|
+
if (typeof window !== 'undefined') {
|
|
55
|
+
setCalendarApp(calendar.createCalendar(config));
|
|
56
|
+
}
|
|
57
|
+
}, []);
|
|
58
|
+
return calendarApp;
|
|
59
|
+
}
|
|
49
60
|
|
|
50
61
|
exports.Calendar = ScheduleXCalendar;
|
|
51
62
|
exports.ScheduleXCalendar = ScheduleXCalendar;
|
|
52
63
|
exports.useCalendarApp = useCalendarApp;
|
|
64
|
+
exports.useNextCalendarApp = useNextCalendarApp;
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@ function ScheduleXCalendar({ calendarApp, customComponents }) {
|
|
|
27
27
|
setRandomId('sx' + Math.random().toString(36).substring(2, 11));
|
|
28
28
|
}, []);
|
|
29
29
|
useEffect(() => {
|
|
30
|
+
if (!calendarApp)
|
|
31
|
+
return; // in SSR, calendarApp will be undefined
|
|
30
32
|
for (const [componentName, Component] of Object.entries(customComponents || {})) {
|
|
31
33
|
calendarApp._setCustomComponentFn(componentName, createCustomComponentFn(setComponent, Component));
|
|
32
34
|
}
|
|
@@ -44,5 +46,14 @@ function useCalendarApp(config) {
|
|
|
44
46
|
const [calendarApp] = useState(createCalendar(config));
|
|
45
47
|
return calendarApp;
|
|
46
48
|
}
|
|
49
|
+
function useNextCalendarApp(config) {
|
|
50
|
+
const [calendarApp, setCalendarApp] = useState();
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (typeof window !== 'undefined') {
|
|
53
|
+
setCalendarApp(createCalendar(config));
|
|
54
|
+
}
|
|
55
|
+
}, []);
|
|
56
|
+
return calendarApp;
|
|
57
|
+
}
|
|
47
58
|
|
|
48
|
-
export { ScheduleXCalendar as Calendar, ScheduleXCalendar, useCalendarApp };
|
|
59
|
+
export { ScheduleXCalendar as Calendar, ScheduleXCalendar, useCalendarApp, useNextCalendarApp };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ScheduleXCalendar as Calendar } from './schedule-x-calendar.tsx';
|
|
2
2
|
export { ScheduleXCalendar } from './schedule-x-calendar.tsx';
|
|
3
|
-
export { useCalendarApp } from './use-calendar-app.tsx';
|
|
3
|
+
export { useCalendarApp, useNextCalendarApp } from './use-calendar-app.tsx';
|
|
@@ -2,7 +2,7 @@ import { CalendarApp } from '@schedule-x/calendar';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type ReactComponent = React.ComponentType<any>;
|
|
4
4
|
type props = {
|
|
5
|
-
calendarApp: CalendarApp;
|
|
5
|
+
calendarApp: CalendarApp | undefined;
|
|
6
6
|
customComponents?: {
|
|
7
7
|
timeGridEvent?: ReactComponent;
|
|
8
8
|
dateGridEvent?: ReactComponent;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { CalendarConfig } from '@schedule-x/calendar';
|
|
2
|
-
export declare function useCalendarApp(config: CalendarConfig):
|
|
1
|
+
import { CalendarApp, CalendarConfig } from '@schedule-x/calendar';
|
|
2
|
+
export declare function useCalendarApp(config: CalendarConfig): CalendarApp;
|
|
3
|
+
export declare function useNextCalendarApp(config: CalendarConfig): CalendarApp | undefined;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"main": "dist/index.cjs.js",
|
|
15
15
|
"module": "dist/index.js",
|
|
16
16
|
"types": "dist/types/index.d.ts",
|
|
17
|
-
"version": "1.
|
|
17
|
+
"version": "1.6.0",
|
|
18
18
|
"type": "module",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"dev": "vite",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build:publish": "npm run build && npm publish"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@schedule-x/calendar": "1.
|
|
29
|
+
"@schedule-x/calendar": "1.9.0",
|
|
30
30
|
"react": "^16.7.0 || ^17 || ^18",
|
|
31
31
|
"react-dom": "^16.7.0 || ^17 || ^18"
|
|
32
32
|
},
|
package/src/index.tsx
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
export { ScheduleXCalendar as Calendar } from './schedule-x-calendar.tsx'
|
|
3
3
|
|
|
4
4
|
export { ScheduleXCalendar } from './schedule-x-calendar.tsx'
|
|
5
|
-
export { useCalendarApp } from './use-calendar-app.tsx'
|
|
5
|
+
export { useCalendarApp, useNextCalendarApp } from './use-calendar-app.tsx'
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type ReactComponent = React.ComponentType<any>
|
|
11
11
|
|
|
12
12
|
type props = {
|
|
13
|
-
calendarApp: CalendarApp
|
|
13
|
+
calendarApp: CalendarApp | undefined // undefined allowed to prevent errors in SSR
|
|
14
14
|
customComponents?: {
|
|
15
15
|
timeGridEvent?: ReactComponent
|
|
16
16
|
dateGridEvent?: ReactComponent
|
|
@@ -57,6 +57,8 @@ export function ScheduleXCalendar({ calendarApp, customComponents }: props) {
|
|
|
57
57
|
}, [])
|
|
58
58
|
|
|
59
59
|
useEffect(() => {
|
|
60
|
+
if (!calendarApp) return // in SSR, calendarApp will be undefined
|
|
61
|
+
|
|
60
62
|
for (const [componentName, Component] of Object.entries(
|
|
61
63
|
customComponents || {}
|
|
62
64
|
)) {
|
package/src/use-calendar-app.tsx
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
CalendarApp,
|
|
3
|
+
CalendarConfig,
|
|
4
|
+
createCalendar,
|
|
5
|
+
} from '@schedule-x/calendar'
|
|
6
|
+
import { useEffect, useState } from 'react'
|
|
3
7
|
|
|
4
8
|
export function useCalendarApp(config: CalendarConfig) {
|
|
5
9
|
const [calendarApp] = useState(createCalendar(config))
|
|
6
10
|
return calendarApp
|
|
7
11
|
}
|
|
12
|
+
|
|
13
|
+
export function useNextCalendarApp(config: CalendarConfig) {
|
|
14
|
+
const [calendarApp, setCalendarApp] = useState<CalendarApp>()
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (typeof window !== 'undefined') {
|
|
18
|
+
setCalendarApp(createCalendar(config))
|
|
19
|
+
}
|
|
20
|
+
}, [])
|
|
21
|
+
|
|
22
|
+
return calendarApp
|
|
23
|
+
}
|