@tmagic/editor 1.3.0-beta.7 → 1.3.0-beta.8

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.
@@ -4981,19 +4981,22 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
4981
4981
  centerClass: {}
4982
4982
  },
4983
4983
  emits: ["update:left", "change", "update:right"],
4984
- setup(__props, { emit }) {
4984
+ setup(__props, { expose: __expose, emit }) {
4985
4985
  const props = __props;
4986
4986
  const el = ref();
4987
4987
  const hasLeft = computed(() => typeof props.left !== "undefined");
4988
4988
  const hasRight = computed(() => typeof props.right !== "undefined");
4989
- const getCenterWidth = (clientWidth2, left, right) => {
4989
+ const getCenterWidth = (clientWidth2, l = 0, r = 0) => {
4990
+ let right = r > 0 ? r : 0;
4991
+ let left = l > 0 ? l : 0;
4990
4992
  let center2 = clientWidth2 - left - right;
4991
4993
  if (center2 < props.minCenter) {
4992
4994
  center2 = props.minCenter;
4993
- if (left < right) {
4994
- right = clientWidth2 - left - props.minCenter;
4995
+ if (right > center2 + props.minRight) {
4996
+ right = clientWidth2 - left - center2;
4995
4997
  } else {
4996
- left = clientWidth2 - right - props.minCenter;
4998
+ right = props.minRight;
4999
+ left = clientWidth2 - right - center2;
4997
5000
  }
4998
5001
  }
4999
5002
  return {
@@ -5056,7 +5059,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
5056
5059
  if (clientWidth - (props.left || 0) - right <= 0) {
5057
5060
  right = props.right;
5058
5061
  }
5059
- const columnWidth = getCenterWidth(clientWidth, props.left || 0, right);
5062
+ const columnWidth = getCenterWidth(clientWidth, props.left, right);
5060
5063
  center.value = columnWidth.center;
5061
5064
  emit("change", {
5062
5065
  left: columnWidth.left,
@@ -5064,11 +5067,22 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
5064
5067
  right: columnWidth.right
5065
5068
  });
5066
5069
  };
5070
+ __expose({
5071
+ updateWidth() {
5072
+ const columnWidth = getCenterWidth(el.value?.clientWidth || clientWidth, props.left, props.right);
5073
+ emit("change", {
5074
+ left: columnWidth.left,
5075
+ center: center.value,
5076
+ right: columnWidth.right
5077
+ });
5078
+ }
5079
+ });
5067
5080
  return (_ctx, _cache) => {
5068
5081
  return openBlock(), createElementBlock("div", {
5069
5082
  ref_key: "el",
5070
5083
  ref: el,
5071
- class: "m-editor-layout"
5084
+ class: "m-editor-layout",
5085
+ style: normalizeStyle(`min-width: ${props.minCenter + props.minLeft + props.minRight}px`)
5072
5086
  }, [
5073
5087
  hasLeft.value && _ctx.$slots.left ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
5074
5088
  createElementVNode("div", {
@@ -5094,7 +5108,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
5094
5108
  renderSlot(_ctx.$slots, "right")
5095
5109
  ], 6)
5096
5110
  ], 64)) : createCommentVNode("", true)
5097
- ], 512);
5111
+ ], 4);
5098
5112
  };
5099
5113
  }
5100
5114
  });
@@ -5152,31 +5166,21 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5152
5166
  const codeOptions = inject("codeOptions", {});
5153
5167
  const { editorService, uiService } = inject("services") || {};
5154
5168
  const content = ref();
5169
+ const splitView = ref();
5155
5170
  const root = computed(() => editorService?.get("root"));
5156
5171
  const pageLength = computed(() => editorService?.get("pageLength") || 0);
5157
5172
  const showSrc = computed(() => uiService?.get("showSrc"));
5158
- const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
5159
- const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
5173
+ const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
5174
+ const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
5160
5175
  const columnWidth = ref({
5161
5176
  left: leftColumnWidthCacheData,
5162
5177
  center: 0,
5163
5178
  right: RightColumnWidthCacheData
5164
5179
  });
5165
5180
  watch(
5166
- pageLength,
5167
- (length) => {
5168
- const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
5169
- columnWidth.value.left = left;
5170
- const container = content.value || document.body;
5171
- if (length <= 0) {
5172
- columnWidth.value.right = void 0;
5173
- columnWidth.value.center = container.clientWidth - left;
5174
- } else {
5175
- const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
5176
- columnWidth.value.right = right;
5177
- columnWidth.value.center = container.clientWidth - left - right;
5178
- }
5179
- uiService?.set("columnWidth", columnWidth.value);
5181
+ [pageLength, splitView],
5182
+ () => {
5183
+ splitView.value?.updateWidth();
5180
5184
  },
5181
5185
  {
5182
5186
  immediate: true
@@ -5214,7 +5218,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5214
5218
  return openBlock(), createElementBlock("div", {
5215
5219
  class: "m-editor",
5216
5220
  ref_key: "content",
5217
- ref: content
5221
+ ref: content,
5222
+ style: { "min-width": "180px" }
5218
5223
  }, [
5219
5224
  renderSlot(_ctx.$slots, "header"),
5220
5225
  renderSlot(_ctx.$slots, "nav"),
@@ -5228,6 +5233,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5228
5233
  }, null, 8, ["init-values", "options"])
5229
5234
  ]) : (openBlock(), createBlock(_sfc_main$A, {
5230
5235
  key: 1,
5236
+ ref_key: "splitView",
5237
+ ref: splitView,
5231
5238
  class: "m-editor-content",
5232
5239
  "left-class": "m-editor-framework-left",
5233
5240
  "center-class": "m-editor-framework-center",
@@ -5238,6 +5245,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5238
5245
  "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
5239
5246
  "min-left": 65,
5240
5247
  "min-right": 20,
5248
+ "min-center": 100,
5241
5249
  onChange: columnWidthChange
5242
5250
  }, createSlots({
5243
5251
  left: withCtx(() => [
@@ -6082,25 +6090,25 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6082
6090
  id,
6083
6091
  children: getKeyTreeConfig(dep, type)
6084
6092
  });
6093
+ const mergeChildren = (children, deps, type) => {
6094
+ Object.entries(deps).forEach(([id, dep]) => {
6095
+ const nodeItem = children.find((item) => item.id === id);
6096
+ if (nodeItem) {
6097
+ nodeItem.children = nodeItem.children.concat(getKeyTreeConfig(dep, type));
6098
+ } else {
6099
+ children.push(getNodeTreeConfig(id, dep, type));
6100
+ }
6101
+ });
6102
+ };
6085
6103
  const list = computed(
6086
6104
  () => dataSources.value.map((ds) => {
6087
6105
  const dsDeps = dsDep.value[ds.id].deps;
6088
6106
  const dsMethodDeps = dsMethodDep.value[ds.id].deps;
6089
6107
  const dsCondDeps = dsCondDep.value[ds.id].deps;
6090
6108
  const children = [];
6091
- const mergeChildren = (deps, type) => {
6092
- Object.entries(deps).forEach(([id, dep]) => {
6093
- const nodeItem = children.find((item) => item.id === id);
6094
- if (nodeItem) {
6095
- nodeItem.children = nodeItem.children.concat(getKeyTreeConfig(dep, type));
6096
- } else {
6097
- children.push(getNodeTreeConfig(id, dep, type));
6098
- }
6099
- });
6100
- };
6101
- mergeChildren(dsDeps);
6102
- mergeChildren(dsMethodDeps, "method");
6103
- mergeChildren(dsCondDeps, "cond");
6109
+ mergeChildren(children, dsDeps);
6110
+ mergeChildren(children, dsMethodDeps, "method");
6111
+ mergeChildren(children, dsCondDeps, "cond");
6104
6112
  return {
6105
6113
  id: ds.id,
6106
6114
  name: ds.title,
@@ -6574,11 +6582,8 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6574
6582
  const show = (e) => {
6575
6583
  setTimeout(() => {
6576
6584
  visible.value = true;
6577
- if (!e) {
6578
- return;
6579
- }
6580
6585
  nextTick(() => {
6581
- setPosition(e);
6586
+ e && setPosition(e);
6582
6587
  emit("show");
6583
6588
  });
6584
6589
  }, 300);
@@ -8439,6 +8444,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8439
8444
  }
8440
8445
  });
8441
8446
 
8447
+ const PINNED_STATUE_CACHE_KEY = "tmagic-pinned-node-list-pinned-status";
8442
8448
  const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8443
8449
  __name: "NodeListMenu",
8444
8450
  props: {
@@ -8448,7 +8454,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8448
8454
  const props = __props;
8449
8455
  const menu = ref();
8450
8456
  const nodeList = ref([]);
8451
- const pinned = ref(false);
8457
+ const pinned = ref(Boolean(globalThis.localStorage.getItem(PINNED_STATUE_CACHE_KEY)));
8458
+ const firstShow = ref(true);
8452
8459
  const services = inject("services");
8453
8460
  const editorService = services?.editorService;
8454
8461
  const componentListService = services?.componentListService;
@@ -8497,7 +8504,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8497
8504
  }
8498
8505
  nodeList.value = nodes;
8499
8506
  if (nodeList.value.length > 1) {
8500
- menu.value?.show(pinned.value ? void 0 : event);
8507
+ menu.value?.show(pinned.value && !firstShow.value ? void 0 : event);
8508
+ firstShow.value = false;
8501
8509
  }
8502
8510
  }, 1500);
8503
8511
  });
@@ -8555,6 +8563,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8555
8563
  const closeHandler = () => {
8556
8564
  menu.value?.hide();
8557
8565
  };
8566
+ watch(pinned, () => {
8567
+ globalThis.localStorage.setItem(PINNED_STATUE_CACHE_KEY, pinned.value.toString());
8568
+ });
8558
8569
  return (_ctx, _cache) => {
8559
8570
  return openBlock(), createBlock(_sfc_main$k, {
8560
8571
  ref_key: "menu",
@@ -9668,7 +9679,7 @@ class Watcher extends EventEmitter {
9668
9679
  const doCollect = (key, value) => {
9669
9680
  const keyIsItems = key === "items";
9670
9681
  const fullKey = prop ? `${prop}.${key}` : key;
9671
- if (target.isTarget(key, value)) {
9682
+ if (target.isTarget(fullKey, value)) {
9672
9683
  target.updateDep(node, fullKey);
9673
9684
  this.emit("update-dep", node, fullKey);
9674
9685
  } else if (!keyIsItems && Array.isArray(value)) {
@@ -9956,7 +9967,12 @@ const createDataSourceTarget = (id) => new Target({
9956
9967
  const createDataSourceCondTarget = (id) => new Target({
9957
9968
  type: DepTargetType.DATA_SOURCE_COND,
9958
9969
  id,
9959
- isTarget: (key, value) => Array.isArray(value) && value[0] === id && Boolean(dataSourceService.getDataSourceById(id))
9970
+ isTarget: (key, value) => {
9971
+ if (!Array.isArray(value) || value[0] !== id || !`${key}`.startsWith("displayConds"))
9972
+ return false;
9973
+ const ds = dataSourceService.getDataSourceById(id);
9974
+ return Boolean(ds?.fields?.find((field) => field.name === value[1]));
9975
+ }
9960
9976
  });
9961
9977
  const createDataSourceMethodTarget = (id) => new Target({
9962
9978
  type: DepTargetType.DATA_SOURCE_METHOD,