@blocklet/pages-kit 0.3.27 → 0.3.29

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,17 @@ 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 ((dev === null || dev === void 0 ? void 0 : dev.mode) === 'draft') {
73
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
74
+ p: 3,
75
+ border: '1px dashed #d32f2f',
76
+ borderRadius: 1,
77
+ bgcolor: 'rgba(211, 47, 47, 0.04)',
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ gap: 1,
81
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle1", sx: { color: '#d32f2f', fontWeight: 500 }, children: "Component Failed to Load" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { color: 'text.secondary' }, children: "Please try the following:" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "ul", sx: { m: 0, pl: 2 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { component: "li", variant: "body2", sx: { color: 'text.secondary' }, children: ["Select component", ' ', (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: { fontWeight: 500 }, children: componentName !== null && componentName !== void 0 ? componentName : props.componentId }), ' ', "in settings or create this component."] }), (blockletId || blockletTitle) && ((0, jsx_runtime_1.jsxs)(material_1.Typography, { component: "li", variant: "body2", sx: { color: 'text.secondary' }, children: ["Contact administrator to install", ' ', (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: { fontWeight: 500 }, children: blockletTitle !== null && blockletTitle !== void 0 ? blockletTitle : blockletId }), ' ', "Blocklet"] }))] })] }));
82
+ }
72
83
  return null;
73
84
  }
74
85
  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
  }));