@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.
package/dist/style.css CHANGED
@@ -584,29 +584,29 @@
584
584
  .magic-editor-content-menu .menu-item.divider .el-divider {
585
585
  margin: 0;
586
586
  }
587
- .magic-editor-content-menu .menu-item.active {
588
- background-color: #2882e0;
589
- }
590
- .magic-editor-content-menu .menu-item.active .tmagic-design-button,
591
- .magic-editor-content-menu .menu-item.active .tmagic-design-button:active,
592
- .magic-editor-content-menu .menu-item.active .tmagic-design-button:focus {
593
- color: #fff;
594
- background-color: #2882e0;
595
- }
596
- .magic-editor-content-menu .menu-item.active.menu-item i {
597
- color: #fff;
598
- }
599
- .magic-editor-content-menu .menu-item:hover {
587
+ .magic-editor-content-menu .menu-item.button:hover {
600
588
  background-color: #f3f5f9;
601
589
  }
602
- .magic-editor-content-menu .menu-item:hover .tmagic-design-button,
603
- .magic-editor-content-menu .menu-item:hover .tmagic-design-button:active,
604
- .magic-editor-content-menu .menu-item:hover .tmagic-design-button:focus {
590
+ .magic-editor-content-menu .menu-item.button:hover .tmagic-design-button,
591
+ .magic-editor-content-menu .menu-item.button:hover .tmagic-design-button:active,
592
+ .magic-editor-content-menu .menu-item.button:hover .tmagic-design-button:focus {
605
593
  color: #070303;
606
594
  }
607
- .magic-editor-content-menu .menu-item:hover.menu-item i {
595
+ .magic-editor-content-menu .menu-item.button:hover.menu-item i {
608
596
  color: #070303;
609
597
  }
598
+ .magic-editor-content-menu .menu-item.button.active {
599
+ background-color: #2882e0;
600
+ }
601
+ .magic-editor-content-menu .menu-item.button.active .tmagic-design-button,
602
+ .magic-editor-content-menu .menu-item.button.active .tmagic-design-button:active,
603
+ .magic-editor-content-menu .menu-item.button.active .tmagic-design-button:focus {
604
+ color: #fff;
605
+ background-color: transparent;
606
+ }
607
+ .magic-editor-content-menu .menu-item.button.active.menu-item i {
608
+ color: #fff;
609
+ }
610
610
  .m-editor-stage {
611
611
  position: relative;
612
612
  width: 100%;
@@ -786,6 +786,18 @@ const fillConfig$1 = (config) => [
786
786
  defaultValue: () => []
787
787
  }
788
788
  ]
789
+ },
790
+ {
791
+ type: "panel",
792
+ title: "事件配置",
793
+ display: false,
794
+ items: [
795
+ {
796
+ name: "events",
797
+ src: "datasource",
798
+ type: "event-select"
799
+ }
800
+ ]
789
801
  }
790
802
  ];
791
803
  const getFormConfig = (type, configs) => {
@@ -966,7 +978,8 @@ class DataSource extends BaseService {
966
978
  dataSources: [],
967
979
  editable: true,
968
980
  configs: {},
969
- values: {}
981
+ values: {},
982
+ events: {}
970
983
  });
971
984
  set(name, value) {
972
985
  this.state[name] = value;
@@ -986,6 +999,12 @@ class DataSource extends BaseService {
986
999
  setFormValue(type, value) {
987
1000
  this.get("values")[type] = value;
988
1001
  }
1002
+ getFormEvent(type = "base") {
1003
+ return this.get("events")[type] || [];
1004
+ }
1005
+ setFormEvent(type, value = []) {
1006
+ this.get("events")[type] = value;
1007
+ }
989
1008
  add(config) {
990
1009
  const newConfig = {
991
1010
  ...config,
@@ -1202,6 +1221,7 @@ const eventTabConfig = {
1202
1221
  items: [
1203
1222
  {
1204
1223
  name: "events",
1224
+ src: "component",
1205
1225
  type: "event-select"
1206
1226
  }
1207
1227
  ]
@@ -3178,7 +3198,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
3178
3198
  return "number";
3179
3199
  if (model.type === "boolean")
3180
3200
  return "select";
3181
- return "string";
3201
+ return "text";
3182
3202
  },
3183
3203
  options: [
3184
3204
  { text: "true", value: true },
@@ -3900,10 +3920,20 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
3900
3920
  text: "事件",
3901
3921
  type: "select",
3902
3922
  labelWidth: "40px",
3903
- options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
3904
- text: option.label,
3905
- value: option.value
3906
- }))
3923
+ options: (mForm, { formValue }) => {
3924
+ let events = [];
3925
+ if (!services)
3926
+ return events;
3927
+ if (props.config.src === "component") {
3928
+ events = services.eventsService.getEvent(formValue.type);
3929
+ } else if (props.config.src === "datasource") {
3930
+ events = services.dataSourceService.getFormEvent(formValue.type);
3931
+ }
3932
+ return events.map((option) => ({
3933
+ text: option.label,
3934
+ value: option.value
3935
+ }));
3936
+ }
3907
3937
  };
3908
3938
  return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
3909
3939
  });
@@ -4852,7 +4882,8 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
4852
4882
  key: 1,
4853
4883
  size: "small",
4854
4884
  text: "",
4855
- disabled: disabled.value
4885
+ disabled: disabled.value,
4886
+ title: _ctx.data.text
4856
4887
  }, {
4857
4888
  default: withCtx(() => [
4858
4889
  _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$K, {
@@ -4862,7 +4893,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
4862
4893
  createElementVNode("span", null, toDisplayString(_ctx.data.text), 1)
4863
4894
  ]),
4864
4895
  _: 1
4865
- }, 8, ["disabled"]))
4896
+ }, 8, ["disabled", "title"]))
4866
4897
  ], 64)) : _ctx.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
4867
4898
  key: 3,
4868
4899
  trigger: "click",
@@ -7493,6 +7524,13 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
7493
7524
  nodeList.value = [];
7494
7525
  menu.value?.hide();
7495
7526
  };
7527
+ const clearTimeoutLazy = () => {
7528
+ globalThis.setTimeout(() => {
7529
+ if (timeout) {
7530
+ globalThis.clearTimeout(timeout);
7531
+ }
7532
+ }, 300);
7533
+ };
7496
7534
  const unWatch = watch(
7497
7535
  stage,
7498
7536
  (stage2) => {
@@ -7522,7 +7560,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
7522
7560
  }, 1500);
7523
7561
  });
7524
7562
  stage2.on("mouseleave", () => {
7525
- cancel();
7563
+ clearTimeoutLazy();
7526
7564
  });
7527
7565
  unWatch();
7528
7566
  },
@@ -7561,11 +7599,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
7561
7599
  })
7562
7600
  );
7563
7601
  const mouseenterHandler = () => {
7564
- globalThis.setTimeout(() => {
7565
- if (timeout) {
7566
- globalThis.clearTimeout(timeout);
7567
- }
7568
- }, 300);
7602
+ clearTimeoutLazy();
7569
7603
  };
7570
7604
  const dragMenuHandler = ({ deltaY, deltaX }) => {
7571
7605
  if (!menu.value)
@@ -7583,6 +7617,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
7583
7617
  return openBlock(), createBlock(_sfc_main$j, {
7584
7618
  ref_key: "menu",
7585
7619
  ref: menu,
7620
+ class: "magic-editor-node-list-menu",
7621
+ style: { "max-width": "280px" },
7586
7622
  "menu-data": menuData.value,
7587
7623
  active: node.value?.id,
7588
7624
  "auto-hide": !pinned.value,