@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.
@@ -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
- const newHeight = `${lines * lineHeight + 10}px`;
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
  });
@@ -5830,33 +5861,65 @@
5830
5861
  return node;
5831
5862
  };
5832
5863
  const change2Fixed = (node, root) => {
5864
+ const style = {
5865
+ ...node.style || {}
5866
+ };
5833
5867
  const path = utils.getNodePath(node.id, root.items);
5834
5868
  const offset = {
5835
5869
  left: 0,
5836
5870
  top: 0
5837
5871
  };
5838
- path.forEach((value) => {
5839
- offset.left = offset.left + globalThis.parseFloat(value.style?.left || 0);
5840
- offset.top = offset.top + globalThis.parseFloat(value.style?.top || 0);
5841
- });
5842
- return {
5843
- ...node.style || {},
5844
- ...offset
5845
- };
5872
+ if (!node.style?.right && utils.isNumber(node.style?.left || 0)) {
5873
+ for (const value of path) {
5874
+ if (value.style?.right || !utils.isNumber(value.style?.left || 0)) {
5875
+ offset.left = 0;
5876
+ break;
5877
+ }
5878
+ offset.left = offset.left + Number(value.style?.left || 0);
5879
+ }
5880
+ }
5881
+ if (!node.style?.bottom && utils.isNumber(node.style?.top || 0)) {
5882
+ for (const value of path) {
5883
+ if (value.style?.bottom || !utils.isNumber(value.style?.top || 0)) {
5884
+ offset.top = 0;
5885
+ break;
5886
+ }
5887
+ offset.top = offset.top + Number(value.style?.top || 0);
5888
+ }
5889
+ }
5890
+ if (offset.left) {
5891
+ style.left = offset.left;
5892
+ }
5893
+ if (offset.top) {
5894
+ style.top = offset.top;
5895
+ }
5896
+ return style;
5846
5897
  };
5847
5898
  const Fixed2Other = async (node, root, getLayout) => {
5848
5899
  const path = utils.getNodePath(node.id, root.items);
5849
5900
  const cur = path.pop();
5850
5901
  const offset = {
5851
5902
  left: cur?.style?.left || 0,
5852
- top: cur?.style?.top || 0,
5853
- right: "",
5854
- bottom: ""
5903
+ top: cur?.style?.top || 0
5855
5904
  };
5856
- path.forEach((value) => {
5857
- offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
5858
- offset.top = offset.top - globalThis.parseFloat(value.style?.top || 0);
5859
- });
5905
+ if (!node.style?.right && utils.isNumber(node.style?.left || 0)) {
5906
+ for (const value of path) {
5907
+ if (value.style?.right || !utils.isNumber(value.style?.left || 0)) {
5908
+ offset.left = 0;
5909
+ break;
5910
+ }
5911
+ offset.left = offset.left - Number(value.style?.left || 0);
5912
+ }
5913
+ }
5914
+ if (!node.style?.bottom && utils.isNumber(node.style?.top || 0)) {
5915
+ for (const value of path) {
5916
+ if (value.style?.bottom || !utils.isNumber(value.style?.top || 0)) {
5917
+ offset.top = 0;
5918
+ break;
5919
+ }
5920
+ offset.top = offset.top - Number(value.style?.top || 0);
5921
+ }
5922
+ }
5860
5923
  const style = node.style || {};
5861
5924
  const parent = path.pop();
5862
5925
  if (!parent) {
@@ -5864,9 +5927,14 @@
5864
5927
  }
5865
5928
  const layout = await getLayout(parent);
5866
5929
  if (layout !== Layout.RELATIVE) {
5930
+ if (offset.left) {
5931
+ style.left = offset.left;
5932
+ }
5933
+ if (offset.top) {
5934
+ style.top = offset.top;
5935
+ }
5867
5936
  return {
5868
5937
  ...style,
5869
- ...offset,
5870
5938
  position: "absolute"
5871
5939
  };
5872
5940
  }
@@ -5977,6 +6045,23 @@
5977
6045
  }
5978
6046
  return isIncludeDataSource2;
5979
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
+ };
5980
6065
 
5981
6066
  const compose = (middleware, isAsync) => {
5982
6067
  if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
@@ -7784,36 +7869,36 @@
7784
7869
  return displayState;
7785
7870
  };
7786
7871
  const getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"]) => {
7787
- const child = [];
7788
- fields.forEach((field) => {
7789
- if (!dataSourceFieldType.length) {
7790
- dataSourceFieldType.push("any");
7791
- }
7792
- let children = [];
7793
- if (field.type && ["any", "array", "object"].includes(field.type)) {
7794
- children = getCascaderOptionsFromFields(field.fields, dataSourceFieldType);
7795
- }
7796
- const item = {
7797
- label: `${field.title || field.name}(${field.type})`,
7798
- value: field.name,
7799
- children
7800
- };
7872
+ const typeSet = new Set(dataSourceFieldType.length ? dataSourceFieldType : ["any"]);
7873
+ const includesAny = typeSet.has("any");
7874
+ const result = [];
7875
+ for (const field of fields) {
7801
7876
  const fieldType = field.type || "any";
7802
- if (dataSourceFieldType.includes("any") || dataSourceFieldType.includes(fieldType)) {
7803
- child.push(item);
7804
- return;
7805
- }
7806
- if (!dataSourceFieldType.includes(fieldType) && !["array", "object", "any"].includes(fieldType)) {
7807
- return;
7808
- }
7809
- if (!children.length && ["object", "array", "any"].includes(field.type || "")) {
7810
- return;
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
+ });
7811
7886
  }
7812
- child.push(item);
7813
- });
7814
- return child;
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;
7815
7901
  };
7816
- const removeDataSourceFieldPrefix = (id) => id?.replace(utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, "") || "";
7817
7902
 
7818
7903
  globalThis.requestIdleCallback = globalThis.requestIdleCallback || function(cb) {
7819
7904
  const start = Date.now();
@@ -8272,17 +8357,11 @@
8272
8357
  const options = vue.computed(() => {
8273
8358
  const [id, ...fieldNames] = [...props.config.parentFields || [], ...props.model.field];
8274
8359
  const ds = dataSourceService.getDataSourceById(id);
8275
- let fields = ds?.fields || [];
8276
- let type = "";
8277
- (fieldNames || []).forEach((fieldName) => {
8278
- const field = fields.find((f) => f.name === fieldName);
8279
- fields = field?.fields || [];
8280
- type = field?.type || "";
8281
- });
8360
+ const type = getFieldType(ds, fieldNames);
8282
8361
  if (type === "array") {
8283
8362
  return arrayOptions;
8284
8363
  }
8285
- if (type === "boolean") {
8364
+ if (type === "boolean" || type === "null") {
8286
8365
  return [
8287
8366
  { text: "是", value: "is" },
8288
8367
  { text: "不是", value: "not" }
@@ -8769,7 +8848,12 @@
8769
8848
  }
8770
8849
  return;
8771
8850
  }
8772
- editorService.update(ev.data.map((data) => ({ id: utils.getIdFromEl()(data.el) || "", style: data.style })));
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
+ });
8773
8857
  });
8774
8858
  stage.on("sort", (ev) => {
8775
8859
  editorService.sort(ev.src, ev.dist);
@@ -9219,6 +9303,7 @@
9219
9303
  name: "defaultValue",
9220
9304
  text: "默认值",
9221
9305
  parse: true,
9306
+ mFormItemType: "data-source-field-defaultValue",
9222
9307
  type: (mForm, { model }) => {
9223
9308
  if (model.type === "number") return "number";
9224
9309
  if (model.type === "boolean") return "select";
@@ -9452,7 +9537,7 @@
9452
9537
  }
9453
9538
  );
9454
9539
  const fieldsOptions = vue.computed(() => {
9455
- const ds = dataSources.value.find((ds2) => ds2.id === removeDataSourceFieldPrefix(selectDataSourceId.value));
9540
+ const ds = dataSources.value.find((ds2) => ds2.id === utils.removeDataSourceFieldPrefix(selectDataSourceId.value));
9456
9541
  if (!ds) return [];
9457
9542
  return getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType);
9458
9543
  });
@@ -9480,7 +9565,7 @@
9480
9565
  () => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE)
9481
9566
  );
9482
9567
  const editHandler = (id) => {
9483
- eventBus?.emit("edit-data-source", removeDataSourceFieldPrefix(id));
9568
+ eventBus?.emit("edit-data-source", utils.removeDataSourceFieldPrefix(id));
9484
9569
  };
9485
9570
  return (_ctx, _cache) => {
9486
9571
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$W, [
@@ -9647,7 +9732,7 @@
9647
9732
  if (typeof props.config.checkStrictly !== "function") {
9648
9733
  value = props.config.checkStrictly;
9649
9734
  } else {
9650
- const dsId = removeDataSourceFieldPrefix(props.model[0]);
9735
+ const dsId = utils.removeDataSourceFieldPrefix(props.model[0]);
9651
9736
  const dataSource = dataSources.value.find((ds) => ds.id === dsId);
9652
9737
  value = props.config.checkStrictly(mForm, {
9653
9738
  values: mForm?.initValues || {},
@@ -9667,7 +9752,7 @@
9667
9752
  return;
9668
9753
  }
9669
9754
  const [dsId, ...keys] = value;
9670
- const dataSource = dataSources.value.find((ds) => ds.id === removeDataSourceFieldPrefix(dsId));
9755
+ const dataSource = dataSources.value.find((ds) => ds.id === utils.removeDataSourceFieldPrefix(dsId));
9671
9756
  if (!dataSource) {
9672
9757
  emit("change", value, eventData);
9673
9758
  return;
@@ -11107,6 +11192,21 @@
11107
11192
  const { dataSourceService } = useServices();
11108
11193
  const mForm = vue.inject("mForm");
11109
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
+ };
11110
11210
  const config = vue.computed(() => ({
11111
11211
  type: "groupList",
11112
11212
  name: props.name,
@@ -11137,14 +11237,16 @@
11137
11237
  name: "field",
11138
11238
  value: "key",
11139
11239
  label: "字段",
11140
- checkStrictly: false
11240
+ checkStrictly: false,
11241
+ onChange: fieldOnChange
11141
11242
  } : {
11142
11243
  type: "data-source-field-select",
11143
11244
  name: "field",
11144
11245
  value: "key",
11145
11246
  label: "字段",
11146
11247
  checkStrictly: false,
11147
- dataSourceFieldType: ["string", "number", "boolean", "any"]
11248
+ dataSourceFieldType: ["string", "number", "boolean", "any"],
11249
+ onChange: fieldOnChange
11148
11250
  },
11149
11251
  {
11150
11252
  type: "cond-op-select",
@@ -11159,29 +11261,32 @@
11159
11261
  items: [
11160
11262
  {
11161
11263
  name: "value",
11162
- type: (mForm2, { model }) => {
11264
+ type: (_mForm, { model }) => {
11163
11265
  const [id, ...fieldNames] = [...parentFields.value, ...model.field];
11164
11266
  const ds = dataSourceService.getDataSourceById(id);
11165
- let fields = ds?.fields || [];
11166
- let type = "";
11167
- (fieldNames || []).forEach((fieldName) => {
11168
- const field = fields.find((f) => f.name === fieldName);
11169
- fields = field?.fields || [];
11170
- type = field?.type || "";
11171
- });
11267
+ const type = getFieldType(ds, fieldNames);
11172
11268
  if (type === "number") {
11173
11269
  return "number";
11174
11270
  }
11175
11271
  if (type === "boolean") {
11176
11272
  return "select";
11177
11273
  }
11274
+ if (type === "null") {
11275
+ return "display";
11276
+ }
11178
11277
  return "text";
11179
11278
  },
11180
11279
  options: [
11181
11280
  { text: "true", value: true },
11182
11281
  { text: "false", value: false }
11183
11282
  ],
11184
- display: (vm, { model }) => !["between", "not_between"].includes(model.op)
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
+ }
11185
11290
  },
11186
11291
  {
11187
11292
  name: "range",
@@ -11725,8 +11830,9 @@
11725
11830
  ])) : vue.createCommentVNode("v-if", true),
11726
11831
  __props.config.advanced && showCode.value ? (vue.openBlock(), vue.createBlock(_sfc_main$1r, {
11727
11832
  key: 1,
11728
- "init-values": __props.model[__props.name],
11833
+ "editor-custom-type": "m-fields-key-value",
11729
11834
  language: "javascript",
11835
+ "init-values": __props.model[__props.name],
11730
11836
  options: {
11731
11837
  readOnly: __props.disabled
11732
11838
  },
@@ -14408,6 +14514,7 @@
14408
14514
  showSrc.value ? vue.renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
14409
14515
  vue.createVNode(_sfc_main$1r, {
14410
14516
  class: "m-editor-content",
14517
+ "editor-custom-type": "m-editor-content",
14411
14518
  "init-values": root.value,
14412
14519
  options: vue.unref(codeOptions),
14413
14520
  onSave: saveCode
@@ -14788,6 +14895,7 @@
14788
14895
  showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$1r, {
14789
14896
  key: 1,
14790
14897
  class: "m-editor-props-panel-src-code",
14898
+ "editor-custom-type": "m-editor-props-panel-src-code",
14791
14899
  height: `${vue.unref(editorContentHeight)}px`,
14792
14900
  "init-values": __props.codeValueKey ? __props.values[__props.codeValueKey] : __props.values,
14793
14901
  options: vue.unref(codeOptions),
@@ -21792,6 +21900,7 @@
21792
21900
  exports.advancedTabConfig = advancedTabConfig;
21793
21901
  exports.arrayOptions = arrayOptions;
21794
21902
  exports.beforePaste = beforePaste;
21903
+ exports.buildChangeRecords = buildChangeRecords;
21795
21904
  exports.change2Fixed = change2Fixed;
21796
21905
  exports.codeBlockService = codeBlockService;
21797
21906
  exports.dataSourceService = dataSourceService;
@@ -21814,6 +21923,7 @@
21814
21923
  exports.getDefaultConfig = getDefaultConfig;
21815
21924
  exports.getDisplayField = getDisplayField;
21816
21925
  exports.getEditorConfig = getEditorConfig;
21926
+ exports.getFieldType = getFieldType;
21817
21927
  exports.getFormConfig = getFormConfig;
21818
21928
  exports.getFormValue = getFormValue;
21819
21929
  exports.getGuideLineFromCache = getGuideLineFromCache;
@@ -21831,7 +21941,6 @@
21831
21941
  exports.moveItemsInContainer = moveItemsInContainer;
21832
21942
  exports.numberOptions = numberOptions;
21833
21943
  exports.propsService = propsService;
21834
- exports.removeDataSourceFieldPrefix = removeDataSourceFieldPrefix;
21835
21944
  exports.serializeConfig = serializeConfig;
21836
21945
  exports.setChildrenLayout = setChildrenLayout;
21837
21946
  exports.setEditorConfig = setEditorConfig;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.4",
2
+ "version": "1.7.5",
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/design": "1.7.4",
61
- "@tmagic/stage": "1.7.4",
62
- "@tmagic/form": "1.7.4",
63
- "@tmagic/table": "1.7.4",
64
- "@tmagic/utils": "1.7.4"
60
+ "@tmagic/design": "1.7.5",
61
+ "@tmagic/stage": "1.7.5",
62
+ "@tmagic/table": "1.7.5",
63
+ "@tmagic/utils": "1.7.5",
64
+ "@tmagic/form": "1.7.5"
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.4"
78
+ "@tmagic/core": "1.7.5"
79
79
  },
80
80
  "peerDependenciesMeta": {
81
81
  "typescript": {
@@ -9,6 +9,7 @@
9
9
  }"
10
10
  :autosize="config.autosize"
11
11
  :parse="config.parse"
12
+ :editor-custom-type="config.mFormItemType"
12
13
  @save="save"
13
14
  ></MagicCodeEditor>
14
15
  </template>
@@ -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
- let fields = ds?.fields || [];
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, removeDataSourceFieldPrefix } from '@editor/utils';
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';