@pisell/materials 3.3.87 → 3.3.88
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +4 -4
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +25 -25
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +15 -15
- package/es/components/PisellLayouts/index.d.ts +0 -1
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceSubForm/index.d.ts +13 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/index.js +274 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/index.less +19 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +544 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/schema-simple-example.json +174 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/types.d.ts +117 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/types.js +1 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.d.ts +9 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.js +61 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/WithMode.d.ts +4 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +176 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/index.d.ts +12 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/index.js +11 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/type.d.ts +87 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Tabs/ReadPretty.d.ts +9 -0
- package/es/components/dataSourceComponents/fields/Tabs/ReadPretty.js +16 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.d.ts +23 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.js +93 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.less +64 -0
- package/es/components/dataSourceComponents/fields/Tabs/WithMode.d.ts +6 -0
- package/es/components/dataSourceComponents/fields/Tabs/WithMode.js +9 -0
- package/es/components/dataSourceComponents/fields/Tabs/index.d.ts +12 -0
- package/es/components/dataSourceComponents/fields/Tabs/index.js +18 -0
- package/es/components/dataSourceComponents/fields/Tabs/type.d.ts +38 -0
- package/es/components/dataSourceComponents/fields/Tabs/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/index.d.ts +44 -7
- package/es/components/dataSourceComponents/fields/index.js +5 -1
- package/es/components/dataSourceComponents/fields/utils.js +3 -0
- package/es/components/pisellLookup/PisellLookup.d.ts +4 -0
- package/es/components/pisellLookup/PisellLookup.js +8 -1
- package/es/components/productCard/components/Packages/utils.d.ts +2 -2
- package/es/index.d.ts +4 -0
- package/es/index.js +3 -0
- package/lib/components/PisellLayouts/index.d.ts +0 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.d.ts +13 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.js +229 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.less +19 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +544 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/schema-simple-example.json +174 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/types.d.ts +117 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/types.js +17 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.d.ts +9 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.js +64 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/WithMode.d.ts +4 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +157 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/index.d.ts +12 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/index.js +40 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/type.d.ts +87 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Tabs/ReadPretty.d.ts +9 -0
- package/lib/components/dataSourceComponents/fields/Tabs/ReadPretty.js +45 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.d.ts +23 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.js +95 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.less +64 -0
- package/lib/components/dataSourceComponents/fields/Tabs/WithMode.d.ts +6 -0
- package/lib/components/dataSourceComponents/fields/Tabs/WithMode.js +39 -0
- package/lib/components/dataSourceComponents/fields/Tabs/index.d.ts +12 -0
- package/lib/components/dataSourceComponents/fields/Tabs/index.js +40 -0
- package/lib/components/dataSourceComponents/fields/Tabs/type.d.ts +38 -0
- package/lib/components/dataSourceComponents/fields/Tabs/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/index.d.ts +44 -7
- package/lib/components/dataSourceComponents/fields/index.js +5 -1
- package/lib/components/dataSourceComponents/fields/utils.js +3 -0
- package/lib/components/pisellLookup/PisellLookup.d.ts +4 -0
- package/lib/components/pisellLookup/PisellLookup.js +5 -1
- package/lib/components/productCard/components/Packages/utils.d.ts +2 -2
- package/lib/index.d.ts +4 -0
- package/lib/index.js +9 -0
- package/lowcode/auto-resize-text/meta.ts +9 -9
- package/lowcode/data-source-form/constants.ts +3 -0
- package/lowcode/data-source-form/utils.ts +31 -5
- package/lowcode/data-source-sub-form/meta.ts +259 -0
- package/lowcode/data-source-sub-form/snippets.ts +21 -0
- package/lowcode/form-item-record-list-wrapper/meta.ts +180 -0
- package/lowcode/form-item-record-list-wrapper/snippets.ts +18 -0
- package/lowcode/form-item-tabs/meta.ts +172 -0
- package/package.json +3 -3
- package/es/components/PisellCards/components/GraphicTextCard/components/BadgeWrapper.d.ts +0 -5
- package/es/components/PisellCards/components/GraphicTextCard/components/TextContent.d.ts +0 -27
- package/es/components/PisellCards/components/GraphicTextCard/hooks/index.d.ts +0 -5
- package/es/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardClick.d.ts +0 -15
- package/es/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardStyle.d.ts +0 -18
- package/es/components/PisellCards/components/GraphicTextCard/types.d.ts +0 -290
- package/es/components/PisellCards/components/GraphicTextCard/utils/index.d.ts +0 -19
- package/es/components/PisellCards/components/TextCard/TextCard.d.ts +0 -8
- package/es/components/PisellCards/components/TextCard/components/BadgeWrapper.d.ts +0 -26
- package/es/components/PisellCards/components/TextCard/components/IconWrapper.d.ts +0 -17
- package/es/components/PisellCards/components/TextCard/components/TextContent.d.ts +0 -21
- package/es/components/PisellCards/components/TextCard/components/index.d.ts +0 -6
- package/es/components/PisellCards/components/TextCard/index.d.ts +0 -5
- package/es/components/PisellCards/components/TextCard/types.d.ts +0 -270
- package/es/components/PisellCards/index.d.ts +0 -15
- package/es/components/config-provider/index.d.ts +0 -10
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -84
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +0 -27
- package/es/components/dataSourceComponents/fields/Upload/constants.d.ts +0 -9
- package/es/components/drag-sort-tree/index.d.ts +0 -5
- package/es/components/filter/components/Dropdown/types.d.ts +0 -13
- package/es/components/filter/components/FilterButton/types.d.ts +0 -24
- package/es/components/filter/types.d.ts +0 -48
- package/es/components/login-and-register/index.d.ts +0 -82
- package/es/components/pisellCurrency/PisellCurrency.d.ts +0 -39
- package/es/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +0 -24
- package/es/components/pisellEmail/PisellEmail.d.ts +0 -37
- package/es/components/pisellFilter/type.d.ts +0 -5
- package/es/components/pisellGridPro/index.d.ts +0 -4
- package/es/components/pisellLongText/PisellLongText.d.ts +0 -39
- package/es/components/pisellMultipleSelect/PisellMultipleSelect.d.ts +0 -9
- package/es/components/pisellMultipleSelect/components/EditView.d.ts +0 -8
- package/es/components/pisellNumber/PisellNumber.d.ts +0 -42
- package/es/components/pisellPhone/PisellPhone.d.ts +0 -36
- package/es/components/pisellPhone/components/EditView.d.ts +0 -19
- package/es/components/pisellPhone/constants/countryCodes.d.ts +0 -20
- package/es/components/pisellPhone/types.d.ts +0 -209
- package/es/components/pisellPhone/utils/countryCodeHelper.d.ts +0 -35
- package/es/components/pisellQuickFilter/type.d.ts +0 -12
- package/es/components/pisellRating/PisellRating.d.ts +0 -31
- package/es/components/pisellRecordBoard/shellFrame/BatchActionBar/index.d.ts +0 -8
- package/es/components/pisellRecordBoard/shellFrame/Search/index.d.ts +0 -10
- package/es/components/pisellRecordBoard/shellFrame/ToolBarReset/index.d.ts +0 -16
- package/es/components/pisellSingleLineText/PisellSingleLineText.d.ts +0 -40
- package/es/components/pisellSingleSelect/PisellSingleSelect.d.ts +0 -9
- package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +0 -32
- package/es/components/pisellUrl/PisellUrl.d.ts +0 -37
- package/es/components/productCard/components/Header/DeleteButton/index.d.ts +0 -4
- package/es/components/productCard/components/Time/components/SelectHolder/index.d.ts +0 -4
- package/es/components/productCard/components/Time/components/SelectResource/index.d.ts +0 -19
- package/es/components/sort/index.d.ts +0 -5
- package/es/components/table/Actions/component/ViewMode/index.d.ts +0 -9
- package/es/components/table/Gallery/components/GalleryItem/index.d.ts +0 -14
- package/es/components/table/types.d.ts +0 -268
- package/es/components/translation/index.d.ts +0 -17
- package/es/components/translation/utils.d.ts +0 -9
- package/lib/components/PisellCards/components/GraphicTextCard/components/BadgeWrapper.d.ts +0 -5
- package/lib/components/PisellCards/components/GraphicTextCard/components/TextContent.d.ts +0 -27
- package/lib/components/PisellCards/components/GraphicTextCard/hooks/index.d.ts +0 -5
- package/lib/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardClick.d.ts +0 -15
- package/lib/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardStyle.d.ts +0 -18
- package/lib/components/PisellCards/components/GraphicTextCard/types.d.ts +0 -290
- package/lib/components/PisellCards/components/GraphicTextCard/utils/index.d.ts +0 -19
- package/lib/components/PisellCards/components/TextCard/TextCard.d.ts +0 -8
- package/lib/components/PisellCards/components/TextCard/components/BadgeWrapper.d.ts +0 -26
- package/lib/components/PisellCards/components/TextCard/components/IconWrapper.d.ts +0 -17
- package/lib/components/PisellCards/components/TextCard/components/TextContent.d.ts +0 -21
- package/lib/components/PisellCards/components/TextCard/components/index.d.ts +0 -6
- package/lib/components/PisellCards/components/TextCard/index.d.ts +0 -5
- package/lib/components/PisellCards/components/TextCard/types.d.ts +0 -270
- package/lib/components/PisellCards/index.d.ts +0 -15
- package/lib/components/config-provider/index.d.ts +0 -10
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +0 -84
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +0 -27
- package/lib/components/dataSourceComponents/fields/Upload/constants.d.ts +0 -9
- package/lib/components/drag-sort-tree/index.d.ts +0 -5
- package/lib/components/filter/components/Dropdown/types.d.ts +0 -13
- package/lib/components/filter/components/FilterButton/types.d.ts +0 -24
- package/lib/components/filter/types.d.ts +0 -48
- package/lib/components/login-and-register/index.d.ts +0 -82
- package/lib/components/pisellCurrency/PisellCurrency.d.ts +0 -39
- package/lib/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +0 -24
- package/lib/components/pisellEmail/PisellEmail.d.ts +0 -37
- package/lib/components/pisellFilter/type.d.ts +0 -5
- package/lib/components/pisellGridPro/index.d.ts +0 -4
- package/lib/components/pisellLongText/PisellLongText.d.ts +0 -39
- package/lib/components/pisellMultipleSelect/PisellMultipleSelect.d.ts +0 -9
- package/lib/components/pisellMultipleSelect/components/EditView.d.ts +0 -8
- package/lib/components/pisellNumber/PisellNumber.d.ts +0 -42
- package/lib/components/pisellPhone/PisellPhone.d.ts +0 -36
- package/lib/components/pisellPhone/components/EditView.d.ts +0 -19
- package/lib/components/pisellPhone/constants/countryCodes.d.ts +0 -20
- package/lib/components/pisellPhone/types.d.ts +0 -209
- package/lib/components/pisellPhone/utils/countryCodeHelper.d.ts +0 -35
- package/lib/components/pisellQuickFilter/type.d.ts +0 -12
- package/lib/components/pisellRating/PisellRating.d.ts +0 -31
- package/lib/components/pisellRecordBoard/shellFrame/BatchActionBar/index.d.ts +0 -8
- package/lib/components/pisellRecordBoard/shellFrame/Search/index.d.ts +0 -10
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarReset/index.d.ts +0 -16
- package/lib/components/pisellSingleLineText/PisellSingleLineText.d.ts +0 -40
- package/lib/components/pisellSingleSelect/PisellSingleSelect.d.ts +0 -9
- package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +0 -32
- package/lib/components/pisellUrl/PisellUrl.d.ts +0 -37
- package/lib/components/productCard/components/Header/DeleteButton/index.d.ts +0 -4
- package/lib/components/productCard/components/Time/components/SelectHolder/index.d.ts +0 -4
- package/lib/components/productCard/components/Time/components/SelectResource/index.d.ts +0 -19
- package/lib/components/sort/index.d.ts +0 -5
- package/lib/components/table/Actions/component/ViewMode/index.d.ts +0 -9
- package/lib/components/table/Gallery/components/GalleryItem/index.d.ts +0 -14
- package/lib/components/table/types.d.ts +0 -268
- package/lib/components/translation/index.d.ts +0 -17
- package/lib/components/translation/utils.d.ts +0 -9
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
systemFields,
|
|
6
6
|
formItemMetaMap,
|
|
7
7
|
} from './constants';
|
|
8
|
+
import { parseXRecordSchemaToChildSchemas } from '../data-source-sub-form/meta';
|
|
8
9
|
|
|
9
10
|
type UiSchema = {
|
|
10
11
|
title: string;
|
|
@@ -30,7 +31,8 @@ type UiSchema = {
|
|
|
30
31
|
dataSource?: any;
|
|
31
32
|
extraParams?: Record<string, any>;
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
+
'x-record-schema'?: Record<string, any> | Record<string, any>[] | string;
|
|
35
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
// 创建表单组
|
|
@@ -131,6 +133,7 @@ export const createFormItemSchema = (
|
|
|
131
133
|
item: {
|
|
132
134
|
name: string;
|
|
133
135
|
uiSchema: UiSchema;
|
|
136
|
+
schema?: Record<string, any>;
|
|
134
137
|
children?: any[];
|
|
135
138
|
_children?: any[];
|
|
136
139
|
interface?: string;
|
|
@@ -303,12 +306,33 @@ export const createFormItemSchema = (
|
|
|
303
306
|
componentName = 'Translation';
|
|
304
307
|
}
|
|
305
308
|
|
|
309
|
+
// 注入默认值
|
|
310
|
+
props.defaultValue = defaultValue;
|
|
311
|
+
|
|
306
312
|
// 获取选项配置
|
|
307
|
-
const dataSourceConfig = (uiSchema as any)?.['x-data-source'];
|
|
313
|
+
const dataSourceConfig = (uiSchema as any)?.['x-data-source'] || item?.schema?.['x-data-source'];
|
|
314
|
+
const recordSchemaConfig = (uiSchema as any)?.['x-record-schema'] || item?.schema?.['x-record-schema'];
|
|
315
|
+
const isRecordListWrapper =
|
|
316
|
+
item?.interface === 'RecordListWrapper' || xComponent === 'RecordListWrapper';
|
|
317
|
+
|
|
318
|
+
if (isRecordListWrapper) {
|
|
319
|
+
cptTitle = '记录列表包装器';
|
|
320
|
+
componentName = 'RecordListWrapper';
|
|
321
|
+
props.xRecordSchema = recordSchemaConfig;
|
|
322
|
+
|
|
323
|
+
// 自动将 recordSchemaConfig 解析为子节点 Schema,与 JsonSetter 的 setValue 保持一致,
|
|
324
|
+
// 避免用户必须在低代码面板手动触发 JsonSetter 才能渲染子表单字段。
|
|
325
|
+
if (recordSchemaConfig) {
|
|
326
|
+
childrenSchema = parseXRecordSchemaToChildSchemas(recordSchemaConfig);
|
|
327
|
+
} else {
|
|
328
|
+
childrenSchema = [];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
308
331
|
|
|
309
332
|
if (
|
|
310
|
-
['Select', 'Radio.Group', 'Checkbox.Group'].includes(xComponent)
|
|
311
|
-
|
|
333
|
+
(['Select', 'Radio.Group', 'Checkbox.Group'].includes(xComponent) ||
|
|
334
|
+
isRecordListWrapper) &&
|
|
335
|
+
(uiSchema?.enum?.length > 0 || dataSourceConfig || isRecordListWrapper)
|
|
312
336
|
) {
|
|
313
337
|
if (['Radio.Group', 'Checkbox.Group'].includes(xComponent)) {
|
|
314
338
|
props.direction = 'horizontal';
|
|
@@ -343,7 +367,7 @@ export const createFormItemSchema = (
|
|
|
343
367
|
const optionConfig = dataSourceConfig || {};
|
|
344
368
|
|
|
345
369
|
// 设置 optionSourceType
|
|
346
|
-
props.optionSourceType = optionConfig?.type || '
|
|
370
|
+
props.optionSourceType = optionConfig?.type || '';
|
|
347
371
|
|
|
348
372
|
// 根据 sourceType 设置不同的配置
|
|
349
373
|
if (props.optionSourceType === 'default') {
|
|
@@ -427,6 +451,8 @@ export const createFormItemSchema = (
|
|
|
427
451
|
schemaType = type as any;
|
|
428
452
|
} else if (xComponent === 'InputNumber' || xComponent === 'Percent') {
|
|
429
453
|
schemaType = 'number';
|
|
454
|
+
} else if (componentName === 'RecordListWrapper') {
|
|
455
|
+
schemaType = 'array';
|
|
430
456
|
} else if (xComponent === 'Input.JSON' || item?.interface === 'i18nInput') {
|
|
431
457
|
schemaType = 'object';
|
|
432
458
|
} else if (['Checkbox.Group', 'Select'].includes(xComponent) && props.mode === 'multiple') {
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import snippets from './snippets';
|
|
2
|
+
import { createFormItemSchema } from '../data-source-form/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @title 将 xRecordSchema JSON 字段定义转换为低代码子组件 Schema
|
|
6
|
+
* @description
|
|
7
|
+
* 解析 xRecordSchema(支持单对象、数组、字符串),对每个字段补全 uiSchema,
|
|
8
|
+
* 调用 createFormItemSchema 生成低代码引擎可识别的组件 Schema。
|
|
9
|
+
*/
|
|
10
|
+
export const parseXRecordSchemaToChildSchemas = (value: any): any[] => {
|
|
11
|
+
let fields = value;
|
|
12
|
+
|
|
13
|
+
// 解析字符串
|
|
14
|
+
if (typeof fields === 'string') {
|
|
15
|
+
try {
|
|
16
|
+
fields = JSON.parse(fields);
|
|
17
|
+
} catch {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!fields) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 处理 properties 格式
|
|
27
|
+
if (fields.properties && typeof fields.properties === 'object') {
|
|
28
|
+
fields = Object.keys(fields.properties).map((name) => ({
|
|
29
|
+
...fields.properties[name],
|
|
30
|
+
name,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 处理 fields 格式
|
|
35
|
+
if (fields.fields && Array.isArray(fields.fields)) {
|
|
36
|
+
fields = fields.fields;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 处理 children 格式
|
|
40
|
+
if (fields.children && Array.isArray(fields.children)) {
|
|
41
|
+
fields = fields.children;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 单对象转数组
|
|
45
|
+
if (!Array.isArray(fields)) {
|
|
46
|
+
fields = [fields];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 补全每个字段的 uiSchema 并生成子组件 Schema
|
|
50
|
+
return fields
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.map((field: any) => {
|
|
53
|
+
const uiSchema = { ...(field.uiSchema || {}) };
|
|
54
|
+
|
|
55
|
+
// 从 interface 映射 x-component(如 Select、Input 等)
|
|
56
|
+
if (!uiSchema['x-component'] && field.interface) {
|
|
57
|
+
uiSchema['x-component'] = field.interface;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 兼容简单格式(只有 componentName/component,没有 interface 和 uiSchema)
|
|
61
|
+
if (!uiSchema['x-component']) {
|
|
62
|
+
uiSchema['x-component'] =
|
|
63
|
+
field.componentName || field.component || 'Input';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 从 field.type 映射 uiSchema.type
|
|
67
|
+
if (!uiSchema.type && field.type) {
|
|
68
|
+
uiSchema.type = field.type;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 确保 title 存在(用于生成 label)
|
|
72
|
+
if (!uiSchema.title && field.label) {
|
|
73
|
+
uiSchema.title = field.label;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return createFormItemSchema({ ...field, uiSchema }, 'edit');
|
|
77
|
+
})
|
|
78
|
+
.filter((schema: any) => !!schema?.componentName);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default {
|
|
82
|
+
snippets,
|
|
83
|
+
componentName: 'DataSourceSubForm',
|
|
84
|
+
title: '子表单',
|
|
85
|
+
category: '无代码表单',
|
|
86
|
+
group: '无代码组件',
|
|
87
|
+
docUrl: '',
|
|
88
|
+
screenshot: '',
|
|
89
|
+
devMode: 'proCode',
|
|
90
|
+
npm: {
|
|
91
|
+
package: '@pisell/materials',
|
|
92
|
+
version: '1.0.3',
|
|
93
|
+
exportName: 'DataSourceSubForm',
|
|
94
|
+
main: 'src/index.tsx',
|
|
95
|
+
destructuring: true,
|
|
96
|
+
subName: '',
|
|
97
|
+
},
|
|
98
|
+
generalProps: [
|
|
99
|
+
{
|
|
100
|
+
type: 'group',
|
|
101
|
+
title: {
|
|
102
|
+
type: 'i18n',
|
|
103
|
+
'en-US': 'Data',
|
|
104
|
+
'zh-CN': '数据',
|
|
105
|
+
},
|
|
106
|
+
display: 'accordion',
|
|
107
|
+
items: [
|
|
108
|
+
{
|
|
109
|
+
name: 'value',
|
|
110
|
+
title: {
|
|
111
|
+
label: {
|
|
112
|
+
type: 'i18n',
|
|
113
|
+
'en-US': 'Value',
|
|
114
|
+
'zh-CN': '表单值',
|
|
115
|
+
},
|
|
116
|
+
tip: {
|
|
117
|
+
type: 'i18n',
|
|
118
|
+
'en-US': 'Form value object',
|
|
119
|
+
'zh-CN': '表单值对象',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
setter: ['JsonSetter', 'VariableSetter'],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'xRecordSchema',
|
|
126
|
+
title: {
|
|
127
|
+
label: {
|
|
128
|
+
type: 'i18n',
|
|
129
|
+
'en-US': 'Record Schema',
|
|
130
|
+
'zh-CN': '字段配置',
|
|
131
|
+
},
|
|
132
|
+
tip: {
|
|
133
|
+
type: 'i18n',
|
|
134
|
+
'en-US':
|
|
135
|
+
'Define form fields structure, supports JSON string, array, or object format',
|
|
136
|
+
'zh-CN': '定义表单字段结构,支持 JSON 字符串、数组或对象格式',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
setter: ['JsonSetter', 'StringSetter', 'VariableSetter'],
|
|
140
|
+
extraProps: {
|
|
141
|
+
setValue(target: any, value: any) {
|
|
142
|
+
// 先写入 prop 值,确保持久化
|
|
143
|
+
const result = target.getProps().setPropValue('xRecordSchema', value);
|
|
144
|
+
|
|
145
|
+
const parsedSchemas = parseXRecordSchemaToChildSchemas(value);
|
|
146
|
+
|
|
147
|
+
// 先清空现有子节点,避免第二次及之后调用时 importSchema 做 diff/merge 导致节点数量异常
|
|
148
|
+
target.node.children.importSchema([]);
|
|
149
|
+
// 节点刚添加时可能尚未挂载完成,用 setTimeout 错开时序
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
target.node.children.importSchema(parsedSchemas);
|
|
152
|
+
// replaceSchema 后有概率不触发重渲染,手动 rerender
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
target.document?.project?.simulatorHost?.rerender();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
return result;
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'group',
|
|
166
|
+
title: {
|
|
167
|
+
type: 'i18n',
|
|
168
|
+
'en-US': 'Appearance',
|
|
169
|
+
'zh-CN': '外观',
|
|
170
|
+
},
|
|
171
|
+
display: 'accordion',
|
|
172
|
+
items: [
|
|
173
|
+
{
|
|
174
|
+
name: 'renderMode',
|
|
175
|
+
title: {
|
|
176
|
+
label: {
|
|
177
|
+
type: 'i18n',
|
|
178
|
+
'en-US': 'Render Mode',
|
|
179
|
+
'zh-CN': '渲染模式',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
defaultValue: 'edit',
|
|
183
|
+
setter: [
|
|
184
|
+
{
|
|
185
|
+
componentName: 'RadioGroupSetter',
|
|
186
|
+
props: {
|
|
187
|
+
options: [
|
|
188
|
+
{ title: '编辑', value: 'edit' },
|
|
189
|
+
{ title: '禁用', value: 'disabled' },
|
|
190
|
+
{ title: '预览', value: 'preview' },
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
'VariableSetter',
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'layout',
|
|
199
|
+
title: {
|
|
200
|
+
label: {
|
|
201
|
+
type: 'i18n',
|
|
202
|
+
'en-US': 'Layout',
|
|
203
|
+
'zh-CN': '布局方式',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
defaultValue: 'vertical',
|
|
207
|
+
setter: [
|
|
208
|
+
{
|
|
209
|
+
componentName: 'RadioGroupSetter',
|
|
210
|
+
props: {
|
|
211
|
+
options: [
|
|
212
|
+
{ title: '垂直', value: 'vertical' },
|
|
213
|
+
{ title: '水平', value: 'horizontal' },
|
|
214
|
+
{ title: '行内', value: 'inline' },
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
'VariableSetter',
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
configure: {
|
|
225
|
+
props: [
|
|
226
|
+
{
|
|
227
|
+
name: 'onChange',
|
|
228
|
+
title: {
|
|
229
|
+
label: {
|
|
230
|
+
type: 'i18n',
|
|
231
|
+
'en-US': 'On Change',
|
|
232
|
+
'zh-CN': '值变化回调',
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
setter: {
|
|
236
|
+
componentName: 'FunctionSetter',
|
|
237
|
+
props: {
|
|
238
|
+
template:
|
|
239
|
+
'onChange(value,${extParams}){\n// 表单值变化时触发\nconsole.log("onChange", value);\n}',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
component: {
|
|
245
|
+
isContainer: true,
|
|
246
|
+
},
|
|
247
|
+
supports: {
|
|
248
|
+
style: true,
|
|
249
|
+
className: true,
|
|
250
|
+
events: [
|
|
251
|
+
{
|
|
252
|
+
name: 'onChange',
|
|
253
|
+
template:
|
|
254
|
+
'onChange(value,${extParams}){\n// 表单值变化时触发\nconsole.log("onChange", value);\n}',
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title DataSourceSubForm 组件片段
|
|
3
|
+
* @description 定义组件在低代码平台中的初始配置
|
|
4
|
+
*/
|
|
5
|
+
const snippets = [
|
|
6
|
+
{
|
|
7
|
+
title: '子表单',
|
|
8
|
+
screenshot: '',
|
|
9
|
+
schema: {
|
|
10
|
+
componentName: 'DataSourceSubForm',
|
|
11
|
+
props: {
|
|
12
|
+
renderMode: 'edit',
|
|
13
|
+
layout: 'vertical',
|
|
14
|
+
value: {},
|
|
15
|
+
xRecordSchema: [],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export default snippets;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import snippets from './snippets';
|
|
2
|
+
import {
|
|
3
|
+
formItemGeneralDataGroup,
|
|
4
|
+
generalItemMap,
|
|
5
|
+
getFormItemGeneralInfoGroup,
|
|
6
|
+
formItemGeneralOptionTypeGroup,
|
|
7
|
+
} from '../_utils/defaultSchema';
|
|
8
|
+
import { parseXRecordSchemaToChildSchemas } from '../data-source-sub-form/meta';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
snippets,
|
|
12
|
+
componentName: 'FormItemRecordListWrapper',
|
|
13
|
+
title: '记录列表包装器',
|
|
14
|
+
category: '无代码表单',
|
|
15
|
+
group: '无代码组件',
|
|
16
|
+
docUrl: '',
|
|
17
|
+
screenshot: '',
|
|
18
|
+
devMode: 'proCode',
|
|
19
|
+
npm: {
|
|
20
|
+
package: '@pisell/materials',
|
|
21
|
+
version: '1.0.1',
|
|
22
|
+
exportName: 'FormItemRecordListWrapper',
|
|
23
|
+
main: 'src/index.tsx',
|
|
24
|
+
destructuring: true,
|
|
25
|
+
subName: '',
|
|
26
|
+
},
|
|
27
|
+
generalProps: [
|
|
28
|
+
// 数据分组
|
|
29
|
+
formItemGeneralDataGroup,
|
|
30
|
+
// 信息分组
|
|
31
|
+
getFormItemGeneralInfoGroup([
|
|
32
|
+
generalItemMap['label'],
|
|
33
|
+
generalItemMap['placeholder'],
|
|
34
|
+
generalItemMap['tooltip'],
|
|
35
|
+
generalItemMap['extra'],
|
|
36
|
+
generalItemMap['hideLabel'],
|
|
37
|
+
generalItemMap['renderMode'],
|
|
38
|
+
generalItemMap['defaultValue'],
|
|
39
|
+
]),
|
|
40
|
+
// 选项类型分组
|
|
41
|
+
formItemGeneralOptionTypeGroup,
|
|
42
|
+
// Schema 分组
|
|
43
|
+
{
|
|
44
|
+
type: 'group',
|
|
45
|
+
title: {
|
|
46
|
+
type: 'i18n',
|
|
47
|
+
'en-US': 'Schema',
|
|
48
|
+
'zh-CN': 'Schema',
|
|
49
|
+
},
|
|
50
|
+
display: 'accordion',
|
|
51
|
+
items: [
|
|
52
|
+
{
|
|
53
|
+
name: 'xRecordSchema',
|
|
54
|
+
title: {
|
|
55
|
+
label: {
|
|
56
|
+
type: 'i18n',
|
|
57
|
+
'en-US': 'Record Schema',
|
|
58
|
+
'zh-CN': '记录字段配置',
|
|
59
|
+
},
|
|
60
|
+
tip: {
|
|
61
|
+
type: 'i18n',
|
|
62
|
+
'en-US':
|
|
63
|
+
'Define the fields for each record. When configured, the system will automatically generate form fields based on the schema. You can also manually drag form items into the container.',
|
|
64
|
+
'zh-CN':
|
|
65
|
+
'定义每条记录的字段结构。配置后,系统会自动根据 Schema 生成表单字段。你也可以手动拖拽表单项到容器中。',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
propType: 'string',
|
|
69
|
+
setter: 'JsonSetter',
|
|
70
|
+
description: `
|
|
71
|
+
示例配置:
|
|
72
|
+
[
|
|
73
|
+
{
|
|
74
|
+
"name": "code",
|
|
75
|
+
"uiSchema": {
|
|
76
|
+
"title": "代码",
|
|
77
|
+
"x-component": "Input",
|
|
78
|
+
"x-component-props": {
|
|
79
|
+
"placeholder": "请输入代码"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "type",
|
|
85
|
+
"uiSchema": {
|
|
86
|
+
"title": "类型",
|
|
87
|
+
"x-component": "Select",
|
|
88
|
+
"enum": [
|
|
89
|
+
{ "label": "类型A", "value": "a" },
|
|
90
|
+
{ "label": "类型B", "value": "b" }
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
`,
|
|
96
|
+
extraProps: {
|
|
97
|
+
/**
|
|
98
|
+
* 当 xRecordSchema 值变化时,解析 JSON 并生成子组件节点
|
|
99
|
+
*/
|
|
100
|
+
setValue(target: any, value: any) {
|
|
101
|
+
const result = target
|
|
102
|
+
.getProps()
|
|
103
|
+
.setPropValue('xRecordSchema', value);
|
|
104
|
+
|
|
105
|
+
const parsedSchemas = parseXRecordSchemaToChildSchemas(value);
|
|
106
|
+
|
|
107
|
+
// 先清空现有子节点,避免第二次及之后调用时 importSchema 做 diff/merge 导致节点数量异常
|
|
108
|
+
target.node.children.importSchema([]);
|
|
109
|
+
// 节点刚添加时可能尚未挂载完成,用 setTimeout 错开时序
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
target.node.children.importSchema(parsedSchemas);
|
|
112
|
+
// replaceSchema 后有概率不触发重渲染,手动 rerender
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
target.document?.project?.simulatorHost?.rerender();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return result;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
// 插槽分组
|
|
125
|
+
{
|
|
126
|
+
type: 'group',
|
|
127
|
+
title: {
|
|
128
|
+
type: 'i18n',
|
|
129
|
+
'en-US': 'Slot',
|
|
130
|
+
'zh-CN': '插槽',
|
|
131
|
+
},
|
|
132
|
+
display: 'accordion',
|
|
133
|
+
items: [
|
|
134
|
+
{
|
|
135
|
+
name: 'topSlot',
|
|
136
|
+
title: {
|
|
137
|
+
label: {
|
|
138
|
+
type: 'i18n',
|
|
139
|
+
'en-US': 'Tab Area',
|
|
140
|
+
'zh-CN': 'Tab 区域',
|
|
141
|
+
},
|
|
142
|
+
tip: {
|
|
143
|
+
type: 'i18n',
|
|
144
|
+
'en-US':
|
|
145
|
+
'Drag a component here to customize the tab navigation. The component will receive options, value, and onChange props.',
|
|
146
|
+
'zh-CN':
|
|
147
|
+
'拖入自定义组件来替换默认 Tab 导航。组件会自动接收 options、value、onChange 属性。',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
setter: {
|
|
151
|
+
componentName: 'SlotSetter',
|
|
152
|
+
initialValue: {
|
|
153
|
+
type: 'JSSlot',
|
|
154
|
+
value: [],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
configure: {
|
|
162
|
+
component: {
|
|
163
|
+
isContainer: true,
|
|
164
|
+
},
|
|
165
|
+
supports: {
|
|
166
|
+
style: true,
|
|
167
|
+
events: [
|
|
168
|
+
{ name: 'onChange', template: 'onChange(value,${extParams}){}' },
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
advanced: {
|
|
172
|
+
callbacks: {
|
|
173
|
+
// 当拖入新组件时的回调
|
|
174
|
+
onNodeAdd: (dragment: any, currentNode: any) => {
|
|
175
|
+
console.log('RecordListWrapper: 新增子组件', dragment?.componentName);
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const snippets = [
|
|
2
|
+
{
|
|
3
|
+
title: '记录列表包装器',
|
|
4
|
+
screenshot: '',
|
|
5
|
+
schema: {
|
|
6
|
+
componentName: 'FormItemRecordListWrapper',
|
|
7
|
+
props: {
|
|
8
|
+
label: '记录列表',
|
|
9
|
+
name: 'recordList',
|
|
10
|
+
optionSourceType: 'default',
|
|
11
|
+
options: [],
|
|
12
|
+
xRecordSchema: null,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export default snippets;
|