@blocklet/pages-kit 0.3.26 → 0.3.28

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.
@@ -54,7 +54,7 @@ function ErrorView({ error }) {
54
54
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", children: error.message }) }));
55
55
  }
56
56
  function ComponentRenderer(_a) {
57
- var { renderCount = 0 } = _a, props = __rest(_a, ["renderCount"]);
57
+ var { renderCount = 0, blockletId, blockletTitle, componentName } = _a, props = __rest(_a, ["renderCount", "blockletId", "blockletTitle", "componentName"]);
58
58
  const dev = (0, DevProvider_1.useDev)();
59
59
  if (renderCount > MAXIMUM_RENDER_STACK_SIZE) {
60
60
  throw new Error('Maximum render stack size exceeded');
@@ -69,6 +69,9 @@ function ComponentRenderer(_a) {
69
69
  const children = ((0, jsx_runtime_1.jsx)(Renderer, Object.assign({ renderCount: renderCount + 1 }, props, { Component: component.Component, props: Object.assign(Object.assign({}, component.props), props.props) })));
70
70
  return (ctx === null || ctx === void 0 ? void 0 : ctx.customRendererComponent) ? ((0, jsx_runtime_1.jsx)(ctx.customRendererComponent, { Component: component.Component, children: children })) : (children);
71
71
  }
72
+ if (blockletId || blockletTitle) {
73
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { px: 2, py: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { color: '#d32f2f' }, children: `Failed to load component, please select '${componentName !== null && componentName !== void 0 ? componentName : props.componentId}' component in settings, or contact administrator to install '${blockletTitle !== null && blockletTitle !== void 0 ? blockletTitle : blockletTitle}' Blocklet.` }) }));
74
+ }
72
75
  return null;
73
76
  }
74
77
  function Renderer({ renderCount, Component, locale, props, }) {
@@ -208,7 +208,7 @@ function useComponent({ instanceId, componentId, properties, locale, dev }) {
208
208
  }
209
209
  const COMPONENT_LOADER_MAP = {};
210
210
  function usePreloadComponent({ instanceId, componentId, properties, locale, dev }) {
211
- var _a;
211
+ var _a, _b;
212
212
  const previousRef = (0, react_1.useRef)();
213
213
  const requestLocale = (0, exports.customComponentStates)()((s) => { var _a; return ((_a = s.state.config.supportedLocales) === null || _a === void 0 ? void 0 : _a.some((i) => i.locale === locale)) ? locale : undefined; });
214
214
  const defaultLocale = (0, exports.customComponentStates)()((s) => s.state.config.defaultLocale);
@@ -224,7 +224,7 @@ function usePreloadComponent({ instanceId, componentId, properties, locale, dev
224
224
  .getState()
225
225
  .loadComponents({
226
226
  mode: dev === null || dev === void 0 ? void 0 : dev.mode,
227
- projectId: dev === null || dev === void 0 ? void 0 : dev.projectId,
227
+ projectId: (_b = dev === null || dev === void 0 ? void 0 : dev.projectId) !== null && _b !== void 0 ? _b : window.__PROJECT_ID__,
228
228
  locale: realLocale,
229
229
  instances: [{ id: instanceId, component: { id: componentId }, properties }],
230
230
  }));