@tmagic/stage 1.3.0-alpha.2 → 1.3.0-alpha.21
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/tmagic-stage.js +91 -78
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +91 -78
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +8 -8
- package/src/ActionManager.ts +18 -4
- package/src/MoveableActionsAble.ts +36 -54
- package/src/MoveableOptionsManager.ts +11 -5
- package/src/StageCore.ts +12 -3
- package/src/StageDragResize.ts +2 -2
- package/src/StageHighlight.ts +18 -11
- package/src/StageMultiDragResize.ts +2 -2
- package/src/moveable-able.css +108 -0
- package/src/types.ts +5 -3
- package/types/ActionManager.d.ts +3 -1
- package/types/MoveableActionsAble.d.ts +2 -4
- package/types/MoveableOptionsManager.d.ts +2 -0
- package/types/StageCore.d.ts +5 -2
- package/types/StageHighlight.d.ts +1 -1
- package/types/types.d.ts +5 -3
|
@@ -556,6 +556,8 @@
|
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
+
const ableCss = ".moveable-button {\n width: 20px;\n height: 20px;\n background: #4af;\n border-radius: 4px;\n appearance: none;\n border: 0;\n color: white;\n font-size: 12px;\n font-weight: bold;\n margin-left: 2px;\n position: relative;\n}\n.moveable-remove-button:before, .moveable-remove-button:after {\n content: \"\";\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%) rotate(45deg);\n width: 14px;\n height: 2px;\n background: #fff;\n border-radius: 1px;\n cursor: pointer;\n}\n.moveable-remove-button:after {\n transform: translate(-50%, -50%) rotate(-45deg);\n}\n\n.moveable-select-parent-arrow-top-icon {\n transform: rotateZ(-45deg);\n width: 4px;\n height: 4px;\n border-color: #fff;\n border-width: 2px 2px 0 0;\n border-style: solid;\n position: absolute;\n left: 4px;\n top: 4px;\n}\n\n.moveable-select-parent-arrow-body-icon {\n width: 7px;\n height: 11px;\n border-color: #fff;\n border-width: 0 0 2px 2px;\n border-style: solid;\n}\n\n.moveable-drag-area-button {\n cursor: move;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon {\n width: 2px;\n height: 2px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-top {\n transform: rotateZ(-45deg) translateX(-50%);\n left: 50%;\n top: 3px;\n transform-origin: left;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-bottom {\n transform: rotateZ(135deg) translateX(-50%);\n transform-origin: left;\n left: 50%;\n top: auto;\n bottom: 3px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-right {\n transform: rotateZ(45deg) translateY(-50%);\n transform-origin: top;\n right: 3px;\n left: auto;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-left {\n transform: rotateZ(235deg) translateY(-50%);\n transform-origin: top;\n left: 3px;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-horizontal {\n width: 2px;\n height: 11px;\n background-color: #fff;\n position: absolute;\n transform: translateX(-50%);\n left: 50%;\n top: 4px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-vertical {\n width: 11px;\n height: 2px;\n background-color: #fff;\n position: absolute;\n transform: translateY(-50%);\n left: 4px;\n top: 50%;;\n}\n\n";
|
|
560
|
+
|
|
559
561
|
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
560
562
|
ContainerHighlightType2["DEFAULT"] = "default";
|
|
561
563
|
ContainerHighlightType2["ALT"] = "alt";
|
|
@@ -580,10 +582,8 @@
|
|
|
580
582
|
|
|
581
583
|
const MoveableActionsAble = (handler) => ({
|
|
582
584
|
name: "actions",
|
|
583
|
-
props:
|
|
584
|
-
|
|
585
|
-
},
|
|
586
|
-
events: {},
|
|
585
|
+
props: [],
|
|
586
|
+
events: [],
|
|
587
587
|
render(moveable, React) {
|
|
588
588
|
const rect = moveable.getRect();
|
|
589
589
|
const { pos2 } = moveable.state;
|
|
@@ -598,34 +598,7 @@
|
|
|
598
598
|
transform-origin: 0px 0px;
|
|
599
599
|
display: flex;
|
|
600
600
|
}
|
|
601
|
-
|
|
602
|
-
width: 20px;
|
|
603
|
-
height: 20px;
|
|
604
|
-
background: #4af;
|
|
605
|
-
border-radius: 4px;
|
|
606
|
-
appearance: none;
|
|
607
|
-
border: 0;
|
|
608
|
-
color: white;
|
|
609
|
-
font-size: 12px;
|
|
610
|
-
font-weight: bold;
|
|
611
|
-
margin-left: 2px;
|
|
612
|
-
position: relative;
|
|
613
|
-
}
|
|
614
|
-
.moveable-remove-button:before, .moveable-remove-button:after {
|
|
615
|
-
content: "";
|
|
616
|
-
position: absolute;
|
|
617
|
-
left: 50%;
|
|
618
|
-
top: 50%;
|
|
619
|
-
transform: translate(-50%, -50%) rotate(45deg);
|
|
620
|
-
width: 14px;
|
|
621
|
-
height: 2px;
|
|
622
|
-
background: #fff;
|
|
623
|
-
border-radius: 1px;
|
|
624
|
-
cursor: pointer;
|
|
625
|
-
}
|
|
626
|
-
.moveable-remove-button:after {
|
|
627
|
-
transform: translate(-50%, -50%) rotate(-45deg);
|
|
628
|
-
}
|
|
601
|
+
${ableCss}
|
|
629
602
|
`
|
|
630
603
|
);
|
|
631
604
|
return React.createElement(
|
|
@@ -633,7 +606,7 @@
|
|
|
633
606
|
{
|
|
634
607
|
className: "moveable-editable",
|
|
635
608
|
style: {
|
|
636
|
-
transform: `translate(${pos2[0] -
|
|
609
|
+
transform: `translate(${pos2[0] - 60}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg)`
|
|
637
610
|
}
|
|
638
611
|
},
|
|
639
612
|
[
|
|
@@ -646,27 +619,12 @@
|
|
|
646
619
|
handler(AbleActionEventType.SELECT_PARENT);
|
|
647
620
|
}
|
|
648
621
|
},
|
|
649
|
-
React.createElement(
|
|
650
|
-
"
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
fill: "none",
|
|
656
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
657
|
-
style: {
|
|
658
|
-
transform: "rotate(90deg)",
|
|
659
|
-
position: "absolute",
|
|
660
|
-
left: 0,
|
|
661
|
-
top: 0
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
|
-
React.createElement("path", {
|
|
665
|
-
d: "M13.0001 4V10H4.20718L5.85363 8.35355L5.14652 7.64645L2.64652 10.1464C2.45126 10.3417 2.45126 10.6583 2.64652 10.8536L5.14652 13.3536L5.85363 12.6464L4.20718 11H13.0001C13.5524 11 14.0001 10.5523 14.0001 10V4H13.0001Z",
|
|
666
|
-
fill: "currentColor",
|
|
667
|
-
fillOpacity: "0.9"
|
|
668
|
-
})
|
|
669
|
-
)
|
|
622
|
+
React.createElement("div", {
|
|
623
|
+
className: "moveable-select-parent-arrow-top-icon"
|
|
624
|
+
}),
|
|
625
|
+
React.createElement("div", {
|
|
626
|
+
className: "moveable-select-parent-arrow-body-icon"
|
|
627
|
+
})
|
|
670
628
|
),
|
|
671
629
|
React.createElement("button", {
|
|
672
630
|
className: "moveable-button moveable-remove-button",
|
|
@@ -674,7 +632,32 @@
|
|
|
674
632
|
onClick: () => {
|
|
675
633
|
handler(AbleActionEventType.REMOVE);
|
|
676
634
|
}
|
|
677
|
-
})
|
|
635
|
+
}),
|
|
636
|
+
React.createElement(
|
|
637
|
+
"button",
|
|
638
|
+
{
|
|
639
|
+
className: "moveable-button moveable-drag-area-button",
|
|
640
|
+
title: "拖动"
|
|
641
|
+
},
|
|
642
|
+
React.createElement("div", {
|
|
643
|
+
className: "moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-top"
|
|
644
|
+
}),
|
|
645
|
+
React.createElement("div", {
|
|
646
|
+
className: "moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-bottom"
|
|
647
|
+
}),
|
|
648
|
+
React.createElement("div", {
|
|
649
|
+
className: "moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-left"
|
|
650
|
+
}),
|
|
651
|
+
React.createElement("div", {
|
|
652
|
+
className: " moveable-select-parent-arrow-top-icon moveable-select-parent-arrow-top-icon-right"
|
|
653
|
+
}),
|
|
654
|
+
React.createElement("div", {
|
|
655
|
+
className: "moveable-select-parent-arrow-body-icon-horizontal"
|
|
656
|
+
}),
|
|
657
|
+
React.createElement("div", {
|
|
658
|
+
className: "moveable-select-parent-arrow-body-icon-vertical"
|
|
659
|
+
})
|
|
660
|
+
)
|
|
678
661
|
]
|
|
679
662
|
);
|
|
680
663
|
}
|
|
@@ -685,6 +668,7 @@
|
|
|
685
668
|
mode = Mode.ABSOLUTE;
|
|
686
669
|
/** 画布容器 */
|
|
687
670
|
container;
|
|
671
|
+
options = {};
|
|
688
672
|
/** 水平参考线 */
|
|
689
673
|
horizontalGuidelines = [];
|
|
690
674
|
/** 垂直参考线 */
|
|
@@ -701,6 +685,9 @@
|
|
|
701
685
|
this.container = config.container;
|
|
702
686
|
this.getRootContainer = config.getRootContainer;
|
|
703
687
|
}
|
|
688
|
+
getOption(key) {
|
|
689
|
+
return this.options[key];
|
|
690
|
+
}
|
|
704
691
|
/**
|
|
705
692
|
* 设置水平/垂直参考线
|
|
706
693
|
* @param type 参考线类型
|
|
@@ -745,7 +732,8 @@
|
|
|
745
732
|
getOptions(isMultiSelect, runtimeOptions = {}) {
|
|
746
733
|
const defaultOptions = this.getDefaultOptions(isMultiSelect);
|
|
747
734
|
const customizedOptions = this.getCustomizeOptions();
|
|
748
|
-
|
|
735
|
+
this.options = lodashEs.merge(defaultOptions, customizedOptions, runtimeOptions);
|
|
736
|
+
return this.options;
|
|
749
737
|
}
|
|
750
738
|
/**
|
|
751
739
|
* 获取单选和多选的moveable公共参数
|
|
@@ -765,9 +753,8 @@
|
|
|
765
753
|
elementGuidelines: this.elementGuidelines,
|
|
766
754
|
bounds: {
|
|
767
755
|
top: 0,
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
right: this.container.clientWidth - 1,
|
|
756
|
+
left: 0,
|
|
757
|
+
right: this.container.clientWidth,
|
|
771
758
|
bottom: isSortable ? void 0 : this.container.clientHeight
|
|
772
759
|
}
|
|
773
760
|
};
|
|
@@ -805,6 +792,8 @@
|
|
|
805
792
|
left: isAbsolute
|
|
806
793
|
},
|
|
807
794
|
isDisplayInnerSnapDigit: true,
|
|
795
|
+
dragTarget: ".moveable-drag-area-button",
|
|
796
|
+
dragTargetSelf: true,
|
|
808
797
|
props: {
|
|
809
798
|
actions: true
|
|
810
799
|
},
|
|
@@ -931,14 +920,14 @@
|
|
|
931
920
|
Object.entries(options).forEach(([key, value]) => {
|
|
932
921
|
this.moveable[key] = value;
|
|
933
922
|
});
|
|
934
|
-
this.moveable.
|
|
923
|
+
this.moveable.updateRect();
|
|
935
924
|
}
|
|
936
925
|
clearSelectStatus() {
|
|
937
926
|
if (!this.moveable)
|
|
938
927
|
return;
|
|
939
928
|
this.dragResizeHelper.destroyShadowEl();
|
|
940
929
|
this.moveable.target = null;
|
|
941
|
-
this.moveable.
|
|
930
|
+
this.moveable.updateRect();
|
|
942
931
|
}
|
|
943
932
|
/**
|
|
944
933
|
* 销毁实例
|
|
@@ -1150,13 +1139,18 @@
|
|
|
1150
1139
|
if (!el || el === this.target)
|
|
1151
1140
|
return;
|
|
1152
1141
|
this.target = el;
|
|
1153
|
-
this.
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1142
|
+
this.targetShadow?.update(el);
|
|
1143
|
+
if (this.moveable) {
|
|
1144
|
+
this.moveable.zoom = 2;
|
|
1145
|
+
this.moveable.updateRect();
|
|
1146
|
+
} else {
|
|
1147
|
+
this.moveable = new Moveable(this.container, {
|
|
1148
|
+
target: this.targetShadow?.el,
|
|
1149
|
+
origin: false,
|
|
1150
|
+
rootContainer: this.getRootContainer(),
|
|
1151
|
+
zoom: 2
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1160
1154
|
}
|
|
1161
1155
|
/**
|
|
1162
1156
|
* 清空高亮
|
|
@@ -1164,16 +1158,18 @@
|
|
|
1164
1158
|
clearHighlight() {
|
|
1165
1159
|
if (!this.moveable || !this.target)
|
|
1166
1160
|
return;
|
|
1161
|
+
this.moveable.zoom = 0;
|
|
1162
|
+
this.moveable.updateRect();
|
|
1167
1163
|
this.target = void 0;
|
|
1168
|
-
this.moveable.target = null;
|
|
1169
|
-
this.moveable.updateTarget();
|
|
1170
1164
|
}
|
|
1171
1165
|
/**
|
|
1172
1166
|
* 销毁实例
|
|
1173
1167
|
*/
|
|
1174
1168
|
destroy() {
|
|
1175
1169
|
this.moveable?.destroy();
|
|
1176
|
-
this.targetShadow
|
|
1170
|
+
this.targetShadow?.destroy();
|
|
1171
|
+
this.moveable = void 0;
|
|
1172
|
+
this.targetShadow = void 0;
|
|
1177
1173
|
}
|
|
1178
1174
|
}
|
|
1179
1175
|
|
|
@@ -1192,7 +1188,7 @@
|
|
|
1192
1188
|
constructor(config) {
|
|
1193
1189
|
const moveableOptionsManagerConfig = {
|
|
1194
1190
|
container: config.container,
|
|
1195
|
-
moveableOptions: config.
|
|
1191
|
+
moveableOptions: config.moveableOptions,
|
|
1196
1192
|
getRootContainer: config.getRootContainer
|
|
1197
1193
|
};
|
|
1198
1194
|
super(moveableOptionsManagerConfig);
|
|
@@ -1289,7 +1285,7 @@
|
|
|
1289
1285
|
Object.entries(options).forEach(([key, value]) => {
|
|
1290
1286
|
this.moveableForMulti[key] = value;
|
|
1291
1287
|
});
|
|
1292
|
-
this.moveableForMulti.
|
|
1288
|
+
this.moveableForMulti.updateRect();
|
|
1293
1289
|
}
|
|
1294
1290
|
/**
|
|
1295
1291
|
* 清除多选状态
|
|
@@ -1384,7 +1380,7 @@
|
|
|
1384
1380
|
this.dr = new StageDragResize({
|
|
1385
1381
|
container: config.container,
|
|
1386
1382
|
disabledDragStart: config.disabledDragStart,
|
|
1387
|
-
moveableOptions: this.changeCallback(config.moveableOptions),
|
|
1383
|
+
moveableOptions: this.changeCallback(config.moveableOptions, false),
|
|
1388
1384
|
dragResizeHelper: createDrHelper(),
|
|
1389
1385
|
getRootContainer: config.getRootContainer,
|
|
1390
1386
|
getRenderDocument: config.getRenderDocument,
|
|
@@ -1393,7 +1389,7 @@
|
|
|
1393
1389
|
});
|
|
1394
1390
|
this.multiDr = new StageMultiDragResize({
|
|
1395
1391
|
container: config.container,
|
|
1396
|
-
|
|
1392
|
+
moveableOptions: this.changeCallback(config.moveableOptions, true),
|
|
1397
1393
|
dragResizeHelper: createDrHelper(),
|
|
1398
1394
|
getRootContainer: config.getRootContainer,
|
|
1399
1395
|
getRenderDocument: config.getRenderDocument,
|
|
@@ -1448,6 +1444,14 @@
|
|
|
1448
1444
|
getSelectedElList() {
|
|
1449
1445
|
return this.selectedElList;
|
|
1450
1446
|
}
|
|
1447
|
+
getMoveableOption(key) {
|
|
1448
|
+
if (this.dr.getTarget()) {
|
|
1449
|
+
return this.dr.getOption(key);
|
|
1450
|
+
}
|
|
1451
|
+
if (this.multiDr.targetList.length) {
|
|
1452
|
+
return this.multiDr.getOption(key);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1451
1455
|
/**
|
|
1452
1456
|
* 获取鼠标下方第一个可选中元素,如果元素层叠,返回到是最上层元素
|
|
1453
1457
|
* @param event 鼠标事件
|
|
@@ -1586,12 +1590,16 @@
|
|
|
1586
1590
|
this.multiDr.destroy();
|
|
1587
1591
|
this.highlightLayer.destroy();
|
|
1588
1592
|
}
|
|
1589
|
-
changeCallback(options) {
|
|
1593
|
+
changeCallback(options, isMulti) {
|
|
1590
1594
|
if (typeof options === "function") {
|
|
1591
1595
|
return () => {
|
|
1592
1596
|
if (typeof options === "function") {
|
|
1593
1597
|
const cfg = {
|
|
1594
|
-
|
|
1598
|
+
targetEl: this.selectedEl,
|
|
1599
|
+
targetElId: this.selectedEl?.id,
|
|
1600
|
+
targetEls: this.selectedElList,
|
|
1601
|
+
targetElIds: this.selectedElList?.map((item) => item.id),
|
|
1602
|
+
isMulti
|
|
1595
1603
|
};
|
|
1596
1604
|
return options(cfg);
|
|
1597
1605
|
}
|
|
@@ -2367,6 +2375,9 @@
|
|
|
2367
2375
|
highlight(idOrEl) {
|
|
2368
2376
|
this.actionManager.highlight(idOrEl);
|
|
2369
2377
|
}
|
|
2378
|
+
clearHighlight() {
|
|
2379
|
+
this.actionManager.clearHighlight();
|
|
2380
|
+
}
|
|
2370
2381
|
/**
|
|
2371
2382
|
* 更新组件
|
|
2372
2383
|
* @param data 更新组件的数据
|
|
@@ -2434,6 +2445,9 @@
|
|
|
2434
2445
|
delayedMarkContainer(event, excludeElList = []) {
|
|
2435
2446
|
return this.actionManager.delayedMarkContainer(event, excludeElList);
|
|
2436
2447
|
}
|
|
2448
|
+
getMoveableOption(key) {
|
|
2449
|
+
return this.actionManager.getMoveableOption(key);
|
|
2450
|
+
}
|
|
2437
2451
|
/**
|
|
2438
2452
|
* 销毁实例
|
|
2439
2453
|
*/
|
|
@@ -2464,7 +2478,6 @@
|
|
|
2464
2478
|
containerHighlightDuration: config.containerHighlightDuration,
|
|
2465
2479
|
containerHighlightType: config.containerHighlightType,
|
|
2466
2480
|
moveableOptions: config.moveableOptions,
|
|
2467
|
-
multiMoveableOptions: config.multiMoveableOptions,
|
|
2468
2481
|
container: this.mask.content,
|
|
2469
2482
|
disabledDragStart: config.disabledDragStart,
|
|
2470
2483
|
canSelect: config.canSelect,
|