@tmagic/editor 1.7.5-beta.1 → 1.7.6
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 +127 -56
- package/dist/tmagic-editor.umd.cjs +136 -64
- 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 +25 -0
- package/types/index.d.ts +13 -4
|
@@ -2605,7 +2605,7 @@
|
|
|
2605
2605
|
var Promise$1 = getNative(root$1, 'Promise');
|
|
2606
2606
|
|
|
2607
2607
|
/* Built-in method references that are verified to be native. */
|
|
2608
|
-
var Set = getNative(root$1, 'Set');
|
|
2608
|
+
var Set$1 = getNative(root$1, 'Set');
|
|
2609
2609
|
|
|
2610
2610
|
/** `Object#toString` result references. */
|
|
2611
2611
|
var mapTag$5 = '[object Map]',
|
|
@@ -2620,7 +2620,7 @@
|
|
|
2620
2620
|
var dataViewCtorString = toSource(DataView),
|
|
2621
2621
|
mapCtorString = toSource(Map$1),
|
|
2622
2622
|
promiseCtorString = toSource(Promise$1),
|
|
2623
|
-
setCtorString = toSource(Set),
|
|
2623
|
+
setCtorString = toSource(Set$1),
|
|
2624
2624
|
weakMapCtorString = toSource(WeakMap);
|
|
2625
2625
|
|
|
2626
2626
|
/**
|
|
@@ -2636,7 +2636,7 @@
|
|
|
2636
2636
|
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$3) ||
|
|
2637
2637
|
(Map$1 && getTag(new Map$1) != mapTag$5) ||
|
|
2638
2638
|
(Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
|
|
2639
|
-
(Set && getTag(new Set) != setTag$5) ||
|
|
2639
|
+
(Set$1 && getTag(new Set$1) != setTag$5) ||
|
|
2640
2640
|
(WeakMap && getTag(new WeakMap) != weakMapTag$1)) {
|
|
2641
2641
|
getTag = function(value) {
|
|
2642
2642
|
var result = baseGetTag(value),
|
|
@@ -4737,8 +4737,8 @@
|
|
|
4737
4737
|
* @param {Array} values The values to add to the set.
|
|
4738
4738
|
* @returns {Object} Returns the new set.
|
|
4739
4739
|
*/
|
|
4740
|
-
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
|
|
4741
|
-
return new Set(values);
|
|
4740
|
+
var createSet = !(Set$1 && (1 / setToArray(new Set$1([,-0]))[1]) == INFINITY) ? noop : function(values) {
|
|
4741
|
+
return new Set$1(values);
|
|
4742
4742
|
};
|
|
4743
4743
|
|
|
4744
4744
|
/** Used as the size to enable large array optimizations. */
|
|
@@ -4882,9 +4882,7 @@
|
|
|
4882
4882
|
emmetMonacoEs.emmetHTML(monaco__namespace);
|
|
4883
4883
|
emmetMonacoEs.emmetCSS(monaco__namespace, ["css", "scss"]);
|
|
4884
4884
|
|
|
4885
|
-
const _hoisted_1$_ = {
|
|
4886
|
-
class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
|
|
4887
|
-
};
|
|
4885
|
+
const _hoisted_1$_ = { class: "magic-code-editor" };
|
|
4888
4886
|
const _hoisted_2$o = {
|
|
4889
4887
|
ref: "codeEditor",
|
|
4890
4888
|
class: "magic-code-editor-content"
|
|
@@ -4906,13 +4904,15 @@
|
|
|
4906
4904
|
autoSave: { type: Boolean, default: true },
|
|
4907
4905
|
parse: { type: Boolean, default: false },
|
|
4908
4906
|
disabledFullScreen: { type: Boolean, default: false },
|
|
4909
|
-
autosize: {}
|
|
4907
|
+
autosize: {},
|
|
4908
|
+
editorCustomType: {}
|
|
4910
4909
|
},
|
|
4911
4910
|
emits: ["initd", "save"],
|
|
4912
4911
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4913
4912
|
const props = __props;
|
|
4914
4913
|
const emit = __emit;
|
|
4915
4914
|
const autoHeight = vue.ref("");
|
|
4915
|
+
let cachedExtraHeight = null;
|
|
4916
4916
|
const computeHeight = vue.computed(() => {
|
|
4917
4917
|
if (fullScreen.value) {
|
|
4918
4918
|
return "100%";
|
|
@@ -4925,6 +4925,30 @@
|
|
|
4925
4925
|
}
|
|
4926
4926
|
return "100%";
|
|
4927
4927
|
});
|
|
4928
|
+
const calculateExtraHeight = () => {
|
|
4929
|
+
let extraHeight = 10;
|
|
4930
|
+
if (vsEditor && codeEditorEl.value) {
|
|
4931
|
+
try {
|
|
4932
|
+
const editorElement = codeEditorEl.value.querySelector(".monaco-editor");
|
|
4933
|
+
const scrollableElement = codeEditorEl.value.querySelector(".monaco-scrollable-element");
|
|
4934
|
+
if (editorElement && scrollableElement) {
|
|
4935
|
+
const editorRect = editorElement.getBoundingClientRect();
|
|
4936
|
+
const scrollableRect = scrollableElement.getBoundingClientRect();
|
|
4937
|
+
extraHeight = Math.max(editorRect.height - scrollableRect.height, 0);
|
|
4938
|
+
if (extraHeight === 0) {
|
|
4939
|
+
const editorOptions = vsEditor.getOptions();
|
|
4940
|
+
const scrollBeyondLastLine = editorOptions.get(monaco__namespace.editor.EditorOption.scrollBeyondLastLine);
|
|
4941
|
+
const padding = editorOptions.get(monaco__namespace.editor.EditorOption.padding);
|
|
4942
|
+
const lineHeight = editorOptions.get(monaco__namespace.editor.EditorOption.lineHeight) || 20;
|
|
4943
|
+
extraHeight = (scrollBeyondLastLine ? lineHeight : 0) + (padding?.top || 0) + (padding?.bottom || 0) + 10;
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4946
|
+
} catch (error) {
|
|
4947
|
+
console.warn("Failed to calculate editor extra height:", error);
|
|
4948
|
+
}
|
|
4949
|
+
}
|
|
4950
|
+
return extraHeight;
|
|
4951
|
+
};
|
|
4928
4952
|
const setAutoHeight = (v = "") => {
|
|
4929
4953
|
let lines = Math.max(v.split("\n").length, props.autosize?.minRows || 1);
|
|
4930
4954
|
if (v) {
|
|
@@ -4937,7 +4961,10 @@
|
|
|
4937
4961
|
const editorOptions = vsEditor.getOptions();
|
|
4938
4962
|
lineHeight = editorOptions.get(monaco__namespace.editor.EditorOption.lineHeight) || 20;
|
|
4939
4963
|
}
|
|
4940
|
-
|
|
4964
|
+
if (cachedExtraHeight === null) {
|
|
4965
|
+
cachedExtraHeight = calculateExtraHeight();
|
|
4966
|
+
}
|
|
4967
|
+
const newHeight = `${lines * lineHeight + cachedExtraHeight}px`;
|
|
4941
4968
|
if (autoHeight.value !== newHeight) {
|
|
4942
4969
|
autoHeight.value = newHeight;
|
|
4943
4970
|
vue.nextTick(() => {
|
|
@@ -5028,10 +5055,12 @@
|
|
|
5028
5055
|
if (codeEditorEl.value.clientHeight === 0) {
|
|
5029
5056
|
await vue.nextTick();
|
|
5030
5057
|
}
|
|
5058
|
+
cachedExtraHeight = null;
|
|
5031
5059
|
const options = {
|
|
5032
5060
|
value: values.value,
|
|
5033
5061
|
language: props.language,
|
|
5034
5062
|
theme: "vs-dark",
|
|
5063
|
+
editorCustomType: props.editorCustomType,
|
|
5035
5064
|
...props.options
|
|
5036
5065
|
};
|
|
5037
5066
|
if (props.type === "diff") {
|
|
@@ -5096,6 +5125,7 @@
|
|
|
5096
5125
|
vsDiffEditor?.dispose();
|
|
5097
5126
|
vsEditor = null;
|
|
5098
5127
|
vsDiffEditor = null;
|
|
5128
|
+
cachedExtraHeight = null;
|
|
5099
5129
|
});
|
|
5100
5130
|
vue.onUnmounted(() => {
|
|
5101
5131
|
codeEditorEl.value?.removeEventListener("keydown", handleKeyDown);
|
|
@@ -5205,8 +5235,9 @@
|
|
|
5205
5235
|
},
|
|
5206
5236
|
autosize: __props.config.autosize,
|
|
5207
5237
|
parse: __props.config.parse,
|
|
5238
|
+
"editor-custom-type": __props.config.mFormItemType,
|
|
5208
5239
|
onSave: save
|
|
5209
|
-
}, null, 8, ["height", "init-values", "language", "options", "autosize", "parse"]);
|
|
5240
|
+
}, null, 8, ["height", "init-values", "language", "options", "autosize", "parse", "editor-custom-type"]);
|
|
5210
5241
|
};
|
|
5211
5242
|
}
|
|
5212
5243
|
});
|
|
@@ -6014,6 +6045,23 @@
|
|
|
6014
6045
|
}
|
|
6015
6046
|
return isIncludeDataSource2;
|
|
6016
6047
|
};
|
|
6048
|
+
const buildChangeRecords = (value, basePath) => {
|
|
6049
|
+
const changeRecords = [];
|
|
6050
|
+
const buildChangeRecords2 = (obj, basePath2) => {
|
|
6051
|
+
Object.entries(obj).forEach(([key, value2]) => {
|
|
6052
|
+
if (value2 !== void 0) {
|
|
6053
|
+
const currentPath = basePath2 ? `${basePath2}.${key}` : key;
|
|
6054
|
+
if (typeof value2 === "object" && value2 !== null && !Array.isArray(value2)) {
|
|
6055
|
+
buildChangeRecords2(value2, currentPath);
|
|
6056
|
+
} else {
|
|
6057
|
+
changeRecords.push({ propPath: currentPath, value: value2 });
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
});
|
|
6061
|
+
};
|
|
6062
|
+
buildChangeRecords2(value, basePath);
|
|
6063
|
+
return changeRecords;
|
|
6064
|
+
};
|
|
6017
6065
|
|
|
6018
6066
|
const compose = (middleware, isAsync) => {
|
|
6019
6067
|
if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
|
|
@@ -7821,36 +7869,36 @@
|
|
|
7821
7869
|
return displayState;
|
|
7822
7870
|
};
|
|
7823
7871
|
const getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"]) => {
|
|
7824
|
-
const
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
}
|
|
7829
|
-
let children = [];
|
|
7830
|
-
if (field.type && ["any", "array", "object"].includes(field.type)) {
|
|
7831
|
-
children = getCascaderOptionsFromFields(field.fields, dataSourceFieldType);
|
|
7832
|
-
}
|
|
7833
|
-
const item = {
|
|
7834
|
-
label: `${field.title || field.name}(${field.type})`,
|
|
7835
|
-
value: field.name,
|
|
7836
|
-
children
|
|
7837
|
-
};
|
|
7872
|
+
const typeSet = new Set(dataSourceFieldType.length ? dataSourceFieldType : ["any"]);
|
|
7873
|
+
const includesAny = typeSet.has("any");
|
|
7874
|
+
const result = [];
|
|
7875
|
+
for (const field of fields) {
|
|
7838
7876
|
const fieldType = field.type || "any";
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7877
|
+
const isContainerType = fieldType === "any" || fieldType === "array" || fieldType === "object";
|
|
7878
|
+
const children = isContainerType ? getCascaderOptionsFromFields(field.fields, dataSourceFieldType) : [];
|
|
7879
|
+
const matchesType = includesAny || typeSet.has(fieldType);
|
|
7880
|
+
if (matchesType || isContainerType && children.length) {
|
|
7881
|
+
result.push({
|
|
7882
|
+
label: `${field.title || field.name}(${field.type})`,
|
|
7883
|
+
value: field.name,
|
|
7884
|
+
children
|
|
7885
|
+
});
|
|
7848
7886
|
}
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7887
|
+
}
|
|
7888
|
+
return result;
|
|
7889
|
+
};
|
|
7890
|
+
const getFieldType = (ds, fieldNames) => {
|
|
7891
|
+
let fields = ds?.fields;
|
|
7892
|
+
let type = "";
|
|
7893
|
+
for (const fieldName of fieldNames) {
|
|
7894
|
+
if (!fields?.length) return "";
|
|
7895
|
+
const field = fields.find((f) => f.name === fieldName);
|
|
7896
|
+
if (!field) return "";
|
|
7897
|
+
type = field.type || "";
|
|
7898
|
+
fields = field.fields;
|
|
7899
|
+
}
|
|
7900
|
+
return type;
|
|
7852
7901
|
};
|
|
7853
|
-
const removeDataSourceFieldPrefix = (id) => id?.replace(utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, "") || "";
|
|
7854
7902
|
|
|
7855
7903
|
globalThis.requestIdleCallback = globalThis.requestIdleCallback || function(cb) {
|
|
7856
7904
|
const start = Date.now();
|
|
@@ -8309,17 +8357,11 @@
|
|
|
8309
8357
|
const options = vue.computed(() => {
|
|
8310
8358
|
const [id, ...fieldNames] = [...props.config.parentFields || [], ...props.model.field];
|
|
8311
8359
|
const ds = dataSourceService.getDataSourceById(id);
|
|
8312
|
-
|
|
8313
|
-
let type = "";
|
|
8314
|
-
(fieldNames || []).forEach((fieldName) => {
|
|
8315
|
-
const field = fields.find((f) => f.name === fieldName);
|
|
8316
|
-
fields = field?.fields || [];
|
|
8317
|
-
type = field?.type || "";
|
|
8318
|
-
});
|
|
8360
|
+
const type = getFieldType(ds, fieldNames);
|
|
8319
8361
|
if (type === "array") {
|
|
8320
8362
|
return arrayOptions;
|
|
8321
8363
|
}
|
|
8322
|
-
if (type === "boolean") {
|
|
8364
|
+
if (type === "boolean" || type === "null") {
|
|
8323
8365
|
return [
|
|
8324
8366
|
{ text: "是", value: "is" },
|
|
8325
8367
|
{ text: "不是", value: "not" }
|
|
@@ -8806,7 +8848,12 @@
|
|
|
8806
8848
|
}
|
|
8807
8849
|
return;
|
|
8808
8850
|
}
|
|
8809
|
-
|
|
8851
|
+
ev.data.forEach((data) => {
|
|
8852
|
+
const id = utils.getIdFromEl()(data.el);
|
|
8853
|
+
if (!id) return;
|
|
8854
|
+
const { style = {} } = data;
|
|
8855
|
+
editorService.update({ id, style }, { changeRecords: buildChangeRecords(style, "style") });
|
|
8856
|
+
});
|
|
8810
8857
|
});
|
|
8811
8858
|
stage.on("sort", (ev) => {
|
|
8812
8859
|
editorService.sort(ev.src, ev.dist);
|
|
@@ -9256,6 +9303,7 @@
|
|
|
9256
9303
|
name: "defaultValue",
|
|
9257
9304
|
text: "默认值",
|
|
9258
9305
|
parse: true,
|
|
9306
|
+
mFormItemType: "data-source-field-defaultValue",
|
|
9259
9307
|
type: (mForm, { model }) => {
|
|
9260
9308
|
if (model.type === "number") return "number";
|
|
9261
9309
|
if (model.type === "boolean") return "select";
|
|
@@ -9489,7 +9537,7 @@
|
|
|
9489
9537
|
}
|
|
9490
9538
|
);
|
|
9491
9539
|
const fieldsOptions = vue.computed(() => {
|
|
9492
|
-
const ds = dataSources.value.find((ds2) => ds2.id === removeDataSourceFieldPrefix(selectDataSourceId.value));
|
|
9540
|
+
const ds = dataSources.value.find((ds2) => ds2.id === utils.removeDataSourceFieldPrefix(selectDataSourceId.value));
|
|
9493
9541
|
if (!ds) return [];
|
|
9494
9542
|
return getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType);
|
|
9495
9543
|
});
|
|
@@ -9517,7 +9565,7 @@
|
|
|
9517
9565
|
() => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE)
|
|
9518
9566
|
);
|
|
9519
9567
|
const editHandler = (id) => {
|
|
9520
|
-
eventBus?.emit("edit-data-source", removeDataSourceFieldPrefix(id));
|
|
9568
|
+
eventBus?.emit("edit-data-source", utils.removeDataSourceFieldPrefix(id));
|
|
9521
9569
|
};
|
|
9522
9570
|
return (_ctx, _cache) => {
|
|
9523
9571
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$W, [
|
|
@@ -9684,7 +9732,7 @@
|
|
|
9684
9732
|
if (typeof props.config.checkStrictly !== "function") {
|
|
9685
9733
|
value = props.config.checkStrictly;
|
|
9686
9734
|
} else {
|
|
9687
|
-
const dsId = removeDataSourceFieldPrefix(props.model[0]);
|
|
9735
|
+
const dsId = utils.removeDataSourceFieldPrefix(props.model[0]);
|
|
9688
9736
|
const dataSource = dataSources.value.find((ds) => ds.id === dsId);
|
|
9689
9737
|
value = props.config.checkStrictly(mForm, {
|
|
9690
9738
|
values: mForm?.initValues || {},
|
|
@@ -9704,7 +9752,7 @@
|
|
|
9704
9752
|
return;
|
|
9705
9753
|
}
|
|
9706
9754
|
const [dsId, ...keys] = value;
|
|
9707
|
-
const dataSource = dataSources.value.find((ds) => ds.id === removeDataSourceFieldPrefix(dsId));
|
|
9755
|
+
const dataSource = dataSources.value.find((ds) => ds.id === utils.removeDataSourceFieldPrefix(dsId));
|
|
9708
9756
|
if (!dataSource) {
|
|
9709
9757
|
emit("change", value, eventData);
|
|
9710
9758
|
return;
|
|
@@ -11144,6 +11192,21 @@
|
|
|
11144
11192
|
const { dataSourceService } = useServices();
|
|
11145
11193
|
const mForm = vue.inject("mForm");
|
|
11146
11194
|
const parentFields = vue.computed(() => formPlugin.filterFunction(mForm, props.config.parentFields, props) || []);
|
|
11195
|
+
const fieldOnChange = (_formState, v, { model }) => {
|
|
11196
|
+
const [id, ...fieldNames] = [...parentFields.value, ...v];
|
|
11197
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
11198
|
+
const type = getFieldType(ds, fieldNames);
|
|
11199
|
+
if (type === "number") {
|
|
11200
|
+
model.value = Number(model.value);
|
|
11201
|
+
} else if (type === "boolean") {
|
|
11202
|
+
model.value = Boolean(model.value);
|
|
11203
|
+
} else if (type === "null") {
|
|
11204
|
+
model.value = null;
|
|
11205
|
+
} else {
|
|
11206
|
+
model.value = `${model.value}`;
|
|
11207
|
+
}
|
|
11208
|
+
return v;
|
|
11209
|
+
};
|
|
11147
11210
|
const config = vue.computed(() => ({
|
|
11148
11211
|
type: "groupList",
|
|
11149
11212
|
name: props.name,
|
|
@@ -11174,14 +11237,16 @@
|
|
|
11174
11237
|
name: "field",
|
|
11175
11238
|
value: "key",
|
|
11176
11239
|
label: "字段",
|
|
11177
|
-
checkStrictly: false
|
|
11240
|
+
checkStrictly: false,
|
|
11241
|
+
onChange: fieldOnChange
|
|
11178
11242
|
} : {
|
|
11179
11243
|
type: "data-source-field-select",
|
|
11180
11244
|
name: "field",
|
|
11181
11245
|
value: "key",
|
|
11182
11246
|
label: "字段",
|
|
11183
11247
|
checkStrictly: false,
|
|
11184
|
-
dataSourceFieldType: ["string", "number", "boolean", "any"]
|
|
11248
|
+
dataSourceFieldType: ["string", "number", "boolean", "any"],
|
|
11249
|
+
onChange: fieldOnChange
|
|
11185
11250
|
},
|
|
11186
11251
|
{
|
|
11187
11252
|
type: "cond-op-select",
|
|
@@ -11196,29 +11261,32 @@
|
|
|
11196
11261
|
items: [
|
|
11197
11262
|
{
|
|
11198
11263
|
name: "value",
|
|
11199
|
-
type: (
|
|
11264
|
+
type: (_mForm, { model }) => {
|
|
11200
11265
|
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
11201
11266
|
const ds = dataSourceService.getDataSourceById(id);
|
|
11202
|
-
|
|
11203
|
-
let type = "";
|
|
11204
|
-
(fieldNames || []).forEach((fieldName) => {
|
|
11205
|
-
const field = fields.find((f) => f.name === fieldName);
|
|
11206
|
-
fields = field?.fields || [];
|
|
11207
|
-
type = field?.type || "";
|
|
11208
|
-
});
|
|
11267
|
+
const type = getFieldType(ds, fieldNames);
|
|
11209
11268
|
if (type === "number") {
|
|
11210
11269
|
return "number";
|
|
11211
11270
|
}
|
|
11212
11271
|
if (type === "boolean") {
|
|
11213
11272
|
return "select";
|
|
11214
11273
|
}
|
|
11274
|
+
if (type === "null") {
|
|
11275
|
+
return "display";
|
|
11276
|
+
}
|
|
11215
11277
|
return "text";
|
|
11216
11278
|
},
|
|
11217
11279
|
options: [
|
|
11218
11280
|
{ text: "true", value: true },
|
|
11219
11281
|
{ text: "false", value: false }
|
|
11220
11282
|
],
|
|
11221
|
-
display: (
|
|
11283
|
+
display: (_mForm, { model }) => !["between", "not_between"].includes(model.op),
|
|
11284
|
+
displayText: (_mForm, { model }) => {
|
|
11285
|
+
if (model.value === null) {
|
|
11286
|
+
return "null";
|
|
11287
|
+
}
|
|
11288
|
+
return model.value;
|
|
11289
|
+
}
|
|
11222
11290
|
},
|
|
11223
11291
|
{
|
|
11224
11292
|
name: "range",
|
|
@@ -11762,8 +11830,9 @@
|
|
|
11762
11830
|
])) : vue.createCommentVNode("v-if", true),
|
|
11763
11831
|
__props.config.advanced && showCode.value ? (vue.openBlock(), vue.createBlock(_sfc_main$1r, {
|
|
11764
11832
|
key: 1,
|
|
11765
|
-
"
|
|
11833
|
+
"editor-custom-type": "m-fields-key-value",
|
|
11766
11834
|
language: "javascript",
|
|
11835
|
+
"init-values": __props.model[__props.name],
|
|
11767
11836
|
options: {
|
|
11768
11837
|
readOnly: __props.disabled
|
|
11769
11838
|
},
|
|
@@ -14445,6 +14514,7 @@
|
|
|
14445
14514
|
showSrc.value ? vue.renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
|
|
14446
14515
|
vue.createVNode(_sfc_main$1r, {
|
|
14447
14516
|
class: "m-editor-content",
|
|
14517
|
+
"editor-custom-type": "m-editor-content",
|
|
14448
14518
|
"init-values": root.value,
|
|
14449
14519
|
options: vue.unref(codeOptions),
|
|
14450
14520
|
onSave: saveCode
|
|
@@ -14825,6 +14895,7 @@
|
|
|
14825
14895
|
showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$1r, {
|
|
14826
14896
|
key: 1,
|
|
14827
14897
|
class: "m-editor-props-panel-src-code",
|
|
14898
|
+
"editor-custom-type": "m-editor-props-panel-src-code",
|
|
14828
14899
|
height: `${vue.unref(editorContentHeight)}px`,
|
|
14829
14900
|
"init-values": __props.codeValueKey ? __props.values[__props.codeValueKey] : __props.values,
|
|
14830
14901
|
options: vue.unref(codeOptions),
|
|
@@ -21829,6 +21900,7 @@
|
|
|
21829
21900
|
exports.advancedTabConfig = advancedTabConfig;
|
|
21830
21901
|
exports.arrayOptions = arrayOptions;
|
|
21831
21902
|
exports.beforePaste = beforePaste;
|
|
21903
|
+
exports.buildChangeRecords = buildChangeRecords;
|
|
21832
21904
|
exports.change2Fixed = change2Fixed;
|
|
21833
21905
|
exports.codeBlockService = codeBlockService;
|
|
21834
21906
|
exports.dataSourceService = dataSourceService;
|
|
@@ -21851,6 +21923,7 @@
|
|
|
21851
21923
|
exports.getDefaultConfig = getDefaultConfig;
|
|
21852
21924
|
exports.getDisplayField = getDisplayField;
|
|
21853
21925
|
exports.getEditorConfig = getEditorConfig;
|
|
21926
|
+
exports.getFieldType = getFieldType;
|
|
21854
21927
|
exports.getFormConfig = getFormConfig;
|
|
21855
21928
|
exports.getFormValue = getFormValue;
|
|
21856
21929
|
exports.getGuideLineFromCache = getGuideLineFromCache;
|
|
@@ -21868,7 +21941,6 @@
|
|
|
21868
21941
|
exports.moveItemsInContainer = moveItemsInContainer;
|
|
21869
21942
|
exports.numberOptions = numberOptions;
|
|
21870
21943
|
exports.propsService = propsService;
|
|
21871
|
-
exports.removeDataSourceFieldPrefix = removeDataSourceFieldPrefix;
|
|
21872
21944
|
exports.serializeConfig = serializeConfig;
|
|
21873
21945
|
exports.setChildrenLayout = setChildrenLayout;
|
|
21874
21946
|
exports.setEditorConfig = setEditorConfig;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.
|
|
2
|
+
"version": "1.7.6",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"moveable": "^0.53.0",
|
|
58
58
|
"serialize-javascript": "^7.0.0",
|
|
59
59
|
"sortablejs": "^1.15.6",
|
|
60
|
-
"@tmagic/
|
|
61
|
-
"@tmagic/
|
|
62
|
-
"@tmagic/utils": "1.7.
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/table": "1.7.
|
|
60
|
+
"@tmagic/design": "1.7.6",
|
|
61
|
+
"@tmagic/form": "1.7.6",
|
|
62
|
+
"@tmagic/utils": "1.7.6",
|
|
63
|
+
"@tmagic/stage": "1.7.6",
|
|
64
|
+
"@tmagic/table": "1.7.6"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/events": "^3.0.3",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"monaco-editor": "^0.48.0",
|
|
76
76
|
"typescript": "^5.9.3",
|
|
77
77
|
"vue": "^3.5.24",
|
|
78
|
-
"@tmagic/core": "1.7.
|
|
78
|
+
"@tmagic/core": "1.7.6"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"typescript": {
|
package/src/fields/Code.vue
CHANGED
|
@@ -33,7 +33,7 @@ import { getDesignConfig, TMagicSelect } from '@tmagic/design';
|
|
|
33
33
|
import type { CondOpSelectConfig, FieldProps } from '@tmagic/form';
|
|
34
34
|
|
|
35
35
|
import { useServices } from '@editor/hooks/use-services';
|
|
36
|
-
import { arrayOptions, eqOptions, numberOptions } from '@editor/utils';
|
|
36
|
+
import { arrayOptions, eqOptions, getFieldType, numberOptions } from '@editor/utils';
|
|
37
37
|
|
|
38
38
|
defineOptions({
|
|
39
39
|
name: 'MFieldsCondOpSelect',
|
|
@@ -54,19 +54,13 @@ const options = computed(() => {
|
|
|
54
54
|
|
|
55
55
|
const ds = dataSourceService.getDataSourceById(id);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
let type = '';
|
|
59
|
-
(fieldNames || []).forEach((fieldName: string) => {
|
|
60
|
-
const field = fields.find((f) => f.name === fieldName);
|
|
61
|
-
fields = field?.fields || [];
|
|
62
|
-
type = field?.type || '';
|
|
63
|
-
});
|
|
57
|
+
const type = getFieldType(ds, fieldNames);
|
|
64
58
|
|
|
65
59
|
if (type === 'array') {
|
|
66
60
|
return arrayOptions;
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
if (type === 'boolean') {
|
|
63
|
+
if (type === 'boolean' || type === 'null') {
|
|
70
64
|
return [
|
|
71
65
|
{ text: '是', value: 'is' },
|
|
72
66
|
{ text: '不是', value: 'not' },
|
|
@@ -72,12 +72,12 @@ import { Edit, View } from '@element-plus/icons-vue';
|
|
|
72
72
|
import type { DataSourceFieldType } from '@tmagic/core';
|
|
73
73
|
import { getDesignConfig, TMagicButton, TMagicCascader, TMagicSelect, TMagicTooltip } from '@tmagic/design';
|
|
74
74
|
import { type FilterFunction, filterFunction, type FormState, type SelectOption } from '@tmagic/form';
|
|
75
|
-
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
|
|
75
|
+
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, removeDataSourceFieldPrefix } from '@tmagic/utils';
|
|
76
76
|
|
|
77
77
|
import MIcon from '@editor/components/Icon.vue';
|
|
78
78
|
import { useServices } from '@editor/hooks/use-services';
|
|
79
79
|
import { type EventBus, SideItemKey } from '@editor/type';
|
|
80
|
-
import { getCascaderOptionsFromFields
|
|
80
|
+
import { getCascaderOptionsFromFields } from '@editor/utils';
|
|
81
81
|
|
|
82
82
|
const props = defineProps<{
|
|
83
83
|
/**
|
|
@@ -48,11 +48,10 @@ import { Coin } from '@element-plus/icons-vue';
|
|
|
48
48
|
import { DataSchema } from '@tmagic/core';
|
|
49
49
|
import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
|
|
50
50
|
import type { ContainerChangeEventData, DataSourceFieldSelectConfig, FieldProps, FormState } from '@tmagic/form';
|
|
51
|
-
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
|
|
51
|
+
import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, removeDataSourceFieldPrefix } from '@tmagic/utils';
|
|
52
52
|
|
|
53
53
|
import MIcon from '@editor/components/Icon.vue';
|
|
54
54
|
import { useServices } from '@editor/hooks/use-services';
|
|
55
|
-
import { removeDataSourceFieldPrefix } from '@editor/utils';
|
|
56
55
|
|
|
57
56
|
import FieldSelect from './FieldSelect.vue';
|
|
58
57
|
|
|
@@ -234,6 +234,7 @@ const dataSourceFieldsConfig: FormConfig = [
|
|
|
234
234
|
name: 'defaultValue',
|
|
235
235
|
text: '默认值',
|
|
236
236
|
parse: true,
|
|
237
|
+
mFormItemType: 'data-source-field-defaultValue',
|
|
237
238
|
type: (mForm: FormState | undefined, { model }: any) => {
|
|
238
239
|
if (model.type === 'number') return 'number';
|
|
239
240
|
if (model.type === 'boolean') return 'select';
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from '@tmagic/form';
|
|
28
28
|
|
|
29
29
|
import { useServices } from '@editor/hooks/use-services';
|
|
30
|
-
import { getCascaderOptionsFromFields } from '@editor/utils';
|
|
30
|
+
import { getCascaderOptionsFromFields, getFieldType } from '@editor/utils';
|
|
31
31
|
|
|
32
32
|
defineOptions({
|
|
33
33
|
name: 'm-fields-display-conds',
|
|
@@ -46,6 +46,22 @@ const mForm = inject<FormState | undefined>('mForm');
|
|
|
46
46
|
|
|
47
47
|
const parentFields = computed(() => filterFunction<string[]>(mForm, props.config.parentFields, props) || []);
|
|
48
48
|
|
|
49
|
+
const fieldOnChange = (_formState: FormState | undefined, v: string[], { model }: { model: Record<string, any> }) => {
|
|
50
|
+
const [id, ...fieldNames] = [...parentFields.value, ...v];
|
|
51
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
52
|
+
const type = getFieldType(ds, fieldNames);
|
|
53
|
+
if (type === 'number') {
|
|
54
|
+
model.value = Number(model.value);
|
|
55
|
+
} else if (type === 'boolean') {
|
|
56
|
+
model.value = Boolean(model.value);
|
|
57
|
+
} else if (type === 'null') {
|
|
58
|
+
model.value = null;
|
|
59
|
+
} else {
|
|
60
|
+
model.value = `${model.value}`;
|
|
61
|
+
}
|
|
62
|
+
return v;
|
|
63
|
+
};
|
|
64
|
+
|
|
49
65
|
const config = computed<GroupListConfig>(() => ({
|
|
50
66
|
type: 'groupList',
|
|
51
67
|
name: props.name,
|
|
@@ -80,6 +96,7 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
80
96
|
value: 'key',
|
|
81
97
|
label: '字段',
|
|
82
98
|
checkStrictly: false,
|
|
99
|
+
onChange: fieldOnChange,
|
|
83
100
|
}
|
|
84
101
|
: {
|
|
85
102
|
type: 'data-source-field-select',
|
|
@@ -88,6 +105,7 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
88
105
|
label: '字段',
|
|
89
106
|
checkStrictly: false,
|
|
90
107
|
dataSourceFieldType: ['string', 'number', 'boolean', 'any'],
|
|
108
|
+
onChange: fieldOnChange,
|
|
91
109
|
},
|
|
92
110
|
{
|
|
93
111
|
type: 'cond-op-select',
|
|
@@ -102,18 +120,10 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
102
120
|
items: [
|
|
103
121
|
{
|
|
104
122
|
name: 'value',
|
|
105
|
-
type: (
|
|
123
|
+
type: (_mForm, { model }) => {
|
|
106
124
|
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
107
|
-
|
|
108
125
|
const ds = dataSourceService.getDataSourceById(id);
|
|
109
|
-
|
|
110
|
-
let fields = ds?.fields || [];
|
|
111
|
-
let type = '';
|
|
112
|
-
(fieldNames || []).forEach((fieldName: string) => {
|
|
113
|
-
const field = fields.find((f) => f.name === fieldName);
|
|
114
|
-
fields = field?.fields || [];
|
|
115
|
-
type = field?.type || '';
|
|
116
|
-
});
|
|
126
|
+
const type = getFieldType(ds, fieldNames);
|
|
117
127
|
|
|
118
128
|
if (type === 'number') {
|
|
119
129
|
return 'number';
|
|
@@ -123,13 +133,23 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
123
133
|
return 'select';
|
|
124
134
|
}
|
|
125
135
|
|
|
136
|
+
if (type === 'null') {
|
|
137
|
+
return 'display';
|
|
138
|
+
}
|
|
139
|
+
|
|
126
140
|
return 'text';
|
|
127
141
|
},
|
|
128
142
|
options: [
|
|
129
143
|
{ text: 'true', value: true },
|
|
130
144
|
{ text: 'false', value: false },
|
|
131
145
|
],
|
|
132
|
-
display: (
|
|
146
|
+
display: (_mForm, { model }) => !['between', 'not_between'].includes(model.op),
|
|
147
|
+
displayText: (_mForm: FormState | undefined, { model }: any) => {
|
|
148
|
+
if (model.value === null) {
|
|
149
|
+
return 'null';
|
|
150
|
+
}
|
|
151
|
+
return model.value;
|
|
152
|
+
},
|
|
133
153
|
},
|
|
134
154
|
{
|
|
135
155
|
name: 'range',
|
package/src/fields/KeyValue.vue
CHANGED