@schedule-x/react 1.3.2 → 1.5.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 CHANGED
@@ -2,33 +2,42 @@
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.3.2](https://github.com/schedule-x/react/compare/v1.3.1...v1.3.2) (2024-01-11)
5
+ # [1.5.0](https://github.com/schedule-x/react/compare/v1.4.0...v1.5.0) (2024-01-15)
6
+
7
+
8
+ ### Features
6
9
 
10
+ * add useNextCalendarApp hook ([#32](https://github.com/schedule-x/react/issues/32)) ([2d3c561](https://github.com/schedule-x/react/commit/2d3c561c479eeea38011588842484e140416644c))
11
+
12
+ # [1.4.0](https://github.com/schedule-x/react/compare/v1.3.2...v1.4.0) (2024-01-13)
13
+
14
+ ### Features
15
+
16
+ - 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))
17
+
18
+ ## [1.3.2](https://github.com/schedule-x/react/compare/v1.3.1...v1.3.2) (2024-01-11)
7
19
 
8
20
  ### Bug Fixes
9
21
 
10
- * **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))
22
+ - **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))
11
23
 
12
24
  ## [1.3.1](https://github.com/schedule-x/react/compare/v1.3.0...v1.3.1) (2024-01-08)
13
25
 
14
-
15
26
  ### Bug Fixes
16
27
 
17
- * **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))
28
+ - **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))
18
29
 
19
30
  # [1.3.0](https://github.com/schedule-x/react/compare/v1.2.1...v1.3.0) (2024-01-05)
20
31
 
21
-
22
32
  ### Features
23
33
 
24
- * **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))
34
+ - **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))
25
35
 
26
36
  ## [1.2.1](https://github.com/schedule-x/react/compare/v1.2.0...v1.2.1) (2024-01-04)
27
37
 
28
-
29
38
  ### Bug Fixes
30
39
 
31
- * usage in nextjs ([#22](https://github.com/schedule-x/react/issues/22)) ([70f81df](https://github.com/schedule-x/react/commit/70f81dff94c7c3334cf69ed5935aa4b0fdf6966d))
40
+ - usage in nextjs ([#22](https://github.com/schedule-x/react/issues/22)) ([70f81df](https://github.com/schedule-x/react/commit/70f81dff94c7c3334cf69ed5935aa4b0fdf6966d))
32
41
 
33
42
  # [1.2.0](https://github.com/schedule-x/react/compare/v1.1.1...v1.2.0) (2024-01-04)
34
43
 
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import styles from './page.module.css'
3
3
  // import { Calendar, useCalendarApp } from '../../../..'
4
- import { useCalendarApp, ScheduleXCalendar } from '../../..'
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 = useCalendarApp({
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.10.7",
172
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz",
173
- "integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==",
171
+ "version": "20.11.0",
172
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.0.tgz",
173
+ "integrity": "sha512-o9bjXmDNcF7GbM4CNQpmi+TutCgap/K3w1JyKgxAjqx41zp9qlIAVFi0IhCNsJcXolEqLWhbFbEeL0PvYm4pcQ==",
174
174
  "dev": true,
175
175
  "dependencies": {
176
176
  "undici-types": "~5.26.4"
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 };
@@ -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): import("@schedule-x/calendar").CalendarApp;
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.3.2",
17
+ "version": "1.5.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.5.1",
29
+ "@schedule-x/calendar": "1.6.0",
30
30
  "react": "^16.7.0 || ^17 || ^18",
31
31
  "react-dom": "^16.7.0 || ^17 || ^18"
32
32
  },
@@ -57,7 +57,7 @@
57
57
  "rollup": "^4.9.0",
58
58
  "rollup-plugin-peer-deps-external": "^2.2.4",
59
59
  "rollup-plugin-postcss": "^4.0.2",
60
- "semantic-release": "^22.0.12",
60
+ "semantic-release": "^23.0.0",
61
61
  "typescript": "^5.2.2",
62
62
  "vite": "^5.0.8"
63
63
  },
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
  )) {
@@ -1,7 +1,23 @@
1
- import { CalendarConfig, createCalendar } from '@schedule-x/calendar'
2
- import { useState } from 'react'
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
+ }