@schedule-x/react 1.33.0 → 1.35.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 +14 -0
- package/development/next-app/package-lock.json +3 -3
- package/dist/index.cjs +64 -0
- package/package.json +3 -3
- package/rollup.config.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.35.0](https://github.com/schedule-x/react/compare/v1.34.0...v1.35.0) (2024-05-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* make commonjs filename use cjs extension ([#103](https://github.com/schedule-x/react/issues/103)) ([cae187b](https://github.com/schedule-x/react/commit/cae187b4ae576711f07ed4437bdec3f4f8b42791))
|
|
11
|
+
|
|
12
|
+
# [1.34.0](https://github.com/schedule-x/react/compare/v1.33.0...v1.34.0) (2024-04-30)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **deps:** update devdependencies (non-major) ([#102](https://github.com/schedule-x/react/issues/102)) ([8f22c1f](https://github.com/schedule-x/react/commit/8f22c1f3b058aa9fcc0238527fcc054489a0ddae))
|
|
18
|
+
|
|
5
19
|
# [1.33.0](https://github.com/schedule-x/react/compare/v1.32.0...v1.33.0) (2024-04-26)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -189,9 +189,9 @@
|
|
|
189
189
|
"dev": true
|
|
190
190
|
},
|
|
191
191
|
"node_modules/@types/react": {
|
|
192
|
-
"version": "18.3.
|
|
193
|
-
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.
|
|
194
|
-
"integrity": "sha512-
|
|
192
|
+
"version": "18.3.1",
|
|
193
|
+
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.1.tgz",
|
|
194
|
+
"integrity": "sha512-V0kuGBX3+prX+DQ/7r2qsv1NsdfnCLnTgnRJ1pYnxykBhGMz+qj+box5lq7XsO5mtZsBqpjwwTu/7wszPfMBcw==",
|
|
195
195
|
"dev": true,
|
|
196
196
|
"dependencies": {
|
|
197
197
|
"@types/prop-types": "*",
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
|
+
var calendar = require('@schedule-x/calendar');
|
|
7
|
+
|
|
8
|
+
const createCustomComponentFn = (setCustomComponent, customComponent) => (wrapperElement, props) => {
|
|
9
|
+
setCustomComponent({
|
|
10
|
+
Component: react.createElement(customComponent, props),
|
|
11
|
+
wrapperElement,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
function ScheduleXCalendar({ calendarApp, customComponents }) {
|
|
15
|
+
const [randomId, setRandomId] = react.useState('');
|
|
16
|
+
const [customComponentsMeta, setCustomComponentsMeta] = react.useState([]);
|
|
17
|
+
const setComponent = (component) => {
|
|
18
|
+
setCustomComponentsMeta((prev) => {
|
|
19
|
+
const newComponents = [...prev];
|
|
20
|
+
const ccid = component.wrapperElement.dataset.ccid;
|
|
21
|
+
const existingComponent = newComponents.find((c) => c.wrapperElement.dataset.ccid === ccid);
|
|
22
|
+
if (existingComponent) {
|
|
23
|
+
newComponents.splice(newComponents.indexOf(existingComponent), 1);
|
|
24
|
+
}
|
|
25
|
+
return [...newComponents, component];
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
react.useEffect(() => {
|
|
29
|
+
setRandomId('sx' + Math.random().toString(36).substring(2, 11));
|
|
30
|
+
}, []);
|
|
31
|
+
react.useEffect(() => {
|
|
32
|
+
if (!calendarApp)
|
|
33
|
+
return; // in SSR, calendarApp will be undefined
|
|
34
|
+
for (const [componentName, Component] of Object.entries(customComponents || {})) {
|
|
35
|
+
calendarApp._setCustomComponentFn(componentName, createCustomComponentFn(setComponent, Component));
|
|
36
|
+
}
|
|
37
|
+
const calendarElement = document.getElementById(randomId);
|
|
38
|
+
if (!calendarElement)
|
|
39
|
+
return;
|
|
40
|
+
calendarApp.render(calendarElement);
|
|
41
|
+
}, [calendarApp, customComponents, randomId]);
|
|
42
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx("div", { className: "sx-react-calendar-wrapper", id: randomId }), customComponentsMeta.map(({ Component, wrapperElement }) => {
|
|
43
|
+
return reactDom.createPortal(Component, wrapperElement);
|
|
44
|
+
})] }) }));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function useCalendarApp(config) {
|
|
48
|
+
const [calendarApp] = react.useState(calendar.createCalendar(config));
|
|
49
|
+
return calendarApp;
|
|
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
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.Calendar = ScheduleXCalendar;
|
|
62
|
+
exports.ScheduleXCalendar = ScheduleXCalendar;
|
|
63
|
+
exports.useCalendarApp = useCalendarApp;
|
|
64
|
+
exports.useNextCalendarApp = useNextCalendarApp;
|
package/package.json
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"internationalization",
|
|
12
12
|
"react"
|
|
13
13
|
],
|
|
14
|
-
"main": "dist/index.cjs
|
|
14
|
+
"main": "dist/index.cjs",
|
|
15
15
|
"module": "dist/index.js",
|
|
16
16
|
"types": "dist/types/index.d.ts",
|
|
17
|
-
"version": "1.
|
|
17
|
+
"version": "1.35.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.36.0",
|
|
30
30
|
"react": "^16.7.0 || ^17 || ^18",
|
|
31
31
|
"react-dom": "^16.7.0 || ^17 || ^18"
|
|
32
32
|
},
|
package/rollup.config.js
CHANGED
|
@@ -13,6 +13,7 @@ export default {
|
|
|
13
13
|
input: 'src/index.tsx',
|
|
14
14
|
output: [
|
|
15
15
|
{
|
|
16
|
+
// deprecate with v2
|
|
16
17
|
file: pJson.main,
|
|
17
18
|
format: 'cjs',
|
|
18
19
|
name: 'react-lib',
|
|
@@ -21,6 +22,10 @@ export default {
|
|
|
21
22
|
file: pJson.module,
|
|
22
23
|
format: 'esm',
|
|
23
24
|
},
|
|
25
|
+
{
|
|
26
|
+
file: 'dist/index.cjs.js',
|
|
27
|
+
format: 'cjs',
|
|
28
|
+
},
|
|
24
29
|
],
|
|
25
30
|
plugins: [
|
|
26
31
|
external(),
|