@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.
@@ -30,6 +30,18 @@ import { PreloadComponentsStateGlobalVariableName } from '../../types/preload';
30
30
  import { mergeComponent } from '../../utils/property';
31
31
  const PRELOAD_COMPONENTS_STATE = window[PreloadComponentsStateGlobalVariableName];
32
32
  let states;
33
+ function importCustomComponent(m, { componentId }) {
34
+ let Component;
35
+ const css = m.__PagesKit_CSS__;
36
+ if (typeof m === 'function')
37
+ Component = m;
38
+ else if (!css)
39
+ Component = m.default;
40
+ else {
41
+ Component = (props) => (_jsxs(Box, { className: `CustomComponent_${componentId}`, children: [_jsx("style", { children: `.CustomComponent_${componentId} {${css}}` }), _jsx(m.default, Object.assign({}, props))] }));
42
+ }
43
+ return Component;
44
+ }
33
45
  export const customComponentStates = () => {
34
46
  states !== null && states !== void 0 ? states : (states = create()(immer((set, get) => ({
35
47
  state: {
@@ -38,17 +50,7 @@ export const customComponentStates = () => {
38
50
  let Component;
39
51
  if (preload.componentModuleGlobalVariable) {
40
52
  const m = window[preload.componentModuleGlobalVariable];
41
- if (typeof m === 'function') {
42
- const mod = m();
43
- const css = mod.__PagesKit_CSS__;
44
- if (typeof mod === 'function')
45
- Component = mod;
46
- else if (!css)
47
- Component = mod.default;
48
- else {
49
- Component = (props) => (_jsxs(Box, { className: `${preload.componentModuleGlobalVariable}`, children: [_jsx("style", { children: `.${preload.componentModuleGlobalVariable} {${css}}` }), _jsx(mod.default, Object.assign({}, props))] }));
50
- }
51
- }
53
+ Component = typeof m === 'function' ? importCustomComponent(m(), { componentId }) : undefined;
52
54
  }
53
55
  return [componentId, Object.assign(Object.assign({}, preload), { Component })];
54
56
  })),
@@ -115,7 +117,7 @@ function loadComponents(input) {
115
117
  item.component.id,
116
118
  {
117
119
  component: item.component,
118
- Component: m.default,
120
+ Component: importCustomComponent(m, { componentId: item.component.id }),
119
121
  },
120
122
  ];
121
123
  }))));