@schedule-x/react 1.34.0 → 1.36.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.36.0](https://github.com/schedule-x/react/compare/v1.35.0...v1.36.0) (2024-05-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* update schedule-x monorepo packages to v1.38.0 ([#104](https://github.com/schedule-x/react/issues/104)) ([ca69698](https://github.com/schedule-x/react/commit/ca696987049a9b914ae50add988c5db89058374e))
|
|
11
|
+
|
|
12
|
+
# [1.35.0](https://github.com/schedule-x/react/compare/v1.34.0...v1.35.0) (2024-05-01)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* make commonjs filename use cjs extension ([#103](https://github.com/schedule-x/react/issues/103)) ([cae187b](https://github.com/schedule-x/react/commit/cae187b4ae576711f07ed4437bdec3f4f8b42791))
|
|
18
|
+
|
|
5
19
|
# [1.34.0](https://github.com/schedule-x/react/compare/v1.33.0...v1.34.0) (2024-04-30)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -174,9 +174,9 @@
|
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
176
|
"node_modules/@types/node": {
|
|
177
|
-
"version": "20.12.
|
|
178
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.
|
|
179
|
-
"integrity": "sha512-
|
|
177
|
+
"version": "20.12.8",
|
|
178
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.8.tgz",
|
|
179
|
+
"integrity": "sha512-NU0rJLJnshZWdE/097cdCBbyW1h4hEg0xpovcoAQYHl8dnEyp/NAOiE45pvc+Bd1Dt+2r94v2eGFpQJ4R7g+2w==",
|
|
180
180
|
"dev": true,
|
|
181
181
|
"dependencies": {
|
|
182
182
|
"undici-types": "~5.26.4"
|
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.36.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.38.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(),
|