@tmagic/editor 1.7.4 → 1.7.5
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/dist/tmagic-editor.js +180 -72
- package/dist/tmagic-editor.umd.cjs +189 -80
- package/package.json +7 -7
- package/src/fields/Code.vue +1 -0
- package/src/fields/CondOpSelect.vue +3 -9
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +2 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +1 -2
- package/src/fields/DataSourceFields.vue +1 -0
- package/src/fields/DisplayConds.vue +32 -12
- package/src/fields/KeyValue.vue +2 -1
- package/src/hooks/use-stage.ts +10 -2
- package/src/layouts/CodeEditor.vue +51 -2
- package/src/layouts/Framework.vue +7 -1
- package/src/layouts/props-panel/FormPanel.vue +1 -0
- package/src/type.ts +2 -2
- package/src/utils/data-source/index.ts +33 -35
- package/src/utils/editor.ts +85 -15
- package/types/index.d.ts +14 -6
package/dist/tmagic-editor.js
CHANGED
|
@@ -15,7 +15,7 @@ import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
|
|
|
15
15
|
import * as monaco from 'monaco-editor';
|
|
16
16
|
import { HookCodeType, HookType, NODE_DISABLE_CODE_BLOCK_KEY, NODE_DISABLE_DATA_SOURCE_KEY, NODE_CONDS_RESULT_KEY, NODE_CONDS_KEY, Target, Watcher, NodeType, ActionType, DepTargetType, traverseTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceCondTarget, createDataSourceMethodTarget, updateNode } from '@tmagic/core';
|
|
17
17
|
export { DepTargetType } from '@tmagic/core';
|
|
18
|
-
import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, isValueIncludeDataSource, toLine, guid, getValueByKeyPath, setValueByKeyPath, getNodeInfo,
|
|
18
|
+
import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, isValueIncludeDataSource, toLine, guid, getValueByKeyPath, setValueByKeyPath, getNodeInfo, dataSourceTemplateRegExp, getKeysArray, getKeys, convertToNumber, getIdFromEl, traverseNode, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, removeDataSourceFieldPrefix, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, removeClassName, addClassName, removeClassNameByClassName, getNodes, getDepNodeIds } from '@tmagic/utils';
|
|
19
19
|
export * from '@tmagic/utils';
|
|
20
20
|
import VanillaMoveable from 'moveable';
|
|
21
21
|
import StageCore__default, { isFixed, GuidesType, getOffset, ContainerHighlightType, CONTAINER_HIGHLIGHT_CLASS_NAME, RenderType } from '@tmagic/stage';
|
|
@@ -89,9 +89,7 @@ const getEditorConfig = (key) => $TMAGIC_EDITOR[key];
|
|
|
89
89
|
emmetHTML(monaco);
|
|
90
90
|
emmetCSS(monaco, ["css", "scss"]);
|
|
91
91
|
|
|
92
|
-
const _hoisted_1$_ = {
|
|
93
|
-
class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
|
|
94
|
-
};
|
|
92
|
+
const _hoisted_1$_ = { class: "magic-code-editor" };
|
|
95
93
|
const _hoisted_2$o = {
|
|
96
94
|
ref: "codeEditor",
|
|
97
95
|
class: "magic-code-editor-content"
|
|
@@ -113,13 +111,15 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
113
111
|
autoSave: { type: Boolean, default: true },
|
|
114
112
|
parse: { type: Boolean, default: false },
|
|
115
113
|
disabledFullScreen: { type: Boolean, default: false },
|
|
116
|
-
autosize: {}
|
|
114
|
+
autosize: {},
|
|
115
|
+
editorCustomType: {}
|
|
117
116
|
},
|
|
118
117
|
emits: ["initd", "save"],
|
|
119
118
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
120
119
|
const props = __props;
|
|
121
120
|
const emit = __emit;
|
|
122
121
|
const autoHeight = ref("");
|
|
122
|
+
let cachedExtraHeight = null;
|
|
123
123
|
const computeHeight = computed(() => {
|
|
124
124
|
if (fullScreen.value) {
|
|
125
125
|
return "100%";
|
|
@@ -132,6 +132,30 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
132
132
|
}
|
|
133
133
|
return "100%";
|
|
134
134
|
});
|
|
135
|
+
const calculateExtraHeight = () => {
|
|
136
|
+
let extraHeight = 10;
|
|
137
|
+
if (vsEditor && codeEditorEl.value) {
|
|
138
|
+
try {
|
|
139
|
+
const editorElement = codeEditorEl.value.querySelector(".monaco-editor");
|
|
140
|
+
const scrollableElement = codeEditorEl.value.querySelector(".monaco-scrollable-element");
|
|
141
|
+
if (editorElement && scrollableElement) {
|
|
142
|
+
const editorRect = editorElement.getBoundingClientRect();
|
|
143
|
+
const scrollableRect = scrollableElement.getBoundingClientRect();
|
|
144
|
+
extraHeight = Math.max(editorRect.height - scrollableRect.height, 0);
|
|
145
|
+
if (extraHeight === 0) {
|
|
146
|
+
const editorOptions = vsEditor.getOptions();
|
|
147
|
+
const scrollBeyondLastLine = editorOptions.get(monaco.editor.EditorOption.scrollBeyondLastLine);
|
|
148
|
+
const padding = editorOptions.get(monaco.editor.EditorOption.padding);
|
|
149
|
+
const lineHeight = editorOptions.get(monaco.editor.EditorOption.lineHeight) || 20;
|
|
150
|
+
extraHeight = (scrollBeyondLastLine ? lineHeight : 0) + (padding?.top || 0) + (padding?.bottom || 0) + 10;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.warn("Failed to calculate editor extra height:", error);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return extraHeight;
|
|
158
|
+
};
|
|
135
159
|
const setAutoHeight = (v = "") => {
|
|
136
160
|
let lines = Math.max(v.split("\n").length, props.autosize?.minRows || 1);
|
|
137
161
|
if (v) {
|
|
@@ -144,7 +168,10 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
144
168
|
const editorOptions = vsEditor.getOptions();
|
|
145
169
|
lineHeight = editorOptions.get(monaco.editor.EditorOption.lineHeight) || 20;
|
|
146
170
|
}
|
|
147
|
-
|
|
171
|
+
if (cachedExtraHeight === null) {
|
|
172
|
+
cachedExtraHeight = calculateExtraHeight();
|
|
173
|
+
}
|
|
174
|
+
const newHeight = `${lines * lineHeight + cachedExtraHeight}px`;
|
|
148
175
|
if (autoHeight.value !== newHeight) {
|
|
149
176
|
autoHeight.value = newHeight;
|
|
150
177
|
nextTick(() => {
|
|
@@ -235,10 +262,12 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
235
262
|
if (codeEditorEl.value.clientHeight === 0) {
|
|
236
263
|
await nextTick();
|
|
237
264
|
}
|
|
265
|
+
cachedExtraHeight = null;
|
|
238
266
|
const options = {
|
|
239
267
|
value: values.value,
|
|
240
268
|
language: props.language,
|
|
241
269
|
theme: "vs-dark",
|
|
270
|
+
editorCustomType: props.editorCustomType,
|
|
242
271
|
...props.options
|
|
243
272
|
};
|
|
244
273
|
if (props.type === "diff") {
|
|
@@ -303,6 +332,7 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
303
332
|
vsDiffEditor?.dispose();
|
|
304
333
|
vsEditor = null;
|
|
305
334
|
vsDiffEditor = null;
|
|
335
|
+
cachedExtraHeight = null;
|
|
306
336
|
});
|
|
307
337
|
onUnmounted(() => {
|
|
308
338
|
codeEditorEl.value?.removeEventListener("keydown", handleKeyDown);
|
|
@@ -412,8 +442,9 @@ const _sfc_main$1q = /* @__PURE__ */ defineComponent({
|
|
|
412
442
|
},
|
|
413
443
|
autosize: __props.config.autosize,
|
|
414
444
|
parse: __props.config.parse,
|
|
445
|
+
"editor-custom-type": __props.config.mFormItemType,
|
|
415
446
|
onSave: save
|
|
416
|
-
}, null, 8, ["height", "init-values", "language", "options", "autosize", "parse"]);
|
|
447
|
+
}, null, 8, ["height", "init-values", "language", "options", "autosize", "parse", "editor-custom-type"]);
|
|
417
448
|
};
|
|
418
449
|
}
|
|
419
450
|
});
|
|
@@ -1037,33 +1068,65 @@ const setLayout = (node, layout) => {
|
|
|
1037
1068
|
return node;
|
|
1038
1069
|
};
|
|
1039
1070
|
const change2Fixed = (node, root) => {
|
|
1071
|
+
const style = {
|
|
1072
|
+
...node.style || {}
|
|
1073
|
+
};
|
|
1040
1074
|
const path = getNodePath(node.id, root.items);
|
|
1041
1075
|
const offset = {
|
|
1042
1076
|
left: 0,
|
|
1043
1077
|
top: 0
|
|
1044
1078
|
};
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1079
|
+
if (!node.style?.right && isNumber(node.style?.left || 0)) {
|
|
1080
|
+
for (const value of path) {
|
|
1081
|
+
if (value.style?.right || !isNumber(value.style?.left || 0)) {
|
|
1082
|
+
offset.left = 0;
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1085
|
+
offset.left = offset.left + Number(value.style?.left || 0);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
if (!node.style?.bottom && isNumber(node.style?.top || 0)) {
|
|
1089
|
+
for (const value of path) {
|
|
1090
|
+
if (value.style?.bottom || !isNumber(value.style?.top || 0)) {
|
|
1091
|
+
offset.top = 0;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
offset.top = offset.top + Number(value.style?.top || 0);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
if (offset.left) {
|
|
1098
|
+
style.left = offset.left;
|
|
1099
|
+
}
|
|
1100
|
+
if (offset.top) {
|
|
1101
|
+
style.top = offset.top;
|
|
1102
|
+
}
|
|
1103
|
+
return style;
|
|
1053
1104
|
};
|
|
1054
1105
|
const Fixed2Other = async (node, root, getLayout) => {
|
|
1055
1106
|
const path = getNodePath(node.id, root.items);
|
|
1056
1107
|
const cur = path.pop();
|
|
1057
1108
|
const offset = {
|
|
1058
1109
|
left: cur?.style?.left || 0,
|
|
1059
|
-
top: cur?.style?.top || 0
|
|
1060
|
-
right: "",
|
|
1061
|
-
bottom: ""
|
|
1110
|
+
top: cur?.style?.top || 0
|
|
1062
1111
|
};
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1112
|
+
if (!node.style?.right && isNumber(node.style?.left || 0)) {
|
|
1113
|
+
for (const value of path) {
|
|
1114
|
+
if (value.style?.right || !isNumber(value.style?.left || 0)) {
|
|
1115
|
+
offset.left = 0;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
offset.left = offset.left - Number(value.style?.left || 0);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
if (!node.style?.bottom && isNumber(node.style?.top || 0)) {
|
|
1122
|
+
for (const value of path) {
|
|
1123
|
+
if (value.style?.bottom || !isNumber(value.style?.top || 0)) {
|
|
1124
|
+
offset.top = 0;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
offset.top = offset.top - Number(value.style?.top || 0);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1067
1130
|
const style = node.style || {};
|
|
1068
1131
|
const parent = path.pop();
|
|
1069
1132
|
if (!parent) {
|
|
@@ -1071,9 +1134,14 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
1071
1134
|
}
|
|
1072
1135
|
const layout = await getLayout(parent);
|
|
1073
1136
|
if (layout !== Layout.RELATIVE) {
|
|
1137
|
+
if (offset.left) {
|
|
1138
|
+
style.left = offset.left;
|
|
1139
|
+
}
|
|
1140
|
+
if (offset.top) {
|
|
1141
|
+
style.top = offset.top;
|
|
1142
|
+
}
|
|
1074
1143
|
return {
|
|
1075
1144
|
...style,
|
|
1076
|
-
...offset,
|
|
1077
1145
|
position: "absolute"
|
|
1078
1146
|
};
|
|
1079
1147
|
}
|
|
@@ -1184,6 +1252,23 @@ const isIncludeDataSource = (node, oldNode) => {
|
|
|
1184
1252
|
}
|
|
1185
1253
|
return isIncludeDataSource2;
|
|
1186
1254
|
};
|
|
1255
|
+
const buildChangeRecords = (value, basePath) => {
|
|
1256
|
+
const changeRecords = [];
|
|
1257
|
+
const buildChangeRecords2 = (obj, basePath2) => {
|
|
1258
|
+
Object.entries(obj).forEach(([key, value2]) => {
|
|
1259
|
+
if (value2 !== void 0) {
|
|
1260
|
+
const currentPath = basePath2 ? `${basePath2}.${key}` : key;
|
|
1261
|
+
if (typeof value2 === "object" && value2 !== null && !Array.isArray(value2)) {
|
|
1262
|
+
buildChangeRecords2(value2, currentPath);
|
|
1263
|
+
} else {
|
|
1264
|
+
changeRecords.push({ propPath: currentPath, value: value2 });
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
};
|
|
1269
|
+
buildChangeRecords2(value, basePath);
|
|
1270
|
+
return changeRecords;
|
|
1271
|
+
};
|
|
1187
1272
|
|
|
1188
1273
|
const compose = (middleware, isAsync) => {
|
|
1189
1274
|
if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
|
|
@@ -2991,36 +3076,36 @@ const getDisplayField = (dataSources, key) => {
|
|
|
2991
3076
|
return displayState;
|
|
2992
3077
|
};
|
|
2993
3078
|
const getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"]) => {
|
|
2994
|
-
const
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
}
|
|
2999
|
-
let children = [];
|
|
3000
|
-
if (field.type && ["any", "array", "object"].includes(field.type)) {
|
|
3001
|
-
children = getCascaderOptionsFromFields(field.fields, dataSourceFieldType);
|
|
3002
|
-
}
|
|
3003
|
-
const item = {
|
|
3004
|
-
label: `${field.title || field.name}(${field.type})`,
|
|
3005
|
-
value: field.name,
|
|
3006
|
-
children
|
|
3007
|
-
};
|
|
3079
|
+
const typeSet = new Set(dataSourceFieldType.length ? dataSourceFieldType : ["any"]);
|
|
3080
|
+
const includesAny = typeSet.has("any");
|
|
3081
|
+
const result = [];
|
|
3082
|
+
for (const field of fields) {
|
|
3008
3083
|
const fieldType = field.type || "any";
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3084
|
+
const isContainerType = fieldType === "any" || fieldType === "array" || fieldType === "object";
|
|
3085
|
+
const children = isContainerType ? getCascaderOptionsFromFields(field.fields, dataSourceFieldType) : [];
|
|
3086
|
+
const matchesType = includesAny || typeSet.has(fieldType);
|
|
3087
|
+
if (matchesType || isContainerType && children.length) {
|
|
3088
|
+
result.push({
|
|
3089
|
+
label: `${field.title || field.name}(${field.type})`,
|
|
3090
|
+
value: field.name,
|
|
3091
|
+
children
|
|
3092
|
+
});
|
|
3018
3093
|
}
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3094
|
+
}
|
|
3095
|
+
return result;
|
|
3096
|
+
};
|
|
3097
|
+
const getFieldType = (ds, fieldNames) => {
|
|
3098
|
+
let fields = ds?.fields;
|
|
3099
|
+
let type = "";
|
|
3100
|
+
for (const fieldName of fieldNames) {
|
|
3101
|
+
if (!fields?.length) return "";
|
|
3102
|
+
const field = fields.find((f) => f.name === fieldName);
|
|
3103
|
+
if (!field) return "";
|
|
3104
|
+
type = field.type || "";
|
|
3105
|
+
fields = field.fields;
|
|
3106
|
+
}
|
|
3107
|
+
return type;
|
|
3022
3108
|
};
|
|
3023
|
-
const removeDataSourceFieldPrefix = (id) => id?.replace(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, "") || "";
|
|
3024
3109
|
|
|
3025
3110
|
globalThis.requestIdleCallback = globalThis.requestIdleCallback || function(cb) {
|
|
3026
3111
|
const start = Date.now();
|
|
@@ -3479,17 +3564,11 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
|
|
|
3479
3564
|
const options = computed(() => {
|
|
3480
3565
|
const [id, ...fieldNames] = [...props.config.parentFields || [], ...props.model.field];
|
|
3481
3566
|
const ds = dataSourceService.getDataSourceById(id);
|
|
3482
|
-
|
|
3483
|
-
let type = "";
|
|
3484
|
-
(fieldNames || []).forEach((fieldName) => {
|
|
3485
|
-
const field = fields.find((f) => f.name === fieldName);
|
|
3486
|
-
fields = field?.fields || [];
|
|
3487
|
-
type = field?.type || "";
|
|
3488
|
-
});
|
|
3567
|
+
const type = getFieldType(ds, fieldNames);
|
|
3489
3568
|
if (type === "array") {
|
|
3490
3569
|
return arrayOptions;
|
|
3491
3570
|
}
|
|
3492
|
-
if (type === "boolean") {
|
|
3571
|
+
if (type === "boolean" || type === "null") {
|
|
3493
3572
|
return [
|
|
3494
3573
|
{ text: "是", value: "is" },
|
|
3495
3574
|
{ text: "不是", value: "not" }
|
|
@@ -3976,7 +4055,12 @@ const useStage = (stageOptions) => {
|
|
|
3976
4055
|
}
|
|
3977
4056
|
return;
|
|
3978
4057
|
}
|
|
3979
|
-
|
|
4058
|
+
ev.data.forEach((data) => {
|
|
4059
|
+
const id = getIdFromEl()(data.el);
|
|
4060
|
+
if (!id) return;
|
|
4061
|
+
const { style = {} } = data;
|
|
4062
|
+
editorService.update({ id, style }, { changeRecords: buildChangeRecords(style, "style") });
|
|
4063
|
+
});
|
|
3980
4064
|
});
|
|
3981
4065
|
stage.on("sort", (ev) => {
|
|
3982
4066
|
editorService.sort(ev.src, ev.dist);
|
|
@@ -4426,6 +4510,7 @@ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
|
|
|
4426
4510
|
name: "defaultValue",
|
|
4427
4511
|
text: "默认值",
|
|
4428
4512
|
parse: true,
|
|
4513
|
+
mFormItemType: "data-source-field-defaultValue",
|
|
4429
4514
|
type: (mForm, { model }) => {
|
|
4430
4515
|
if (model.type === "number") return "number";
|
|
4431
4516
|
if (model.type === "boolean") return "select";
|
|
@@ -6314,6 +6399,21 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
6314
6399
|
const { dataSourceService } = useServices();
|
|
6315
6400
|
const mForm = inject("mForm");
|
|
6316
6401
|
const parentFields = computed(() => filterFunction(mForm, props.config.parentFields, props) || []);
|
|
6402
|
+
const fieldOnChange = (_formState, v, { model }) => {
|
|
6403
|
+
const [id, ...fieldNames] = [...parentFields.value, ...v];
|
|
6404
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
6405
|
+
const type = getFieldType(ds, fieldNames);
|
|
6406
|
+
if (type === "number") {
|
|
6407
|
+
model.value = Number(model.value);
|
|
6408
|
+
} else if (type === "boolean") {
|
|
6409
|
+
model.value = Boolean(model.value);
|
|
6410
|
+
} else if (type === "null") {
|
|
6411
|
+
model.value = null;
|
|
6412
|
+
} else {
|
|
6413
|
+
model.value = `${model.value}`;
|
|
6414
|
+
}
|
|
6415
|
+
return v;
|
|
6416
|
+
};
|
|
6317
6417
|
const config = computed(() => ({
|
|
6318
6418
|
type: "groupList",
|
|
6319
6419
|
name: props.name,
|
|
@@ -6344,14 +6444,16 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
6344
6444
|
name: "field",
|
|
6345
6445
|
value: "key",
|
|
6346
6446
|
label: "字段",
|
|
6347
|
-
checkStrictly: false
|
|
6447
|
+
checkStrictly: false,
|
|
6448
|
+
onChange: fieldOnChange
|
|
6348
6449
|
} : {
|
|
6349
6450
|
type: "data-source-field-select",
|
|
6350
6451
|
name: "field",
|
|
6351
6452
|
value: "key",
|
|
6352
6453
|
label: "字段",
|
|
6353
6454
|
checkStrictly: false,
|
|
6354
|
-
dataSourceFieldType: ["string", "number", "boolean", "any"]
|
|
6455
|
+
dataSourceFieldType: ["string", "number", "boolean", "any"],
|
|
6456
|
+
onChange: fieldOnChange
|
|
6355
6457
|
},
|
|
6356
6458
|
{
|
|
6357
6459
|
type: "cond-op-select",
|
|
@@ -6366,29 +6468,32 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
6366
6468
|
items: [
|
|
6367
6469
|
{
|
|
6368
6470
|
name: "value",
|
|
6369
|
-
type: (
|
|
6471
|
+
type: (_mForm, { model }) => {
|
|
6370
6472
|
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
6371
6473
|
const ds = dataSourceService.getDataSourceById(id);
|
|
6372
|
-
|
|
6373
|
-
let type = "";
|
|
6374
|
-
(fieldNames || []).forEach((fieldName) => {
|
|
6375
|
-
const field = fields.find((f) => f.name === fieldName);
|
|
6376
|
-
fields = field?.fields || [];
|
|
6377
|
-
type = field?.type || "";
|
|
6378
|
-
});
|
|
6474
|
+
const type = getFieldType(ds, fieldNames);
|
|
6379
6475
|
if (type === "number") {
|
|
6380
6476
|
return "number";
|
|
6381
6477
|
}
|
|
6382
6478
|
if (type === "boolean") {
|
|
6383
6479
|
return "select";
|
|
6384
6480
|
}
|
|
6481
|
+
if (type === "null") {
|
|
6482
|
+
return "display";
|
|
6483
|
+
}
|
|
6385
6484
|
return "text";
|
|
6386
6485
|
},
|
|
6387
6486
|
options: [
|
|
6388
6487
|
{ text: "true", value: true },
|
|
6389
6488
|
{ text: "false", value: false }
|
|
6390
6489
|
],
|
|
6391
|
-
display: (
|
|
6490
|
+
display: (_mForm, { model }) => !["between", "not_between"].includes(model.op),
|
|
6491
|
+
displayText: (_mForm, { model }) => {
|
|
6492
|
+
if (model.value === null) {
|
|
6493
|
+
return "null";
|
|
6494
|
+
}
|
|
6495
|
+
return model.value;
|
|
6496
|
+
}
|
|
6392
6497
|
},
|
|
6393
6498
|
{
|
|
6394
6499
|
name: "range",
|
|
@@ -6932,8 +7037,9 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent({
|
|
|
6932
7037
|
])) : createCommentVNode("v-if", true),
|
|
6933
7038
|
__props.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$1r, {
|
|
6934
7039
|
key: 1,
|
|
6935
|
-
"
|
|
7040
|
+
"editor-custom-type": "m-fields-key-value",
|
|
6936
7041
|
language: "javascript",
|
|
7042
|
+
"init-values": __props.model[__props.name],
|
|
6937
7043
|
options: {
|
|
6938
7044
|
readOnly: __props.disabled
|
|
6939
7045
|
},
|
|
@@ -9615,6 +9721,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
9615
9721
|
showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
|
|
9616
9722
|
createVNode(_sfc_main$1r, {
|
|
9617
9723
|
class: "m-editor-content",
|
|
9724
|
+
"editor-custom-type": "m-editor-content",
|
|
9618
9725
|
"init-values": root.value,
|
|
9619
9726
|
options: unref(codeOptions),
|
|
9620
9727
|
onSave: saveCode
|
|
@@ -9995,6 +10102,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
9995
10102
|
showSrc.value ? (openBlock(), createBlock(_sfc_main$1r, {
|
|
9996
10103
|
key: 1,
|
|
9997
10104
|
class: "m-editor-props-panel-src-code",
|
|
10105
|
+
"editor-custom-type": "m-editor-props-panel-src-code",
|
|
9998
10106
|
height: `${unref(editorContentHeight)}px`,
|
|
9999
10107
|
"init-values": __props.codeValueKey ? __props.values[__props.codeValueKey] : __props.values,
|
|
10000
10108
|
options: unref(codeOptions),
|
|
@@ -16926,4 +17034,4 @@ const index = {
|
|
|
16926
17034
|
}
|
|
16927
17035
|
};
|
|
16928
17036
|
|
|
16929
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$1f as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$1o as CodeSelect, _sfc_main$1m as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$1l as CondOpSelect, _sfc_main$p as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, _sfc_main$j as DataSourceAddButton, _sfc_main$i as DataSourceConfigPanel, _sfc_main$1h as DataSourceFieldSelect, _sfc_main$1j as DataSourceFields, _sfc_main$1g as DataSourceInput, _sfc_main$1d as DataSourceMethodSelect, _sfc_main$1e as DataSourceMethods, _sfc_main$1c as DataSourceMocks, _sfc_main$1b as DataSourceSelect, _sfc_main$1a as DisplayConds, DragType, _sfc_main$19 as EventSelect, Fixed2Other, _sfc_main$1k as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$1s as Icon, IdleTask, KeyBindingCommand, _sfc_main$17 as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$B as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, _sfc_main$16 as PageFragmentSelect, _sfc_main$r as PropsFormPanel, _sfc_main$q as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, _sfc_main$C as Resizer, ScrollViewer, SideItemKey, _sfc_main$B as SplitView, _sfc_main$E as StyleSetter, _sfc_main$1r as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$A as ToolButton, _sfc_main$m as Tree, _sfc_main$n as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, arrayOptions, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, eqOptions, error, eventTabConfig, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getDefaultConfig, getDisplayField, getEditorConfig, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isIncludeDataSource, log, moveItemsInContainer, numberOptions, propsService,
|
|
17037
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$1f as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$1o as CodeSelect, _sfc_main$1m as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$1l as CondOpSelect, _sfc_main$p as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, _sfc_main$j as DataSourceAddButton, _sfc_main$i as DataSourceConfigPanel, _sfc_main$1h as DataSourceFieldSelect, _sfc_main$1j as DataSourceFields, _sfc_main$1g as DataSourceInput, _sfc_main$1d as DataSourceMethodSelect, _sfc_main$1e as DataSourceMethods, _sfc_main$1c as DataSourceMocks, _sfc_main$1b as DataSourceSelect, _sfc_main$1a as DisplayConds, DragType, _sfc_main$19 as EventSelect, Fixed2Other, _sfc_main$1k as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$1s as Icon, IdleTask, KeyBindingCommand, _sfc_main$17 as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$B as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, _sfc_main$16 as PageFragmentSelect, _sfc_main$r as PropsFormPanel, _sfc_main$q as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, _sfc_main$C as Resizer, ScrollViewer, SideItemKey, _sfc_main$B as SplitView, _sfc_main$E as StyleSetter, _sfc_main$1r as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$A as ToolButton, _sfc_main$m as Tree, _sfc_main$n as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, eqOptions, error, eventTabConfig, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isIncludeDataSource, log, moveItemsInContainer, numberOptions, propsService, serializeConfig, setChildrenLayout, setEditorConfig, setLayout, stageOverlayService, storageService, styleTabConfig, uiService, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus$1 as useNodeStatus, useServices, useStage, useWindowRect, warn };
|