@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.
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { Alert, Box } from '@mui/material';
13
+ import { Alert, Box, Typography } from '@mui/material';
14
14
  import { ErrorBoundary } from 'react-error-boundary';
15
15
  import { RenderNestedComponent } from '../../utils/property';
16
16
  import BlockletReactComponentRenderer from './BlockletReactComponentRenderer';
@@ -34,7 +34,7 @@ function ErrorView({ error }) {
34
34
  return (_jsx(Box, { children: _jsx(Alert, { severity: "error", children: error.message }) }));
35
35
  }
36
36
  function ComponentRenderer(_a) {
37
- var { renderCount = 0 } = _a, props = __rest(_a, ["renderCount"]);
37
+ var { renderCount = 0, blockletId, blockletTitle, componentName } = _a, props = __rest(_a, ["renderCount", "blockletId", "blockletTitle", "componentName"]);
38
38
  const dev = useDev();
39
39
  if (renderCount > MAXIMUM_RENDER_STACK_SIZE) {
40
40
  throw new Error('Maximum render stack size exceeded');
@@ -49,6 +49,9 @@ function ComponentRenderer(_a) {
49
49
  const children = (_jsx(Renderer, Object.assign({ renderCount: renderCount + 1 }, props, { Component: component.Component, props: Object.assign(Object.assign({}, component.props), props.props) })));
50
50
  return (ctx === null || ctx === void 0 ? void 0 : ctx.customRendererComponent) ? (_jsx(ctx.customRendererComponent, { Component: component.Component, children: children })) : (children);
51
51
  }
52
+ if (blockletId || blockletTitle) {
53
+ return (_jsx(Box, { sx: { px: 2, py: 2 }, children: _jsx(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.` }) }));
54
+ }
52
55
  return null;
53
56
  }
54
57
  function Renderer({ renderCount, Component, locale, props, }) {
@@ -175,7 +175,7 @@ export function useComponent({ instanceId, componentId, properties, locale, dev
175
175
  }
176
176
  const COMPONENT_LOADER_MAP = {};
177
177
  function usePreloadComponent({ instanceId, componentId, properties, locale, dev }) {
178
- var _a;
178
+ var _a, _b;
179
179
  const previousRef = useRef();
180
180
  const requestLocale = customComponentStates()((s) => { var _a; return ((_a = s.state.config.supportedLocales) === null || _a === void 0 ? void 0 : _a.some((i) => i.locale === locale)) ? locale : undefined; });
181
181
  const defaultLocale = customComponentStates()((s) => s.state.config.defaultLocale);
@@ -191,7 +191,7 @@ function usePreloadComponent({ instanceId, componentId, properties, locale, dev
191
191
  .getState()
192
192
  .loadComponents({
193
193
  mode: dev === null || dev === void 0 ? void 0 : dev.mode,
194
- projectId: dev === null || dev === void 0 ? void 0 : dev.projectId,
194
+ projectId: (_b = dev === null || dev === void 0 ? void 0 : dev.projectId) !== null && _b !== void 0 ? _b : window.__PROJECT_ID__,
195
195
  locale: realLocale,
196
196
  instances: [{ id: instanceId, component: { id: componentId }, properties }],
197
197
  }));