@blocklet/pages-kit-block-studio 0.4.73 → 0.4.75
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.
- package/lib/cjs/plugins/_theme.js +29 -15
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/zod-utils.js +2 -5
- package/lib/esm/plugins/_theme.js +29 -15
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/zod-utils.js +2 -5
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -53,6 +53,7 @@ const components_1 = require("@blocklet/pages-kit-runtime/components");
|
|
|
53
53
|
// @ts-ignore
|
|
54
54
|
const locales_1 = require("@blocklet/pages-kit-runtime/locales");
|
|
55
55
|
const components_2 = require("@blocklet/pages-kit/components");
|
|
56
|
+
const property_1 = require("@blocklet/pages-kit/utils/property");
|
|
56
57
|
// @ts-ignore
|
|
57
58
|
const studio_ui_1 = require("@blocklet/studio-ui");
|
|
58
59
|
const ui_react_1 = require("@blocklet/ui-react");
|
|
@@ -60,6 +61,7 @@ const Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
|
60
61
|
const material_1 = require("@mui/material");
|
|
61
62
|
const ahooks_1 = require("ahooks");
|
|
62
63
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
64
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
63
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
64
66
|
const react_1 = require("react");
|
|
65
67
|
const react_dnd_1 = require("react-dnd");
|
|
@@ -83,6 +85,7 @@ function useSessionContext() {
|
|
|
83
85
|
}
|
|
84
86
|
const LEFT_DRAWER_WIDTH = 200;
|
|
85
87
|
const RIGHT_DRAWER_WIDTH = 300;
|
|
88
|
+
const defaultLocale = 'en';
|
|
86
89
|
const ComparisonPreviewDialog = ({ open, title, leftTitle, leftContent, rightTitle, rightContent, description = '确认后将更新配置。', loading, onConfirm, onClose, }) => {
|
|
87
90
|
const handleConfirm = async () => {
|
|
88
91
|
try {
|
|
@@ -121,7 +124,6 @@ function Layout({ loadState, loadedData }) {
|
|
|
121
124
|
createdAt: '',
|
|
122
125
|
updatedAt: '',
|
|
123
126
|
},
|
|
124
|
-
data: {},
|
|
125
127
|
allResources: {},
|
|
126
128
|
searchValue: '',
|
|
127
129
|
newBlockParams: {
|
|
@@ -141,6 +143,7 @@ function Layout({ loadState, loadedData }) {
|
|
|
141
143
|
},
|
|
142
144
|
init: false,
|
|
143
145
|
allComponents: [],
|
|
146
|
+
propertiesValue: {},
|
|
144
147
|
});
|
|
145
148
|
const { locale } = (0, context_1.useLocaleContext)();
|
|
146
149
|
const { session } = useSessionContext();
|
|
@@ -270,6 +273,18 @@ function Layout({ loadState, loadedData }) {
|
|
|
270
273
|
description: '',
|
|
271
274
|
};
|
|
272
275
|
};
|
|
276
|
+
let mergedPropertiesValues = Object.fromEntries(Object.values(state.metadata.properties ?? {}).map(({ data }) => {
|
|
277
|
+
return [
|
|
278
|
+
data.id,
|
|
279
|
+
{
|
|
280
|
+
value: state.propertiesValue[data.id]?.value ??
|
|
281
|
+
(0, property_1.parsePropertyValue)(data, data.locales?.[locale]?.defaultValue ?? data.locales?.[defaultLocale]?.defaultValue, {
|
|
282
|
+
locale,
|
|
283
|
+
defaultLocale,
|
|
284
|
+
}),
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
}));
|
|
273
288
|
const getRenderContent = (0, react_1.useCallback)(() => {
|
|
274
289
|
if (loadState.type === '404') {
|
|
275
290
|
return null;
|
|
@@ -279,12 +294,12 @@ function Layout({ loadState, loadedData }) {
|
|
|
279
294
|
}
|
|
280
295
|
// const pageData = loadedData[loadState.routePath];
|
|
281
296
|
// const Component = pageData.main.default;
|
|
282
|
-
// return <Component
|
|
297
|
+
// return <Component />;
|
|
283
298
|
return [
|
|
284
|
-
(0, jsx_runtime_1.jsx)(components_2.CustomComponentRenderer, { locale: locale, componentId: state.metadata.id, dev: { mode: 'draft', components: mergedAllBlocks, defaultLocale
|
|
285
|
-
// <Component key="original"
|
|
299
|
+
(0, jsx_runtime_1.jsx)(components_2.CustomComponentRenderer, { locale: locale, componentId: state.metadata.id, dev: { mode: 'draft', components: mergedAllBlocks, defaultLocale }, properties: mergedPropertiesValues }, "custom"),
|
|
300
|
+
// <Component key="original" />,
|
|
286
301
|
];
|
|
287
|
-
}, [loadedData, loadState, locale, state.injectBlocks, state.metadata, mergedAllBlocks]);
|
|
302
|
+
}, [loadedData, loadState, locale, state.injectBlocks, state.metadata, mergedAllBlocks, mergedPropertiesValues]);
|
|
288
303
|
// add auto redirect to first route
|
|
289
304
|
if (loadState.type === '404' &&
|
|
290
305
|
!routes.includes(location.pathname) &&
|
|
@@ -369,7 +384,7 @@ function Layout({ loadState, loadedData }) {
|
|
|
369
384
|
position: 'relative',
|
|
370
385
|
height: '100%',
|
|
371
386
|
},
|
|
372
|
-
}, children: (0, jsx_runtime_1.jsxs)(material_1.List, { sx: { display: 'flex', flexDirection: 'column', gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(components_1.BasicInfo, { config: state.metadata }) }) }), (0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(components_1.PropertiesConfig, { config: state.metadata, currentLocale: locale, defaultLocale:
|
|
387
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.List, { sx: { display: 'flex', flexDirection: 'column', gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(components_1.BasicInfo, { config: state.metadata }) }) }), (0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(components_1.PropertiesConfig, { config: state.metadata, currentLocale: locale, defaultLocale: defaultLocale, allComponents: mergedAllBlocks, onUpdateConfig: (updater) => {
|
|
373
388
|
updater(state.metadata);
|
|
374
389
|
}, useI18nEditor: false }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "column", spacing: 1, sx: { mt: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", size: "small", color: "primary", onClick: async () => {
|
|
375
390
|
try {
|
|
@@ -478,16 +493,15 @@ function Layout({ loadState, loadedData }) {
|
|
|
478
493
|
console.error('生成接口预览失败:', error);
|
|
479
494
|
Toast_1.default.error('生成接口预览失败');
|
|
480
495
|
}
|
|
481
|
-
}, children: "Properties \u2192 Interface" })] })] }) }), state.metadata.id && ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(components_1.ParametersConfig, { config: state.metadata, allComponents: mergedAllBlocks, defaultLocale:
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
496
|
+
}, children: "Properties \u2192 Interface" })] })] }) }), state.metadata.id && ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(components_1.ParametersConfig, { config: state.metadata, allComponents: mergedAllBlocks, defaultLocale: defaultLocale, locale: locale, propertiesValue: mergedPropertiesValues, onChange: ({ key, value, id, path, ...rest }) => {
|
|
497
|
+
const property = (0, get_1.default)(state.metadata, [...path, 'data']);
|
|
498
|
+
const realValue = (0, property_1.parsePropertyValue)(property, value.value, {
|
|
499
|
+
locale,
|
|
500
|
+
defaultLocale,
|
|
501
|
+
});
|
|
502
|
+
state.propertiesValue[id] = {
|
|
503
|
+
value: realValue,
|
|
488
504
|
};
|
|
489
|
-
}, props: {
|
|
490
|
-
...state.data,
|
|
491
505
|
} }) }) }))] }) }), (0, jsx_runtime_1.jsx)(CreateResource, { open: state.createResourceOpen, onClose: () => {
|
|
492
506
|
state.createResourceOpen = false;
|
|
493
507
|
} }), (0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: state.createBlockOpen, onClose: onCloseCreateBlock, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: "Create New Block" }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 2, sx: { pt: 1, minWidth: 300 }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { autoFocus: true, required: true, label: "Name", fullWidth: true, value: state.newBlockParams.name, onChange: (e) => {
|