@tmagic/editor 1.2.14 → 1.3.0-alpha.0

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 (59) hide show
  1. package/dist/style.css +173 -80
  2. package/dist/tmagic-editor.js +975 -222
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +984 -230
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +10 -9
  7. package/src/Editor.vue +2 -0
  8. package/src/components/CodeDraftEditor.vue +2 -2
  9. package/src/components/SearchInput.vue +6 -3
  10. package/src/editorProps.ts +5 -0
  11. package/src/fields/CodeSelect.vue +1 -0
  12. package/src/fields/DataSourceFields.vue +178 -0
  13. package/src/fields/EventSelect.vue +1 -0
  14. package/src/fields/KeyValue.vue +93 -0
  15. package/src/icons/AppManageIcon.vue +1 -1
  16. package/src/icons/CodeIcon.vue +1 -10
  17. package/src/index.ts +6 -0
  18. package/src/initService.ts +59 -3
  19. package/src/layouts/sidebar/LayerPanel.vue +2 -0
  20. package/src/layouts/sidebar/Sidebar.vue +24 -14
  21. package/src/layouts/sidebar/code-block/CodeBlockList.vue +11 -4
  22. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +84 -0
  23. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +130 -0
  24. package/src/services/codeBlock.ts +0 -2
  25. package/src/services/dataSource.ts +90 -0
  26. package/src/services/props.ts +2 -15
  27. package/src/theme/code-block.scss +4 -66
  28. package/src/theme/data-source-fields.scss +13 -0
  29. package/src/theme/data-source.scss +17 -0
  30. package/src/theme/dep-list.scss +59 -0
  31. package/src/theme/key-value.scss +13 -0
  32. package/src/theme/sidebar.scss +26 -6
  33. package/src/theme/theme.scss +4 -0
  34. package/src/type.ts +3 -1
  35. package/src/utils/data-source/formConfigs/base.ts +32 -0
  36. package/src/utils/data-source/formConfigs/http.ts +50 -0
  37. package/src/utils/data-source/index.ts +31 -0
  38. package/src/utils/dep.ts +9 -1
  39. package/src/utils/props.ts +1 -0
  40. package/types/Editor.vue.d.ts +9 -0
  41. package/types/components/ContentMenu.vue.d.ts +2 -2
  42. package/types/components/ScrollViewer.vue.d.ts +1 -1
  43. package/types/editorProps.d.ts +4 -0
  44. package/types/fields/DataSourceFields.vue.d.ts +40 -0
  45. package/types/fields/KeyValue.vue.d.ts +50 -0
  46. package/types/index.d.ts +2 -0
  47. package/types/initService.d.ts +1 -1
  48. package/types/layouts/CodeEditor.vue.d.ts +1 -1
  49. package/types/layouts/sidebar/Sidebar.vue.d.ts +2 -2
  50. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +22 -0
  51. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +12 -0
  52. package/types/services/dataSource.d.ts +25 -0
  53. package/types/services/props.d.ts +17 -12
  54. package/types/type.d.ts +3 -1
  55. package/types/utils/data-source/formConfigs/base.d.ts +3 -0
  56. package/types/utils/data-source/formConfigs/http.d.ts +3 -0
  57. package/types/utils/data-source/index.d.ts +2 -0
  58. package/types/utils/dep.d.ts +2 -1
  59. package/types/utils/props.d.ts +2 -3
@@ -1,23 +1,24 @@
1
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, createElementBlock, normalizeClass, createVNode, withCtx, createElementVNode, resolveDynamicComponent, toRaw, inject, ref, Fragment, renderList, createTextVNode, withModifiers, createCommentVNode, toDisplayString, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, mergeProps, markRaw, getCurrentInstance, watchEffect, createStaticVNode, withDirectives, Teleport, vShow, nextTick, toHandlers, provide } from 'vue';
1
+ import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, createElementBlock, normalizeClass, createVNode, withCtx, createElementVNode, resolveDynamicComponent, toRaw, inject, ref, createTextVNode, Fragment, renderList, watchEffect, withModifiers, createCommentVNode, toDisplayString, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, mergeProps, markRaw, getCurrentInstance, createStaticVNode, withDirectives, Teleport, vShow, nextTick, toHandlers, provide } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
3
  import { isEmpty, map, has, throttle, cloneDeep, mergeWith, isObject, uniq, forIn, difference, union, pick, keys } from 'lodash-es';
4
- import { TMagicCard, TMagicIcon, TMagicButton, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, TMagicInput, tMagicMessageBox, TMagicDrawer, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
4
+ import { TMagicCard, TMagicIcon, TMagicButton, tMagicMessageBox, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, TMagicDrawer, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicPopover } from '@tmagic/design';
5
5
  import { HookType, ActionType, NodeType } from '@tmagic/schema';
6
- import { Edit, View, Delete, Close, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Files, CopyDocument, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
7
- import { createValues, MForm } from '@tmagic/form';
6
+ import { Edit, View, Delete, Plus, Close, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Coin, Aim, Files, CopyDocument, Goods, List, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
7
+ import { createValues, MFormDialog, MForm } from '@tmagic/form';
8
+ import { MagicTable } from '@tmagic/table';
8
9
  import * as monaco from 'monaco-editor';
9
10
  import Gesto from 'gesto';
10
- import { isPop, getNodePath, isNumber, isPage, toLine, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
11
+ import { isPop, getNodePath, isNumber, isPage, toLine, guid, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
11
12
  import KeyController from 'keycon';
12
13
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
13
14
  import { EventEmitter } from 'events';
14
15
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
15
16
 
16
- const __default__$v = defineComponent({
17
+ const __default__$w = defineComponent({
17
18
  name: "MEditorCode"
18
19
  });
19
- const _sfc_main$z = /* @__PURE__ */ defineComponent({
20
- ...__default__$v,
20
+ const _sfc_main$D = /* @__PURE__ */ defineComponent({
21
+ ...__default__$w,
21
22
  props: {
22
23
  model: null,
23
24
  name: null,
@@ -46,11 +47,11 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
46
47
  }
47
48
  });
48
49
 
49
- const __default__$u = defineComponent({
50
+ const __default__$v = defineComponent({
50
51
  name: "MEditorCodeLink"
51
52
  });
52
- const _sfc_main$y = /* @__PURE__ */ defineComponent({
53
- ...__default__$u,
53
+ const _sfc_main$C = /* @__PURE__ */ defineComponent({
54
+ ...__default__$v,
54
55
  props: {
55
56
  config: null,
56
57
  model: null,
@@ -119,11 +120,11 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
119
120
  }
120
121
  });
121
122
 
122
- const __default__$t = defineComponent({
123
+ const __default__$u = defineComponent({
123
124
  name: "MEditorCodeSelect"
124
125
  });
125
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
126
- ...__default__$t,
126
+ const _sfc_main$B = /* @__PURE__ */ defineComponent({
127
+ ...__default__$u,
127
128
  props: {
128
129
  config: null,
129
130
  model: null,
@@ -140,7 +141,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
140
141
  enableToggleMode: false,
141
142
  items: [
142
143
  {
143
- type: "code-select-col"
144
+ type: "code-select-col",
145
+ labelWidth: 0
144
146
  }
145
147
  ]
146
148
  }));
@@ -181,12 +183,12 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
181
183
  }
182
184
  });
183
185
 
184
- const _hoisted_1$j = ["src"];
185
- const __default__$s = defineComponent({
186
+ const _hoisted_1$n = ["src"];
187
+ const __default__$t = defineComponent({
186
188
  name: "MEditorIcon"
187
189
  });
188
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
189
- ...__default__$s,
190
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
191
+ ...__default__$t,
190
192
  props: {
191
193
  icon: null
192
194
  },
@@ -205,7 +207,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
205
207
  class: "magic-editor-icon"
206
208
  }, {
207
209
  default: withCtx(() => [
208
- createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$j)
210
+ createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$n)
209
211
  ]),
210
212
  _: 1
211
213
  })) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -224,13 +226,13 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
224
226
  }
225
227
  });
226
228
 
227
- const _hoisted_1$i = { class: "m-fields-code-select-col" };
228
- const _hoisted_2$a = { class: "code-select-container" };
229
- const __default__$r = defineComponent({
229
+ const _hoisted_1$m = { class: "m-fields-code-select-col" };
230
+ const _hoisted_2$e = { class: "code-select-container" };
231
+ const __default__$s = defineComponent({
230
232
  name: "MEditorCodeSelectCol"
231
233
  });
232
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
233
- ...__default__$r,
234
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
235
+ ...__default__$s,
234
236
  props: {
235
237
  config: null,
236
238
  model: null,
@@ -318,15 +320,15 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
318
320
  };
319
321
  return (_ctx, _cache) => {
320
322
  const _component_m_form_container = resolveComponent("m-form-container");
321
- return openBlock(), createElementBlock("div", _hoisted_1$i, [
322
- createElementVNode("div", _hoisted_2$a, [
323
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
324
+ createElementVNode("div", _hoisted_2$e, [
323
325
  createVNode(_component_m_form_container, {
324
326
  class: "select",
325
327
  config: selectConfig,
326
328
  model: __props.model,
327
329
  onChange: onParamsChangeHandler
328
330
  }, null, 8, ["model"]),
329
- createVNode(_sfc_main$w, {
331
+ createVNode(_sfc_main$A, {
330
332
  class: "icon",
331
333
  icon: unref(editable) ? unref(Edit) : unref(View),
332
334
  onClick: editCode
@@ -342,17 +344,196 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
342
344
  }
343
345
  });
344
346
 
345
- const _hoisted_1$h = { class: "m-fields-event-select" };
346
- const _hoisted_2$9 = {
347
+ const _hoisted_1$l = { class: "m-editor-data-source-fields" };
348
+ const _hoisted_2$d = { class: "m-editor-data-source-fields-footer" };
349
+ const _hoisted_3$8 = /* @__PURE__ */ createTextVNode("添加");
350
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
351
+ __name: "DataSourceFields",
352
+ props: {
353
+ config: null,
354
+ model: null,
355
+ prop: null,
356
+ disabled: { type: Boolean, default: false },
357
+ name: null
358
+ },
359
+ emits: ["change"],
360
+ setup(__props, { emit }) {
361
+ const props = __props;
362
+ const addDialog = ref();
363
+ const fieldValues = ref({});
364
+ const filedTitle = ref("");
365
+ const newHandler = () => {
366
+ if (!addDialog.value)
367
+ return;
368
+ fieldValues.value = {};
369
+ filedTitle.value = "新增属性";
370
+ addDialog.value.dialogVisible = true;
371
+ };
372
+ const fieldChange = ({ index, ...value }) => {
373
+ if (!addDialog.value)
374
+ return;
375
+ if (index > -1) {
376
+ props.model[props.name][index] = value;
377
+ } else {
378
+ props.model[props.name].push(value);
379
+ }
380
+ addDialog.value.dialogVisible = false;
381
+ emit("change", props.model[props.name]);
382
+ };
383
+ const filedColumns = [
384
+ {
385
+ label: "属性名称",
386
+ prop: "title"
387
+ },
388
+ {
389
+ label: "属性key",
390
+ prop: "name"
391
+ },
392
+ {
393
+ label: "属性描述",
394
+ prop: "desc"
395
+ },
396
+ {
397
+ label: "操作",
398
+ fixed: "right",
399
+ actions: [
400
+ {
401
+ text: "编辑",
402
+ handler: (row, index) => {
403
+ if (!addDialog.value)
404
+ return;
405
+ fieldValues.value = {
406
+ ...row,
407
+ index
408
+ };
409
+ filedTitle.value = `编辑${row.title}`;
410
+ addDialog.value.dialogVisible = true;
411
+ }
412
+ },
413
+ {
414
+ text: "删除",
415
+ buttonType: "danger",
416
+ handler: async (row, index) => {
417
+ await tMagicMessageBox.confirm(`确定删除${row.title}(${row.name})?`, "提示");
418
+ props.model[props.name].splice(index, 1);
419
+ emit("change", props.model[props.name]);
420
+ }
421
+ }
422
+ ]
423
+ }
424
+ ];
425
+ const dataSourceFieldsConfig = [
426
+ { name: "index", type: "hidden", filter: "number", defaultValue: -1 },
427
+ {
428
+ name: "type",
429
+ text: "数据类型",
430
+ type: "select",
431
+ defaultValue: "string",
432
+ options: [
433
+ { text: "字符串", value: "string" },
434
+ { text: "数字", value: "number" },
435
+ { text: "布尔值", value: "boolean" },
436
+ { text: "对象", value: "object" },
437
+ { text: "数组", value: "array" },
438
+ { text: "null", value: "null" },
439
+ { text: "any", value: "any" }
440
+ ]
441
+ },
442
+ {
443
+ name: "name",
444
+ text: "字段名称",
445
+ rules: [
446
+ {
447
+ required: true,
448
+ message: "请输入字段名称"
449
+ },
450
+ {
451
+ validator: ({ value, callback }, { model, parent }) => {
452
+ const index = parent.findIndex((item) => item.name === value);
453
+ if (model.index === -1 && index > -1 || model.index > -1 && index !== model.index) {
454
+ return callback(`属性key(${value})已存在`);
455
+ }
456
+ callback();
457
+ }
458
+ }
459
+ ]
460
+ },
461
+ {
462
+ name: "title",
463
+ text: "展示名称",
464
+ rules: [
465
+ {
466
+ required: true,
467
+ message: "请输入展示名称"
468
+ }
469
+ ]
470
+ },
471
+ {
472
+ name: "description",
473
+ text: "描述"
474
+ },
475
+ {
476
+ name: "defaultValue",
477
+ text: "默认值"
478
+ },
479
+ {
480
+ name: "enable",
481
+ text: "是否可用",
482
+ type: "switch",
483
+ defaultValue: true
484
+ },
485
+ {
486
+ name: "fields",
487
+ type: "data-source-fields",
488
+ defaultValue: [],
489
+ display: (formState, { model }) => model.type === "object"
490
+ }
491
+ ];
492
+ return (_ctx, _cache) => {
493
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
494
+ createVNode(unref(MagicTable), {
495
+ data: __props.model[__props.name],
496
+ columns: filedColumns
497
+ }, null, 8, ["data"]),
498
+ createElementVNode("div", _hoisted_2$d, [
499
+ createVNode(unref(TMagicButton), {
500
+ size: "small",
501
+ type: "primary",
502
+ disabled: __props.disabled,
503
+ plain: "",
504
+ onClick: _cache[0] || (_cache[0] = ($event) => newHandler())
505
+ }, {
506
+ default: withCtx(() => [
507
+ _hoisted_3$8
508
+ ]),
509
+ _: 1
510
+ }, 8, ["disabled"])
511
+ ]),
512
+ createVNode(unref(MFormDialog), {
513
+ ref_key: "addDialog",
514
+ ref: addDialog,
515
+ title: filedTitle.value,
516
+ config: dataSourceFieldsConfig,
517
+ values: fieldValues.value,
518
+ parentValues: __props.model[__props.name],
519
+ onSubmit: fieldChange
520
+ }, null, 8, ["title", "values", "parentValues"])
521
+ ]);
522
+ };
523
+ }
524
+ });
525
+
526
+ const _hoisted_1$k = { class: "m-fields-event-select" };
527
+ const _hoisted_2$c = {
347
528
  key: 1,
348
529
  class: "fullWidth"
349
530
  };
350
- const _hoisted_3$5 = /* @__PURE__ */ createTextVNode("添加事件");
351
- const __default__$q = defineComponent({
531
+ const _hoisted_3$7 = /* @__PURE__ */ createTextVNode("添加事件");
532
+ const __default__$r = defineComponent({
352
533
  name: "MEditorEventSelect"
353
534
  });
354
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
355
- ...__default__$q,
535
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
536
+ ...__default__$r,
356
537
  props: {
357
538
  config: null,
358
539
  model: null,
@@ -431,6 +612,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
431
612
  const codeActionConfig = computed(() => {
432
613
  const defaultCodeActionConfig = {
433
614
  type: "code-select-col",
615
+ labelWidth: 0,
434
616
  display: (mForm, { model }) => model.actionType === ActionType.CODE
435
617
  };
436
618
  return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
@@ -508,7 +690,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
508
690
  const _component_m_form_table = resolveComponent("m-form-table");
509
691
  const _component_m_form_container = resolveComponent("m-form-container");
510
692
  const _component_m_form_panel = resolveComponent("m-form-panel");
511
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
693
+ return openBlock(), createElementBlock("div", _hoisted_1$k, [
512
694
  unref(isOldVersion) ? (openBlock(), createBlock(_component_m_form_table, {
513
695
  key: 0,
514
696
  ref: "eventForm",
@@ -517,7 +699,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
517
699
  name: "events",
518
700
  config: unref(tableConfig),
519
701
  onChange: onChangeHandler
520
- }, null, 8, ["size", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$9, [
702
+ }, null, 8, ["size", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$c, [
521
703
  createVNode(unref(TMagicButton), {
522
704
  class: "create-button",
523
705
  type: "primary",
@@ -525,7 +707,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
525
707
  onClick: _cache[0] || (_cache[0] = ($event) => addEvent())
526
708
  }, {
527
709
  default: withCtx(() => [
528
- _hoisted_3$5
710
+ _hoisted_3$7
529
711
  ]),
530
712
  _: 1
531
713
  }),
@@ -559,12 +741,106 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
559
741
  }
560
742
  });
561
743
 
562
- const _hoisted_1$g = /* @__PURE__ */ createTextVNode("取消");
563
- const __default__$p = defineComponent({
744
+ const _hoisted_1$j = { class: "m-fields-key-value" };
745
+ const _hoisted_2$b = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
746
+ const _hoisted_3$6 = /* @__PURE__ */ createTextVNode("添加");
747
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
748
+ __name: "KeyValue",
749
+ props: {
750
+ config: null,
751
+ model: null,
752
+ name: null,
753
+ prop: null,
754
+ disabled: { type: Boolean, default: false },
755
+ lastValues: null,
756
+ size: null
757
+ },
758
+ emits: ["change"],
759
+ setup(__props, { emit }) {
760
+ const props = __props;
761
+ const records = ref([]);
762
+ watchEffect(() => {
763
+ records.value = Object.entries(props.model[props.name] || {});
764
+ });
765
+ const getValue = () => {
766
+ const record = {};
767
+ records.value.forEach(([key, value]) => {
768
+ if (key) {
769
+ record[key] = value;
770
+ }
771
+ });
772
+ return record;
773
+ };
774
+ const keyChangeHandler = () => {
775
+ emit("change", getValue());
776
+ };
777
+ const valueChangeHandler = () => {
778
+ emit("change", getValue());
779
+ };
780
+ const addHandler = () => {
781
+ records.value.push(["", ""]);
782
+ };
783
+ const deleteHandler = (index) => {
784
+ records.value.splice(index, 1);
785
+ };
786
+ return (_ctx, _cache) => {
787
+ return openBlock(), createElementBlock("div", _hoisted_1$j, [
788
+ (openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
789
+ return openBlock(), createElementBlock("div", {
790
+ class: "m-fields-key-value-item",
791
+ key: index
792
+ }, [
793
+ createVNode(unref(TMagicInput), {
794
+ placeholder: "key",
795
+ modelValue: records.value[index][0],
796
+ "onUpdate:modelValue": ($event) => records.value[index][0] = $event,
797
+ disabled: __props.disabled,
798
+ size: __props.size,
799
+ onChange: keyChangeHandler
800
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
801
+ _hoisted_2$b,
802
+ createVNode(unref(TMagicInput), {
803
+ placeholder: "value",
804
+ modelValue: records.value[index][1],
805
+ "onUpdate:modelValue": ($event) => records.value[index][1] = $event,
806
+ disabled: __props.disabled,
807
+ size: __props.size,
808
+ onChange: valueChangeHandler
809
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
810
+ createVNode(unref(TMagicButton), {
811
+ class: "m-fileds-key-value-delete",
812
+ type: "danger",
813
+ size: __props.size,
814
+ circle: "",
815
+ plain: "",
816
+ icon: unref(Delete),
817
+ onClick: ($event) => deleteHandler(index)
818
+ }, null, 8, ["size", "icon", "onClick"])
819
+ ]);
820
+ }), 128)),
821
+ createVNode(unref(TMagicButton), {
822
+ type: "primary",
823
+ size: __props.size,
824
+ plain: "",
825
+ icon: unref(Plus),
826
+ onClick: addHandler
827
+ }, {
828
+ default: withCtx(() => [
829
+ _hoisted_3$6
830
+ ]),
831
+ _: 1
832
+ }, 8, ["size", "icon"])
833
+ ]);
834
+ };
835
+ }
836
+ });
837
+
838
+ const _hoisted_1$i = /* @__PURE__ */ createTextVNode("取消");
839
+ const __default__$q = defineComponent({
564
840
  name: "MEditorUISelect"
565
841
  });
566
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
567
- ...__default__$p,
842
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
843
+ ...__default__$q,
568
844
  props: {
569
845
  config: null,
570
846
  model: null,
@@ -626,7 +902,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
626
902
  style: { "padding": "0" }
627
903
  }, {
628
904
  default: withCtx(() => [
629
- _hoisted_1$g
905
+ _hoisted_1$i
630
906
  ]),
631
907
  _: 1
632
908
  }, 8, ["icon"])
@@ -674,11 +950,11 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
674
950
 
675
951
  const UISelect_vue_vue_type_style_index_0_lang = '';
676
952
 
677
- const __default__$o = defineComponent({
953
+ const __default__$p = defineComponent({
678
954
  name: "MEditorCodeEditor"
679
955
  });
680
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
681
- ...__default__$o,
956
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
957
+ ...__default__$p,
682
958
  props: {
683
959
  initValues: null,
684
960
  modifiedValues: null,
@@ -807,11 +1083,11 @@ const setConfig = (option) => {
807
1083
  };
808
1084
  const getConfig = (key) => $TMAGIC_EDITOR[key];
809
1085
 
810
- const __default__$n = defineComponent({
1086
+ const __default__$o = defineComponent({
811
1087
  name: "MEditorResizer"
812
1088
  });
813
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
814
- ...__default__$n,
1089
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1090
+ ...__default__$o,
815
1091
  emits: ["change"],
816
1092
  setup(__props, { emit }) {
817
1093
  const target = ref();
@@ -843,11 +1119,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
843
1119
  }
844
1120
  });
845
1121
 
846
- const __default__$m = defineComponent({
1122
+ const __default__$n = defineComponent({
847
1123
  name: "MEditorLayout"
848
1124
  });
849
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
850
- ...__default__$m,
1125
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1126
+ ...__default__$n,
851
1127
  props: {
852
1128
  left: null,
853
1129
  right: null,
@@ -955,7 +1231,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
955
1231
  }, [
956
1232
  renderSlot(_ctx.$slots, "left")
957
1233
  ], 6),
958
- createVNode(_sfc_main$r, { onChange: changeLeft })
1234
+ createVNode(_sfc_main$t, { onChange: changeLeft })
959
1235
  ], 64)) : createCommentVNode("", true),
960
1236
  createElementVNode("div", {
961
1237
  class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
@@ -964,7 +1240,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
964
1240
  renderSlot(_ctx.$slots, "center")
965
1241
  ], 6),
966
1242
  unref(hasRight) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
967
- createVNode(_sfc_main$r, { onChange: changeRight }),
1243
+ createVNode(_sfc_main$t, { onChange: changeRight }),
968
1244
  createElementVNode("div", {
969
1245
  class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
970
1246
  style: normalizeStyle(`width: ${__props.right}px`)
@@ -977,7 +1253,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
977
1253
  }
978
1254
  });
979
1255
 
980
- const fillConfig = (config = []) => [
1256
+ const fillConfig$1 = (config = []) => [
981
1257
  {
982
1258
  type: "tab",
983
1259
  items: [
@@ -1133,7 +1409,8 @@ const fillConfig = (config = []) => [
1133
1409
  items: [
1134
1410
  {
1135
1411
  name: "events",
1136
- type: "event-select"
1412
+ type: "event-select",
1413
+ labelWidth: 0
1137
1414
  }
1138
1415
  ]
1139
1416
  },
@@ -1763,7 +2040,7 @@ class Props extends BaseService {
1763
2040
  this.emit("props-configs-change");
1764
2041
  }
1765
2042
  async fillConfig(config) {
1766
- return fillConfig(config);
2043
+ return fillConfig$1(config);
1767
2044
  }
1768
2045
  /**
1769
2046
  * 为指定类型组件设置组件属性表单配置
@@ -1829,7 +2106,7 @@ class Props extends BaseService {
1829
2106
  };
1830
2107
  }
1831
2108
  async createId(type) {
1832
- return `${type}_${this.guid()}`;
2109
+ return `${type}_${guid()}`;
1833
2110
  }
1834
2111
  /**
1835
2112
  * 将组件与组件的子元素配置中的id都设置成一个新的ID
@@ -1872,18 +2149,6 @@ class Props extends BaseService {
1872
2149
  this.removeAllListeners();
1873
2150
  this.removeAllPlugins();
1874
2151
  }
1875
- /**
1876
- * 生成指定位数的GUID,无【-】格式
1877
- * @param digit 位数,默认值8
1878
- * @returns
1879
- */
1880
- guid(digit = 8) {
1881
- return "x".repeat(digit).replace(/[xy]/g, (c) => {
1882
- const r = Math.random() * 16 | 0;
1883
- const v = c === "x" ? r : r & 3 | 8;
1884
- return v.toString(16);
1885
- });
1886
- }
1887
2152
  }
1888
2153
  const propsService = new Props();
1889
2154
 
@@ -2842,14 +3107,14 @@ const useStage = (stageOptions) => {
2842
3107
  return stage;
2843
3108
  };
2844
3109
 
2845
- const _hoisted_1$f = { class: "m-editor-empty-panel" };
2846
- const _hoisted_2$8 = { class: "m-editor-empty-content" };
2847
- const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
2848
- const __default__$l = defineComponent({
3110
+ const _hoisted_1$h = { class: "m-editor-empty-panel" };
3111
+ const _hoisted_2$a = { class: "m-editor-empty-content" };
3112
+ const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
3113
+ const __default__$m = defineComponent({
2849
3114
  name: "MEditorAddPageBox"
2850
3115
  });
2851
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
2852
- ...__default__$l,
3116
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3117
+ ...__default__$m,
2853
3118
  setup(__props) {
2854
3119
  const services = inject("services");
2855
3120
  const clickHandler = () => {
@@ -2865,16 +3130,16 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
2865
3130
  });
2866
3131
  };
2867
3132
  return (_ctx, _cache) => {
2868
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
2869
- createElementVNode("div", _hoisted_2$8, [
3133
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
3134
+ createElementVNode("div", _hoisted_2$a, [
2870
3135
  createElementVNode("div", {
2871
3136
  class: "m-editor-empty-button",
2872
3137
  onClick: clickHandler
2873
3138
  }, [
2874
3139
  createElementVNode("div", null, [
2875
- createVNode(_sfc_main$w, { icon: unref(Plus) }, null, 8, ["icon"])
3140
+ createVNode(_sfc_main$A, { icon: unref(Plus) }, null, 8, ["icon"])
2876
3141
  ]),
2877
- _hoisted_3$4
3142
+ _hoisted_3$5
2878
3143
  ])
2879
3144
  ])
2880
3145
  ]);
@@ -2882,12 +3147,12 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
2882
3147
  }
2883
3148
  });
2884
3149
 
2885
- const _hoisted_1$e = { class: "m-editor" };
2886
- const __default__$k = defineComponent({
3150
+ const _hoisted_1$g = { class: "m-editor" };
3151
+ const __default__$l = defineComponent({
2887
3152
  name: "MEditorFramework"
2888
3153
  });
2889
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
2890
- ...__default__$k,
3154
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3155
+ ...__default__$l,
2891
3156
  props: {
2892
3157
  codeOptions: { default: () => ({}) }
2893
3158
  },
@@ -2956,7 +3221,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2956
3221
  };
2957
3222
  return (_ctx, _cache) => {
2958
3223
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
2959
- return openBlock(), createElementBlock("div", _hoisted_1$e, [
3224
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
2960
3225
  renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2961
3226
  unref(showSrc) ? (openBlock(), createBlock(_component_magic_code_editor, {
2962
3227
  key: 0,
@@ -2964,7 +3229,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2964
3229
  "init-values": unref(root),
2965
3230
  options: __props.codeOptions,
2966
3231
  onSave: saveCode
2967
- }, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$q, {
3232
+ }, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$s, {
2968
3233
  key: 1,
2969
3234
  class: "m-editor-content",
2970
3235
  "left-class": "m-editor-framework-left",
@@ -2983,7 +3248,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2983
3248
  ]),
2984
3249
  center: withCtx(() => [
2985
3250
  unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2986
- createVNode(_sfc_main$p)
3251
+ createVNode(_sfc_main$r)
2987
3252
  ])
2988
3253
  ]),
2989
3254
  _: 2
@@ -3005,16 +3270,16 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3005
3270
  }
3006
3271
  });
3007
3272
 
3008
- const _hoisted_1$d = {
3273
+ const _hoisted_1$f = {
3009
3274
  key: 1,
3010
3275
  class: "menu-item-text"
3011
3276
  };
3012
- const _hoisted_2$7 = { class: "el-dropdown-link menubar-menu-button" };
3013
- const __default__$j = defineComponent({
3277
+ const _hoisted_2$9 = { class: "el-dropdown-link menubar-menu-button" };
3278
+ const __default__$k = defineComponent({
3014
3279
  name: "MEditorToolButton"
3015
3280
  });
3016
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
3017
- ...__default__$j,
3281
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3282
+ ...__default__$k,
3018
3283
  props: {
3019
3284
  data: { default: () => ({
3020
3285
  type: "text",
@@ -3089,7 +3354,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3089
3354
  __props.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
3090
3355
  key: 0,
3091
3356
  direction: __props.data.direction || "vertical"
3092
- }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$d, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3357
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$f, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3093
3358
  __props.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
3094
3359
  key: 0,
3095
3360
  effect: "dark",
@@ -3103,7 +3368,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3103
3368
  disabled: unref(disabled)
3104
3369
  }, {
3105
3370
  default: withCtx(() => [
3106
- __props.data.icon ? (openBlock(), createBlock(_sfc_main$w, {
3371
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$A, {
3107
3372
  key: 0,
3108
3373
  icon: __props.data.icon
3109
3374
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -3120,7 +3385,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3120
3385
  disabled: unref(disabled)
3121
3386
  }, {
3122
3387
  default: withCtx(() => [
3123
- __props.data.icon ? (openBlock(), createBlock(_sfc_main$w, {
3388
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$A, {
3124
3389
  key: 0,
3125
3390
  icon: __props.data.icon
3126
3391
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -3153,7 +3418,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3153
3418
  })) : createCommentVNode("", true)
3154
3419
  ]),
3155
3420
  default: withCtx(() => [
3156
- createElementVNode("span", _hoisted_2$7, [
3421
+ createElementVNode("span", _hoisted_2$9, [
3157
3422
  createTextVNode(toDisplayString(__props.data.text), 1),
3158
3423
  createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
3159
3424
  default: withCtx(() => [
@@ -3170,11 +3435,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3170
3435
  }
3171
3436
  });
3172
3437
 
3173
- const __default__$i = defineComponent({
3438
+ const __default__$j = defineComponent({
3174
3439
  name: "MEditorNavMenu"
3175
3440
  });
3176
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
3177
- ...__default__$i,
3441
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3442
+ ...__default__$j,
3178
3443
  props: {
3179
3444
  data: { default: () => ({}) },
3180
3445
  height: { default: 35 }
@@ -3332,7 +3597,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
3332
3597
  style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
3333
3598
  }, [
3334
3599
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
3335
- return openBlock(), createBlock(_sfc_main$n, {
3600
+ return openBlock(), createBlock(_sfc_main$p, {
3336
3601
  data: item,
3337
3602
  key: index
3338
3603
  }, null, 8, ["data"]);
@@ -3344,12 +3609,12 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
3344
3609
  }
3345
3610
  });
3346
3611
 
3347
- const _hoisted_1$c = { class: "m-editor-props-panel" };
3348
- const __default__$h = defineComponent({
3612
+ const _hoisted_1$e = { class: "m-editor-props-panel" };
3613
+ const __default__$i = defineComponent({
3349
3614
  name: "MEditorPropsPanel"
3350
3615
  });
3351
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
3352
- ...__default__$h,
3616
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
3617
+ ...__default__$i,
3353
3618
  emits: ["mounted"],
3354
3619
  setup(__props, { expose, emit }) {
3355
3620
  const internalInstance = getCurrentInstance();
@@ -3394,7 +3659,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
3394
3659
  };
3395
3660
  expose({ submit });
3396
3661
  return (_ctx, _cache) => {
3397
- return openBlock(), createElementBlock("div", _hoisted_1$c, [
3662
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
3398
3663
  renderSlot(_ctx.$slots, "props-panel-header"),
3399
3664
  createVNode(unref(MForm), {
3400
3665
  ref_key: "configForm",
@@ -3411,7 +3676,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
3411
3676
  }
3412
3677
  });
3413
3678
 
3414
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
3679
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
3415
3680
  __name: "SearchInput",
3416
3681
  emits: ["search"],
3417
3682
  setup(__props, { emit }) {
@@ -3427,9 +3692,18 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
3427
3692
  size: "small",
3428
3693
  placeholder: "输入关键字进行过滤",
3429
3694
  clearable: "",
3430
- "prefix-icon": unref(Search),
3431
3695
  onInput: filterTextChangeHandler
3432
- }, null, 8, ["modelValue", "prefix-icon"]);
3696
+ }, {
3697
+ prefix: withCtx(() => [
3698
+ createVNode(unref(TMagicIcon), null, {
3699
+ default: withCtx(() => [
3700
+ createVNode(unref(Search))
3701
+ ]),
3702
+ _: 1
3703
+ })
3704
+ ]),
3705
+ _: 1
3706
+ }, 8, ["modelValue"]);
3433
3707
  };
3434
3708
  }
3435
3709
  });
@@ -3442,14 +3716,10 @@ const _export_sfc = (sfc, props) => {
3442
3716
  return target;
3443
3717
  };
3444
3718
 
3445
- const _sfc_main$j = {};
3719
+ const _sfc_main$l = {};
3446
3720
 
3447
- const _hoisted_1$b = {
3448
- width: "16px",
3449
- height: "16px",
3450
- xmlns: "http://www.w3.org/2000/svg"
3451
- };
3452
- const _hoisted_2$6 = /*#__PURE__*/createElementVNode("g", {
3721
+ const _hoisted_1$d = { xmlns: "http://www.w3.org/2000/svg" };
3722
+ const _hoisted_2$8 = /*#__PURE__*/createElementVNode("g", {
3453
3723
  fill: "#7C878E",
3454
3724
  "fill-rule": "evenodd"
3455
3725
  }, [
@@ -3459,51 +3729,49 @@ const _hoisted_2$6 = /*#__PURE__*/createElementVNode("g", {
3459
3729
  }),
3460
3730
  /*#__PURE__*/createElementVNode("path", { d: "M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" })
3461
3731
  ], -1);
3462
- const _hoisted_3$3 = [
3463
- _hoisted_2$6
3732
+ const _hoisted_3$4 = [
3733
+ _hoisted_2$8
3464
3734
  ];
3465
3735
 
3466
3736
  function _sfc_render$2(_ctx, _cache) {
3467
- return (openBlock(), createElementBlock("svg", _hoisted_1$b, _hoisted_3$3))
3737
+ return (openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_3$4))
3468
3738
  }
3469
- const AppManageIcon = /*#__PURE__*/_export_sfc(_sfc_main$j, [['render',_sfc_render$2]]);
3739
+ const AppManageIcon = /*#__PURE__*/_export_sfc(_sfc_main$l, [['render',_sfc_render$2]]);
3470
3740
 
3471
- const _sfc_main$i = {};
3741
+ const _sfc_main$k = {};
3472
3742
 
3473
- const _hoisted_1$a = {
3474
- width: "32px",
3475
- height: "32px",
3743
+ const _hoisted_1$c = {
3476
3744
  viewBox: "0 0 32 32",
3477
3745
  version: "1.1",
3478
3746
  xmlns: "http://www.w3.org/2000/svg",
3479
3747
  "xmlns:xlink": "http://www.w3.org/1999/xlink"
3480
3748
  };
3481
- const _hoisted_2$5 = /*#__PURE__*/createStaticVNode("<title>gsd-icon-line-Universal-code</title><desc>Created with Sketch.</desc><defs><rect id=\"path-1\" x=\"0\" y=\"0\" width=\"32\" height=\"32\"></rect></defs><g id=\"组件规范\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"03图标\" transform=\"translate(-561.000000, -2356.000000)\"><g id=\"icon/line/Universal/code\" transform=\"translate(561.000000, 2356.000000)\"><g id=\"路径\"><mask id=\"mask-2\" fill=\"white\"><use xlink:href=\"#path-1\"></use></mask><use id=\"蒙版\" fill=\"#D8D8D8\" opacity=\"0\" xlink:href=\"#path-1\"></use><path d=\"M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z\" id=\"形状\" fill=\"#1D1F24\" mask=\"url(#mask-2)\"></path></g></g><g id=\"icon切图\" transform=\"translate(226.000000, 1782.000000)\"></g></g></g>", 4);
3482
- const _hoisted_6 = [
3483
- _hoisted_2$5
3749
+ const _hoisted_2$7 = /*#__PURE__*/createStaticVNode("<defs><rect id=\"path-1\" x=\"0\" y=\"0\" width=\"32\" height=\"32\"></rect></defs><g id=\"组件规范\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"03图标\" transform=\"translate(-561.000000, -2356.000000)\"><g id=\"icon/line/Universal/code\" transform=\"translate(561.000000, 2356.000000)\"><g id=\"路径\"><mask id=\"mask-2\" fill=\"white\"><use xlink:href=\"#path-1\"></use></mask><use id=\"蒙版\" fill=\"#D8D8D8\" opacity=\"0\" xlink:href=\"#path-1\"></use><path d=\"M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z\" id=\"形状\" fill=\"#1D1F24\" mask=\"url(#mask-2)\"></path></g></g><g id=\"icon切图\" transform=\"translate(226.000000, 1782.000000)\"></g></g></g>", 2);
3750
+ const _hoisted_4$4 = [
3751
+ _hoisted_2$7
3484
3752
  ];
3485
3753
 
3486
3754
  function _sfc_render$1(_ctx, _cache) {
3487
- return (openBlock(), createElementBlock("svg", _hoisted_1$a, _hoisted_6))
3755
+ return (openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_4$4))
3488
3756
  }
3489
- const CodeIcon = /*#__PURE__*/_export_sfc(_sfc_main$i, [['render',_sfc_render$1]]);
3757
+ const CodeIcon = /*#__PURE__*/_export_sfc(_sfc_main$k, [['render',_sfc_render$1]]);
3490
3758
 
3491
- const _hoisted_1$9 = {
3759
+ const _hoisted_1$b = {
3492
3760
  key: 0,
3493
3761
  class: "m-editor-content-bottom"
3494
3762
  };
3495
- const _hoisted_2$4 = /* @__PURE__ */ createTextVNode("确认");
3496
- const _hoisted_3$2 = /* @__PURE__ */ createTextVNode("关闭");
3497
- const _hoisted_4$2 = {
3763
+ const _hoisted_2$6 = /* @__PURE__ */ createTextVNode("确认");
3764
+ const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("关闭");
3765
+ const _hoisted_4$3 = {
3498
3766
  key: 1,
3499
3767
  class: "m-editor-content-bottom"
3500
3768
  };
3501
- const _hoisted_5$1 = /* @__PURE__ */ createTextVNode("关闭");
3502
- const __default__$g = defineComponent({
3769
+ const _hoisted_5$2 = /* @__PURE__ */ createTextVNode("关闭");
3770
+ const __default__$h = defineComponent({
3503
3771
  name: "MEditorCodeDraftEditor"
3504
3772
  });
3505
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
3506
- ...__default__$g,
3773
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
3774
+ ...__default__$h,
3507
3775
  props: {
3508
3776
  id: null,
3509
3777
  content: null,
@@ -3586,7 +3854,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3586
3854
  return openBlock(), createElementBlock("div", {
3587
3855
  class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
3588
3856
  }, [
3589
- createVNode(_sfc_main$s, {
3857
+ createVNode(_sfc_main$u, {
3590
3858
  ref_key: "codeEditor",
3591
3859
  ref: codeEditor,
3592
3860
  class: "m-editor-container",
@@ -3595,7 +3863,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3595
3863
  language: __props.language,
3596
3864
  options: unref(codeOptions)
3597
3865
  }, null, 8, ["init-values", "language", "options"]),
3598
- __props.editable ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
3866
+ __props.editable ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
3599
3867
  createVNode(unref(TMagicButton), {
3600
3868
  type: "primary",
3601
3869
  class: "button",
@@ -3612,21 +3880,20 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3612
3880
  onClick: saveAndClose
3613
3881
  }, {
3614
3882
  default: withCtx(() => [
3615
- _hoisted_2$4
3883
+ _hoisted_2$6
3616
3884
  ]),
3617
3885
  _: 1
3618
3886
  }),
3619
3887
  createVNode(unref(TMagicButton), {
3620
- type: "primary",
3621
3888
  class: "button",
3622
3889
  onClick: close
3623
3890
  }, {
3624
3891
  default: withCtx(() => [
3625
- _hoisted_3$2
3892
+ _hoisted_3$3
3626
3893
  ]),
3627
3894
  _: 1
3628
3895
  })
3629
- ])) : (openBlock(), createElementBlock("div", _hoisted_4$2, [
3896
+ ])) : (openBlock(), createElementBlock("div", _hoisted_4$3, [
3630
3897
  createVNode(unref(TMagicButton), {
3631
3898
  type: "primary",
3632
3899
  class: "button",
@@ -3638,12 +3905,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3638
3905
  _: 1
3639
3906
  }),
3640
3907
  createVNode(unref(TMagicButton), {
3641
- type: "primary",
3642
3908
  class: "button",
3643
3909
  onClick: close
3644
3910
  }, {
3645
3911
  default: withCtx(() => [
3646
- _hoisted_5$1
3912
+ _hoisted_5$2
3647
3913
  ]),
3648
3914
  _: 1
3649
3915
  })
@@ -3653,15 +3919,15 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
3653
3919
  }
3654
3920
  });
3655
3921
 
3656
- const _hoisted_1$8 = { class: "code-name-wrapper" };
3657
- const _hoisted_2$3 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
3658
- const _hoisted_3$1 = { class: "code-name-wrapper" };
3659
- const _hoisted_4$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "参数", -1);
3660
- const __default__$f = defineComponent({
3922
+ const _hoisted_1$a = { class: "code-name-wrapper" };
3923
+ const _hoisted_2$5 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
3924
+ const _hoisted_3$2 = { class: "code-name-wrapper" };
3925
+ const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "参数", -1);
3926
+ const __default__$g = defineComponent({
3661
3927
  name: "MEditorFunctionEditor"
3662
3928
  });
3663
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
3664
- ...__default__$f,
3929
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3930
+ ...__default__$g,
3665
3931
  props: {
3666
3932
  id: null,
3667
3933
  name: null,
@@ -3779,8 +4045,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3779
4045
  const _component_m_form_table = resolveComponent("m-form-table");
3780
4046
  return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
3781
4047
  header: withCtx(() => [
3782
- createElementVNode("div", _hoisted_1$8, [
3783
- _hoisted_2$3,
4048
+ createElementVNode("div", _hoisted_1$a, [
4049
+ _hoisted_2$5,
3784
4050
  createVNode(unref(TMagicInput), {
3785
4051
  class: "code-name-input",
3786
4052
  modelValue: codeName.value,
@@ -3788,8 +4054,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3788
4054
  disabled: !__props.editable
3789
4055
  }, null, 8, ["modelValue", "disabled"])
3790
4056
  ]),
3791
- createElementVNode("div", _hoisted_3$1, [
3792
- _hoisted_4$1,
4057
+ createElementVNode("div", _hoisted_3$2, [
4058
+ _hoisted_4$2,
3793
4059
  createVNode(_component_m_form_table, {
3794
4060
  style: { "width": "800px" },
3795
4061
  config: tableConfig,
@@ -3802,7 +4068,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3802
4068
  ])
3803
4069
  ]),
3804
4070
  default: withCtx(() => [
3805
- createVNode(_sfc_main$h, {
4071
+ createVNode(_sfc_main$j, {
3806
4072
  ref_key: "codeDraftEditor",
3807
4073
  ref: codeDraftEditor,
3808
4074
  id: __props.id,
@@ -3821,15 +4087,15 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
3821
4087
  }
3822
4088
  });
3823
4089
 
3824
- const _hoisted_1$7 = {
4090
+ const _hoisted_1$9 = {
3825
4091
  key: 0,
3826
4092
  class: "m-editor-code-block-editor-panel"
3827
4093
  };
3828
- const __default__$e = defineComponent({
4094
+ const __default__$f = defineComponent({
3829
4095
  name: "MEditorCodeBlockEditor"
3830
4096
  });
3831
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
3832
- ...__default__$e,
4097
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4098
+ ...__default__$f,
3833
4099
  props: {
3834
4100
  paramsColConfig: null
3835
4101
  },
@@ -3882,16 +4148,16 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3882
4148
  "before-close": handleClose
3883
4149
  }, {
3884
4150
  default: withCtx(() => [
3885
- createVNode(_sfc_main$q, {
4151
+ createVNode(_sfc_main$s, {
3886
4152
  left: left.value,
3887
4153
  "onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
3888
4154
  "min-left": 45,
3889
4155
  class: "code-editor-layout"
3890
4156
  }, {
3891
4157
  center: withCtx(() => [
3892
- !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
4158
+ !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
3893
4159
  renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: unref(id) }),
3894
- codeConfig.value ? (openBlock(), createBlock(_sfc_main$g, {
4160
+ codeConfig.value ? (openBlock(), createBlock(_sfc_main$i, {
3895
4161
  key: 0,
3896
4162
  ref_key: "functionEditor",
3897
4163
  ref: functionEditor,
@@ -3914,25 +4180,30 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
3914
4180
  }
3915
4181
  });
3916
4182
 
3917
- const _hoisted_1$6 = { class: "code-header-wrapper" };
3918
- const _hoisted_2$2 = /* @__PURE__ */ createTextVNode("新增");
3919
- const _hoisted_3 = ["id"];
3920
- const _hoisted_4 = { class: "list-item" };
3921
- const _hoisted_5 = {
4183
+ const _hoisted_1$8 = { class: "search-wrapper" };
4184
+ const _hoisted_2$4 = /* @__PURE__ */ createTextVNode("新增");
4185
+ const _hoisted_3$1 = ["id"];
4186
+ const _hoisted_4$1 = { class: "list-item" };
4187
+ const _hoisted_5$1 = {
3922
4188
  key: 2,
3923
4189
  class: "right-tool"
3924
4190
  };
3925
- const __default__$d = defineComponent({
4191
+ const __default__$e = defineComponent({
3926
4192
  name: "MEditorCodeBlockList"
3927
4193
  });
3928
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
3929
- ...__default__$d,
4194
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4195
+ ...__default__$e,
3930
4196
  props: {
3931
4197
  customError: null,
3932
4198
  paramsColConfig: null
3933
4199
  },
3934
4200
  setup(__props) {
3935
4201
  const props = __props;
4202
+ const treeProps = {
4203
+ children: "children",
4204
+ label: "name",
4205
+ value: "id"
4206
+ };
3936
4207
  const { codeBlockService, depService, editorService } = inject("services") || {};
3937
4208
  const codeList = computed(
3938
4209
  () => Object.values(depService?.targets["code-block"] || {}).map((target) => {
@@ -4010,11 +4281,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4010
4281
  }
4011
4282
  };
4012
4283
  return (_ctx, _cache) => {
4013
- return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list" }, {
4284
+ return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
4014
4285
  default: withCtx(() => [
4015
4286
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
4016
- createElementVNode("div", _hoisted_1$6, [
4017
- createVNode(_sfc_main$k, { onSearch: filterTextChangeHandler }),
4287
+ createElementVNode("div", _hoisted_1$8, [
4288
+ createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4018
4289
  unref(editable) ? (openBlock(), createBlock(unref(TMagicButton), {
4019
4290
  key: 0,
4020
4291
  class: "create-code-button",
@@ -4023,7 +4294,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4023
4294
  onClick: createCodeBlock
4024
4295
  }, {
4025
4296
  default: withCtx(() => [
4026
- _hoisted_2$2
4297
+ _hoisted_2$4
4027
4298
  ]),
4028
4299
  _: 1
4029
4300
  })) : createCommentVNode("", true)
@@ -4038,6 +4309,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4038
4309
  "default-expanded-keys": unref(expandedKeys),
4039
4310
  "expand-on-click-node": false,
4040
4311
  data: unref(codeList),
4312
+ props: treeProps,
4041
4313
  "highlight-current": true,
4042
4314
  "filter-node-method": filterNode,
4043
4315
  onNodeClick: clickHandler
@@ -4047,7 +4319,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4047
4319
  id: data.id,
4048
4320
  class: "list-container"
4049
4321
  }, [
4050
- createElementVNode("div", _hoisted_4, [
4322
+ createElementVNode("div", _hoisted_4$1, [
4051
4323
  data.type === "code" ? (openBlock(), createBlock(CodeIcon, {
4052
4324
  key: 0,
4053
4325
  class: "codeIcon"
@@ -4057,16 +4329,16 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4057
4329
  class: "compIcon"
4058
4330
  })) : createCommentVNode("", true),
4059
4331
  createElementVNode("span", {
4060
- class: normalizeClass(["code-name", { code: data.type === "code", hook: data.type === "key" }])
4061
- }, toDisplayString(data.name) + "" + toDisplayString(data.id) + "", 3),
4062
- data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_5, [
4332
+ class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
4333
+ }, toDisplayString(data.name) + " (" + toDisplayString(data.id) + ")", 3),
4334
+ data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
4063
4335
  createVNode(unref(TMagicTooltip), {
4064
4336
  effect: "dark",
4065
4337
  content: unref(editable) ? "编辑" : "查看",
4066
4338
  placement: "bottom"
4067
4339
  }, {
4068
4340
  default: withCtx(() => [
4069
- createVNode(_sfc_main$w, {
4341
+ createVNode(_sfc_main$A, {
4070
4342
  icon: unref(editable) ? unref(Edit) : unref(View),
4071
4343
  class: "edit-icon",
4072
4344
  onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
@@ -4081,7 +4353,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4081
4353
  placement: "bottom"
4082
4354
  }, {
4083
4355
  default: withCtx(() => [
4084
- createVNode(_sfc_main$w, {
4356
+ createVNode(_sfc_main$A, {
4085
4357
  icon: unref(Close),
4086
4358
  class: "edit-icon",
4087
4359
  onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
@@ -4095,11 +4367,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4095
4367
  })
4096
4368
  ])) : createCommentVNode("", true)
4097
4369
  ])
4098
- ], 8, _hoisted_3)
4370
+ ], 8, _hoisted_3$1)
4099
4371
  ]),
4100
4372
  _: 3
4101
4373
  }, 8, ["default-expanded-keys", "data"]),
4102
- unref(isShowCodeBlockEditor) ? (openBlock(), createBlock(_sfc_main$f, {
4374
+ unref(isShowCodeBlockEditor) ? (openBlock(), createBlock(_sfc_main$h, {
4103
4375
  key: 0,
4104
4376
  paramsColConfig: __props.paramsColConfig
4105
4377
  }, {
@@ -4115,6 +4387,263 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4115
4387
  }
4116
4388
  });
4117
4389
 
4390
+ const _hoisted_1$7 = /* @__PURE__ */ createTextVNode("确定");
4391
+ const _hoisted_2$3 = /* @__PURE__ */ createTextVNode("关闭");
4392
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
4393
+ __name: "DataSourceConfigPanel",
4394
+ props: {
4395
+ title: null,
4396
+ values: null
4397
+ },
4398
+ emits: ["submit"],
4399
+ setup(__props, { expose, emit }) {
4400
+ const props = __props;
4401
+ const type = ref("base");
4402
+ const services = inject("services");
4403
+ const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4404
+ const dataSourceConfig = computed(() => services?.dataSourceService.getFormConfig(type.value) || []);
4405
+ const form = ref();
4406
+ const initValues = ref({});
4407
+ watchEffect(() => {
4408
+ initValues.value = props.values;
4409
+ type.value = props.values.type || "base";
4410
+ });
4411
+ const changeHandler = (value) => {
4412
+ if (value.type === type.value) {
4413
+ return;
4414
+ }
4415
+ type.value = value.type || "base";
4416
+ initValues.value = value;
4417
+ };
4418
+ const submitHandler = async () => {
4419
+ try {
4420
+ const values = await form.value?.submitForm();
4421
+ emit("submit", values);
4422
+ } catch (error) {
4423
+ tMagicMessage.error(error.message);
4424
+ }
4425
+ };
4426
+ const visible = ref(false);
4427
+ const hide = () => {
4428
+ visible.value = false;
4429
+ };
4430
+ expose({
4431
+ show() {
4432
+ visible.value = true;
4433
+ },
4434
+ hide
4435
+ });
4436
+ return (_ctx, _cache) => {
4437
+ return openBlock(), createBlock(unref(TMagicDrawer), {
4438
+ modelValue: visible.value,
4439
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
4440
+ title: __props.title,
4441
+ "close-on-press-escape": true,
4442
+ "append-to-body": true,
4443
+ "show-close": true,
4444
+ "close-on-click-modal": true,
4445
+ size: unref(size)
4446
+ }, {
4447
+ footer: withCtx(() => [
4448
+ createElementVNode("div", null, [
4449
+ createVNode(unref(TMagicButton), {
4450
+ type: "primary",
4451
+ onClick: submitHandler
4452
+ }, {
4453
+ default: withCtx(() => [
4454
+ _hoisted_1$7
4455
+ ]),
4456
+ _: 1
4457
+ }),
4458
+ createVNode(unref(TMagicButton), { onClick: hide }, {
4459
+ default: withCtx(() => [
4460
+ _hoisted_2$3
4461
+ ]),
4462
+ _: 1
4463
+ })
4464
+ ])
4465
+ ]),
4466
+ default: withCtx(() => [
4467
+ createVNode(unref(MForm), {
4468
+ ref_key: "form",
4469
+ ref: form,
4470
+ config: unref(dataSourceConfig),
4471
+ "init-values": initValues.value,
4472
+ onChange: changeHandler
4473
+ }, null, 8, ["config", "init-values"])
4474
+ ]),
4475
+ _: 1
4476
+ }, 8, ["modelValue", "title", "size"]);
4477
+ };
4478
+ }
4479
+ });
4480
+
4481
+ const _hoisted_1$6 = { class: "search-wrapper" };
4482
+ const _hoisted_2$2 = /* @__PURE__ */ createTextVNode("新增");
4483
+ const _hoisted_3 = ["id"];
4484
+ const _hoisted_4 = { class: "list-item" };
4485
+ const _hoisted_5 = {
4486
+ key: 2,
4487
+ class: "right-tool"
4488
+ };
4489
+ const __default__$d = defineComponent({
4490
+ name: "MEditorDataSourceListPanel"
4491
+ });
4492
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4493
+ ...__default__$d,
4494
+ setup(__props) {
4495
+ const services = inject("services", {});
4496
+ const { dataSourceService, depService } = inject("services") || {};
4497
+ const list = computed(
4498
+ () => Object.values(depService?.targets["data-source"] || {}).map((target) => ({
4499
+ id: target.id,
4500
+ name: target.name,
4501
+ type: "code",
4502
+ children: Object.entries(target.deps).map(([id, dep]) => ({
4503
+ name: dep.name,
4504
+ type: "node",
4505
+ id,
4506
+ children: dep.keys.map((key) => ({ name: key, id: key, type: "key" }))
4507
+ }))
4508
+ }))
4509
+ );
4510
+ const editDialog = ref();
4511
+ const dataSourceValues = ref({});
4512
+ const addHandler = () => {
4513
+ if (!editDialog.value)
4514
+ return;
4515
+ dataSourceValues.value = {};
4516
+ editDialog.value.show();
4517
+ };
4518
+ const editHandler = (id) => {
4519
+ if (!editDialog.value || !services)
4520
+ return;
4521
+ dataSourceValues.value = {
4522
+ ...dataSourceService?.getDataSourceById(id)
4523
+ };
4524
+ editDialog.value.show();
4525
+ };
4526
+ const removeHandler = async (id) => {
4527
+ await tMagicMessageBox.confirm("确定删除?", "提示", {
4528
+ confirmButtonText: "确定",
4529
+ cancelButtonText: "取消",
4530
+ type: "warning"
4531
+ });
4532
+ dataSourceService?.remove(id);
4533
+ };
4534
+ const submitDataSourceHandler = (value) => {
4535
+ if (!services)
4536
+ return;
4537
+ if (value.id) {
4538
+ dataSourceService?.update(value);
4539
+ } else {
4540
+ dataSourceService?.add(value);
4541
+ }
4542
+ editDialog.value?.hide();
4543
+ };
4544
+ const tree = ref();
4545
+ const filterTextChangeHandler = (val) => {
4546
+ tree.value?.filter(val);
4547
+ };
4548
+ return (_ctx, _cache) => {
4549
+ return openBlock(), createBlock(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
4550
+ default: withCtx(() => [
4551
+ createElementVNode("div", _hoisted_1$6, [
4552
+ createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4553
+ createVNode(unref(TMagicButton), {
4554
+ type: "primary",
4555
+ size: "small",
4556
+ onClick: addHandler
4557
+ }, {
4558
+ default: withCtx(() => [
4559
+ _hoisted_2$2
4560
+ ]),
4561
+ _: 1
4562
+ })
4563
+ ]),
4564
+ createVNode(unref(TMagicTree), {
4565
+ ref_key: "tree",
4566
+ ref: tree,
4567
+ class: "magic-editor-layer-tree",
4568
+ "node-key": "id",
4569
+ "empty-text": "暂无代码块",
4570
+ "default-expand-all": "",
4571
+ "expand-on-click-node": false,
4572
+ data: unref(list),
4573
+ "highlight-current": true
4574
+ }, {
4575
+ default: withCtx(({ data }) => [
4576
+ createElementVNode("div", {
4577
+ id: data.id,
4578
+ class: "list-container"
4579
+ }, [
4580
+ createElementVNode("div", _hoisted_4, [
4581
+ data.type === "code" ? (openBlock(), createBlock(_sfc_main$A, {
4582
+ key: 0,
4583
+ class: "codeIcon",
4584
+ icon: unref(Coin)
4585
+ }, null, 8, ["icon"])) : createCommentVNode("", true),
4586
+ data.type === "node" ? (openBlock(), createBlock(_sfc_main$A, {
4587
+ key: 1,
4588
+ class: "compIcon",
4589
+ icon: unref(Aim)
4590
+ }, null, 8, ["icon"])) : createCommentVNode("", true),
4591
+ createElementVNode("span", {
4592
+ class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
4593
+ }, toDisplayString(data.name) + "(" + toDisplayString(data.id) + ")", 3),
4594
+ data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_5, [
4595
+ createVNode(unref(TMagicTooltip), {
4596
+ effect: "dark",
4597
+ content: "编辑",
4598
+ placement: "bottom"
4599
+ }, {
4600
+ default: withCtx(() => [
4601
+ createVNode(_sfc_main$A, {
4602
+ class: "edit-icon",
4603
+ icon: unref(Edit),
4604
+ onClick: withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
4605
+ }, null, 8, ["icon", "onClick"])
4606
+ ]),
4607
+ _: 2
4608
+ }, 1024),
4609
+ createVNode(unref(TMagicTooltip), {
4610
+ effect: "dark",
4611
+ content: "删除",
4612
+ placement: "bottom"
4613
+ }, {
4614
+ default: withCtx(() => [
4615
+ createVNode(_sfc_main$A, {
4616
+ icon: unref(Close),
4617
+ class: "edit-icon",
4618
+ onClick: withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
4619
+ }, null, 8, ["icon", "onClick"])
4620
+ ]),
4621
+ _: 2
4622
+ }, 1024),
4623
+ renderSlot(_ctx.$slots, "data-source-panel-tool", {
4624
+ id: data.id,
4625
+ data: data.codeBlockContent
4626
+ })
4627
+ ])) : createCommentVNode("", true)
4628
+ ])
4629
+ ], 8, _hoisted_3)
4630
+ ]),
4631
+ _: 3
4632
+ }, 8, ["data"]),
4633
+ createVNode(_sfc_main$f, {
4634
+ ref_key: "editDialog",
4635
+ ref: editDialog,
4636
+ values: dataSourceValues.value,
4637
+ title: typeof dataSourceValues.value.id !== "undefined" ? `编辑${dataSourceValues.value.title}` : "新增",
4638
+ onSubmit: submitDataSourceHandler
4639
+ }, null, 8, ["values", "title"])
4640
+ ]),
4641
+ _: 3
4642
+ });
4643
+ };
4644
+ }
4645
+ });
4646
+
4118
4647
  const _hoisted_1$5 = ["onClick", "onDragstart"];
4119
4648
  const __default__$c = defineComponent({
4120
4649
  name: "MEditorComponentListPanel"
@@ -4196,7 +4725,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4196
4725
  "model-value": unref(collapseValue)
4197
4726
  }, {
4198
4727
  default: withCtx(() => [
4199
- createVNode(_sfc_main$k, { onSearch: filterTextChangeHandler }),
4728
+ createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4200
4729
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
4201
4730
  return openBlock(), createElementBlock(Fragment, null, [
4202
4731
  group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
@@ -4204,7 +4733,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4204
4733
  name: `${index}`
4205
4734
  }, {
4206
4735
  title: withCtx(() => [
4207
- createVNode(_sfc_main$w, { icon: unref(Grid) }, null, 8, ["icon"]),
4736
+ createVNode(_sfc_main$A, { icon: unref(Grid) }, null, 8, ["icon"]),
4208
4737
  createTextVNode(toDisplayString(group.title), 1)
4209
4738
  ]),
4210
4739
  default: withCtx(() => [
@@ -4219,7 +4748,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4219
4748
  onDrag: dragHandler
4220
4749
  }, [
4221
4750
  renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
4222
- createVNode(_sfc_main$w, {
4751
+ createVNode(_sfc_main$A, {
4223
4752
  icon: item.icon
4224
4753
  }, null, 8, ["icon"]),
4225
4754
  createVNode(unref(TMagicTooltip), {
@@ -4342,7 +4871,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
4342
4871
  }, [
4343
4872
  createElementVNode("div", null, [
4344
4873
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
4345
- return openBlock(), createBlock(_sfc_main$n, {
4874
+ return openBlock(), createBlock(_sfc_main$p, {
4346
4875
  "event-type": "mouseup",
4347
4876
  data: item,
4348
4877
  key: index,
@@ -4494,6 +5023,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4494
5023
  const clicked = ref(false);
4495
5024
  const treeProps = {
4496
5025
  children: "items",
5026
+ label: "name",
5027
+ value: "id",
4497
5028
  disabled: (data) => Boolean(data.items?.length),
4498
5029
  class: (data) => {
4499
5030
  if (clicked.value || isPage(data))
@@ -4673,7 +5204,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4673
5204
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
4674
5205
  default: withCtx(() => [
4675
5206
  renderSlot(_ctx.$slots, "layer-panel-header"),
4676
- createVNode(_sfc_main$k, { onSearch: filterTextChangeHandler }),
5207
+ createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4677
5208
  unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
4678
5209
  key: 0,
4679
5210
  class: "magic-editor-layer-tree",
@@ -4742,19 +5273,20 @@ const __default__$8 = defineComponent({
4742
5273
  const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4743
5274
  ...__default__$8,
4744
5275
  props: {
4745
- data: { default: () => ({ type: "tabs", status: "组件", items: ["component-list", "layer", "code-block"] }) },
5276
+ data: { default: () => ({ type: "tabs", status: "组件", items: ["component-list", "layer", "code-block", "data-source"] }) },
4746
5277
  layerContentMenu: null
4747
5278
  },
4748
5279
  setup(__props, { expose }) {
4749
5280
  const props = __props;
4750
- const uiComponent = getConfig$1("components").tabPane;
5281
+ const tabPaneComponent = getConfig$1("components").tabPane;
5282
+ const tabsComponent = getConfig$1("components").tabs;
4751
5283
  const activeTabName = ref(props.data?.status);
4752
5284
  const getItemConfig = (data) => {
4753
5285
  const map = {
4754
5286
  "component-list": {
4755
5287
  $key: "component-list",
4756
5288
  type: "component",
4757
- icon: Coin,
5289
+ icon: Goods,
4758
5290
  text: "组件",
4759
5291
  component: _sfc_main$d,
4760
5292
  slots: {}
@@ -4762,7 +5294,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4762
5294
  layer: {
4763
5295
  $key: "layer",
4764
5296
  type: "component",
4765
- icon: Files,
5297
+ icon: List,
4766
5298
  text: "已选组件",
4767
5299
  props: {
4768
5300
  layerContentMenu: props.layerContentMenu
@@ -4775,6 +5307,14 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4775
5307
  type: "component",
4776
5308
  icon: EditPen,
4777
5309
  text: "代码编辑",
5310
+ component: _sfc_main$g,
5311
+ slots: {}
5312
+ },
5313
+ "data-source": {
5314
+ $key: "data-source",
5315
+ type: "component",
5316
+ icon: Coin,
5317
+ text: "数据源",
4778
5318
  component: _sfc_main$e,
4779
5319
  slots: {}
4780
5320
  }
@@ -4792,25 +5332,22 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4792
5332
  activeTabName
4793
5333
  });
4794
5334
  return (_ctx, _cache) => {
4795
- return __props.data.type === "tabs" && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicTabs), {
5335
+ return __props.data.type === "tabs" && __props.data.items.length ? (openBlock(), createBlock(resolveDynamicComponent(unref(tabsComponent).component), mergeProps({
4796
5336
  key: 0,
4797
- class: "m-editor-sidebar",
4798
5337
  modelValue: activeTabName.value,
4799
5338
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
4800
- type: "card",
4801
- "tab-position": "left"
4802
- }, {
5339
+ class: "m-editor-sidebar tmagic-design-tabs"
5340
+ }, unref(tabsComponent).props({ type: "card", tabPosition: "left" })), {
4803
5341
  default: withCtx(() => [
4804
5342
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(sideBarItems), (config, index) => {
4805
- return openBlock(), createBlock(resolveDynamicComponent(unref(uiComponent).component), {
4806
- key: config.$key || index,
4807
- name: config.text
4808
- }, {
5343
+ return openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent).component), mergeProps(unref(tabPaneComponent).props({ name: config.text }), {
5344
+ key: config.$key || index
5345
+ }), {
4809
5346
  label: withCtx(() => [
4810
5347
  (openBlock(), createElementBlock("div", {
4811
5348
  key: config.text
4812
5349
  }, [
4813
- config.icon ? (openBlock(), createBlock(_sfc_main$w, {
5350
+ config.icon ? (openBlock(), createBlock(_sfc_main$A, {
4814
5351
  key: 0,
4815
5352
  icon: config.icon
4816
5353
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -4885,11 +5422,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4885
5422
  ]), 1040)) : createCommentVNode("", true)
4886
5423
  ]),
4887
5424
  _: 2
4888
- }, 1032, ["name"]);
5425
+ }, 1040);
4889
5426
  }), 128))
4890
5427
  ]),
4891
5428
  _: 3
4892
- }, 8, ["modelValue"])) : createCommentVNode("", true);
5429
+ }, 16, ["modelValue"])) : createCommentVNode("", true);
4893
5430
  };
4894
5431
  }
4895
5432
  });
@@ -5031,14 +5568,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5031
5568
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5032
5569
  onClick: addPage
5033
5570
  }, [
5034
- createVNode(_sfc_main$w, { icon: unref(Plus) }, null, 8, ["icon"])
5571
+ createVNode(_sfc_main$A, { icon: unref(Plus) }, null, 8, ["icon"])
5035
5572
  ])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
5036
5573
  canScroll.value ? (openBlock(), createElementBlock("div", {
5037
5574
  key: 2,
5038
5575
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5039
5576
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
5040
5577
  }, [
5041
- createVNode(_sfc_main$w, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
5578
+ createVNode(_sfc_main$A, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
5042
5579
  ])) : createCommentVNode("", true),
5043
5580
  unref(pageLength) ? (openBlock(), createElementBlock("div", {
5044
5581
  key: 3,
@@ -5054,7 +5591,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5054
5591
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5055
5592
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
5056
5593
  }, [
5057
- createVNode(_sfc_main$w, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
5594
+ createVNode(_sfc_main$A, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
5058
5595
  ])) : createCommentVNode("", true)
5059
5596
  ], 512);
5060
5597
  };
@@ -5126,7 +5663,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5126
5663
  default: withCtx(() => [
5127
5664
  createElementVNode("div", null, [
5128
5665
  renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
5129
- createVNode(_sfc_main$n, {
5666
+ createVNode(_sfc_main$p, {
5130
5667
  data: {
5131
5668
  type: "button",
5132
5669
  text: "复制",
@@ -5134,7 +5671,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
5134
5671
  handler: () => copy(item)
5135
5672
  }
5136
5673
  }, null, 8, ["data"]),
5137
- createVNode(_sfc_main$n, {
5674
+ createVNode(_sfc_main$p, {
5138
5675
  data: {
5139
5676
  type: "button",
5140
5677
  text: "删除",
@@ -5964,7 +6501,6 @@ class CodeBlock extends BaseService {
5964
6501
  */
5965
6502
  async setCodeDsl(codeDsl2) {
5966
6503
  this.state.codeDsl = codeDsl2;
5967
- info("[code-block]:code-dsl-change", this.state.codeDsl);
5968
6504
  this.emit("code-dsl-change", this.state.codeDsl);
5969
6505
  }
5970
6506
  /**
@@ -6202,6 +6738,166 @@ class ComponentList extends BaseService {
6202
6738
  }
6203
6739
  const componentListService = new ComponentList();
6204
6740
 
6741
+ const BaseFormConfig = [
6742
+ {
6743
+ name: "id",
6744
+ type: "hidden"
6745
+ },
6746
+ {
6747
+ name: "type",
6748
+ text: "类型",
6749
+ type: "select",
6750
+ options: [
6751
+ { text: "基础", value: "base" },
6752
+ { text: "HTTP", value: "http" }
6753
+ ],
6754
+ defaultValue: "base"
6755
+ },
6756
+ {
6757
+ name: "title",
6758
+ text: "名称",
6759
+ rules: [
6760
+ {
6761
+ required: true,
6762
+ message: "请输入名称"
6763
+ }
6764
+ ]
6765
+ },
6766
+ {
6767
+ name: "description",
6768
+ text: "描述"
6769
+ }
6770
+ ];
6771
+
6772
+ const HttpFormConfig = [
6773
+ {
6774
+ name: "autoFetch",
6775
+ text: "自动请求",
6776
+ type: "switch",
6777
+ defaultValue: true
6778
+ },
6779
+ {
6780
+ type: "fieldset",
6781
+ name: "options",
6782
+ legend: "HTTP 配置",
6783
+ items: [
6784
+ {
6785
+ name: "url",
6786
+ text: "URL"
6787
+ },
6788
+ {
6789
+ name: "method",
6790
+ text: "Method",
6791
+ type: "select",
6792
+ options: [
6793
+ { text: "GET", value: "GET" },
6794
+ { text: "POST", value: "POST" },
6795
+ { text: "PUT", value: "PUT" },
6796
+ { text: "DELETE", value: "DELETE" }
6797
+ ]
6798
+ },
6799
+ {
6800
+ name: "params",
6801
+ type: "key-value",
6802
+ defaultValue: {},
6803
+ text: "参数"
6804
+ },
6805
+ {
6806
+ name: "data",
6807
+ type: "key-value",
6808
+ defaultValue: {},
6809
+ text: "请求体"
6810
+ },
6811
+ {
6812
+ name: "headers",
6813
+ type: "key-value",
6814
+ defaultValue: {},
6815
+ text: "请求头"
6816
+ }
6817
+ ]
6818
+ }
6819
+ ];
6820
+
6821
+ const fillConfig = (config) => [
6822
+ ...BaseFormConfig,
6823
+ ...config,
6824
+ {
6825
+ type: "panel",
6826
+ title: "数据定义",
6827
+ items: [
6828
+ {
6829
+ name: "fields",
6830
+ type: "data-source-fields",
6831
+ defaultValue: []
6832
+ }
6833
+ ]
6834
+ }
6835
+ ];
6836
+ const getFormConfig = (type, configs) => {
6837
+ switch (type) {
6838
+ case "base":
6839
+ return fillConfig([]);
6840
+ case "http":
6841
+ return fillConfig(HttpFormConfig);
6842
+ default:
6843
+ return fillConfig(configs[type] || []);
6844
+ }
6845
+ };
6846
+
6847
+ class DataSource extends BaseService {
6848
+ state = reactive({
6849
+ dataSources: [],
6850
+ configs: {}
6851
+ });
6852
+ set(name, value) {
6853
+ this.state[name] = value;
6854
+ }
6855
+ get(name) {
6856
+ return this.state[name];
6857
+ }
6858
+ getFormConfig(type = "base") {
6859
+ return getFormConfig(type, this.get("configs"));
6860
+ }
6861
+ setFormConfig(type, config) {
6862
+ this.get("configs")[type] = config;
6863
+ }
6864
+ add(config) {
6865
+ const newConfig = {
6866
+ ...config,
6867
+ id: this.createId()
6868
+ };
6869
+ this.get("dataSources").push(newConfig);
6870
+ this.emit("add", newConfig);
6871
+ }
6872
+ update(config) {
6873
+ const dataSources = this.get("dataSources");
6874
+ const index = dataSources.findIndex((ds) => ds.id === config.id);
6875
+ dataSources[index] = cloneDeep(config);
6876
+ this.emit("update", config);
6877
+ }
6878
+ remove(id) {
6879
+ const dataSources = this.get("dataSources");
6880
+ const index = dataSources.findIndex((ds) => ds.id === id);
6881
+ dataSources.splice(index, 1);
6882
+ this.emit("remove", id);
6883
+ }
6884
+ getDataSourceById(id) {
6885
+ return this.get("dataSources").find((ds) => ds.id === id);
6886
+ }
6887
+ resetState() {
6888
+ this.set("dataSources", []);
6889
+ }
6890
+ destroy() {
6891
+ this.removeAllListeners();
6892
+ this.resetState();
6893
+ this.removeAllPlugins();
6894
+ }
6895
+ createId() {
6896
+ return `ds_${guid()}`;
6897
+ }
6898
+ }
6899
+ const dataSourceService = new DataSource();
6900
+
6205
6901
  class Target extends EventEmitter {
6206
6902
  /**
6207
6903
  * 如何识别目标
@@ -6550,6 +7246,10 @@ const editorProps = {
6550
7246
  type: Object,
6551
7247
  default: () => ({})
6552
7248
  },
7249
+ dataScourceConfigs: {
7250
+ type: Object,
7251
+ default: () => ({})
7252
+ },
6553
7253
  /** 画布中组件选中框的移动范围 */
6554
7254
  moveableOptions: {
6555
7255
  type: [Object, Function]
@@ -6605,6 +7305,12 @@ const createCodeBlockTarget = (id, codeBlock) => new Target({
6605
7305
  return false;
6606
7306
  }
6607
7307
  });
7308
+ const createDataSourceTarget = (id, ds) => new Target({
7309
+ type: "data-source",
7310
+ id,
7311
+ name: ds.title || `${id}`,
7312
+ isTarget: (key, value) => typeof value === "string" && value.includes(`${id}`)
7313
+ });
6608
7314
 
6609
7315
  const initServiceState = (props, {
6610
7316
  editorService,
@@ -6684,7 +7390,26 @@ const initServiceState = (props, {
6684
7390
  codeBlockService.resetState();
6685
7391
  });
6686
7392
  };
6687
- const initServiceEvents = (props, emit, { editorService, codeBlockService, depService }) => {
7393
+ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataSourceService, depService }) => {
7394
+ const targetAddHandler = (target) => {
7395
+ if (target.type !== "data-source")
7396
+ return;
7397
+ const root = editorService.get("root");
7398
+ if (!root)
7399
+ return;
7400
+ if (!root.dataSourceDeps) {
7401
+ root.dataSourceDeps = {};
7402
+ }
7403
+ root.dataSourceDeps[target.id] = target.deps;
7404
+ };
7405
+ const targetRemoveHandler = (id) => {
7406
+ const root = editorService.get("root");
7407
+ if (!root?.dataSourceDeps)
7408
+ return;
7409
+ delete root.dataSourceDeps[id];
7410
+ };
7411
+ depService.on("add-target", targetAddHandler);
7412
+ depService.on("remove-target", targetRemoveHandler);
6688
7413
  const rootChangeHandler = async (value, preValue) => {
6689
7414
  const nodeId = editorService.get("node")?.id || props.defaultSelected;
6690
7415
  let node;
@@ -6704,15 +7429,21 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, depSe
6704
7429
  emit("update:modelValue", value);
6705
7430
  }
6706
7431
  value.codeBlocks = value.codeBlocks || {};
7432
+ value.dataSources = value.dataSources || [];
6707
7433
  codeBlockService.setCodeDsl(value.codeBlocks);
7434
+ dataSourceService.set("dataSources", value.dataSources);
6708
7435
  depService.removeTargets("code-block");
6709
7436
  Object.entries(value.codeBlocks).forEach(([id, code]) => {
6710
7437
  depService.addTarget(createCodeBlockTarget(id, code));
6711
7438
  });
7439
+ value.dataSources.forEach((ds) => {
7440
+ depService.addTarget(createDataSourceTarget(ds.id, ds));
7441
+ });
6712
7442
  if (value && Array.isArray(value.items)) {
6713
7443
  depService.collect(value.items, true);
6714
7444
  } else {
6715
7445
  depService.clear();
7446
+ delete value.dataSourceDeps;
6716
7447
  }
6717
7448
  };
6718
7449
  const nodeAddHandler = (nodes) => {
@@ -6744,7 +7475,23 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, depSe
6744
7475
  };
6745
7476
  codeBlockService.on("addOrUpdate", codeBlockAddOrUpdateHandler);
6746
7477
  codeBlockService.on("remove", codeBlockRemoveHandler);
7478
+ const dataSourceAddHandler = (config) => {
7479
+ depService.addTarget(createDataSourceTarget(config.id, config));
7480
+ };
7481
+ const dataSourceUpdateHandler = (config) => {
7482
+ if (config.title) {
7483
+ depService.getTarget(config.id).name = config.title;
7484
+ }
7485
+ };
7486
+ const dataSourceRemoveHandler = (id) => {
7487
+ depService.removeTarget(id);
7488
+ };
7489
+ dataSourceService.on("add", dataSourceAddHandler);
7490
+ dataSourceService.on("update", dataSourceUpdateHandler);
7491
+ dataSourceService.on("remove", dataSourceRemoveHandler);
6747
7492
  onUnmounted(() => {
7493
+ depService.off("add-target", targetAddHandler);
7494
+ depService.off("remove-target", targetRemoveHandler);
6748
7495
  editorService.off("history-change", historyChangeHandler);
6749
7496
  editorService.off("root-change", rootChangeHandler);
6750
7497
  editorService.off("add", nodeAddHandler);
@@ -6752,17 +7499,20 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, depSe
6752
7499
  editorService.off("update", nodeUpdateHandler);
6753
7500
  codeBlockService.off("addOrUpdate", codeBlockAddOrUpdateHandler);
6754
7501
  codeBlockService.off("remove", codeBlockRemoveHandler);
7502
+ dataSourceService.off("add", dataSourceAddHandler);
7503
+ dataSourceService.off("update", dataSourceUpdateHandler);
7504
+ dataSourceService.off("remove", dataSourceRemoveHandler);
6755
7505
  });
6756
7506
  };
6757
7507
 
6758
7508
  const _sfc_main = defineComponent({
6759
7509
  name: "m-editor",
6760
7510
  components: {
6761
- TMagicNavMenu: _sfc_main$m,
7511
+ TMagicNavMenu: _sfc_main$o,
6762
7512
  Sidebar: _sfc_main$9,
6763
7513
  Workspace: _sfc_main$1,
6764
- PropsPanel: _sfc_main$l,
6765
- Framework: _sfc_main$o
7514
+ PropsPanel: _sfc_main$n,
7515
+ Framework: _sfc_main$q
6766
7516
  },
6767
7517
  props: editorProps,
6768
7518
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -6776,7 +7526,8 @@ const _sfc_main = defineComponent({
6776
7526
  uiService,
6777
7527
  storageService,
6778
7528
  codeBlockService,
6779
- depService
7529
+ depService,
7530
+ dataSourceService
6780
7531
  };
6781
7532
  initServiceEvents(props, emit, services);
6782
7533
  initServiceState(props, services);
@@ -6901,15 +7652,17 @@ const index = {
6901
7652
  app.config.globalProperties.$TMAGIC_EDITOR = option;
6902
7653
  setConfig(option);
6903
7654
  app.component(Editor.name, Editor);
6904
- app.component("m-fields-ui-select", _sfc_main$t);
6905
- app.component("m-fields-code-link", _sfc_main$y);
6906
- app.component("m-fields-vs-code", _sfc_main$z);
6907
- app.component("magic-code-editor", _sfc_main$s);
6908
- app.component("m-fields-code-select", _sfc_main$x);
6909
- app.component("m-fields-code-select-col", _sfc_main$v);
6910
- app.component("m-fields-event-select", _sfc_main$u);
7655
+ app.component("m-fields-ui-select", _sfc_main$v);
7656
+ app.component("m-fields-code-link", _sfc_main$C);
7657
+ app.component("m-fields-vs-code", _sfc_main$D);
7658
+ app.component("magic-code-editor", _sfc_main$u);
7659
+ app.component("m-fields-code-select", _sfc_main$B);
7660
+ app.component("m-fields-code-select-col", _sfc_main$z);
7661
+ app.component("m-fields-event-select", _sfc_main$x);
7662
+ app.component("m-fields-data-source-fields", _sfc_main$y);
7663
+ app.component("m-fields-key-value", _sfc_main$w);
6911
7664
  }
6912
7665
  };
6913
7666
 
6914
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, _sfc_main$x as CodeSelect, _sfc_main$v as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$u as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$w as Icon, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$q as LayoutContainer, _sfc_main$l as PropsPanel, _sfc_main$s as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$n as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, debug, index as default, depService, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
7667
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$B as CodeSelect, _sfc_main$z as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$y as DataSourceFields, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$A as Icon, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
6915
7668
  //# sourceMappingURL=tmagic-editor.js.map