@tmagic/stage 1.4.7 → 1.4.9

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.
@@ -139,27 +139,21 @@ const isFixedParent = (el) => {
139
139
  return fixed;
140
140
  };
141
141
  const getMode = (el) => {
142
- if (isFixedParent(el))
143
- return Mode.FIXED;
142
+ if (isFixedParent(el)) return Mode.FIXED;
144
143
  const style = getComputedStyle(el);
145
- if (isStatic(style) || isRelative(style))
146
- return Mode.SORTABLE;
144
+ if (isStatic(style) || isRelative(style)) return Mode.SORTABLE;
147
145
  return Mode.ABSOLUTE;
148
146
  };
149
147
  const getScrollParent = (element, includeHidden = false) => {
150
148
  let style = getComputedStyle(element);
151
149
  const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
152
- if (isFixed(style))
153
- return null;
150
+ if (isFixed(style)) return null;
154
151
  for (let parent = element; parent.parentElement; ) {
155
152
  parent = parent.parentElement;
156
- if (parent.tagName === "HTML")
157
- return parent;
153
+ if (parent.tagName === "HTML") return parent;
158
154
  style = getComputedStyle(parent);
159
- if (isAbsolute(style) && isStatic(style))
160
- continue;
161
- if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX))
162
- return parent;
155
+ if (isAbsolute(style) && isStatic(style)) continue;
156
+ if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;
163
157
  }
164
158
  return null;
165
159
  };
@@ -167,8 +161,7 @@ const removeSelectedClassName = (doc) => {
167
161
  const oldEl = doc.querySelector(`.${SELECTED_CLASS}`);
168
162
  if (oldEl) {
169
163
  removeClassName(oldEl, SELECTED_CLASS);
170
- if (oldEl.parentNode)
171
- removeClassName(oldEl.parentNode, `${SELECTED_CLASS}-parent`);
164
+ if (oldEl.parentNode) removeClassName(oldEl.parentNode, `${SELECTED_CLASS}-parent`);
172
165
  doc.querySelectorAll(`.${SELECTED_CLASS}-parents`).forEach((item) => {
173
166
  removeClassName(item, `${SELECTED_CLASS}-parents`);
174
167
  });
@@ -216,13 +209,10 @@ const up = (deltaTop, target) => {
216
209
  let swapIndex = upEls.length - 1;
217
210
  for (let i = upEls.length - 1; i >= 0; i--) {
218
211
  const ele = upEls[i];
219
- if (!ele)
220
- continue;
221
- if (ele.style.position === "fixed")
222
- continue;
212
+ if (!ele) continue;
213
+ if (ele.style.position === "fixed") continue;
223
214
  addUpH += ele.clientHeight / 2;
224
- if (-deltaTop <= addUpH)
225
- break;
215
+ if (-deltaTop <= addUpH) break;
226
216
  addUpH += ele.clientHeight / 2;
227
217
  swapIndex = i;
228
218
  }
@@ -497,13 +487,11 @@ class DragResizeHelper {
497
487
  const frameSnapShot = this.framesSnapShot.find(
498
488
  (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
499
489
  );
500
- if (!frameSnapShot)
501
- return;
490
+ if (!frameSnapShot) return;
502
491
  const targeEl = this.targetList.find(
503
492
  (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
504
493
  );
505
- if (!targeEl)
506
- return;
494
+ if (!targeEl) return;
507
495
  const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
508
496
  if (!isParentIncluded) {
509
497
  const { marginLeft, marginTop } = getMarginValue(targeEl);
@@ -526,13 +514,11 @@ class DragResizeHelper {
526
514
  const frameSnapShot = this.framesSnapShot.find(
527
515
  (frameItem) => ev.target.id.startsWith(DRAG_EL_ID_PREFIX) && ev.target.id.endsWith(frameItem.id)
528
516
  );
529
- if (!frameSnapShot)
530
- return;
517
+ if (!frameSnapShot) return;
531
518
  const targeEl = this.targetList.find(
532
519
  (targetItem) => ev.target.id.startsWith(DRAG_EL_ID_PREFIX) && ev.target.id.endsWith(targetItem.id)
533
520
  );
534
- if (!targeEl)
535
- return;
521
+ if (!targeEl) return;
536
522
  const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
537
523
  if (!isParentIncluded) {
538
524
  const { marginLeft, marginTop } = getMarginValue(targeEl);
@@ -570,14 +556,12 @@ class DragResizeHelper {
570
556
  * 多选状态设置多个节点的快照
571
557
  */
572
558
  setFramesSnapShot(events) {
573
- if (this.framesSnapShot.length > 0)
574
- return;
559
+ if (this.framesSnapShot.length > 0) return;
575
560
  events.forEach((ev) => {
576
561
  const matchEventTarget = this.targetList.find(
577
562
  (targetItem) => ev.target.id.startsWith(DRAG_EL_ID_PREFIX) && ev.target.id.endsWith(targetItem.id)
578
563
  );
579
- if (!matchEventTarget)
580
- return;
564
+ if (!matchEventTarget) return;
581
565
  this.framesSnapShot.push({
582
566
  left: matchEventTarget.offsetLeft,
583
567
  top: matchEventTarget.offsetTop,
@@ -879,16 +863,13 @@ class MoveableOptionsManager extends EventEmitter {
879
863
  const frame = globalThis.document.createDocumentFragment();
880
864
  for (const element of allElList) {
881
865
  let node = element.element || element;
882
- if (!node || typeof node === "string")
883
- continue;
866
+ if (!node || typeof node === "string") continue;
884
867
  if (typeof node === "function") {
885
868
  node = node();
886
869
  }
887
- if (this.isInElementList(node, selectedElList))
888
- continue;
870
+ if (this.isInElementList(node, selectedElList)) continue;
889
871
  const { width, height } = node.getBoundingClientRect();
890
- if (!width || !height)
891
- continue;
872
+ if (!width || !height) continue;
892
873
  const { left, top } = getOffset(node);
893
874
  const elementGuideline = globalThis.document.createElement("div");
894
875
  elementGuideline.style.cssText = `position: absolute;width: ${width}px;height: ${height}px;top: ${top}px;left: ${left}px`;
@@ -905,8 +886,7 @@ class MoveableOptionsManager extends EventEmitter {
905
886
  */
906
887
  isInElementList(ele, eleList) {
907
888
  for (const eleItem of eleList) {
908
- if (ele === eleItem)
909
- return true;
889
+ if (ele === eleItem) return true;
910
890
  }
911
891
  return false;
912
892
  }
@@ -965,10 +945,8 @@ class StageDragResize extends MoveableOptionsManager {
965
945
  * 初始化选中框并渲染出来
966
946
  */
967
947
  updateMoveable(el = this.target) {
968
- if (!this.moveable)
969
- return;
970
- if (!el)
971
- throw new Error("未选中任何节点");
948
+ if (!this.moveable) return;
949
+ if (!el) throw new Error("未选中任何节点");
972
950
  const options = this.init(el);
973
951
  Object.entries(options).forEach(([key, value]) => {
974
952
  this.moveable[key] = value;
@@ -976,8 +954,7 @@ class StageDragResize extends MoveableOptionsManager {
976
954
  this.moveable.updateRect();
977
955
  }
978
956
  clearSelectStatus() {
979
- if (!this.moveable)
980
- return;
957
+ if (!this.moveable) return;
981
958
  this.dragResizeHelper.destroyShadowEl();
982
959
  this.moveable.target = null;
983
960
  this.moveable.updateRect();
@@ -1026,16 +1003,13 @@ class StageDragResize extends MoveableOptionsManager {
1026
1003
  this.bindScaleEvent();
1027
1004
  }
1028
1005
  bindResizeEvent() {
1029
- if (!this.moveable)
1030
- throw new Error("moveable 未初始化");
1006
+ if (!this.moveable) throw new Error("moveable 未初始化");
1031
1007
  this.moveable.on("resizeStart", (e) => {
1032
- if (!this.target)
1033
- return;
1008
+ if (!this.target) return;
1034
1009
  this.dragStatus = StageDragStatus.START;
1035
1010
  this.dragResizeHelper.onResizeStart(e);
1036
1011
  }).on("resize", (e) => {
1037
- if (!this.moveable || !this.target || !this.dragResizeHelper.getShadowEl())
1038
- return;
1012
+ if (!this.moveable || !this.target || !this.dragResizeHelper.getShadowEl()) return;
1039
1013
  this.dragStatus = StageDragStatus.ING;
1040
1014
  this.dragResizeHelper.onResize(e);
1041
1015
  }).on("resizeEnd", () => {
@@ -1044,18 +1018,15 @@ class StageDragResize extends MoveableOptionsManager {
1044
1018
  });
1045
1019
  }
1046
1020
  bindDragEvent() {
1047
- if (!this.moveable)
1048
- throw new Error("moveable 未初始化");
1021
+ if (!this.moveable) throw new Error("moveable 未初始化");
1049
1022
  let timeout;
1050
1023
  this.moveable.on("dragStart", (e) => {
1051
- if (!this.target)
1052
- throw new Error("未选中组件");
1024
+ if (!this.target) throw new Error("未选中组件");
1053
1025
  this.dragStatus = StageDragStatus.START;
1054
1026
  this.dragResizeHelper.onDragStart(e);
1055
1027
  this.emit("drag-start", e);
1056
1028
  }).on("drag", (e) => {
1057
- if (!this.target || !this.dragResizeHelper.getShadowEl())
1058
- return;
1029
+ if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
1059
1030
  if (timeout) {
1060
1031
  globalThis.clearTimeout(timeout);
1061
1032
  timeout = void 0;
@@ -1087,14 +1058,12 @@ class StageDragResize extends MoveableOptionsManager {
1087
1058
  });
1088
1059
  }
1089
1060
  bindRotateEvent() {
1090
- if (!this.moveable)
1091
- throw new Error("moveable 未初始化");
1061
+ if (!this.moveable) throw new Error("moveable 未初始化");
1092
1062
  this.moveable.on("rotateStart", (e) => {
1093
1063
  this.dragStatus = StageDragStatus.START;
1094
1064
  this.dragResizeHelper.onRotateStart(e);
1095
1065
  }).on("rotate", (e) => {
1096
- if (!this.target || !this.dragResizeHelper.getShadowEl())
1097
- return;
1066
+ if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
1098
1067
  this.dragStatus = StageDragStatus.ING;
1099
1068
  this.dragResizeHelper.onRotate(e);
1100
1069
  }).on("rotateEnd", (e) => {
@@ -1116,14 +1085,12 @@ class StageDragResize extends MoveableOptionsManager {
1116
1085
  });
1117
1086
  }
1118
1087
  bindScaleEvent() {
1119
- if (!this.moveable)
1120
- throw new Error("moveable 未初始化");
1088
+ if (!this.moveable) throw new Error("moveable 未初始化");
1121
1089
  this.moveable.on("scaleStart", (e) => {
1122
1090
  this.dragStatus = StageDragStatus.START;
1123
1091
  this.dragResizeHelper.onScaleStart(e);
1124
1092
  }).on("scale", (e) => {
1125
- if (!this.target || !this.dragResizeHelper.getShadowEl())
1126
- return;
1093
+ if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
1127
1094
  this.dragStatus = StageDragStatus.ING;
1128
1095
  this.dragResizeHelper.onScale(e);
1129
1096
  }).on("scaleEnd", (e) => {
@@ -1145,8 +1112,7 @@ class StageDragResize extends MoveableOptionsManager {
1145
1112
  });
1146
1113
  }
1147
1114
  sort() {
1148
- if (!this.target || !this.dragResizeHelper.getGhostEl())
1149
- throw new Error("未知错误");
1115
+ if (!this.target || !this.dragResizeHelper.getGhostEl()) throw new Error("未知错误");
1150
1116
  const { top } = this.dragResizeHelper.getGhostEl().getBoundingClientRect();
1151
1117
  const { top: oriTop } = this.target.getBoundingClientRect();
1152
1118
  const deltaTop = top - oriTop;
@@ -1164,11 +1130,9 @@ class StageDragResize extends MoveableOptionsManager {
1164
1130
  }
1165
1131
  }
1166
1132
  update(isResize = false, parentEl = null) {
1167
- if (!this.target)
1168
- return;
1133
+ if (!this.target) return;
1169
1134
  const doc = this.getRenderDocument();
1170
- if (!doc)
1171
- return;
1135
+ if (!doc) return;
1172
1136
  const rect = this.dragResizeHelper.getUpdatedElRect(this.target, parentEl, doc);
1173
1137
  this.emit("update", {
1174
1138
  data: [
@@ -1204,8 +1168,7 @@ class StageHighlight extends EventEmitter$1 {
1204
1168
  * @param el 选中组件的Dom节点元素
1205
1169
  */
1206
1170
  highlight(el) {
1207
- if (!el || el === this.target)
1208
- return;
1171
+ if (!el || el === this.target) return;
1209
1172
  this.target = el;
1210
1173
  this.targetShadow?.update(el);
1211
1174
  if (this.moveable) {
@@ -1224,8 +1187,7 @@ class StageHighlight extends EventEmitter$1 {
1224
1187
  * 清空高亮
1225
1188
  */
1226
1189
  clearHighlight() {
1227
- if (!this.moveable || !this.target)
1228
- return;
1190
+ if (!this.moveable || !this.target) return;
1229
1191
  this.moveable.zoom = 0;
1230
1192
  this.moveable.updateRect();
1231
1193
  this.target = void 0;
@@ -1344,10 +1306,8 @@ class StageMultiDragResize extends MoveableOptionsManager {
1344
1306
  return true;
1345
1307
  }
1346
1308
  updateMoveable(eleList = this.targetList) {
1347
- if (!this.moveableForMulti)
1348
- return;
1349
- if (!eleList)
1350
- throw new Error("未选中任何节点");
1309
+ if (!this.moveableForMulti) return;
1310
+ if (!eleList) throw new Error("未选中任何节点");
1351
1311
  this.targetList = eleList;
1352
1312
  this.dragResizeHelper.setTargetList(eleList);
1353
1313
  const options = this.getOptions(true, {
@@ -1362,8 +1322,7 @@ class StageMultiDragResize extends MoveableOptionsManager {
1362
1322
  * 清除多选状态
1363
1323
  */
1364
1324
  clearSelectStatus() {
1365
- if (!this.moveableForMulti)
1366
- return;
1325
+ if (!this.moveableForMulti) return;
1367
1326
  this.dragResizeHelper.clearMultiSelectStatus();
1368
1327
  this.moveableForMulti.target = null;
1369
1328
  this.moveableForMulti.updateTarget();
@@ -1387,11 +1346,9 @@ class StageMultiDragResize extends MoveableOptionsManager {
1387
1346
  * @param isResize 是否进行大小缩放
1388
1347
  */
1389
1348
  update(isResize = false, parentEl = null) {
1390
- if (this.targetList.length === 0)
1391
- return;
1349
+ if (this.targetList.length === 0) return;
1392
1350
  const doc = this.getRenderDocument();
1393
- if (!doc)
1394
- return;
1351
+ if (!doc) return;
1395
1352
  const data = this.targetList.map((targetItem) => {
1396
1353
  const rect = this.dragResizeHelper.getUpdatedElRect(targetItem, parentEl, doc);
1397
1354
  return {
@@ -1542,8 +1499,7 @@ class ActionManager extends EventEmitter {
1542
1499
  const stop = () => stopped = true;
1543
1500
  for (const el of els) {
1544
1501
  if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isElCanSelect(el, event, stop)) {
1545
- if (stopped)
1546
- break;
1502
+ if (stopped) break;
1547
1503
  return el;
1548
1504
  }
1549
1505
  }
@@ -1558,8 +1514,7 @@ class ActionManager extends EventEmitter {
1558
1514
  */
1559
1515
  async isElCanSelect(el, event, stop) {
1560
1516
  const canSelectByProp = await this.canSelect(el, event, stop);
1561
- if (!canSelectByProp)
1562
- return false;
1517
+ if (!canSelectByProp) return false;
1563
1518
  if (this.isMultiSelectStatus) {
1564
1519
  return this.canMultiSelect(el, stop);
1565
1520
  }
@@ -1613,8 +1568,7 @@ class ActionManager extends EventEmitter {
1613
1568
  this.clearHighlight();
1614
1569
  return;
1615
1570
  }
1616
- if (el === this.highlightedEl || !el)
1617
- return;
1571
+ if (el === this.highlightedEl || !el) return;
1618
1572
  this.highlightLayer.highlight(el);
1619
1573
  this.highlightedEl = el;
1620
1574
  this.emit("highlight", el);
@@ -1642,8 +1596,7 @@ class ActionManager extends EventEmitter {
1642
1596
  */
1643
1597
  async addContainerHighlightClassName(event, excludeElList) {
1644
1598
  const doc = this.getRenderDocument();
1645
- if (!doc)
1646
- return;
1599
+ if (!doc) return;
1647
1600
  const els = this.getElementsFromPoint(event);
1648
1601
  for (const el of els) {
1649
1602
  if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isContainer?.(el) && !excludeElList.includes(el)) {
@@ -1709,8 +1662,7 @@ class ActionManager extends EventEmitter {
1709
1662
  this.emit("select-parent");
1710
1663
  }).on(AbleActionEventType.REMOVE, () => {
1711
1664
  const drTarget = this.dr.getTarget();
1712
- if (!drTarget)
1713
- return;
1665
+ if (!drTarget) return;
1714
1666
  const data = {
1715
1667
  data: [{ el: drTarget }]
1716
1668
  };
@@ -1737,8 +1689,7 @@ class ActionManager extends EventEmitter {
1737
1689
  multiDr?.on("update", (data) => {
1738
1690
  this.emit("multi-update", data);
1739
1691
  }).on("change-to-select", (id, e) => {
1740
- if (this.isMultiSelectStatus)
1741
- return;
1692
+ if (this.isMultiSelectStatus) return;
1742
1693
  this.emit("change-to-select", id, e);
1743
1694
  });
1744
1695
  return multiDr;
@@ -1769,8 +1720,7 @@ class ActionManager extends EventEmitter {
1769
1720
  */
1770
1721
  async beforeMultiSelect(event) {
1771
1722
  const el = await this.getElementFromPoint(event);
1772
- if (!el)
1773
- return;
1723
+ if (!el) return;
1774
1724
  if (this.selectedEl && !this.selectedEl.className.includes(PAGE_CLASS)) {
1775
1725
  this.selectedElList.push(this.selectedEl);
1776
1726
  this.setSelectedEl(null);
@@ -1848,8 +1798,7 @@ class ActionManager extends EventEmitter {
1848
1798
  this.clearHighlight();
1849
1799
  event.stopImmediatePropagation();
1850
1800
  event.stopPropagation();
1851
- if (this.isStopTriggerSelect(event))
1852
- return;
1801
+ if (this.isStopTriggerSelect(event)) return;
1853
1802
  this.container.removeEventListener("mousemove", this.mouseMoveHandler);
1854
1803
  if (this.isMultiSelectStatus) {
1855
1804
  await this.beforeMultiSelect(event);
@@ -1858,17 +1807,14 @@ class ActionManager extends EventEmitter {
1858
1807
  }
1859
1808
  } else {
1860
1809
  const el = await this.getElementFromPoint(event);
1861
- if (!el)
1862
- return;
1810
+ if (!el) return;
1863
1811
  this.emit("before-select", el, event);
1864
1812
  }
1865
1813
  getDocument().addEventListener("mouseup", this.mouseUpHandler);
1866
1814
  };
1867
1815
  isStopTriggerSelect(event) {
1868
- if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
1869
- return true;
1870
- if (!event.target)
1871
- return true;
1816
+ if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT) return true;
1817
+ if (!event.target) return true;
1872
1818
  const targetClassList = event.target.classList;
1873
1819
  if (!this.isMultiSelectStatus && targetClassList.contains("moveable-area")) {
1874
1820
  return true;
@@ -2110,8 +2056,7 @@ class StageMask extends Rule {
2110
2056
  * @param page 页面Dom节点
2111
2057
  */
2112
2058
  observe(page) {
2113
- if (!page)
2114
- return;
2059
+ if (!page) return;
2115
2060
  this.page = page;
2116
2061
  this.initObserverIntersection();
2117
2062
  this.initObserverWrapper();
@@ -2139,19 +2084,16 @@ class StageMask extends Rule {
2139
2084
  * @param el 将蒙层挂载到该Dom节点上
2140
2085
  */
2141
2086
  mount(el) {
2142
- if (!this.content)
2143
- throw new Error("content 不存在");
2087
+ if (!this.content) throw new Error("content 不存在");
2144
2088
  el.appendChild(this.wrapper);
2145
2089
  }
2146
2090
  setLayout(el) {
2147
2091
  this.setMode(isFixedParent(el) ? Mode.FIXED : Mode.ABSOLUTE);
2148
2092
  }
2149
2093
  scrollIntoView(el) {
2150
- if (!this.page || el.getBoundingClientRect().left >= this.page.scrollWidth)
2151
- return;
2094
+ if (!this.page || el.getBoundingClientRect().left >= this.page.scrollWidth) return;
2152
2095
  el.scrollIntoView();
2153
- if (!this.pageScrollParent)
2154
- return;
2096
+ if (!this.pageScrollParent) return;
2155
2097
  this.scrollLeft = this.pageScrollParent.scrollLeft;
2156
2098
  this.scrollTop = this.pageScrollParent.scrollTop;
2157
2099
  this.scroll();
@@ -2275,23 +2217,16 @@ class StageMask extends Rule {
2275
2217
  * 由于滚动容器变化等因素,会导致当前滚动的距离不正确
2276
2218
  */
2277
2219
  fixScrollValue() {
2278
- if (this.scrollTop < 0)
2279
- this.scrollTop = 0;
2280
- if (this.scrollLeft < 0)
2281
- this.scrollLeft = 0;
2282
- if (this.maxScrollTop < this.scrollTop)
2283
- this.scrollTop = this.maxScrollTop;
2284
- if (this.maxScrollLeft < this.scrollLeft)
2285
- this.scrollLeft = this.maxScrollLeft;
2220
+ if (this.scrollTop < 0) this.scrollTop = 0;
2221
+ if (this.scrollLeft < 0) this.scrollLeft = 0;
2222
+ if (this.maxScrollTop < this.scrollTop) this.scrollTop = this.maxScrollTop;
2223
+ if (this.maxScrollLeft < this.scrollLeft) this.scrollLeft = this.maxScrollLeft;
2286
2224
  }
2287
2225
  mouseWheelHandler = (event) => {
2288
- if (!this.page)
2289
- throw new Error("page 未初始化");
2226
+ if (!this.page) throw new Error("page 未初始化");
2290
2227
  const { deltaY, deltaX } = event;
2291
- if (this.page.clientHeight < this.wrapperHeight && deltaY)
2292
- return;
2293
- if (this.page.clientWidth < this.wrapperWidth && deltaX)
2294
- return;
2228
+ if (this.page.clientHeight < this.wrapperHeight && deltaY) return;
2229
+ if (this.page.clientWidth < this.wrapperWidth && deltaX) return;
2295
2230
  if (this.maxScrollTop > 0) {
2296
2231
  this.scrollTop = this.scrollTop + deltaY;
2297
2232
  }
@@ -2377,8 +2312,7 @@ class StageRender extends EventEmitter$1 {
2377
2312
  }
2378
2313
  }
2379
2314
  getRuntime = () => {
2380
- if (this.runtime)
2381
- return Promise.resolve(this.runtime);
2315
+ if (this.runtime) return Promise.resolve(this.runtime);
2382
2316
  return new Promise((resolve) => {
2383
2317
  const listener = (runtime) => {
2384
2318
  this.off("runtime-ready", listener);
@@ -2463,8 +2397,7 @@ class StageRender extends EventEmitter$1 {
2463
2397
  if (!this.contentWindow?.magic) {
2464
2398
  this.postTmagicRuntimeReady();
2465
2399
  }
2466
- if (!this.contentWindow)
2467
- return;
2400
+ if (!this.contentWindow) return;
2468
2401
  if (this.customizedRender) {
2469
2402
  const el = await this.customizedRender();
2470
2403
  if (el) {
@@ -2523,8 +2456,7 @@ class StageCore extends EventEmitter$1 {
2523
2456
  */
2524
2457
  async select(id, event) {
2525
2458
  const el = this.renderer.getTargetElement(id);
2526
- if (el === this.actionManager.getSelectedEl())
2527
- return;
2459
+ if (el === this.actionManager.getSelectedEl()) return;
2528
2460
  await this.renderer.select([id]);
2529
2461
  el && this.mask.setLayout(el);
2530
2462
  this.actionManager.select(el, event);
@@ -2538,8 +2470,7 @@ class StageCore extends EventEmitter$1 {
2538
2470
  */
2539
2471
  async multiSelect(ids) {
2540
2472
  const els = ids.map((id) => this.renderer.getTargetElement(id)).filter((el) => Boolean(el));
2541
- if (els.length === 0)
2542
- return;
2473
+ if (els.length === 0) return;
2543
2474
  const lastEl = els[els.length - 1];
2544
2475
  const isReduceSelect = els.length < this.actionManager.getSelectedElList().length;
2545
2476
  await this.renderer.select(ids);
@@ -136,27 +136,21 @@
136
136
  return fixed;
137
137
  };
138
138
  const getMode = (el) => {
139
- if (isFixedParent(el))
140
- return Mode.FIXED;
139
+ if (isFixedParent(el)) return Mode.FIXED;
141
140
  const style = getComputedStyle(el);
142
- if (isStatic(style) || isRelative(style))
143
- return Mode.SORTABLE;
141
+ if (isStatic(style) || isRelative(style)) return Mode.SORTABLE;
144
142
  return Mode.ABSOLUTE;
145
143
  };
146
144
  const getScrollParent = (element, includeHidden = false) => {
147
145
  let style = getComputedStyle(element);
148
146
  const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
149
- if (isFixed(style))
150
- return null;
147
+ if (isFixed(style)) return null;
151
148
  for (let parent = element; parent.parentElement; ) {
152
149
  parent = parent.parentElement;
153
- if (parent.tagName === "HTML")
154
- return parent;
150
+ if (parent.tagName === "HTML") return parent;
155
151
  style = getComputedStyle(parent);
156
- if (isAbsolute(style) && isStatic(style))
157
- continue;
158
- if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX))
159
- return parent;
152
+ if (isAbsolute(style) && isStatic(style)) continue;
153
+ if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;
160
154
  }
161
155
  return null;
162
156
  };
@@ -164,8 +158,7 @@
164
158
  const oldEl = doc.querySelector(`.${SELECTED_CLASS}`);
165
159
  if (oldEl) {
166
160
  utils.removeClassName(oldEl, SELECTED_CLASS);
167
- if (oldEl.parentNode)
168
- utils.removeClassName(oldEl.parentNode, `${SELECTED_CLASS}-parent`);
161
+ if (oldEl.parentNode) utils.removeClassName(oldEl.parentNode, `${SELECTED_CLASS}-parent`);
169
162
  doc.querySelectorAll(`.${SELECTED_CLASS}-parents`).forEach((item) => {
170
163
  utils.removeClassName(item, `${SELECTED_CLASS}-parents`);
171
164
  });
@@ -213,13 +206,10 @@
213
206
  let swapIndex = upEls.length - 1;
214
207
  for (let i = upEls.length - 1; i >= 0; i--) {
215
208
  const ele = upEls[i];
216
- if (!ele)
217
- continue;
218
- if (ele.style.position === "fixed")
219
- continue;
209
+ if (!ele) continue;
210
+ if (ele.style.position === "fixed") continue;
220
211
  addUpH += ele.clientHeight / 2;
221
- if (-deltaTop <= addUpH)
222
- break;
212
+ if (-deltaTop <= addUpH) break;
223
213
  addUpH += ele.clientHeight / 2;
224
214
  swapIndex = i;
225
215
  }
@@ -494,13 +484,11 @@
494
484
  const frameSnapShot = this.framesSnapShot.find(
495
485
  (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
496
486
  );
497
- if (!frameSnapShot)
498
- return;
487
+ if (!frameSnapShot) return;
499
488
  const targeEl = this.targetList.find(
500
489
  (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
501
490
  );
502
- if (!targeEl)
503
- return;
491
+ if (!targeEl) return;
504
492
  const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
505
493
  if (!isParentIncluded) {
506
494
  const { marginLeft, marginTop } = getMarginValue(targeEl);
@@ -523,13 +511,11 @@
523
511
  const frameSnapShot = this.framesSnapShot.find(
524
512
  (frameItem) => ev.target.id.startsWith(DRAG_EL_ID_PREFIX) && ev.target.id.endsWith(frameItem.id)
525
513
  );
526
- if (!frameSnapShot)
527
- return;
514
+ if (!frameSnapShot) return;
528
515
  const targeEl = this.targetList.find(
529
516
  (targetItem) => ev.target.id.startsWith(DRAG_EL_ID_PREFIX) && ev.target.id.endsWith(targetItem.id)
530
517
  );
531
- if (!targeEl)
532
- return;
518
+ if (!targeEl) return;
533
519
  const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
534
520
  if (!isParentIncluded) {
535
521
  const { marginLeft, marginTop } = getMarginValue(targeEl);
@@ -567,14 +553,12 @@
567
553
  * 多选状态设置多个节点的快照
568
554
  */
569
555
  setFramesSnapShot(events) {
570
- if (this.framesSnapShot.length > 0)
571
- return;
556
+ if (this.framesSnapShot.length > 0) return;
572
557
  events.forEach((ev) => {
573
558
  const matchEventTarget = this.targetList.find(
574
559
  (targetItem) => ev.target.id.startsWith(DRAG_EL_ID_PREFIX) && ev.target.id.endsWith(targetItem.id)
575
560
  );
576
- if (!matchEventTarget)
577
- return;
561
+ if (!matchEventTarget) return;
578
562
  this.framesSnapShot.push({
579
563
  left: matchEventTarget.offsetLeft,
580
564
  top: matchEventTarget.offsetTop,
@@ -876,16 +860,13 @@
876
860
  const frame = globalThis.document.createDocumentFragment();
877
861
  for (const element of allElList) {
878
862
  let node = element.element || element;
879
- if (!node || typeof node === "string")
880
- continue;
863
+ if (!node || typeof node === "string") continue;
881
864
  if (typeof node === "function") {
882
865
  node = node();
883
866
  }
884
- if (this.isInElementList(node, selectedElList))
885
- continue;
867
+ if (this.isInElementList(node, selectedElList)) continue;
886
868
  const { width, height } = node.getBoundingClientRect();
887
- if (!width || !height)
888
- continue;
869
+ if (!width || !height) continue;
889
870
  const { left, top } = getOffset(node);
890
871
  const elementGuideline = globalThis.document.createElement("div");
891
872
  elementGuideline.style.cssText = `position: absolute;width: ${width}px;height: ${height}px;top: ${top}px;left: ${left}px`;
@@ -902,8 +883,7 @@
902
883
  */
903
884
  isInElementList(ele, eleList) {
904
885
  for (const eleItem of eleList) {
905
- if (ele === eleItem)
906
- return true;
886
+ if (ele === eleItem) return true;
907
887
  }
908
888
  return false;
909
889
  }
@@ -962,10 +942,8 @@
962
942
  * 初始化选中框并渲染出来
963
943
  */
964
944
  updateMoveable(el = this.target) {
965
- if (!this.moveable)
966
- return;
967
- if (!el)
968
- throw new Error("未选中任何节点");
945
+ if (!this.moveable) return;
946
+ if (!el) throw new Error("未选中任何节点");
969
947
  const options = this.init(el);
970
948
  Object.entries(options).forEach(([key, value]) => {
971
949
  this.moveable[key] = value;
@@ -973,8 +951,7 @@
973
951
  this.moveable.updateRect();
974
952
  }
975
953
  clearSelectStatus() {
976
- if (!this.moveable)
977
- return;
954
+ if (!this.moveable) return;
978
955
  this.dragResizeHelper.destroyShadowEl();
979
956
  this.moveable.target = null;
980
957
  this.moveable.updateRect();
@@ -1023,16 +1000,13 @@
1023
1000
  this.bindScaleEvent();
1024
1001
  }
1025
1002
  bindResizeEvent() {
1026
- if (!this.moveable)
1027
- throw new Error("moveable 未初始化");
1003
+ if (!this.moveable) throw new Error("moveable 未初始化");
1028
1004
  this.moveable.on("resizeStart", (e) => {
1029
- if (!this.target)
1030
- return;
1005
+ if (!this.target) return;
1031
1006
  this.dragStatus = StageDragStatus.START;
1032
1007
  this.dragResizeHelper.onResizeStart(e);
1033
1008
  }).on("resize", (e) => {
1034
- if (!this.moveable || !this.target || !this.dragResizeHelper.getShadowEl())
1035
- return;
1009
+ if (!this.moveable || !this.target || !this.dragResizeHelper.getShadowEl()) return;
1036
1010
  this.dragStatus = StageDragStatus.ING;
1037
1011
  this.dragResizeHelper.onResize(e);
1038
1012
  }).on("resizeEnd", () => {
@@ -1041,18 +1015,15 @@
1041
1015
  });
1042
1016
  }
1043
1017
  bindDragEvent() {
1044
- if (!this.moveable)
1045
- throw new Error("moveable 未初始化");
1018
+ if (!this.moveable) throw new Error("moveable 未初始化");
1046
1019
  let timeout;
1047
1020
  this.moveable.on("dragStart", (e) => {
1048
- if (!this.target)
1049
- throw new Error("未选中组件");
1021
+ if (!this.target) throw new Error("未选中组件");
1050
1022
  this.dragStatus = StageDragStatus.START;
1051
1023
  this.dragResizeHelper.onDragStart(e);
1052
1024
  this.emit("drag-start", e);
1053
1025
  }).on("drag", (e) => {
1054
- if (!this.target || !this.dragResizeHelper.getShadowEl())
1055
- return;
1026
+ if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
1056
1027
  if (timeout) {
1057
1028
  globalThis.clearTimeout(timeout);
1058
1029
  timeout = void 0;
@@ -1084,14 +1055,12 @@
1084
1055
  });
1085
1056
  }
1086
1057
  bindRotateEvent() {
1087
- if (!this.moveable)
1088
- throw new Error("moveable 未初始化");
1058
+ if (!this.moveable) throw new Error("moveable 未初始化");
1089
1059
  this.moveable.on("rotateStart", (e) => {
1090
1060
  this.dragStatus = StageDragStatus.START;
1091
1061
  this.dragResizeHelper.onRotateStart(e);
1092
1062
  }).on("rotate", (e) => {
1093
- if (!this.target || !this.dragResizeHelper.getShadowEl())
1094
- return;
1063
+ if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
1095
1064
  this.dragStatus = StageDragStatus.ING;
1096
1065
  this.dragResizeHelper.onRotate(e);
1097
1066
  }).on("rotateEnd", (e) => {
@@ -1113,14 +1082,12 @@
1113
1082
  });
1114
1083
  }
1115
1084
  bindScaleEvent() {
1116
- if (!this.moveable)
1117
- throw new Error("moveable 未初始化");
1085
+ if (!this.moveable) throw new Error("moveable 未初始化");
1118
1086
  this.moveable.on("scaleStart", (e) => {
1119
1087
  this.dragStatus = StageDragStatus.START;
1120
1088
  this.dragResizeHelper.onScaleStart(e);
1121
1089
  }).on("scale", (e) => {
1122
- if (!this.target || !this.dragResizeHelper.getShadowEl())
1123
- return;
1090
+ if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
1124
1091
  this.dragStatus = StageDragStatus.ING;
1125
1092
  this.dragResizeHelper.onScale(e);
1126
1093
  }).on("scaleEnd", (e) => {
@@ -1142,8 +1109,7 @@
1142
1109
  });
1143
1110
  }
1144
1111
  sort() {
1145
- if (!this.target || !this.dragResizeHelper.getGhostEl())
1146
- throw new Error("未知错误");
1112
+ if (!this.target || !this.dragResizeHelper.getGhostEl()) throw new Error("未知错误");
1147
1113
  const { top } = this.dragResizeHelper.getGhostEl().getBoundingClientRect();
1148
1114
  const { top: oriTop } = this.target.getBoundingClientRect();
1149
1115
  const deltaTop = top - oriTop;
@@ -1161,11 +1127,9 @@
1161
1127
  }
1162
1128
  }
1163
1129
  update(isResize = false, parentEl = null) {
1164
- if (!this.target)
1165
- return;
1130
+ if (!this.target) return;
1166
1131
  const doc = this.getRenderDocument();
1167
- if (!doc)
1168
- return;
1132
+ if (!doc) return;
1169
1133
  const rect = this.dragResizeHelper.getUpdatedElRect(this.target, parentEl, doc);
1170
1134
  this.emit("update", {
1171
1135
  data: [
@@ -1201,8 +1165,7 @@
1201
1165
  * @param el 选中组件的Dom节点元素
1202
1166
  */
1203
1167
  highlight(el) {
1204
- if (!el || el === this.target)
1205
- return;
1168
+ if (!el || el === this.target) return;
1206
1169
  this.target = el;
1207
1170
  this.targetShadow?.update(el);
1208
1171
  if (this.moveable) {
@@ -1221,8 +1184,7 @@
1221
1184
  * 清空高亮
1222
1185
  */
1223
1186
  clearHighlight() {
1224
- if (!this.moveable || !this.target)
1225
- return;
1187
+ if (!this.moveable || !this.target) return;
1226
1188
  this.moveable.zoom = 0;
1227
1189
  this.moveable.updateRect();
1228
1190
  this.target = void 0;
@@ -1341,10 +1303,8 @@
1341
1303
  return true;
1342
1304
  }
1343
1305
  updateMoveable(eleList = this.targetList) {
1344
- if (!this.moveableForMulti)
1345
- return;
1346
- if (!eleList)
1347
- throw new Error("未选中任何节点");
1306
+ if (!this.moveableForMulti) return;
1307
+ if (!eleList) throw new Error("未选中任何节点");
1348
1308
  this.targetList = eleList;
1349
1309
  this.dragResizeHelper.setTargetList(eleList);
1350
1310
  const options = this.getOptions(true, {
@@ -1359,8 +1319,7 @@
1359
1319
  * 清除多选状态
1360
1320
  */
1361
1321
  clearSelectStatus() {
1362
- if (!this.moveableForMulti)
1363
- return;
1322
+ if (!this.moveableForMulti) return;
1364
1323
  this.dragResizeHelper.clearMultiSelectStatus();
1365
1324
  this.moveableForMulti.target = null;
1366
1325
  this.moveableForMulti.updateTarget();
@@ -1384,11 +1343,9 @@
1384
1343
  * @param isResize 是否进行大小缩放
1385
1344
  */
1386
1345
  update(isResize = false, parentEl = null) {
1387
- if (this.targetList.length === 0)
1388
- return;
1346
+ if (this.targetList.length === 0) return;
1389
1347
  const doc = this.getRenderDocument();
1390
- if (!doc)
1391
- return;
1348
+ if (!doc) return;
1392
1349
  const data = this.targetList.map((targetItem) => {
1393
1350
  const rect = this.dragResizeHelper.getUpdatedElRect(targetItem, parentEl, doc);
1394
1351
  return {
@@ -1539,8 +1496,7 @@
1539
1496
  const stop = () => stopped = true;
1540
1497
  for (const el of els) {
1541
1498
  if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isElCanSelect(el, event, stop)) {
1542
- if (stopped)
1543
- break;
1499
+ if (stopped) break;
1544
1500
  return el;
1545
1501
  }
1546
1502
  }
@@ -1555,8 +1511,7 @@
1555
1511
  */
1556
1512
  async isElCanSelect(el, event, stop) {
1557
1513
  const canSelectByProp = await this.canSelect(el, event, stop);
1558
- if (!canSelectByProp)
1559
- return false;
1514
+ if (!canSelectByProp) return false;
1560
1515
  if (this.isMultiSelectStatus) {
1561
1516
  return this.canMultiSelect(el, stop);
1562
1517
  }
@@ -1610,8 +1565,7 @@
1610
1565
  this.clearHighlight();
1611
1566
  return;
1612
1567
  }
1613
- if (el === this.highlightedEl || !el)
1614
- return;
1568
+ if (el === this.highlightedEl || !el) return;
1615
1569
  this.highlightLayer.highlight(el);
1616
1570
  this.highlightedEl = el;
1617
1571
  this.emit("highlight", el);
@@ -1639,8 +1593,7 @@
1639
1593
  */
1640
1594
  async addContainerHighlightClassName(event, excludeElList) {
1641
1595
  const doc = this.getRenderDocument();
1642
- if (!doc)
1643
- return;
1596
+ if (!doc) return;
1644
1597
  const els = this.getElementsFromPoint(event);
1645
1598
  for (const el of els) {
1646
1599
  if (!el.id.startsWith(GHOST_EL_ID_PREFIX) && await this.isContainer?.(el) && !excludeElList.includes(el)) {
@@ -1706,8 +1659,7 @@
1706
1659
  this.emit("select-parent");
1707
1660
  }).on(AbleActionEventType.REMOVE, () => {
1708
1661
  const drTarget = this.dr.getTarget();
1709
- if (!drTarget)
1710
- return;
1662
+ if (!drTarget) return;
1711
1663
  const data = {
1712
1664
  data: [{ el: drTarget }]
1713
1665
  };
@@ -1734,8 +1686,7 @@
1734
1686
  multiDr?.on("update", (data) => {
1735
1687
  this.emit("multi-update", data);
1736
1688
  }).on("change-to-select", (id, e) => {
1737
- if (this.isMultiSelectStatus)
1738
- return;
1689
+ if (this.isMultiSelectStatus) return;
1739
1690
  this.emit("change-to-select", id, e);
1740
1691
  });
1741
1692
  return multiDr;
@@ -1766,8 +1717,7 @@
1766
1717
  */
1767
1718
  async beforeMultiSelect(event) {
1768
1719
  const el = await this.getElementFromPoint(event);
1769
- if (!el)
1770
- return;
1720
+ if (!el) return;
1771
1721
  if (this.selectedEl && !this.selectedEl.className.includes(PAGE_CLASS)) {
1772
1722
  this.selectedElList.push(this.selectedEl);
1773
1723
  this.setSelectedEl(null);
@@ -1845,8 +1795,7 @@
1845
1795
  this.clearHighlight();
1846
1796
  event.stopImmediatePropagation();
1847
1797
  event.stopPropagation();
1848
- if (this.isStopTriggerSelect(event))
1849
- return;
1798
+ if (this.isStopTriggerSelect(event)) return;
1850
1799
  this.container.removeEventListener("mousemove", this.mouseMoveHandler);
1851
1800
  if (this.isMultiSelectStatus) {
1852
1801
  await this.beforeMultiSelect(event);
@@ -1855,17 +1804,14 @@
1855
1804
  }
1856
1805
  } else {
1857
1806
  const el = await this.getElementFromPoint(event);
1858
- if (!el)
1859
- return;
1807
+ if (!el) return;
1860
1808
  this.emit("before-select", el, event);
1861
1809
  }
1862
1810
  utils.getDocument().addEventListener("mouseup", this.mouseUpHandler);
1863
1811
  };
1864
1812
  isStopTriggerSelect(event) {
1865
- if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
1866
- return true;
1867
- if (!event.target)
1868
- return true;
1813
+ if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT) return true;
1814
+ if (!event.target) return true;
1869
1815
  const targetClassList = event.target.classList;
1870
1816
  if (!this.isMultiSelectStatus && targetClassList.contains("moveable-area")) {
1871
1817
  return true;
@@ -2107,8 +2053,7 @@
2107
2053
  * @param page 页面Dom节点
2108
2054
  */
2109
2055
  observe(page) {
2110
- if (!page)
2111
- return;
2056
+ if (!page) return;
2112
2057
  this.page = page;
2113
2058
  this.initObserverIntersection();
2114
2059
  this.initObserverWrapper();
@@ -2136,19 +2081,16 @@
2136
2081
  * @param el 将蒙层挂载到该Dom节点上
2137
2082
  */
2138
2083
  mount(el) {
2139
- if (!this.content)
2140
- throw new Error("content 不存在");
2084
+ if (!this.content) throw new Error("content 不存在");
2141
2085
  el.appendChild(this.wrapper);
2142
2086
  }
2143
2087
  setLayout(el) {
2144
2088
  this.setMode(isFixedParent(el) ? Mode.FIXED : Mode.ABSOLUTE);
2145
2089
  }
2146
2090
  scrollIntoView(el) {
2147
- if (!this.page || el.getBoundingClientRect().left >= this.page.scrollWidth)
2148
- return;
2091
+ if (!this.page || el.getBoundingClientRect().left >= this.page.scrollWidth) return;
2149
2092
  el.scrollIntoView();
2150
- if (!this.pageScrollParent)
2151
- return;
2093
+ if (!this.pageScrollParent) return;
2152
2094
  this.scrollLeft = this.pageScrollParent.scrollLeft;
2153
2095
  this.scrollTop = this.pageScrollParent.scrollTop;
2154
2096
  this.scroll();
@@ -2272,23 +2214,16 @@
2272
2214
  * 由于滚动容器变化等因素,会导致当前滚动的距离不正确
2273
2215
  */
2274
2216
  fixScrollValue() {
2275
- if (this.scrollTop < 0)
2276
- this.scrollTop = 0;
2277
- if (this.scrollLeft < 0)
2278
- this.scrollLeft = 0;
2279
- if (this.maxScrollTop < this.scrollTop)
2280
- this.scrollTop = this.maxScrollTop;
2281
- if (this.maxScrollLeft < this.scrollLeft)
2282
- this.scrollLeft = this.maxScrollLeft;
2217
+ if (this.scrollTop < 0) this.scrollTop = 0;
2218
+ if (this.scrollLeft < 0) this.scrollLeft = 0;
2219
+ if (this.maxScrollTop < this.scrollTop) this.scrollTop = this.maxScrollTop;
2220
+ if (this.maxScrollLeft < this.scrollLeft) this.scrollLeft = this.maxScrollLeft;
2283
2221
  }
2284
2222
  mouseWheelHandler = (event) => {
2285
- if (!this.page)
2286
- throw new Error("page 未初始化");
2223
+ if (!this.page) throw new Error("page 未初始化");
2287
2224
  const { deltaY, deltaX } = event;
2288
- if (this.page.clientHeight < this.wrapperHeight && deltaY)
2289
- return;
2290
- if (this.page.clientWidth < this.wrapperWidth && deltaX)
2291
- return;
2225
+ if (this.page.clientHeight < this.wrapperHeight && deltaY) return;
2226
+ if (this.page.clientWidth < this.wrapperWidth && deltaX) return;
2292
2227
  if (this.maxScrollTop > 0) {
2293
2228
  this.scrollTop = this.scrollTop + deltaY;
2294
2229
  }
@@ -2374,8 +2309,7 @@
2374
2309
  }
2375
2310
  }
2376
2311
  getRuntime = () => {
2377
- if (this.runtime)
2378
- return Promise.resolve(this.runtime);
2312
+ if (this.runtime) return Promise.resolve(this.runtime);
2379
2313
  return new Promise((resolve) => {
2380
2314
  const listener = (runtime) => {
2381
2315
  this.off("runtime-ready", listener);
@@ -2460,8 +2394,7 @@
2460
2394
  if (!this.contentWindow?.magic) {
2461
2395
  this.postTmagicRuntimeReady();
2462
2396
  }
2463
- if (!this.contentWindow)
2464
- return;
2397
+ if (!this.contentWindow) return;
2465
2398
  if (this.customizedRender) {
2466
2399
  const el = await this.customizedRender();
2467
2400
  if (el) {
@@ -2520,8 +2453,7 @@
2520
2453
  */
2521
2454
  async select(id, event) {
2522
2455
  const el = this.renderer.getTargetElement(id);
2523
- if (el === this.actionManager.getSelectedEl())
2524
- return;
2456
+ if (el === this.actionManager.getSelectedEl()) return;
2525
2457
  await this.renderer.select([id]);
2526
2458
  el && this.mask.setLayout(el);
2527
2459
  this.actionManager.select(el, event);
@@ -2535,8 +2467,7 @@
2535
2467
  */
2536
2468
  async multiSelect(ids) {
2537
2469
  const els = ids.map((id) => this.renderer.getTargetElement(id)).filter((el) => Boolean(el));
2538
- if (els.length === 0)
2539
- return;
2470
+ if (els.length === 0) return;
2540
2471
  const lastEl = els[els.length - 1];
2541
2472
  const isReduceSelect = els.length < this.actionManager.getSelectedElList().length;
2542
2473
  await this.renderer.select(ids);
package/package.json CHANGED
@@ -1,10 +1,7 @@
1
1
  {
2
- "version": "1.4.7",
2
+ "version": "1.4.9",
3
3
  "name": "@tmagic/stage",
4
4
  "type": "module",
5
- "sideEffects": [
6
- "dist/*"
7
- ],
8
5
  "main": "dist/tmagic-stage.umd.cjs",
9
6
  "module": "dist/tmagic-stage.js",
10
7
  "types": "types/index.d.ts",
@@ -16,6 +13,11 @@
16
13
  },
17
14
  "./*": "./*"
18
15
  },
16
+ "files": [
17
+ "dist",
18
+ "types",
19
+ "src"
20
+ ],
19
21
  "license": "Apache-2.0",
20
22
  "engines": {
21
23
  "node": ">=18"
@@ -38,13 +40,13 @@
38
40
  "@types/node": "^18.19.0",
39
41
  "rimraf": "^3.0.2",
40
42
  "sass": "^1.77.0",
41
- "vite": "^5.2.11"
43
+ "vite": "^5.3.1"
42
44
  },
43
45
  "peerDependencies": {
44
46
  "typescript": "*",
45
- "@tmagic/core": "1.4.7",
46
- "@tmagic/utils": "1.4.7",
47
- "@tmagic/schema": "1.4.7"
47
+ "@tmagic/core": "1.4.9",
48
+ "@tmagic/schema": "1.4.9",
49
+ "@tmagic/utils": "1.4.9"
48
50
  },
49
51
  "peerDependenciesMeta": {
50
52
  "typescript": {
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "declaration": true,
6
- "declarationDir": "types",
7
- "forceConsistentCasingInFileNames": true,
8
- "paths": {},
9
- },
10
- "include": [
11
- "src"
12
- ],
13
- }