@schedule-x/react 1.38.0 → 1.39.1
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/package.json +6 -2
- package/.eslintrc.cjs +0 -19
- package/.github/workflows/build-library.yml +0 -28
- package/.github/workflows/lint.yml +0 -19
- package/.github/workflows/release.yml +0 -34
- package/.github/workflows/test-e2e.yml +0 -29
- package/.husky/pre-commit +0 -5
- package/.prettierrc +0 -1
- package/.releaserc +0 -43
- package/CHANGELOG.md +0 -299
- package/cypress/e2e/001-smoke.cy.ts +0 -15
- package/cypress/e2e/002-custom-events.cy.ts +0 -33
- package/cypress/fixtures/example.json +0 -5
- package/cypress/pages/001-smoke/001-smoke.html +0 -21
- package/cypress/pages/001-smoke/001-smoke.tsx +0 -47
- package/cypress/pages/002-custom-events/002-custom-events.html +0 -21
- package/cypress/pages/002-custom-events/002-custom-events.tsx +0 -67
- package/cypress/pages/002-custom-events/components/CustomDateGridEvent.tsx +0 -26
- package/cypress/pages/002-custom-events/components/CustomMonthAgendaEvent.tsx +0 -26
- package/cypress/pages/002-custom-events/components/CustomMonthGridEvent.tsx +0 -26
- package/cypress/pages/002-custom-events/components/CustomTimeGridEvent.tsx +0 -30
- package/cypress/pages/index.css +0 -10
- package/cypress/support/commands.ts +0 -37
- package/cypress/support/e2e.ts +0 -20
- package/cypress.config.ts +0 -8
- package/development/App.css +0 -42
- package/development/App.tsx +0 -67
- package/development/assets/react.svg +0 -1
- package/development/components/CustomDateGridEvent.tsx +0 -26
- package/development/components/CustomEventModal.tsx +0 -26
- package/development/components/CustomTimeGridEvent.tsx +0 -29
- package/development/index.css +0 -30
- package/development/main.tsx +0 -10
- package/development/next-app/README.md +0 -36
- package/development/next-app/app/favicon.ico +0 -0
- package/development/next-app/app/globals.css +0 -113
- package/development/next-app/app/layout.tsx +0 -22
- package/development/next-app/app/page.module.css +0 -231
- package/development/next-app/app/page.tsx +0 -50
- package/development/next-app/cypress.config.js +0 -9
- package/development/next-app/next.config.js +0 -4
- package/development/next-app/package-lock.json +0 -464
- package/development/next-app/package.json +0 -22
- package/development/next-app/public/next.svg +0 -1
- package/development/next-app/public/vercel.svg +0 -1
- package/development/next-app/tsconfig.json +0 -27
- package/development/vite-env.d.ts +0 -1
- package/index.html +0 -13
- package/renovate.json +0 -16
- package/rollup.config.js +0 -37
- package/src/index.tsx +0 -5
- package/src/schedule-x-calendar.tsx +0 -94
- package/src/types/custom-components.ts +0 -8
- package/src/use-calendar-app.tsx +0 -23
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -10
- package/tsconfig.rollup.json +0 -27
- package/vite.config.ts +0 -7
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { CalendarApp } from '@schedule-x/calendar'
|
|
2
|
-
import React, { createElement, Fragment, useEffect, useState } from 'react'
|
|
3
|
-
import { createPortal } from 'react-dom'
|
|
4
|
-
import {
|
|
5
|
-
CustomComponentMeta,
|
|
6
|
-
CustomComponentsMeta,
|
|
7
|
-
} from './types/custom-components.ts'
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
type ReactComponent = React.ComponentType<any>
|
|
11
|
-
|
|
12
|
-
type props = {
|
|
13
|
-
calendarApp: CalendarApp | undefined // undefined allowed to prevent errors in SSR
|
|
14
|
-
customComponents?: {
|
|
15
|
-
timeGridEvent?: ReactComponent
|
|
16
|
-
dateGridEvent?: ReactComponent
|
|
17
|
-
monthGridEvent?: ReactComponent
|
|
18
|
-
monthAgendaEvent?: ReactComponent
|
|
19
|
-
eventModal?: ReactComponent
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const createCustomComponentFn =
|
|
24
|
-
(
|
|
25
|
-
setCustomComponent: (component: CustomComponentMeta) => void,
|
|
26
|
-
customComponent: ReactComponent
|
|
27
|
-
) =>
|
|
28
|
-
(wrapperElement: HTMLElement, props: Record<string, unknown>) => {
|
|
29
|
-
setCustomComponent({
|
|
30
|
-
Component: createElement(customComponent, props),
|
|
31
|
-
wrapperElement,
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function ScheduleXCalendar({ calendarApp, customComponents }: props) {
|
|
36
|
-
const [randomId, setRandomId] = useState('')
|
|
37
|
-
const [customComponentsMeta, setCustomComponentsMeta] =
|
|
38
|
-
useState<CustomComponentsMeta>([])
|
|
39
|
-
|
|
40
|
-
const setComponent = (component: CustomComponentMeta) => {
|
|
41
|
-
setCustomComponentsMeta((prev) => {
|
|
42
|
-
const newComponents = [...prev]
|
|
43
|
-
const ccid = component.wrapperElement.dataset.ccid
|
|
44
|
-
const existingComponent = newComponents.find(
|
|
45
|
-
(c) => c.wrapperElement.dataset.ccid === ccid
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
if (existingComponent) {
|
|
49
|
-
newComponents.splice(newComponents.indexOf(existingComponent), 1)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return [...newComponents, component]
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
setRandomId('sx' + Math.random().toString(36).substring(2, 11))
|
|
58
|
-
}, [])
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (!calendarApp) return // in SSR, calendarApp will be undefined
|
|
62
|
-
|
|
63
|
-
for (const [componentName, Component] of Object.entries(
|
|
64
|
-
customComponents || {}
|
|
65
|
-
)) {
|
|
66
|
-
calendarApp._setCustomComponentFn(
|
|
67
|
-
componentName as
|
|
68
|
-
| 'timeGridEvent'
|
|
69
|
-
| 'dateGridEvent'
|
|
70
|
-
| 'monthGridEvent'
|
|
71
|
-
| 'monthAgendaEvent'
|
|
72
|
-
| 'eventModal',
|
|
73
|
-
createCustomComponentFn(setComponent, Component)
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const calendarElement = document.getElementById(randomId)
|
|
78
|
-
if (!calendarElement) return
|
|
79
|
-
|
|
80
|
-
calendarApp.render(calendarElement as HTMLElement)
|
|
81
|
-
}, [calendarApp, customComponents, randomId])
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<>
|
|
85
|
-
<Fragment>
|
|
86
|
-
<div className="sx-react-calendar-wrapper" id={randomId}></div>
|
|
87
|
-
|
|
88
|
-
{customComponentsMeta.map(({ Component, wrapperElement }) => {
|
|
89
|
-
return createPortal(Component, wrapperElement)
|
|
90
|
-
})}
|
|
91
|
-
</Fragment>
|
|
92
|
-
</>
|
|
93
|
-
)
|
|
94
|
-
}
|
package/src/use-calendar-app.tsx
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CalendarApp,
|
|
3
|
-
CalendarConfig,
|
|
4
|
-
createCalendar,
|
|
5
|
-
} from '@schedule-x/calendar'
|
|
6
|
-
import { useEffect, useState } from 'react'
|
|
7
|
-
|
|
8
|
-
export function useCalendarApp(config: CalendarConfig) {
|
|
9
|
-
const [calendarApp] = useState(createCalendar(config))
|
|
10
|
-
return calendarApp
|
|
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
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2019",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "react-jsx",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"noFallthroughCasesInSwitch": true
|
|
22
|
-
},
|
|
23
|
-
"include": ["cypress/**/*.cy.ts", "cypress", "development"],
|
|
24
|
-
"references": [{ "path": "./tsconfig.node.json" }],
|
|
25
|
-
"types": ["vite/client", "cypress", "node"]
|
|
26
|
-
}
|
package/tsconfig.node.json
DELETED
package/tsconfig.rollup.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2019",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"allowImportingTsExtensions": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"jsx": "react-jsx",
|
|
14
|
-
|
|
15
|
-
"strict": true,
|
|
16
|
-
"noUnusedLocals": true,
|
|
17
|
-
"noUnusedParameters": true,
|
|
18
|
-
"noFallthroughCasesInSwitch": true,
|
|
19
|
-
|
|
20
|
-
"declaration": true,
|
|
21
|
-
"declarationDir": "types",
|
|
22
|
-
"emitDeclarationOnly": true
|
|
23
|
-
},
|
|
24
|
-
"include": ["src"],
|
|
25
|
-
"references": [{ "path": "./tsconfig.node.json" }],
|
|
26
|
-
"types": ["vite/client", "node"]
|
|
27
|
-
}
|