@tmagic/stage 1.2.6 → 1.2.7
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 +99 -50
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +99 -49
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/ActionManager.ts +9 -0
- package/src/MoveableActionsAble.ts +109 -0
- package/src/MoveableOptionsManager.ts +6 -6
- package/src/StageCore.ts +4 -0
- package/src/StageDragResize.ts +4 -0
- package/src/types.ts +11 -0
- package/types/{MoveableSelectParentAble.d.ts → MoveableActionsAble.d.ts} +5 -2
- package/types/MoveableOptionsManager.d.ts +1 -1
- package/types/StageDragResize.d.ts +1 -0
- package/types/types.d.ts +9 -0
- package/src/MoveableSelectParentAble.ts +0 -76
|
@@ -519,9 +519,33 @@
|
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
521
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
522
|
+
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
523
|
+
ContainerHighlightType2["DEFAULT"] = "default";
|
|
524
|
+
ContainerHighlightType2["ALT"] = "alt";
|
|
525
|
+
return ContainerHighlightType2;
|
|
526
|
+
})(ContainerHighlightType || {});
|
|
527
|
+
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
528
|
+
SelectStatus2["SELECT"] = "select";
|
|
529
|
+
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
530
|
+
return SelectStatus2;
|
|
531
|
+
})(SelectStatus || {});
|
|
532
|
+
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
533
|
+
StageDragStatus2["START"] = "start";
|
|
534
|
+
StageDragStatus2["ING"] = "ing";
|
|
535
|
+
StageDragStatus2["END"] = "end";
|
|
536
|
+
return StageDragStatus2;
|
|
537
|
+
})(StageDragStatus || {});
|
|
538
|
+
var AbleActionEventType = /* @__PURE__ */ ((AbleActionEventType2) => {
|
|
539
|
+
AbleActionEventType2["SELECT_PARENT"] = "select-parent";
|
|
540
|
+
AbleActionEventType2["REMOVE"] = "remove";
|
|
541
|
+
return AbleActionEventType2;
|
|
542
|
+
})(AbleActionEventType || {});
|
|
543
|
+
|
|
544
|
+
const MoveableActionsAble = (handler) => ({
|
|
545
|
+
name: "actions",
|
|
546
|
+
props: {
|
|
547
|
+
selectParent: Boolean
|
|
548
|
+
},
|
|
525
549
|
events: {},
|
|
526
550
|
render(moveable, React) {
|
|
527
551
|
const rect = moveable.getRect();
|
|
@@ -547,6 +571,23 @@
|
|
|
547
571
|
color: white;
|
|
548
572
|
font-size: 12px;
|
|
549
573
|
font-weight: bold;
|
|
574
|
+
margin-left: 2px;
|
|
575
|
+
position: relative;
|
|
576
|
+
}
|
|
577
|
+
.moveable-remove-button:before, .moveable-remove-button:after {
|
|
578
|
+
content: "";
|
|
579
|
+
position: absolute;
|
|
580
|
+
left: 50%;
|
|
581
|
+
top: 50%;
|
|
582
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
583
|
+
width: 14px;
|
|
584
|
+
height: 2px;
|
|
585
|
+
background: #fff;
|
|
586
|
+
border-radius: 1px;
|
|
587
|
+
cursor: pointer;
|
|
588
|
+
}
|
|
589
|
+
.moveable-remove-button:after {
|
|
590
|
+
transform: translate(-50%, -50%) rotate(-45deg);
|
|
550
591
|
}
|
|
551
592
|
`
|
|
552
593
|
);
|
|
@@ -555,37 +596,49 @@
|
|
|
555
596
|
{
|
|
556
597
|
className: "moveable-editable",
|
|
557
598
|
style: {
|
|
558
|
-
transform: `translate(${pos2[0] -
|
|
599
|
+
transform: `translate(${pos2[0] - 48}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg) translate(10px)`
|
|
559
600
|
}
|
|
560
601
|
},
|
|
561
|
-
|
|
562
|
-
"button",
|
|
563
|
-
{
|
|
564
|
-
className: "moveable-button",
|
|
565
|
-
title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
|
|
566
|
-
onClick: () => {
|
|
567
|
-
selectParentHandler();
|
|
568
|
-
}
|
|
569
|
-
},
|
|
602
|
+
[
|
|
570
603
|
React.createElement(
|
|
571
|
-
"
|
|
604
|
+
"button",
|
|
572
605
|
{
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
578
|
-
style: {
|
|
579
|
-
transform: "rotate(90deg)"
|
|
606
|
+
className: "moveable-button",
|
|
607
|
+
title: "\u9009\u4E2D\u7236\u7EC4\u4EF6",
|
|
608
|
+
onClick: () => {
|
|
609
|
+
handler(AbleActionEventType.SELECT_PARENT);
|
|
580
610
|
}
|
|
581
611
|
},
|
|
582
|
-
React.createElement(
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
612
|
+
React.createElement(
|
|
613
|
+
"svg",
|
|
614
|
+
{
|
|
615
|
+
width: "20px",
|
|
616
|
+
height: "20px",
|
|
617
|
+
viewBox: "0 0 16 16",
|
|
618
|
+
fill: "none",
|
|
619
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
620
|
+
style: {
|
|
621
|
+
transform: "rotate(90deg)",
|
|
622
|
+
position: "absolute",
|
|
623
|
+
left: 0,
|
|
624
|
+
top: 0
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
React.createElement("path", {
|
|
628
|
+
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",
|
|
629
|
+
fill: "currentColor",
|
|
630
|
+
fillOpacity: "0.9"
|
|
631
|
+
})
|
|
632
|
+
)
|
|
633
|
+
),
|
|
634
|
+
React.createElement("button", {
|
|
635
|
+
className: "moveable-button moveable-remove-button",
|
|
636
|
+
title: "\u5220\u9664",
|
|
637
|
+
onClick: () => {
|
|
638
|
+
handler(AbleActionEventType.REMOVE);
|
|
639
|
+
}
|
|
640
|
+
})
|
|
641
|
+
]
|
|
589
642
|
);
|
|
590
643
|
}
|
|
591
644
|
});
|
|
@@ -681,9 +734,9 @@
|
|
|
681
734
|
},
|
|
682
735
|
isDisplayInnerSnapDigit: true,
|
|
683
736
|
props: {
|
|
684
|
-
|
|
737
|
+
actions: true
|
|
685
738
|
},
|
|
686
|
-
ables: [
|
|
739
|
+
ables: [MoveableActionsAble(this.actionHandler.bind(this))]
|
|
687
740
|
};
|
|
688
741
|
}
|
|
689
742
|
getMultiOptions() {
|
|
@@ -702,8 +755,8 @@
|
|
|
702
755
|
}
|
|
703
756
|
return this.customizedOptions;
|
|
704
757
|
}
|
|
705
|
-
|
|
706
|
-
this.emit(
|
|
758
|
+
actionHandler(type) {
|
|
759
|
+
this.emit(type);
|
|
707
760
|
}
|
|
708
761
|
createGuidelineElements(selectedElList, allElList) {
|
|
709
762
|
const frame = globalThis.document.createDocumentFragment();
|
|
@@ -728,23 +781,6 @@
|
|
|
728
781
|
}
|
|
729
782
|
}
|
|
730
783
|
|
|
731
|
-
var ContainerHighlightType = /* @__PURE__ */ ((ContainerHighlightType2) => {
|
|
732
|
-
ContainerHighlightType2["DEFAULT"] = "default";
|
|
733
|
-
ContainerHighlightType2["ALT"] = "alt";
|
|
734
|
-
return ContainerHighlightType2;
|
|
735
|
-
})(ContainerHighlightType || {});
|
|
736
|
-
var SelectStatus = /* @__PURE__ */ ((SelectStatus2) => {
|
|
737
|
-
SelectStatus2["SELECT"] = "select";
|
|
738
|
-
SelectStatus2["MULTI_SELECT"] = "multiSelect";
|
|
739
|
-
return SelectStatus2;
|
|
740
|
-
})(SelectStatus || {});
|
|
741
|
-
var StageDragStatus = /* @__PURE__ */ ((StageDragStatus2) => {
|
|
742
|
-
StageDragStatus2["START"] = "start";
|
|
743
|
-
StageDragStatus2["ING"] = "ing";
|
|
744
|
-
StageDragStatus2["END"] = "end";
|
|
745
|
-
return StageDragStatus2;
|
|
746
|
-
})(StageDragStatus || {});
|
|
747
|
-
|
|
748
784
|
class StageDragResize extends MoveableOptionsManager {
|
|
749
785
|
target;
|
|
750
786
|
moveable;
|
|
@@ -770,6 +806,9 @@
|
|
|
770
806
|
}
|
|
771
807
|
});
|
|
772
808
|
}
|
|
809
|
+
getTarget() {
|
|
810
|
+
return this.target;
|
|
811
|
+
}
|
|
773
812
|
select(el, event) {
|
|
774
813
|
if (!this.moveable || el !== this.target) {
|
|
775
814
|
this.initMoveable(el);
|
|
@@ -1442,6 +1481,14 @@
|
|
|
1442
1481
|
setTimeout(() => this.emit("sort", data));
|
|
1443
1482
|
}).on("select-parent", () => {
|
|
1444
1483
|
this.emit("select-parent");
|
|
1484
|
+
}).on("remove", () => {
|
|
1485
|
+
const drTarget = this.dr.getTarget();
|
|
1486
|
+
if (!drTarget)
|
|
1487
|
+
return;
|
|
1488
|
+
const data = {
|
|
1489
|
+
data: [{ el: drTarget }]
|
|
1490
|
+
};
|
|
1491
|
+
this.emit("remove", data);
|
|
1445
1492
|
});
|
|
1446
1493
|
this.multiDr.on("update", (data, parentEl) => {
|
|
1447
1494
|
this.emit("multi-update", data, parentEl);
|
|
@@ -2145,6 +2192,8 @@
|
|
|
2145
2192
|
this.emit("sort", data);
|
|
2146
2193
|
}).on("select-parent", () => {
|
|
2147
2194
|
this.emit("select-parent");
|
|
2195
|
+
}).on("remove", (data) => {
|
|
2196
|
+
this.emit("remove", data);
|
|
2148
2197
|
});
|
|
2149
2198
|
}
|
|
2150
2199
|
initMulDrEvent() {
|
|
@@ -2162,6 +2211,7 @@
|
|
|
2162
2211
|
}
|
|
2163
2212
|
}
|
|
2164
2213
|
|
|
2214
|
+
exports.AbleActionEventType = AbleActionEventType;
|
|
2165
2215
|
exports.CONTAINER_HIGHLIGHT_CLASS_NAME = CONTAINER_HIGHLIGHT_CLASS_NAME;
|
|
2166
2216
|
exports.ContainerHighlightType = ContainerHighlightType;
|
|
2167
2217
|
exports.DEFAULT_ZOOM = DEFAULT_ZOOM;
|