@gct-paas/schema 0.1.4-dev.11 → 0.1.4-dev.13

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/es/index.mjs CHANGED
@@ -1,12 +1,10 @@
1
- export { cloneWidget, createdSearchField, deepFindNotField, getCompPos, isFormFieldType, setChildrenId, transformI18n } from './utils/schema/index.mjs';
2
- export { ALIGN_TO_FLEX_MAP, addImportant, addPxUnit, extractFontStyle, formatBorder, generateBorderStyles, generatePositionStyles, generateSpacingStyles, generateWrapperStyle, makeStyleProp, propsToStyle, pxToVw, transAlign2flex } from './utils/schema-style/index.mjs';
3
- export { getWidgetInfo, mobileWidgetInfo, padWidgetInfo, registerMobilePluginWidgetItem, registerMobileWidgetItem, registerPadPluginWidgetItem, registerPadWidgetItem, registerPluginWidgetItem, registerWebPluginWidgetItem, registerWebWidgetItem, registerWidgetItem, webWidgetInfo } from './utils/widget-info/widget-info.mjs';
4
- export { SEARCH_TYPE, padVTableSupportEditFieldTypes } from './constants/index.mjs';
5
- export { convertMappingType, flatten, transformMappingField, transformMappingField4Auto } from './utils/schema/utils.mjs';
6
-
7
- const index = {
8
- install() {
9
- }
10
- };
11
-
12
- export { index as default };
1
+ import { getWidgetInfo, mobileWidgetInfo, padWidgetInfo, registerMobilePluginWidgetItem, registerMobileWidgetItem, registerPadPluginWidgetItem, registerPadWidgetItem, registerPluginWidgetItem, registerWebPluginWidgetItem, registerWebWidgetItem, registerWidgetItem, webWidgetInfo } from "./utils/widget-info/widget-info.mjs";
2
+ import { DatepickerTypes, SEARCH_TYPE, padVTableSupportEditFieldTypes } from "./constants/index.mjs";
3
+ import { convertMappingType, flatten, transformMappingField, transformMappingField4Auto } from "./utils/schema/utils.mjs";
4
+ import { cloneWidget, createdSearchField, deepFindNotField, getCompPos, isFormFieldType, setChildrenId, transformI18n } from "./utils/schema/index.mjs";
5
+ import { ALIGN_TO_FLEX_MAP, addImportant, addPxUnit, extractFontStyle, formatBorder, generateBorderStyles, generatePositionStyles, generateSpacingStyles, generateWrapperStyle, makeStyleProp, propsToStyle, pxToVw, transAlign2flex } from "./utils/schema-style/index.mjs";
6
+ import "./utils/index.mjs";
7
+ //#region src/index.ts
8
+ var src_default = { install() {} };
9
+ //#endregion
10
+ export { ALIGN_TO_FLEX_MAP, DatepickerTypes, SEARCH_TYPE, addImportant, addPxUnit, cloneWidget, convertMappingType, createdSearchField, deepFindNotField, src_default as default, extractFontStyle, flatten, formatBorder, generateBorderStyles, generatePositionStyles, generateSpacingStyles, generateWrapperStyle, getCompPos, getWidgetInfo, isFormFieldType, makeStyleProp, mobileWidgetInfo, padVTableSupportEditFieldTypes, padWidgetInfo, propsToStyle, pxToVw, registerMobilePluginWidgetItem, registerMobileWidgetItem, registerPadPluginWidgetItem, registerPadWidgetItem, registerPluginWidgetItem, registerWebPluginWidgetItem, registerWebWidgetItem, registerWidgetItem, setChildrenId, transAlign2flex, transformI18n, transformMappingField, transformMappingField4Auto, webWidgetInfo };
@@ -4,3 +4,4 @@ export type * from './schema';
4
4
  export type * from './widget';
5
5
  export type * from './widget-info';
6
6
  export type * from './designer';
7
+ export type * from './relationship-diagram-config';
@@ -0,0 +1,82 @@
1
+ /**
2
+ * 节点
3
+ *
4
+ * @author zhanghanrui
5
+ * @date 2024-06-25 10:06:53
6
+ * @export
7
+ * @interface IRelationshipDiagramNode
8
+ */
9
+ export interface IRelationshipDiagramNode {
10
+ /**
11
+ * 节点唯一标识
12
+ *
13
+ * @author zhanghanrui
14
+ * @date 2024-06-25 13:06:35
15
+ * @type {string}
16
+ */
17
+ id: string;
18
+ /**
19
+ * 字段唯一标识
20
+ *
21
+ * @author zhanghanrui
22
+ * @date 2024-07-05 10:07:11
23
+ * @type {string | null}
24
+ */
25
+ id_: string | null;
26
+ /**
27
+ * 节点类型
28
+ *
29
+ * @author zhanghanrui
30
+ * @date 2024-06-25 13:06:44
31
+ * @type {string}
32
+ */
33
+ type: string;
34
+ /**
35
+ * 当前模型标识
36
+ *
37
+ * @author zhanghanrui
38
+ * @date 2024-06-26 16:06:15
39
+ * @type {string | null}
40
+ */
41
+ modelKey: string | null;
42
+ /**
43
+ * 模型类型
44
+ *
45
+ * @author zhanghanrui
46
+ * @date 2024-06-26 16:06:30
47
+ * @type {string | null}
48
+ */
49
+ modelCategory: string | null;
50
+ /**
51
+ * 属性key
52
+ *
53
+ * @author zhanghanrui
54
+ * @date 2024-06-26 16:06:46
55
+ * @type {string | null}
56
+ */
57
+ value: string | null;
58
+ /**
59
+ * 属性文本
60
+ *
61
+ * @author zhanghanrui
62
+ * @date 2024-06-26 16:06:56
63
+ * @type {string | null}
64
+ */
65
+ label: string | null;
66
+ /**
67
+ * 是否为反向节点
68
+ *
69
+ * @author zhanghanrui
70
+ * @date 2024-06-28 15:06:46
71
+ * @type {boolean}
72
+ */
73
+ reverse?: boolean;
74
+ /**
75
+ * 禁止选择属性
76
+ *
77
+ * @author zhanghanrui
78
+ * @date 2024-06-28 13:06:52
79
+ * @type {boolean}
80
+ */
81
+ noSelectField?: boolean;
82
+ }
@@ -0,0 +1,135 @@
1
+ import { IRelationshipDiagramNode } from './i-relationship-diagram-node';
2
+ /**
3
+ * 设计 json
4
+ *
5
+ * @author zhanghanrui
6
+ * @date 2024-06-29 17:06:51
7
+ * @export
8
+ * @interface IDesignJson
9
+ */
10
+ export interface IDesignJson {
11
+ /**
12
+ * 前置信息
13
+ *
14
+ * @author zhanghanrui
15
+ * @date 2024-06-29 17:06:58
16
+ * @type {IData}
17
+ */
18
+ before?: IData;
19
+ /**
20
+ * 节点信息
21
+ *
22
+ * @author zhanghanrui
23
+ * @date 2024-06-29 17:06:10
24
+ * @type {IRelationshipDiagramNode[]}
25
+ */
26
+ nodes: IRelationshipDiagramNode[];
27
+ /**
28
+ * 后置信息
29
+ *
30
+ * @author zhanghanrui
31
+ * @date 2024-06-29 17:06:08
32
+ * @type {IData}
33
+ */
34
+ after?: IData;
35
+ }
36
+ export interface INodeData {
37
+ /**
38
+ * 模型标识
39
+ *
40
+ * @author zhanghanrui
41
+ * @date 2024-06-29 17:06:38
42
+ * @type {string}
43
+ */
44
+ modelKey: string;
45
+ /**
46
+ * 模型类型
47
+ *
48
+ * @author zhanghanrui
49
+ * @date 2024-06-29 17:06:06
50
+ * @type {string}
51
+ */
52
+ modelCategory: string;
53
+ /**
54
+ * 属性标识
55
+ *
56
+ * @author zhanghanrui
57
+ * @date 2024-06-29 17:06:42
58
+ * @type {string}
59
+ */
60
+ fieldKey: string;
61
+ /**
62
+ * 节点方向
63
+ *
64
+ * @author zhanghanrui
65
+ * @date 2024-06-29 17:06:47
66
+ * @type {('forward' | 'backward' | '')}
67
+ */
68
+ direction: 'forward' | 'backward' | '';
69
+ }
70
+ /**
71
+ * 数据联动 ruleConfig 配置清单
72
+ *
73
+ * @author zhanghanrui
74
+ * @date 2024-06-29 17:06:29
75
+ * @export
76
+ * @interface IRuleConfig
77
+ */
78
+ export interface IRuleConfig {
79
+ /**
80
+ * 设计 json 配置
81
+ *
82
+ * @author zhanghanrui
83
+ * @date 2024-06-29 17:06:31
84
+ * @type {IDesignJson}
85
+ */
86
+ designJson: IDesignJson;
87
+ /**
88
+ * 是否强依赖
89
+ *
90
+ * @author zhanghanrui
91
+ * @date 2024-09-02 15:09:15
92
+ * @type {boolean}
93
+ */
94
+ strongDependence: boolean;
95
+ /**
96
+ * 主查字段名称
97
+ *
98
+ * @author zhanghanrui
99
+ * @date 2024-06-29 19:06:48
100
+ * @type {string}
101
+ */
102
+ modelKey: string;
103
+ /**
104
+ * 属性标识(不是所有场景都有)
105
+ *
106
+ * @author zhanghanrui
107
+ * @date 2024-07-05 11:07:25
108
+ * @type {string}
109
+ */
110
+ fieldId?: string;
111
+ /**
112
+ * 属性标识(不是所有场景都有)
113
+ *
114
+ * @author zhanghanrui
115
+ * @date 2024-06-29 17:06:47
116
+ * @type {string}
117
+ */
118
+ fieldKey?: string;
119
+ /**
120
+ * 属性名称
121
+ *
122
+ * @author zhanghanrui
123
+ * @date 2024-06-29 19:06:24
124
+ * @type {string}
125
+ */
126
+ fieldLabel?: string;
127
+ /**
128
+ * 给后台使用的 nodes 清单
129
+ *
130
+ * @author zhanghanrui
131
+ * @date 2024-06-29 17:06:41
132
+ * @type {INodeData[]}
133
+ */
134
+ nodes: INodeData[];
135
+ }
@@ -0,0 +1,2 @@
1
+ export type * from './i-relationship-diagram-node';
2
+ export type * from './i-rule-config';
@@ -0,0 +1,4 @@
1
+ import "./widget-info/widget-info.mjs";
2
+ import "./schema/utils.mjs";
3
+ import "./schema/index.mjs";
4
+ import "./schema-style/index.mjs";
@@ -1,120 +1,128 @@
1
- import { buildShortUUID, t, FieldIconMap, FIELD_TYPE, MaterialEnum, TreeHelper } from '@gct-paas/core';
2
- import { cloneDeep, merge, has } from 'lodash-es';
3
- import { getWidgetInfo } from '../widget-info/widget-info.mjs';
4
- import { transformField2SearchComponent, basicSearchAttrsUtils } from './search.mjs';
5
-
1
+ import { getWidgetInfo } from "../widget-info/widget-info.mjs";
2
+ import { basicSearchAttrsUtils, transformField2SearchComponent } from "./search.mjs";
3
+ import "./utils.mjs";
4
+ import { FIELD_TYPE, FieldIconMap, MaterialEnum, TreeHelper, buildShortUUID, t } from "@gct-paas/core";
5
+ import { cloneDeep, has, merge } from "lodash-es";
6
+ //#region src/utils/schema/index.ts
7
+ /**
8
+ * 获取组件所属位置
9
+ *
10
+ * @export
11
+ * @param {LowCodeWidget.BasicSchema} widget
12
+ * @param {string} fieldType
13
+ * @param {string} componentType
14
+ * @return {*}
15
+ */
6
16
  function getCompPos(widget, fieldType, componentType) {
7
- return widget.type === componentType && has(widget, "preLocation") && new RegExp(`^${fieldType}_`).test(widget.preLocation);
17
+ return widget.type === componentType && has(widget, "preLocation") && new RegExp(`^${fieldType}_`).test(widget.preLocation);
8
18
  }
19
+ /**
20
+ * 是否是表单字段类型
21
+ *
22
+ * @export
23
+ * @param {LowCodeWidget.BasicSchema} widget
24
+ * @return {boolean}
25
+ */
9
26
  function isFormFieldType(widget) {
10
- return [
11
- MaterialEnum.MaterialFormField,
12
- MaterialEnum.MaterialSubTableModalField,
13
- MaterialEnum.DescriptionsFormField
14
- ].includes(widget.materialType);
27
+ return [
28
+ MaterialEnum.MaterialFormField,
29
+ MaterialEnum.MaterialSubTableModalField,
30
+ MaterialEnum.DescriptionsFormField
31
+ ].includes(widget.materialType);
15
32
  }
33
+ /**
34
+ * 初始化国际化处理
35
+ *
36
+ * @export
37
+ * @param {LowCodeWidget.BasicSchema['props']} props
38
+ */
16
39
  function transformI18n(props) {
17
- const reg = /^\$\{(\S+)\}$/;
18
- for (const key in props) {
19
- const value = props[key];
20
- if (reg.test(value)) {
21
- props[key] = t(value.match(reg)?.[1]);
22
- }
23
- }
40
+ const reg = /^\$\{(\S+)\}$/;
41
+ for (const key in props) {
42
+ const value = props[key];
43
+ if (reg.test(value)) props[key] = t(value.match(reg)?.[1]);
44
+ }
24
45
  }
46
+ /**
47
+ * 克隆组件schema
48
+ *
49
+ * @export
50
+ * @param {LowCodeWidget.BasicSchema} widgetSchema
51
+ * @return {*} {LowCodeWidget.BasicSchema}
52
+ */
25
53
  function cloneWidget(widgetSchema) {
26
- const instance = cloneDeep(widgetSchema);
27
- instance.id = buildShortUUID(instance.type);
28
- instance.alias = t(instance.name);
29
- if (instance.formItem) {
30
- instance.props.label = t(instance.name);
31
- }
32
- const widgetInfo = getWidgetInfo(instance.platform);
33
- if (widgetInfo) {
34
- widgetInfo.beforeCreate?.[instance.type]?.(instance);
35
- }
36
- transformI18n(instance.props);
37
- return instance;
54
+ const instance = cloneDeep(widgetSchema);
55
+ instance.id = buildShortUUID(instance.type);
56
+ instance.alias = t(instance.name);
57
+ if (instance.formItem) instance.props.label = t(instance.name);
58
+ const widgetInfo = getWidgetInfo(instance.platform);
59
+ if (widgetInfo) widgetInfo.beforeCreate?.[instance.type]?.(instance);
60
+ transformI18n(instance.props);
61
+ return instance;
38
62
  }
63
+ /**
64
+ * 递归获取所有非字段组件
65
+ *
66
+ * @param {LowCodeWidget.BasicSchema} item
67
+ * @param {string[]} [types=[]]
68
+ * @returns {*} {string[]}
69
+ */
39
70
  function deepFindNotField(item) {
40
- return item.map((node) => ({ ...node })).filter((node) => {
41
- if (node.props?.model) {
42
- return predicate(node);
43
- }
44
- node.children = node.children && deepFindNotField(node.children);
45
- return predicate(node);
46
- });
71
+ return item.map((node) => ({ ...node })).filter((node) => {
72
+ if (node.props?.model) return predicate(node);
73
+ node.children = node.children && deepFindNotField(node.children);
74
+ return predicate(node);
75
+ });
47
76
  }
48
- const predicate = (node) => !node.formItem;
77
+ var predicate = (node) => !node.formItem;
49
78
  function setChildrenId(widget) {
50
- if (widget.children?.length) {
51
- TreeHelper.eachTree(widget.children, (child) => {
52
- child.id = buildShortUUID(child.type);
53
- return child;
54
- });
55
- }
79
+ if (widget.children?.length) TreeHelper.eachTree(widget.children, (child) => {
80
+ child.id = buildShortUUID(child.type);
81
+ return child;
82
+ });
56
83
  }
84
+ /**
85
+ * 创建搜索字段组件
86
+ * @param data
87
+ * @returns
88
+ */
57
89
  function createdSearchField(data) {
58
- const {
59
- field,
60
- fieldId,
61
- fieldName,
62
- fieldCodeChain,
63
- fieldType: comType,
64
- label,
65
- bindModelKey,
66
- modelKey,
67
- returnType,
68
- type,
69
- preLocation,
70
- isFieldModel,
71
- platform
72
- } = data;
73
- const basic = {
74
- id: buildShortUUID(comType),
75
- name: `sys.pageDesigner.fieldCmp.${type || comType}`,
76
- icon: FieldIconMap[type || comType],
77
- isSearchField: true,
78
- preLocation,
79
- platform
80
- };
81
- const fieldType = [FIELD_TYPE.AGG, FIELD_TYPE.EXPRESSION].includes(comType) ? returnType : comType;
82
- data.fieldType = fieldType;
83
- const { searchCmpKey, attrsTransform } = transformField2SearchComponent(fieldType) || {};
84
- if (!searchCmpKey) {
85
- return void 0;
86
- }
87
- const otherAttrs = Object.fromEntries(
88
- attrsTransform.concat([...basicSearchAttrsUtils.ope]).map((row) => {
89
- const value = data[row.from];
90
- return [row.to, row.transform ? row.transform(value) : value];
91
- })
92
- );
93
- merge(
94
- // searchCmp.props,
95
- {
96
- field,
97
- fieldId,
98
- fieldType,
99
- fieldName,
100
- fieldCodeChain,
101
- label,
102
- modelKey,
103
- bindModelKey,
104
- disabled: false,
105
- readonly: false,
106
- modeldata: {
107
- modelCategory: data.modelCategory,
108
- modelType: data.modelType
109
- },
110
- isFieldModel,
111
- ...otherAttrs
112
- }
113
- // searchCmp.props.placeholder && {
114
- // placeholder: t(searchCmp.props.placeholder),
115
- // },
116
- );
117
- return merge(basic);
90
+ const { field, fieldId, fieldName, fieldCodeChain, fieldType: comType, label, bindModelKey, modelKey, returnType, type, preLocation, isFieldModel, platform } = data;
91
+ const basic = {
92
+ id: buildShortUUID(comType),
93
+ name: `sys.pageDesigner.fieldCmp.${type || comType}`,
94
+ icon: FieldIconMap[type || comType],
95
+ isSearchField: true,
96
+ preLocation,
97
+ platform
98
+ };
99
+ const fieldType = [FIELD_TYPE.AGG, FIELD_TYPE.EXPRESSION].includes(comType) ? returnType : comType;
100
+ data.fieldType = fieldType;
101
+ const { searchCmpKey, attrsTransform } = transformField2SearchComponent(fieldType) || {};
102
+ if (!searchCmpKey) return;
103
+ const otherAttrs = Object.fromEntries(attrsTransform.concat([...basicSearchAttrsUtils.ope]).map((row) => {
104
+ const value = data[row.from];
105
+ return [row.to, row.transform ? row.transform(value) : value];
106
+ }));
107
+ merge({
108
+ field,
109
+ fieldId,
110
+ fieldType,
111
+ fieldName,
112
+ fieldCodeChain,
113
+ label,
114
+ modelKey,
115
+ bindModelKey,
116
+ disabled: false,
117
+ readonly: false,
118
+ modeldata: {
119
+ modelCategory: data.modelCategory,
120
+ modelType: data.modelType
121
+ },
122
+ isFieldModel,
123
+ ...otherAttrs
124
+ });
125
+ return merge(basic);
118
126
  }
119
-
127
+ //#endregion
120
128
  export { cloneWidget, createdSearchField, deepFindNotField, getCompPos, isFormFieldType, setChildrenId, transformI18n };