@tmagic/editor 1.3.0-beta.1 → 1.3.0-beta.2

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.
@@ -795,6 +795,18 @@
795
795
  defaultValue: () => []
796
796
  }
797
797
  ]
798
+ },
799
+ {
800
+ type: "panel",
801
+ title: "事件配置",
802
+ display: false,
803
+ items: [
804
+ {
805
+ name: "events",
806
+ src: "datasource",
807
+ type: "event-select"
808
+ }
809
+ ]
798
810
  }
799
811
  ];
800
812
  const getFormConfig = (type, configs) => {
@@ -975,7 +987,8 @@
975
987
  dataSources: [],
976
988
  editable: true,
977
989
  configs: {},
978
- values: {}
990
+ values: {},
991
+ events: {}
979
992
  });
980
993
  set(name, value) {
981
994
  this.state[name] = value;
@@ -995,6 +1008,12 @@
995
1008
  setFormValue(type, value) {
996
1009
  this.get("values")[type] = value;
997
1010
  }
1011
+ getFormEvent(type = "base") {
1012
+ return this.get("events")[type] || [];
1013
+ }
1014
+ setFormEvent(type, value = []) {
1015
+ this.get("events")[type] = value;
1016
+ }
998
1017
  add(config) {
999
1018
  const newConfig = {
1000
1019
  ...config,
@@ -1211,6 +1230,7 @@
1211
1230
  items: [
1212
1231
  {
1213
1232
  name: "events",
1233
+ src: "component",
1214
1234
  type: "event-select"
1215
1235
  }
1216
1236
  ]
@@ -3187,7 +3207,7 @@
3187
3207
  return "number";
3188
3208
  if (model.type === "boolean")
3189
3209
  return "select";
3190
- return "string";
3210
+ return "text";
3191
3211
  },
3192
3212
  options: [
3193
3213
  { text: "true", value: true },
@@ -3909,10 +3929,20 @@
3909
3929
  text: "事件",
3910
3930
  type: "select",
3911
3931
  labelWidth: "40px",
3912
- options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
3913
- text: option.label,
3914
- value: option.value
3915
- }))
3932
+ options: (mForm, { formValue }) => {
3933
+ let events = [];
3934
+ if (!services)
3935
+ return events;
3936
+ if (props.config.src === "component") {
3937
+ events = services.eventsService.getEvent(formValue.type);
3938
+ } else if (props.config.src === "datasource") {
3939
+ events = services.dataSourceService.getFormEvent(formValue.type);
3940
+ }
3941
+ return events.map((option) => ({
3942
+ text: option.label,
3943
+ value: option.value
3944
+ }));
3945
+ }
3916
3946
  };
3917
3947
  return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
3918
3948
  });
@@ -4861,7 +4891,8 @@
4861
4891
  key: 1,
4862
4892
  size: "small",
4863
4893
  text: "",
4864
- disabled: disabled.value
4894
+ disabled: disabled.value,
4895
+ title: _ctx.data.text
4865
4896
  }, {
4866
4897
  default: vue.withCtx(() => [
4867
4898
  _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
@@ -4871,7 +4902,7 @@
4871
4902
  vue.createElementVNode("span", null, vue.toDisplayString(_ctx.data.text), 1)
4872
4903
  ]),
4873
4904
  _: 1
4874
- }, 8, ["disabled"]))
4905
+ }, 8, ["disabled", "title"]))
4875
4906
  ], 64)) : _ctx.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDropdown), {
4876
4907
  key: 3,
4877
4908
  trigger: "click",
@@ -7502,6 +7533,13 @@
7502
7533
  nodeList.value = [];
7503
7534
  menu.value?.hide();
7504
7535
  };
7536
+ const clearTimeoutLazy = () => {
7537
+ globalThis.setTimeout(() => {
7538
+ if (timeout) {
7539
+ globalThis.clearTimeout(timeout);
7540
+ }
7541
+ }, 300);
7542
+ };
7505
7543
  const unWatch = vue.watch(
7506
7544
  stage,
7507
7545
  (stage2) => {
@@ -7531,7 +7569,7 @@
7531
7569
  }, 1500);
7532
7570
  });
7533
7571
  stage2.on("mouseleave", () => {
7534
- cancel();
7572
+ clearTimeoutLazy();
7535
7573
  });
7536
7574
  unWatch();
7537
7575
  },
@@ -7570,11 +7608,7 @@
7570
7608
  })
7571
7609
  );
7572
7610
  const mouseenterHandler = () => {
7573
- globalThis.setTimeout(() => {
7574
- if (timeout) {
7575
- globalThis.clearTimeout(timeout);
7576
- }
7577
- }, 300);
7611
+ clearTimeoutLazy();
7578
7612
  };
7579
7613
  const dragMenuHandler = ({ deltaY, deltaX }) => {
7580
7614
  if (!menu.value)
@@ -7592,6 +7626,8 @@
7592
7626
  return vue.openBlock(), vue.createBlock(_sfc_main$j, {
7593
7627
  ref_key: "menu",
7594
7628
  ref: menu,
7629
+ class: "magic-editor-node-list-menu",
7630
+ style: { "max-width": "280px" },
7595
7631
  "menu-data": menuData.value,
7596
7632
  active: node.value?.id,
7597
7633
  "auto-hide": !pinned.value,