@blocklet/pages-kit 0.2.426 → 0.2.428
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.
|
@@ -61,6 +61,18 @@ const preload_1 = require("../../types/preload");
|
|
|
61
61
|
const property_1 = require("../../utils/property");
|
|
62
62
|
const PRELOAD_COMPONENTS_STATE = window[preload_1.PreloadComponentsStateGlobalVariableName];
|
|
63
63
|
let states;
|
|
64
|
+
function importCustomComponent(m, { componentId }) {
|
|
65
|
+
let Component;
|
|
66
|
+
const css = m.__PagesKit_CSS__;
|
|
67
|
+
if (typeof m === 'function')
|
|
68
|
+
Component = m;
|
|
69
|
+
else if (!css)
|
|
70
|
+
Component = m.default;
|
|
71
|
+
else {
|
|
72
|
+
Component = (props) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: `CustomComponent_${componentId}`, children: [(0, jsx_runtime_1.jsx)("style", { children: `.CustomComponent_${componentId} {${css}}` }), (0, jsx_runtime_1.jsx)(m.default, Object.assign({}, props))] }));
|
|
73
|
+
}
|
|
74
|
+
return Component;
|
|
75
|
+
}
|
|
64
76
|
const customComponentStates = () => {
|
|
65
77
|
states !== null && states !== void 0 ? states : (states = (0, zustand_1.create)()((0, immer_1.immer)((set, get) => ({
|
|
66
78
|
state: {
|
|
@@ -69,17 +81,7 @@ const customComponentStates = () => {
|
|
|
69
81
|
let Component;
|
|
70
82
|
if (preload.componentModuleGlobalVariable) {
|
|
71
83
|
const m = window[preload.componentModuleGlobalVariable];
|
|
72
|
-
|
|
73
|
-
const mod = m();
|
|
74
|
-
const css = mod.__PagesKit_CSS__;
|
|
75
|
-
if (typeof mod === 'function')
|
|
76
|
-
Component = mod;
|
|
77
|
-
else if (!css)
|
|
78
|
-
Component = mod.default;
|
|
79
|
-
else {
|
|
80
|
-
Component = (props) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: `${preload.componentModuleGlobalVariable}`, children: [(0, jsx_runtime_1.jsx)("style", { children: `.${preload.componentModuleGlobalVariable} {${css}}` }), (0, jsx_runtime_1.jsx)(mod.default, Object.assign({}, props))] }));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
84
|
+
Component = typeof m === 'function' ? importCustomComponent(m(), { componentId }) : undefined;
|
|
83
85
|
}
|
|
84
86
|
return [componentId, Object.assign(Object.assign({}, preload), { Component })];
|
|
85
87
|
})),
|
|
@@ -147,7 +149,7 @@ function loadComponents(input) {
|
|
|
147
149
|
item.component.id,
|
|
148
150
|
{
|
|
149
151
|
component: item.component,
|
|
150
|
-
Component: m.
|
|
152
|
+
Component: importCustomComponent(m, { componentId: item.component.id }),
|
|
151
153
|
},
|
|
152
154
|
];
|
|
153
155
|
}))));
|