@schedule-x/react 0.5.0 → 0.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/cypress/e2e/002-custom-events.cy.ts +23 -1
- package/cypress/pages/002-custom-events/002-custom-events.tsx +6 -2
- package/cypress/pages/002-custom-events/components/CustomMonthAgendaEvent.tsx +26 -0
- package/cypress/pages/002-custom-events/components/CustomMonthGridEvent.tsx +26 -0
- package/development/App.tsx +4 -2
- package/dist/index.cjs.js +3 -2
- package/dist/index.js +2 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/types/{calendar.d.ts → schedule-x-calendar.d.ts} +3 -1
- package/package.json +8 -8
- package/src/index.tsx +4 -1
- package/src/{calendar.tsx → schedule-x-calendar.tsx} +3 -1
|
@@ -1,11 +1,33 @@
|
|
|
1
|
+
import { createCalendarHeaderPageObject } from '@schedule-x/e2e-testing'
|
|
2
|
+
|
|
3
|
+
const calendarHeader = createCalendarHeaderPageObject()
|
|
4
|
+
|
|
1
5
|
describe('Custom events', () => {
|
|
2
6
|
beforeEach(() => {
|
|
3
7
|
cy.visit('/cypress/pages/002-custom-events/002-custom-events.html')
|
|
4
8
|
})
|
|
5
9
|
|
|
6
|
-
it('should render custom events', () => {
|
|
10
|
+
it('should render custom events in week view', () => {
|
|
7
11
|
cy.contains('Event 1')
|
|
8
12
|
cy.contains('ID: 1')
|
|
9
13
|
cy.contains('Event 2|ID2')
|
|
10
14
|
})
|
|
15
|
+
|
|
16
|
+
it('should render custom events in month view', () => {
|
|
17
|
+
calendarHeader.openViewByLabel('Month')
|
|
18
|
+
cy.contains('Event 1|ID1').should('exist')
|
|
19
|
+
cy.contains('Event 2|ID2').should('exist')
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('Custom events test on mobile', () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
cy.visit('/cypress/pages/002-custom-events/002-custom-events.html')
|
|
26
|
+
cy.viewport('iphone-6')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('should render custom events in month agenda view', () => {
|
|
30
|
+
calendarHeader.openViewByLabel('Month')
|
|
31
|
+
cy.contains('Event 1|ID1').should('exist')
|
|
32
|
+
})
|
|
11
33
|
})
|
|
@@ -5,7 +5,7 @@ import '@fontsource/open-sans/700.css'
|
|
|
5
5
|
import '@fontsource/open-sans/700-italic.css'
|
|
6
6
|
import ReactDOM from 'react-dom/client'
|
|
7
7
|
import React from 'react'
|
|
8
|
-
import {
|
|
8
|
+
import { ScheduleXCalendar, useCalendarApp } from '../../..'
|
|
9
9
|
import {
|
|
10
10
|
viewDay,
|
|
11
11
|
viewMonthAgenda,
|
|
@@ -16,6 +16,8 @@ import '../index.css'
|
|
|
16
16
|
import '@schedule-x/theme-default/dist/index.css'
|
|
17
17
|
import CustomTimeGridEvent from './components/CustomTimeGridEvent.tsx'
|
|
18
18
|
import CustomDateGridEvent from './components/CustomDateGridEvent.tsx'
|
|
19
|
+
import CustomMonthAgendaEvent from './components/CustomMonthAgendaEvent.tsx'
|
|
20
|
+
import CustomMonthGridEvent from './components/CustomMonthGridEvent.tsx'
|
|
19
21
|
|
|
20
22
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
21
23
|
function App() {
|
|
@@ -42,11 +44,13 @@ function App() {
|
|
|
42
44
|
return (
|
|
43
45
|
<>
|
|
44
46
|
<div className="schedule-x-calendar">
|
|
45
|
-
<
|
|
47
|
+
<ScheduleXCalendar
|
|
46
48
|
calendarApp={calendarApp}
|
|
47
49
|
customComponents={{
|
|
48
50
|
timeGridEvent: CustomTimeGridEvent,
|
|
49
51
|
dateGridEvent: CustomDateGridEvent,
|
|
52
|
+
monthAgendaEvent: CustomMonthAgendaEvent,
|
|
53
|
+
monthGridEvent: CustomMonthGridEvent,
|
|
50
54
|
}}
|
|
51
55
|
/>
|
|
52
56
|
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type props = {
|
|
2
|
+
calendarEvent: {
|
|
3
|
+
id: string | number
|
|
4
|
+
title: string
|
|
5
|
+
start: string
|
|
6
|
+
end: string
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function CustomMonthAgendaEvent({ calendarEvent }: props) {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
height: '100%',
|
|
15
|
+
width: '100%',
|
|
16
|
+
background: 'green',
|
|
17
|
+
color: 'white',
|
|
18
|
+
padding: '2px',
|
|
19
|
+
borderRadius: 5,
|
|
20
|
+
border: '1px solid white',
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<span>{calendarEvent.title}</span>|<span>ID{calendarEvent.id}</span>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type props = {
|
|
2
|
+
calendarEvent: {
|
|
3
|
+
id: string | number
|
|
4
|
+
title: string
|
|
5
|
+
start: string
|
|
6
|
+
end: string
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function CustomMonthGridEvent({ calendarEvent }: props) {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
height: '100%',
|
|
15
|
+
width: '100%',
|
|
16
|
+
background: 'green',
|
|
17
|
+
color: 'white',
|
|
18
|
+
padding: '2px',
|
|
19
|
+
borderRadius: 5,
|
|
20
|
+
border: '1px solid white',
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<span>{calendarEvent.title}</span>|<span>ID{calendarEvent.id}</span>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
package/development/App.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './App.css'
|
|
2
|
-
import {
|
|
2
|
+
import { ScheduleXCalendar, useCalendarApp } from '../src'
|
|
3
3
|
import {
|
|
4
4
|
viewDay,
|
|
5
5
|
viewMonthAgenda,
|
|
@@ -48,11 +48,13 @@ function App() {
|
|
|
48
48
|
return (
|
|
49
49
|
<>
|
|
50
50
|
<div>
|
|
51
|
-
<
|
|
51
|
+
<ScheduleXCalendar
|
|
52
52
|
calendarApp={calendarApp}
|
|
53
53
|
customComponents={{
|
|
54
54
|
timeGridEvent: CustomTimeGridEvent,
|
|
55
55
|
dateGridEvent: CustomDateGridEvent,
|
|
56
|
+
monthAgendaEvent: CustomDateGridEvent,
|
|
57
|
+
monthGridEvent: CustomDateGridEvent,
|
|
56
58
|
}}
|
|
57
59
|
/>
|
|
58
60
|
</div>
|
package/dist/index.cjs.js
CHANGED
|
@@ -11,7 +11,7 @@ const createCustomComponentFn = (setCustomComponent, customComponent) => (wrappe
|
|
|
11
11
|
wrapperElement,
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
-
function
|
|
14
|
+
function ScheduleXCalendar({ calendarApp, customComponents }) {
|
|
15
15
|
const randomId = 'sx' + Math.random().toString(36).substring(2, 11);
|
|
16
16
|
const [customComponentsMeta, setCustomComponentsMeta] = react.useState([]);
|
|
17
17
|
const setComponent = (component) => {
|
|
@@ -41,5 +41,6 @@ function useCalendarApp(config) {
|
|
|
41
41
|
return calendarApp;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
exports.Calendar =
|
|
44
|
+
exports.Calendar = ScheduleXCalendar;
|
|
45
|
+
exports.ScheduleXCalendar = ScheduleXCalendar;
|
|
45
46
|
exports.useCalendarApp = useCalendarApp;
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const createCustomComponentFn = (setCustomComponent, customComponent) => (wrappe
|
|
|
9
9
|
wrapperElement,
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
-
function
|
|
12
|
+
function ScheduleXCalendar({ calendarApp, customComponents }) {
|
|
13
13
|
const randomId = 'sx' + Math.random().toString(36).substring(2, 11);
|
|
14
14
|
const [customComponentsMeta, setCustomComponentsMeta] = useState([]);
|
|
15
15
|
const setComponent = (component) => {
|
|
@@ -39,4 +39,4 @@ function useCalendarApp(config) {
|
|
|
39
39
|
return calendarApp;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export { Calendar, useCalendarApp };
|
|
42
|
+
export { ScheduleXCalendar as Calendar, ScheduleXCalendar, useCalendarApp };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ type props = {
|
|
|
6
6
|
customComponents?: {
|
|
7
7
|
timeGridEvent?: ReactComponent;
|
|
8
8
|
dateGridEvent?: ReactComponent;
|
|
9
|
+
monthGridEvent?: ReactComponent;
|
|
10
|
+
monthAgendaEvent?: ReactComponent;
|
|
9
11
|
};
|
|
10
12
|
};
|
|
11
|
-
export declare function
|
|
13
|
+
export declare function ScheduleXCalendar({ calendarApp, customComponents }: props): import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
export {};
|
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": "0.
|
|
17
|
+
"version": "0.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": "^0.
|
|
29
|
+
"@schedule-x/calendar": "^0.6.0",
|
|
30
30
|
"react": "^16.7.0 || ^17 || ^18",
|
|
31
31
|
"react-dom": "^16.7.0 || ^17 || ^18"
|
|
32
32
|
},
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
36
36
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
37
37
|
"@rollup/plugin-typescript": "^11.1.5",
|
|
38
|
-
"@schedule-x/drag-and-drop": "^0.
|
|
39
|
-
"@schedule-x/e2e-testing": "^0.
|
|
40
|
-
"@schedule-x/eslint-config": "^0.
|
|
41
|
-
"@schedule-x/event-modal": "^0.
|
|
42
|
-
"@schedule-x/prettier-config": "^0.
|
|
43
|
-
"@schedule-x/theme-default": "^0.
|
|
38
|
+
"@schedule-x/drag-and-drop": "^0.6.0",
|
|
39
|
+
"@schedule-x/e2e-testing": "^0.6.0",
|
|
40
|
+
"@schedule-x/eslint-config": "^0.6.0",
|
|
41
|
+
"@schedule-x/event-modal": "^0.6.0",
|
|
42
|
+
"@schedule-x/prettier-config": "^0.6.0",
|
|
43
|
+
"@schedule-x/theme-default": "^0.6.0",
|
|
44
44
|
"@types/react": "^18.2.43",
|
|
45
45
|
"@types/react-dom": "^18.2.17",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
package/src/index.tsx
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// @deprecated. To be removed in v1.0.0
|
|
2
|
+
export { ScheduleXCalendar as Calendar } from './schedule-x-calendar.tsx'
|
|
3
|
+
|
|
4
|
+
export { ScheduleXCalendar } from './schedule-x-calendar.tsx'
|
|
2
5
|
export { useCalendarApp } from './use-calendar-app.tsx'
|
|
@@ -14,6 +14,8 @@ type props = {
|
|
|
14
14
|
customComponents?: {
|
|
15
15
|
timeGridEvent?: ReactComponent
|
|
16
16
|
dateGridEvent?: ReactComponent
|
|
17
|
+
monthGridEvent?: ReactComponent
|
|
18
|
+
monthAgendaEvent?: ReactComponent
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -29,7 +31,7 @@ const createCustomComponentFn =
|
|
|
29
31
|
})
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
export function
|
|
34
|
+
export function ScheduleXCalendar({ calendarApp, customComponents }: props) {
|
|
33
35
|
const randomId = 'sx' + Math.random().toString(36).substring(2, 11)
|
|
34
36
|
const [customComponentsMeta, setCustomComponentsMeta] =
|
|
35
37
|
useState<CustomComponentsMeta>([])
|