@fecp/designer 5.6.29 → 5.6.31

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.
Files changed (118) hide show
  1. package/es/_virtual/_commonjsHelpers.mjs +25 -0
  2. package/es/_virtual/index.mjs +4 -4
  3. package/es/_virtual/index2.mjs +2 -5
  4. package/es/_virtual/index3.mjs +5 -3
  5. package/es/_virtual/index4.mjs +5 -2
  6. package/es/_virtual/index5.mjs +3 -2
  7. package/es/_virtual/index6.mjs +4 -0
  8. package/es/_virtual/index7.mjs +4 -0
  9. package/es/config-dev.js +2 -0
  10. package/es/designer/package.json.mjs +1 -1
  11. package/es/designer/src/axios/config.mjs +10 -3
  12. package/es/designer/src/axios/crypto.mjs +1 -5
  13. package/es/designer/src/packages/aiForm/AiDiffTable.vue.mjs +152 -0
  14. package/es/designer/src/packages/aiForm/api.mjs +21 -0
  15. package/es/designer/src/packages/aiForm/apply.mjs +153 -0
  16. package/es/designer/src/packages/aiForm/compressConfig.mjs +69 -0
  17. package/es/designer/src/packages/aiForm/constants.mjs +184 -0
  18. package/es/designer/src/packages/aiForm/diff.mjs +140 -0
  19. package/es/designer/src/packages/aiForm/index.vue.mjs +301 -0
  20. package/es/designer/src/packages/aiForm/normalizeFieldList.mjs +138 -0
  21. package/es/designer/src/packages/aiForm/parseAiResult.mjs +245 -0
  22. package/es/designer/src/packages/aiForm/prompt.mjs +130 -0
  23. package/es/designer/src/packages/aiForm/useAiFormDrawer.mjs +16 -0
  24. package/es/designer/src/packages/dataSource/dataSource.vue.mjs +45 -30
  25. package/es/designer/src/packages/form/headerBtn.vue.mjs +4 -1
  26. package/es/designer/src/packages/form/index.vue.mjs +16 -2
  27. package/es/designer/src/packages/utils/datasource.mjs +14 -1
  28. package/es/designer.css +523 -232
  29. package/es/node_modules/@braintree/sanitize-url/dist/index.mjs +1 -1
  30. package/es/node_modules/diagram-js/lib/model/index.mjs +1 -1
  31. package/es/node_modules/element-plus/es/utils/vue/icon.mjs +1 -1
  32. package/es/node_modules/highlight.js/es/index.mjs +1 -1
  33. package/es/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-LMCZKHZV.mjs +1 -1
  34. package/es/node_modules/mermaid/dist/chunks/mermaid.core/chunk-32BRIVSS.mjs +1 -1
  35. package/es/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.mjs +1 -1
  36. package/es/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-OUVF2IWQ.mjs +1 -1
  37. package/es/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-EOCWNBFH.mjs +1 -1
  38. package/es/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-23GEKE2U.mjs +1 -1
  39. package/es/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-NO4QXBWP.mjs +1 -1
  40. package/es/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-DBY2YBRQ.mjs +1 -1
  41. package/es/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-2N3HPSRC.mjs +1 -1
  42. package/es/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-6OUMAXLB.mjs +1 -1
  43. package/es/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-G3AALYLV.mjs +1 -1
  44. package/es/node_modules/object-refs/index.mjs +1 -1
  45. package/es/packages/mobile/src/axios/config.mjs +8 -4
  46. package/es/packages/mobile/src/components/ai/MarkdownRenderer/MarkdownRenderer.vue.mjs +1 -1
  47. package/es/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.mjs +53 -13
  48. package/es/packages/mobile/src/components/custom/approvalBar/FlowUserSelect.vue.mjs +215 -0
  49. package/es/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.mjs +19 -15
  50. package/es/packages/mobile/src/utils/datasource.mjs +14 -1
  51. package/es/packages/mobile/src/utils/formatterUtil.mjs +24 -12
  52. package/es/packages/vue/src/components/dialog/DialogRenderer.vue2.mjs +75 -8
  53. package/es/packages/vue/src/components/dialog/index.mjs +2 -1
  54. package/es/packages/vue/src/components/forms/form/Form.vue.mjs +10 -49
  55. package/es/packages/vue/src/components/forms/formItem/FormItem.vue.mjs +2 -12
  56. package/es/packages/vue/src/components/forms/roleSelect/RoleSelect.vue.mjs +9 -3
  57. package/es/packages/vue/src/components/forms/userSelect/UserSelect.vue.mjs +9 -3
  58. package/es/packages/vue/src/components/table/Table.vue.mjs +119 -11
  59. package/es/packages/vue/src/utils/datasource.mjs +14 -1
  60. package/lib/_virtual/_commonjsHelpers.js +25 -0
  61. package/lib/_virtual/index.js +4 -4
  62. package/lib/_virtual/index2.js +3 -6
  63. package/lib/_virtual/index3.js +6 -4
  64. package/lib/_virtual/index4.js +6 -3
  65. package/lib/_virtual/index5.js +3 -2
  66. package/lib/_virtual/index6.js +4 -0
  67. package/lib/_virtual/index7.js +4 -0
  68. package/lib/config-dev.js +2 -0
  69. package/lib/designer/package.json.js +1 -1
  70. package/lib/designer/src/axios/config.js +10 -3
  71. package/lib/designer/src/axios/crypto.js +0 -4
  72. package/lib/designer/src/packages/aiForm/AiDiffTable.vue.js +152 -0
  73. package/lib/designer/src/packages/aiForm/api.js +21 -0
  74. package/lib/designer/src/packages/aiForm/apply.js +153 -0
  75. package/lib/designer/src/packages/aiForm/compressConfig.js +69 -0
  76. package/lib/designer/src/packages/aiForm/constants.js +184 -0
  77. package/lib/designer/src/packages/aiForm/diff.js +140 -0
  78. package/lib/designer/src/packages/aiForm/index.vue.js +301 -0
  79. package/lib/designer/src/packages/aiForm/normalizeFieldList.js +138 -0
  80. package/lib/designer/src/packages/aiForm/parseAiResult.js +245 -0
  81. package/lib/designer/src/packages/aiForm/prompt.js +130 -0
  82. package/lib/designer/src/packages/aiForm/useAiFormDrawer.js +16 -0
  83. package/lib/designer/src/packages/dataSource/dataSource.vue.js +44 -29
  84. package/lib/designer/src/packages/form/headerBtn.vue.js +4 -1
  85. package/lib/designer/src/packages/form/index.vue.js +15 -1
  86. package/lib/designer/src/packages/utils/datasource.js +14 -1
  87. package/lib/designer.css +523 -232
  88. package/lib/node_modules/@braintree/sanitize-url/dist/index.js +1 -1
  89. package/lib/node_modules/diagram-js/lib/model/index.js +1 -1
  90. package/lib/node_modules/highlight.js/es/index.js +1 -1
  91. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-LMCZKHZV.js +1 -1
  92. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/chunk-32BRIVSS.js +1 -1
  93. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.js +1 -1
  94. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-OUVF2IWQ.js +1 -1
  95. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-EOCWNBFH.js +1 -1
  96. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-23GEKE2U.js +1 -1
  97. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-NO4QXBWP.js +1 -1
  98. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-DBY2YBRQ.js +1 -1
  99. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-2N3HPSRC.js +1 -1
  100. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-6OUMAXLB.js +1 -1
  101. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-G3AALYLV.js +1 -1
  102. package/lib/node_modules/object-refs/index.js +1 -1
  103. package/lib/packages/mobile/src/axios/config.js +8 -4
  104. package/lib/packages/mobile/src/components/ai/MarkdownRenderer/MarkdownRenderer.vue.js +1 -1
  105. package/lib/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.js +52 -12
  106. package/lib/packages/mobile/src/components/custom/approvalBar/FlowUserSelect.vue.js +215 -0
  107. package/lib/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.js +19 -15
  108. package/lib/packages/mobile/src/utils/datasource.js +14 -1
  109. package/lib/packages/mobile/src/utils/formatterUtil.js +24 -12
  110. package/lib/packages/vue/src/components/dialog/DialogRenderer.vue2.js +75 -8
  111. package/lib/packages/vue/src/components/dialog/index.js +2 -1
  112. package/lib/packages/vue/src/components/forms/form/Form.vue.js +9 -48
  113. package/lib/packages/vue/src/components/forms/formItem/FormItem.vue.js +1 -11
  114. package/lib/packages/vue/src/components/forms/roleSelect/RoleSelect.vue.js +9 -3
  115. package/lib/packages/vue/src/components/forms/userSelect/UserSelect.vue.js +9 -3
  116. package/lib/packages/vue/src/components/table/Table.vue.js +118 -10
  117. package/lib/packages/vue/src/utils/datasource.js +14 -1
  118. package/package.json +1 -1
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const index = require("../form/aside/index.js");
4
+ const constants = require("./constants.js");
5
+ const cloneDeep = require("../../../../node_modules/lodash-es/cloneDeep.js");
6
+ function getWidgetTemplate(fieldType) {
7
+ const found = findDefinition(fieldType);
8
+ if (!found) return { fieldType };
9
+ const tpl = cloneDeep.default(found);
10
+ if (constants.LAYOUT_FIELD_TYPES.includes(fieldType)) {
11
+ delete tpl.fieldName;
12
+ }
13
+ delete tpl.label;
14
+ return tpl;
15
+ }
16
+ function findDefinition(fieldType) {
17
+ let result = null;
18
+ (index.default || []).some((group) => {
19
+ return (group.children || []).some((child) => {
20
+ if (child.fieldType === fieldType) {
21
+ result = child;
22
+ return true;
23
+ }
24
+ return false;
25
+ });
26
+ });
27
+ return result;
28
+ }
29
+ function buildLayoutItem(payload, opts) {
30
+ const { columns, index: index2, position, width } = opts;
31
+ const id = String(Date.now()) + String(index2).padStart(3, "0");
32
+ const component = {
33
+ ...getWidgetTemplate(payload.fieldType),
34
+ id,
35
+ type: "widgets",
36
+ ...payload
37
+ };
38
+ const x = (position == null ? void 0 : position.x) ?? 0;
39
+ const y = (position == null ? void 0 : position.y) ?? 0;
40
+ const w = payload.width === "full" ? columns : 1;
41
+ return {
42
+ x,
43
+ y,
44
+ w,
45
+ h: constants.getDefaultHeight(payload.fieldType),
46
+ i: id,
47
+ moved: false,
48
+ isResizable: true,
49
+ component,
50
+ id
51
+ };
52
+ }
53
+ function applyChanges(params) {
54
+ const { editConfigData, diffResult, aiFormConfig = {} } = params;
55
+ const oldColumns = (editConfigData == null ? void 0 : editConfigData.columns) ?? 2;
56
+ const newColumns = Number.isFinite(aiFormConfig == null ? void 0 : aiFormConfig.columns) ? aiFormConfig.columns : oldColumns;
57
+ const originals = (editConfigData == null ? void 0 : editConfigData.fieldsData) || [];
58
+ const removedSet = /* @__PURE__ */ new Set();
59
+ (diffResult.removes || []).forEach((r) => {
60
+ if (r.selected) removedSet.add(r.item);
61
+ });
62
+ const surviving = originals.filter((item) => !(item && item.component && item.hidden !== true && removedSet.has(item))).map((item) => ({
63
+ item: cloneDeep.default(item)
64
+ }));
65
+ const modifyMap = /* @__PURE__ */ new Map();
66
+ (diffResult.modifies || []).forEach((m) => {
67
+ if (!m.selected) return;
68
+ modifyMap.set(m.key, m);
69
+ });
70
+ surviving.forEach(({ item }) => {
71
+ item.w = clampWidth(item.w, newColumns);
72
+ const c = item.component;
73
+ if (!c) return;
74
+ const key = c.fieldName || `${c.label || ""}|${c.fieldType}`;
75
+ const mod = modifyMap.get(key);
76
+ if (!mod) return;
77
+ mod.changes.forEach((ch) => {
78
+ if (!ch.selected) return;
79
+ c[ch.prop] = ch.newValue;
80
+ });
81
+ });
82
+ const maxY = originals.reduce((acc, it) => Math.max(acc, (it == null ? void 0 : it.y) || 0), 0);
83
+ const result = [];
84
+ const pendingAdds = (diffResult.adds || []).filter((a) => a.selected);
85
+ const anchorOnAdd = /* @__PURE__ */ new Map();
86
+ pendingAdds.forEach((a) => {
87
+ const anchorKey = a.insertAfter || "";
88
+ if (!anchorOnAdd.has(anchorKey)) anchorOnAdd.set(anchorKey, []);
89
+ anchorOnAdd.get(anchorKey).push(a);
90
+ });
91
+ const widthOf = (a) => a.width === "full" ? newColumns : 1;
92
+ let seq = 0;
93
+ surviving.forEach(({ item }) => {
94
+ result.push(item);
95
+ const c = item.component;
96
+ const key = c == null ? void 0 : c.fieldName;
97
+ if (!key) return;
98
+ const list = anchorOnAdd.get(key);
99
+ if (!list) return;
100
+ let cx = (item.x || 0) + (item.w || 1);
101
+ let cy = item.y || 0;
102
+ list.forEach((a) => {
103
+ if (cx + widthOf(a) > newColumns) {
104
+ cx = 0;
105
+ cy += 1;
106
+ }
107
+ result.push(
108
+ buildLayoutItem(a.payload, {
109
+ columns: newColumns,
110
+ index: seq++,
111
+ position: { x: cx, y: cy }
112
+ })
113
+ );
114
+ cx += widthOf(a);
115
+ });
116
+ anchorOnAdd.delete(key);
117
+ });
118
+ let tailX = 0;
119
+ let tailY = maxY + 1;
120
+ anchorOnAdd.forEach((list) => {
121
+ list.forEach((a) => {
122
+ if (tailX + widthOf(a) > newColumns) {
123
+ tailX = 0;
124
+ tailY += 1;
125
+ }
126
+ result.push(
127
+ buildLayoutItem(a.payload, {
128
+ columns: newColumns,
129
+ index: seq++,
130
+ position: { x: tailX, y: tailY },
131
+ width: a.width
132
+ })
133
+ );
134
+ tailX += widthOf(a);
135
+ });
136
+ });
137
+ return {
138
+ fieldsData: result,
139
+ formConfig: {
140
+ columns: newColumns,
141
+ ...Number.isFinite(aiFormConfig == null ? void 0 : aiFormConfig.labelWidth) ? { labelWidth: aiFormConfig.labelWidth } : {},
142
+ ...(aiFormConfig == null ? void 0 : aiFormConfig.labelPosition) ? { labelPosition: aiFormConfig.labelPosition } : {}
143
+ }
144
+ };
145
+ }
146
+ function clampWidth(w, columns) {
147
+ const n = Number(w);
148
+ if (!Number.isFinite(n) || n <= 0) return 1;
149
+ return Math.min(Math.floor(n), columns);
150
+ }
151
+ exports.applyChanges = applyChanges;
152
+ exports.buildLayoutItem = buildLayoutItem;
153
+ exports.getWidgetTemplate = getWidgetTemplate;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const constants = require("./constants.js");
4
+ function extractDataSources(editConfigData) {
5
+ const list = editConfigData == null ? void 0 : editConfigData.dataSources;
6
+ if (!Array.isArray(list) || !list.length) return [];
7
+ return list.map((ds) => ({
8
+ id: ds.id,
9
+ name: ds.name || "",
10
+ url: ds.url || ""
11
+ }));
12
+ }
13
+ function extractDictionaries(editConfigData) {
14
+ const fields = (editConfigData == null ? void 0 : editConfigData.fieldsData) || [];
15
+ const set = /* @__PURE__ */ new Set();
16
+ fields.forEach((item) => {
17
+ var _a, _b;
18
+ const key = (_b = (_a = item == null ? void 0 : item.component) == null ? void 0 : _a.optionConfig) == null ? void 0 : _b.dictionaryValue;
19
+ if (key) set.add(key);
20
+ });
21
+ return [...set];
22
+ }
23
+ function getVisibleLayoutItems(editConfigData) {
24
+ const fields = (editConfigData == null ? void 0 : editConfigData.fieldsData) || [];
25
+ return fields.filter((item) => item && item.component && item.hidden !== true).sort((a, b) => {
26
+ if (a.y !== b.y) return (a.y || 0) - (b.y || 0);
27
+ return (a.x || 0) - (b.x || 0);
28
+ });
29
+ }
30
+ function compressComponent(component) {
31
+ const fieldType = component.fieldType;
32
+ const result = {};
33
+ if (!constants.AI_FIELD_TYPES[fieldType]) {
34
+ return { fieldType, label: component.label || "", _unsupported: true };
35
+ }
36
+ const allowed = constants.getAllowedProps(fieldType);
37
+ for (const key of allowed) {
38
+ if (component[key] !== void 0) {
39
+ result[key] = component[key];
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+ function compressFormConfig(editConfigData) {
45
+ if (!editConfigData) return null;
46
+ const items = getVisibleLayoutItems(editConfigData);
47
+ if (!items.length) return null;
48
+ const fields = items.map((item) => compressComponent(item.component));
49
+ return {
50
+ columns: editConfigData.columns ?? 2,
51
+ labelWidth: editConfigData.labelWidth ?? 120,
52
+ labelPosition: editConfigData.labelPosition ?? "right",
53
+ fields
54
+ };
55
+ }
56
+ function buildAiInput(editConfigData, opts = {}) {
57
+ const { includeCurrentConfig = true } = opts;
58
+ return {
59
+ currentConfig: includeCurrentConfig ? compressFormConfig(editConfigData) : null,
60
+ dataSources: extractDataSources(editConfigData),
61
+ dictionaries: extractDictionaries(editConfigData)
62
+ };
63
+ }
64
+ exports.buildAiInput = buildAiInput;
65
+ exports.compressComponent = compressComponent;
66
+ exports.compressFormConfig = compressFormConfig;
67
+ exports.extractDataSources = extractDataSources;
68
+ exports.extractDictionaries = extractDictionaries;
69
+ exports.getVisibleLayoutItems = getVisibleLayoutItems;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const AI_FIELD_TYPES = {
4
+ // 输入类
5
+ text: { label: "单行文本", group: "input", height: 1 },
6
+ textarea: { label: "多行文本", group: "input", height: 2 },
7
+ number: { label: "数字", group: "input", height: 1 },
8
+ date: { label: "日期时间", group: "date", height: 1 },
9
+ // 选择类
10
+ select: { label: "下拉单选", group: "select", height: 1 },
11
+ multipleSelection: { label: "下拉多选", group: "select", height: 1 },
12
+ radio: { label: "单选框", group: "select", height: 1 },
13
+ checkbox: { label: "多选框", group: "select", height: 1 },
14
+ switch: { label: "开关", group: "select", height: 1 },
15
+ // 自包含高级类(无需外部资源 id)
16
+ richText: { label: "富文本", group: "advanced", height: 2 },
17
+ area: { label: "区域选择", group: "advanced", height: 1 },
18
+ industry: { label: "行业选择", group: "advanced", height: 1 },
19
+ // 布局/展示类
20
+ subTitle: { label: "子标题", group: "layout", height: 1 },
21
+ h2: { label: "标题", group: "layout", height: 1 },
22
+ blank: { label: "空白占位", group: "layout", height: 1 },
23
+ divider: { label: "分割线", group: "layout", height: 1 }
24
+ };
25
+ const OPTION_FIELD_TYPES = [
26
+ "select",
27
+ "multipleSelection",
28
+ "radio",
29
+ "checkbox"
30
+ ];
31
+ const LAYOUT_FIELD_TYPES = ["subTitle", "h2", "blank", "divider"];
32
+ const AI_COMMON_PROPS = [
33
+ "fieldType",
34
+ // 控件类型,必填
35
+ "label",
36
+ // 中文标题,必填
37
+ "fieldName",
38
+ // 英文字段名,非布局类必填
39
+ "required",
40
+ // 是否必填
41
+ "requiredMessage",
42
+ // 必填提示语
43
+ "placeholder",
44
+ // 输入提示
45
+ "tooltip",
46
+ // 字段说明
47
+ "defaultValue",
48
+ // 默认值
49
+ "disabled",
50
+ // 是否禁用
51
+ "displayMode",
52
+ // all | edit | query
53
+ "maxLength",
54
+ // 最大长度
55
+ "validationType",
56
+ // 校验类型
57
+ "validationMessage",
58
+ // 校验提示语
59
+ "width",
60
+ // half | full,布局档位,不落入 component
61
+ "insertAfter"
62
+ // 插入锚点(某个 fieldName 之后),不落入 component
63
+ ];
64
+ const AI_PROPS_BY_TYPE = {
65
+ number: [
66
+ "format",
67
+ // number | yuan | wan | million | percentage | permillage | permillion
68
+ "hasDecimalPlaces",
69
+ "decimalPlaces",
70
+ "minValue",
71
+ "maxValue",
72
+ "prefix",
73
+ "suffix"
74
+ ],
75
+ text: ["prefix", "suffix"],
76
+ textarea: ["prefix", "suffix"],
77
+ date: [
78
+ "dateType",
79
+ // date | week | month | year | datetime
80
+ "dateValueType",
81
+ // string | date | timestamp
82
+ "dateRange"
83
+ // "" | beforeToday | afterToday
84
+ ],
85
+ select: ["optionStyle"],
86
+ multipleSelection: ["optionStyle"],
87
+ radio: ["optionStyle"],
88
+ checkbox: ["optionStyle"],
89
+ area: ["multiple", "showFullPath", "maxLevel"],
90
+ industry: ["multiple", "showFullPath", "maxLevel"],
91
+ h2: ["subLabel"]
92
+ };
93
+ const AI_OPTION_CONFIG_PROP = "optionConfig";
94
+ const AI_OPTION_SOURCES = ["custom", "dataSource", "dictionary"];
95
+ const AI_VALIDATION_TYPES = [
96
+ "none",
97
+ "idCard",
98
+ "creditCode",
99
+ "zipCode",
100
+ "fax",
101
+ "bankCard",
102
+ "email",
103
+ "mobile",
104
+ "phone",
105
+ "mobilePhone",
106
+ "regex",
107
+ "custom"
108
+ ];
109
+ const AI_DISPLAY_MODES = ["all", "edit", "query"];
110
+ const AI_WIDTH_MODES = ["half", "full"];
111
+ const AI_NUMBER_FORMATS = [
112
+ "number",
113
+ "yuan",
114
+ "wan",
115
+ "million",
116
+ "percentage",
117
+ "permillage",
118
+ "permillion"
119
+ ];
120
+ function getAllowedProps(fieldType) {
121
+ const extra = AI_PROPS_BY_TYPE[fieldType] || [];
122
+ const props = [...AI_COMMON_PROPS, ...extra];
123
+ if (OPTION_FIELD_TYPES.includes(fieldType)) {
124
+ props.push(AI_OPTION_CONFIG_PROP);
125
+ }
126
+ if (LAYOUT_FIELD_TYPES.includes(fieldType)) {
127
+ return props.filter(
128
+ (p) => ["fieldType", "label", "width", "insertAfter", "subLabel"].includes(p)
129
+ );
130
+ }
131
+ return props;
132
+ }
133
+ function getDefaultHeight(fieldType) {
134
+ var _a;
135
+ return ((_a = AI_FIELD_TYPES[fieldType]) == null ? void 0 : _a.height) || 1;
136
+ }
137
+ const PROP_LABELS = {
138
+ label: "标题",
139
+ fieldName: "字段名",
140
+ required: "必填",
141
+ requiredMessage: "必填提示",
142
+ placeholder: "输入提示",
143
+ tooltip: "字段说明",
144
+ defaultValue: "默认值",
145
+ disabled: "禁用",
146
+ displayMode: "显示场景",
147
+ maxLength: "最大长度",
148
+ validationType: "校验类型",
149
+ validationMessage: "校验提示",
150
+ format: "格式",
151
+ hasDecimalPlaces: "允许小数",
152
+ decimalPlaces: "小数位",
153
+ minValue: "最小值",
154
+ maxValue: "最大值",
155
+ prefix: "前缀",
156
+ suffix: "后缀",
157
+ dateType: "日期类型",
158
+ dateValueType: "日期值类型",
159
+ dateRange: "日期范围",
160
+ optionStyle: "选项样式",
161
+ optionConfig: "选项配置",
162
+ subLabel: "副标题",
163
+ multiple: "多选",
164
+ showFullPath: "显示全路径",
165
+ maxLevel: "最大层级"
166
+ };
167
+ function getPropLabel(prop) {
168
+ return PROP_LABELS[prop] || prop;
169
+ }
170
+ exports.AI_COMMON_PROPS = AI_COMMON_PROPS;
171
+ exports.AI_DISPLAY_MODES = AI_DISPLAY_MODES;
172
+ exports.AI_FIELD_TYPES = AI_FIELD_TYPES;
173
+ exports.AI_NUMBER_FORMATS = AI_NUMBER_FORMATS;
174
+ exports.AI_OPTION_CONFIG_PROP = AI_OPTION_CONFIG_PROP;
175
+ exports.AI_OPTION_SOURCES = AI_OPTION_SOURCES;
176
+ exports.AI_PROPS_BY_TYPE = AI_PROPS_BY_TYPE;
177
+ exports.AI_VALIDATION_TYPES = AI_VALIDATION_TYPES;
178
+ exports.AI_WIDTH_MODES = AI_WIDTH_MODES;
179
+ exports.LAYOUT_FIELD_TYPES = LAYOUT_FIELD_TYPES;
180
+ exports.OPTION_FIELD_TYPES = OPTION_FIELD_TYPES;
181
+ exports.PROP_LABELS = PROP_LABELS;
182
+ exports.getAllowedProps = getAllowedProps;
183
+ exports.getDefaultHeight = getDefaultHeight;
184
+ exports.getPropLabel = getPropLabel;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const constants = require("./constants.js");
4
+ const compressConfig = require("./compressConfig.js");
5
+ function diffAiFields(aiFields, editConfigData) {
6
+ const visibleItems = compressConfig.getVisibleLayoutItems(editConfigData);
7
+ const oldByName = /* @__PURE__ */ new Map();
8
+ const oldByLayoutKey = /* @__PURE__ */ new Map();
9
+ visibleItems.forEach((item) => {
10
+ const c = item.component;
11
+ if (constants.LAYOUT_FIELD_TYPES.includes(c.fieldType)) {
12
+ oldByLayoutKey.set(`${c.label || ""}|${c.fieldType}`, item);
13
+ } else if (c.fieldName) {
14
+ oldByName.set(c.fieldName, item);
15
+ }
16
+ });
17
+ const adds = [];
18
+ const modifies = [];
19
+ const matchedItems = /* @__PURE__ */ new Set();
20
+ const usedLayoutKeys = /* @__PURE__ */ new Set();
21
+ (aiFields || []).forEach((fi) => {
22
+ let oldItem = null;
23
+ let key = null;
24
+ if (constants.LAYOUT_FIELD_TYPES.includes(fi.fieldType)) {
25
+ const lk = `${fi.label || ""}|${fi.fieldType}`;
26
+ oldItem = oldByLayoutKey.get(lk) || null;
27
+ if (oldItem && !usedLayoutKeys.has(lk)) {
28
+ usedLayoutKeys.add(lk);
29
+ key = lk;
30
+ } else {
31
+ oldItem = null;
32
+ }
33
+ } else if (fi.fieldName) {
34
+ key = fi.fieldName;
35
+ oldItem = oldByName.get(fi.fieldName) || null;
36
+ }
37
+ if (!oldItem) {
38
+ adds.push({
39
+ kind: "add",
40
+ key: key || `add_${adds.length}`,
41
+ fieldType: fi.fieldType,
42
+ label: fi.label || "",
43
+ fieldName: fi.fieldName || "",
44
+ width: fi.width || "",
45
+ insertAfter: fi.insertAfter || "",
46
+ payload: stripDirectives(fi),
47
+ selected: true
48
+ });
49
+ return;
50
+ }
51
+ matchedItems.add(oldItem);
52
+ const changes = diffProps(fi, oldItem.component);
53
+ if (changes.length) {
54
+ modifies.push({
55
+ kind: "modify",
56
+ key,
57
+ fieldType: fi.fieldType,
58
+ label: fi.label || oldItem.component.label || "",
59
+ changes,
60
+ selected: true
61
+ });
62
+ }
63
+ });
64
+ const removes = visibleItems.filter((item) => !matchedItems.has(item)).map((item) => ({
65
+ kind: "remove",
66
+ key: item.component.fieldName || `remove_${item.id}`,
67
+ fieldType: item.component.fieldType,
68
+ label: item.component.label || item.component.fieldName || "",
69
+ selected: true,
70
+ item
71
+ }));
72
+ return {
73
+ adds,
74
+ removes,
75
+ modifies,
76
+ stats: {
77
+ add: adds.length,
78
+ remove: removes.length,
79
+ modify: modifies.length
80
+ }
81
+ };
82
+ }
83
+ function stripDirectives(fi) {
84
+ const out = { ...fi };
85
+ delete out.width;
86
+ delete out.insertAfter;
87
+ return out;
88
+ }
89
+ function diffProps(aiField, oldComponent) {
90
+ const changes = [];
91
+ Object.keys(aiField).forEach((prop) => {
92
+ if (["fieldType", "fieldName", "width", "insertAfter"].includes(prop)) return;
93
+ const nv = aiField[prop];
94
+ const ov = oldComponent[prop];
95
+ if (isEqualValue(nv, ov)) return;
96
+ changes.push({
97
+ prop,
98
+ oldValue: readable(ov),
99
+ newValue: readable(nv),
100
+ selected: true
101
+ });
102
+ });
103
+ return changes;
104
+ }
105
+ function isEqualValue(a, b) {
106
+ if (a === b) return true;
107
+ if (a === void 0 || b === void 0) return false;
108
+ if (isEmptyish(a) && isEmptyish(b)) return true;
109
+ if (typeof a === "object" || typeof b === "object") {
110
+ try {
111
+ return JSON.stringify(a) === JSON.stringify(b);
112
+ } catch (e) {
113
+ return false;
114
+ }
115
+ }
116
+ return String(a) === String(b);
117
+ }
118
+ function isEmptyish(v) {
119
+ if (v === null || v === void 0) return true;
120
+ if (v === "") return true;
121
+ if (Array.isArray(v)) return v.length === 0;
122
+ if (typeof v === "object") return Object.keys(v).length === 0;
123
+ return false;
124
+ }
125
+ function readable(v) {
126
+ if (v === void 0) return "(空)";
127
+ if (v === null) return "(空)";
128
+ if (v === "") return "(空)";
129
+ if (typeof v === "boolean") return v ? "是" : "否";
130
+ if (typeof v === "object") {
131
+ try {
132
+ return JSON.stringify(v);
133
+ } catch (e) {
134
+ return String(v);
135
+ }
136
+ }
137
+ return String(v);
138
+ }
139
+ exports.diffAiFields = diffAiFields;
140
+ exports.diffProps = diffProps;