@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.
@@ -9,8 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { Alert, Box } from '@mui/material';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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,17 @@ 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 ((dev === null || dev === void 0 ? void 0 : dev.mode) === 'draft') {
53
+ return (_jsxs(Box, { sx: {
54
+ p: 3,
55
+ border: '1px dashed #d32f2f',
56
+ borderRadius: 1,
57
+ bgcolor: 'rgba(211, 47, 47, 0.04)',
58
+ display: 'flex',
59
+ flexDirection: 'column',
60
+ gap: 1,
61
+ }, children: [_jsx(Typography, { variant: "subtitle1", sx: { color: '#d32f2f', fontWeight: 500 }, children: "Component Failed to Load" }), _jsx(Typography, { variant: "body2", sx: { color: 'text.secondary' }, children: "Please try the following:" }), _jsxs(Box, { component: "ul", sx: { m: 0, pl: 2 }, children: [_jsxs(Typography, { component: "li", variant: "body2", sx: { color: 'text.secondary' }, children: ["Select component", ' ', _jsx(Box, { component: "span", sx: { fontWeight: 500 }, children: componentName !== null && componentName !== void 0 ? componentName : props.componentId }), ' ', "in settings or create this component."] }), (blockletId || blockletTitle) && (_jsxs(Typography, { component: "li", variant: "body2", sx: { color: 'text.secondary' }, children: ["Contact administrator to install", ' ', _jsx(Box, { component: "span", sx: { fontWeight: 500 }, children: blockletTitle !== null && blockletTitle !== void 0 ? blockletTitle : blockletId }), ' ', "Blocklet"] }))] })] }));
62
+ }
52
63
  return null;
53
64
  }
54
65
  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
  }));