orcasvn-react-diagrams 0.1.26 → 0.1.29
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/cjs/index.js +562 -1610
- package/dist/cjs/types/components/editor.d.ts +2 -2
- package/dist/cjs/types/components/paper.d.ts +8 -0
- package/dist/cjs/types/models/IEditorContext.d.ts +7 -0
- package/dist/cjs/types/models/IElement.d.ts +0 -3
- package/dist/cjs/types/models/IElementProps.d.ts +4 -4
- package/dist/cjs/types/models/IPort.d.ts +0 -2
- package/dist/cjs/types/models/IPortProps.d.ts +0 -1
- package/dist/cjs/types/models/IText.d.ts +1 -0
- package/dist/cjs/types/models/ITextProps.d.ts +1 -0
- package/dist/cjs/types/models/implementations/EditorContext.d.ts +7 -0
- package/dist/cjs/types/models/implementations/Element.d.ts +0 -3
- package/dist/cjs/types/models/implementations/Port.d.ts +0 -2
- package/dist/cjs/types/models/implementations/Text.d.ts +2 -1
- package/dist/cjs/types/utils/positionUtil.d.ts +21 -0
- package/dist/esm/index.js +432 -1480
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/editor.d.ts +2 -2
- package/dist/esm/types/components/paper.d.ts +8 -0
- package/dist/esm/types/models/IEditorContext.d.ts +7 -0
- package/dist/esm/types/models/IElement.d.ts +0 -3
- package/dist/esm/types/models/IElementProps.d.ts +4 -4
- package/dist/esm/types/models/IPort.d.ts +0 -2
- package/dist/esm/types/models/IPortProps.d.ts +0 -1
- package/dist/esm/types/models/IText.d.ts +1 -0
- package/dist/esm/types/models/ITextProps.d.ts +1 -0
- package/dist/esm/types/models/implementations/EditorContext.d.ts +7 -0
- package/dist/esm/types/models/implementations/Element.d.ts +0 -3
- package/dist/esm/types/models/implementations/Port.d.ts +0 -2
- package/dist/esm/types/models/implementations/Text.d.ts +2 -1
- package/dist/esm/types/utils/positionUtil.d.ts +21 -0
- package/dist/index.d.ts +23 -17
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var require$$0 = require('react-dom');
|
|
7
7
|
|
|
8
8
|
exports.PositioningAnchor = void 0;
|
|
@@ -36,8 +36,6 @@ exports.TextAlign = void 0;
|
|
|
36
36
|
TextAlign[TextAlign["center"] = 2] = "center";
|
|
37
37
|
})(exports.TextAlign || (exports.TextAlign = {}));
|
|
38
38
|
|
|
39
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
40
|
-
|
|
41
39
|
function getDefaultExportFromCjs (x) {
|
|
42
40
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
43
41
|
}
|
|
@@ -442,7 +440,6 @@ function generateUniqueId() {
|
|
|
442
440
|
return v4();
|
|
443
441
|
}
|
|
444
442
|
|
|
445
|
-
var MANUALLY_TRIGGER_RENDER$1 = 'manuallyTriggerRender';
|
|
446
443
|
var Element$2 = /** @class */ (function () {
|
|
447
444
|
function Element(x, y, width, height, cssClass, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection, parentElement, textsPlaceHolderClassName, textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition) {
|
|
448
445
|
if (portMovealeAreas === void 0) { portMovealeAreas = []; }
|
|
@@ -467,27 +464,26 @@ var Element$2 = /** @class */ (function () {
|
|
|
467
464
|
this.textsPlaceHolderFlexStyle = textsPlaceHolderFlexStyle;
|
|
468
465
|
this.textsPlaceHolderFlexboxPosition = textsPlaceHolderFlexboxPosition;
|
|
469
466
|
}
|
|
470
|
-
Element.prototype.manuallyTriggerRender = function () {
|
|
471
|
-
//TODO: Implement this
|
|
472
|
-
this._eventEmitter.emit(MANUALLY_TRIGGER_RENDER$1);
|
|
473
|
-
};
|
|
474
|
-
Element.prototype.manuallyTriggerRenderHandler = function (callback) {
|
|
475
|
-
var _this = this;
|
|
476
|
-
//TODO: Implement this
|
|
477
|
-
this._eventEmitter.on(MANUALLY_TRIGGER_RENDER$1, callback);
|
|
478
|
-
var canceller = function () {
|
|
479
|
-
_this._eventEmitter.off(MANUALLY_TRIGGER_RENDER$1, callback);
|
|
480
|
-
};
|
|
481
|
-
return canceller;
|
|
482
|
-
};
|
|
483
|
-
Element.prototype.manuallyTriggerRenderPort = function (portId) {
|
|
484
|
-
//TODO: Implement this
|
|
485
|
-
var port = this.getPort(portId);
|
|
486
|
-
if (port) {
|
|
487
|
-
port.manuallyTriggerRender();
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
467
|
Object.defineProperty(Element.prototype, "id", {
|
|
468
|
+
// public manuallyTriggerRender() {
|
|
469
|
+
// //TODO: Implement this
|
|
470
|
+
// this._eventEmitter.emit(MANUALLY_TRIGGER_RENDER);
|
|
471
|
+
// }
|
|
472
|
+
// public manuallyTriggerRenderHandler(callback: () => void) {
|
|
473
|
+
// //TODO: Implement this
|
|
474
|
+
// this._eventEmitter.on(MANUALLY_TRIGGER_RENDER, callback);
|
|
475
|
+
// const canceller = () => {
|
|
476
|
+
// this._eventEmitter.off(MANUALLY_TRIGGER_RENDER, callback);
|
|
477
|
+
// }
|
|
478
|
+
// return canceller;
|
|
479
|
+
// }
|
|
480
|
+
// public manuallyTriggerRenderPort(portId: string) {
|
|
481
|
+
// //TODO: Implement this
|
|
482
|
+
// const port = this.getPort(portId);
|
|
483
|
+
// if (port) {
|
|
484
|
+
// port.manuallyTriggerRender();
|
|
485
|
+
// }
|
|
486
|
+
// }
|
|
491
487
|
get: function () {
|
|
492
488
|
return this._id;
|
|
493
489
|
},
|
|
@@ -624,7 +620,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
624
620
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
625
621
|
};
|
|
626
622
|
|
|
627
|
-
var ShapeWrapper = React
|
|
623
|
+
var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
|
|
628
624
|
//if direction is provided, rotation is based on direction
|
|
629
625
|
var rotation = shapeProps.rotation || 0;
|
|
630
626
|
if (shapeProps.direction) {
|
|
@@ -654,7 +650,7 @@ var ShapeWrapper = React$1.forwardRef(function (shapeProps, ref) {
|
|
|
654
650
|
position.x = position.x - shapeProps.width / 2;
|
|
655
651
|
position.y = position.y - shapeProps.height / 2;
|
|
656
652
|
}
|
|
657
|
-
var objectOfAllEventAttributes = React
|
|
653
|
+
var objectOfAllEventAttributes = React.useMemo(function () {
|
|
658
654
|
var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
|
|
659
655
|
var k = _a[0]; _a[1];
|
|
660
656
|
return k.startsWith('on');
|
|
@@ -664,15 +660,14 @@ var ShapeWrapper = React$1.forwardRef(function (shapeProps, ref) {
|
|
|
664
660
|
var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
|
|
665
661
|
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
666
662
|
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
667
|
-
return (React
|
|
668
|
-
React
|
|
663
|
+
return (React.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
664
|
+
React.createElement("svg", __assign({ ref: ref, style: { overflow: "visible" }, x: position.x, y: position.y, width: shapeProps.width, height: shapeProps.height, className: shapeProps.cssClass, viewBox: viewBox }, objectOfAllEventAttributes), shapeProps.children)));
|
|
669
665
|
});
|
|
670
666
|
|
|
671
|
-
var CustomShape = React
|
|
672
|
-
return (React
|
|
667
|
+
var CustomShape = React.forwardRef(function (props, ref) {
|
|
668
|
+
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
673
669
|
});
|
|
674
670
|
|
|
675
|
-
var MANUALLY_TRIGGER_RENDER = 'manuallyTriggerRender';
|
|
676
671
|
var Port$1 = /** @class */ (function () {
|
|
677
672
|
function Port(x, y, label, shapeRenderer, width, height) {
|
|
678
673
|
var _this = this;
|
|
@@ -691,8 +686,8 @@ var Port$1 = /** @class */ (function () {
|
|
|
691
686
|
this.renderShape = shapeRenderer.shape;
|
|
692
687
|
}
|
|
693
688
|
else if (shapeRenderer && shapeRenderer.customShapeWithJSX) {
|
|
694
|
-
this.renderShape = React
|
|
695
|
-
return (React
|
|
689
|
+
this.renderShape = React.forwardRef(function (props, ref) {
|
|
690
|
+
return (React.createElement(CustomShape, { ref: ref, x: props.x, y: props.y, width: props.width, height: props.height, rotation: props.rotation, positioningAnchor: shapeRenderer.positioningAnchor, onClick: function (e) { var _a; return (_a = props.onSelected) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); }, onMouseDown: function (e) { var _a; return (_a = props.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); }, onMouseUp: function (e) { var _a; return (_a = props.onMouseUp) === null || _a === void 0 ? void 0 : _a.call(props, _this.id, e); } }, shapeRenderer.customShapeWithJSX));
|
|
696
691
|
});
|
|
697
692
|
}
|
|
698
693
|
}
|
|
@@ -703,18 +698,6 @@ var Port$1 = /** @class */ (function () {
|
|
|
703
698
|
enumerable: false,
|
|
704
699
|
configurable: true
|
|
705
700
|
});
|
|
706
|
-
Port.prototype.manuallyTriggerRender = function () {
|
|
707
|
-
//TODO: Implement this
|
|
708
|
-
this._eventEmitter.emit(MANUALLY_TRIGGER_RENDER);
|
|
709
|
-
};
|
|
710
|
-
Port.prototype.manuallyTriggerRenderHandler = function (callback) {
|
|
711
|
-
var _this = this;
|
|
712
|
-
this._eventEmitter.on(MANUALLY_TRIGGER_RENDER, callback);
|
|
713
|
-
var canceller = function () {
|
|
714
|
-
_this._eventEmitter.off(MANUALLY_TRIGGER_RENDER, callback);
|
|
715
|
-
};
|
|
716
|
-
return canceller;
|
|
717
|
-
};
|
|
718
701
|
return Port;
|
|
719
702
|
}());
|
|
720
703
|
|
|
@@ -757,7 +740,7 @@ var ElementLink$1 = /** @class */ (function () {
|
|
|
757
740
|
}());
|
|
758
741
|
|
|
759
742
|
var Text$2 = /** @class */ (function () {
|
|
760
|
-
function Text(content, width, height, x, y, align, fontSize, border, style) {
|
|
743
|
+
function Text(content, width, height, editable, x, y, align, fontSize, border, style) {
|
|
761
744
|
this._id = generateUniqueId();
|
|
762
745
|
this.content = content;
|
|
763
746
|
this.align = align;
|
|
@@ -765,6 +748,7 @@ var Text$2 = /** @class */ (function () {
|
|
|
765
748
|
this.border = border;
|
|
766
749
|
this.size = { width: width, height: height };
|
|
767
750
|
this.style = style;
|
|
751
|
+
this.editable = editable;
|
|
768
752
|
if (x && y) {
|
|
769
753
|
this.position = { x: x, y: y };
|
|
770
754
|
}
|
|
@@ -779,20 +763,37 @@ var Text$2 = /** @class */ (function () {
|
|
|
779
763
|
return Text;
|
|
780
764
|
}());
|
|
781
765
|
|
|
766
|
+
var EVENT_MANUALLY_RENDER_ELEMENT = 'manuallyRenderElement';
|
|
767
|
+
var EVENT_MANUALLY_RENDER_PORT = 'manuallyRenderPort';
|
|
768
|
+
var EVENT_EDITOR_CONTEXT_UPDATED = 'editorContextUpdated';
|
|
782
769
|
var EVENT_PAPER_CLICKED = 'paperClicked';
|
|
783
770
|
var EVENT_PAPER_MOUSE_MOVED = 'paperMouseMoved';
|
|
784
771
|
var EVENT_PAPER_MOUSE_DOWN = 'paperMouseDown';
|
|
785
772
|
var EVENT_PAPER_MOUSE_UP = 'paperMouseUp';
|
|
773
|
+
var EVENT_PORT_MOUSE_DOWN = 'portMouseDown';
|
|
774
|
+
var EVENT_PORT_MOUSE_UP = 'portMouseUp';
|
|
786
775
|
var EVENT_PORT_MOVED = 'portMoved';
|
|
787
776
|
var EVENT_PORT_SELECTED = 'portSelected';
|
|
788
777
|
var EVENT_ELEMENT_CONTEXT_MENU = 'elementContextMenu';
|
|
789
778
|
var EVENT_ELEMENT_MOVED = 'elementMoved';
|
|
790
779
|
var EVENT_ELEMENT_RESIZED = 'elementResized';
|
|
791
780
|
var EVENT_ELEMENT_SELECTED = 'elementSelected';
|
|
781
|
+
var EVENT_ELEMENT_MOUSE_MOVE = 'elementMouseMove';
|
|
782
|
+
var EVENT_ELEMENT_MOUSE_LEAVE = 'elementMouseLeave';
|
|
783
|
+
var EVENT_ELEMENT_MOUSE_UP = 'elementMouseUp';
|
|
792
784
|
var EVENT_LINK_SELECTED = 'linkSelected';
|
|
793
785
|
var EVENT_TEXT_SELECTED = 'textSelected';
|
|
794
786
|
var EditorContext = /** @class */ (function () {
|
|
795
787
|
function EditorContext(elements, links, texts) {
|
|
788
|
+
var _this = this;
|
|
789
|
+
/** @internal */
|
|
790
|
+
this.onEditorContextUpdated = function (callback) {
|
|
791
|
+
_this._eventEmitter.on(EVENT_EDITOR_CONTEXT_UPDATED, callback);
|
|
792
|
+
var off = function () {
|
|
793
|
+
_this._eventEmitter.off(EVENT_EDITOR_CONTEXT_UPDATED, callback);
|
|
794
|
+
};
|
|
795
|
+
return off;
|
|
796
|
+
};
|
|
796
797
|
this._elements = elements;
|
|
797
798
|
this._links = links;
|
|
798
799
|
this._texts = texts;
|
|
@@ -832,27 +833,33 @@ var EditorContext = /** @class */ (function () {
|
|
|
832
833
|
};
|
|
833
834
|
EditorContext.prototype.addElement = function (element) {
|
|
834
835
|
this._elements = __spreadArray(__spreadArray([], this._elements, true), [element], false);
|
|
836
|
+
this._eventEmitter.emit(EVENT_EDITOR_CONTEXT_UPDATED);
|
|
835
837
|
};
|
|
836
838
|
EditorContext.prototype.removeElement = function (elementId) {
|
|
837
839
|
this._elements = this._elements.filter(function (e) { return e.id !== elementId; });
|
|
840
|
+
this._eventEmitter.emit(EVENT_EDITOR_CONTEXT_UPDATED);
|
|
838
841
|
};
|
|
839
842
|
EditorContext.prototype.getLink = function (linkId) {
|
|
840
843
|
return this._links.find(function (l) { return l.id === linkId; });
|
|
841
844
|
};
|
|
842
845
|
EditorContext.prototype.addLink = function (link) {
|
|
843
846
|
this._links = __spreadArray(__spreadArray([], this._links, true), [link], false);
|
|
847
|
+
this._eventEmitter.emit(EVENT_EDITOR_CONTEXT_UPDATED);
|
|
844
848
|
};
|
|
845
849
|
EditorContext.prototype.removeLink = function (linkId) {
|
|
846
850
|
this._links = this._links.filter(function (l) { return l.id !== linkId; });
|
|
851
|
+
this._eventEmitter.emit(EVENT_EDITOR_CONTEXT_UPDATED);
|
|
847
852
|
};
|
|
848
853
|
EditorContext.prototype.getText = function (textId) {
|
|
849
854
|
return this._texts.find(function (t) { return t.id === textId; });
|
|
850
855
|
};
|
|
851
856
|
EditorContext.prototype.addText = function (text) {
|
|
852
857
|
this._texts = __spreadArray(__spreadArray([], this._texts, true), [text], false);
|
|
858
|
+
this._eventEmitter.emit(EVENT_EDITOR_CONTEXT_UPDATED);
|
|
853
859
|
};
|
|
854
860
|
EditorContext.prototype.removeText = function (textId) {
|
|
855
861
|
this._texts = this._texts.filter(function (t) { return t.id !== textId; });
|
|
862
|
+
this._eventEmitter.emit(EVENT_EDITOR_CONTEXT_UPDATED);
|
|
856
863
|
};
|
|
857
864
|
EditorContext.prototype.onPaperClicked = function (callback) {
|
|
858
865
|
return this.addEventListener(EVENT_PAPER_CLICKED, callback);
|
|
@@ -882,6 +889,20 @@ var EditorContext = /** @class */ (function () {
|
|
|
882
889
|
EditorContext.prototype.onPaperMouseUpHandler = function (position) {
|
|
883
890
|
this._eventEmitter.emit(EVENT_PAPER_MOUSE_UP, position);
|
|
884
891
|
};
|
|
892
|
+
EditorContext.prototype.onPortMouseDown = function (callback) {
|
|
893
|
+
return this.addEventListener(EVENT_PORT_MOUSE_DOWN, callback);
|
|
894
|
+
};
|
|
895
|
+
/** @internal */
|
|
896
|
+
EditorContext.prototype.onPortMouseDownHandler = function (port, element) {
|
|
897
|
+
this._eventEmitter.emit(EVENT_PORT_MOUSE_DOWN, port, element);
|
|
898
|
+
};
|
|
899
|
+
EditorContext.prototype.onPortMouseUp = function (callback) {
|
|
900
|
+
return this.addEventListener(EVENT_PORT_MOUSE_UP, callback);
|
|
901
|
+
};
|
|
902
|
+
/** @internal */
|
|
903
|
+
EditorContext.prototype.onPortMouseUpHandler = function (port, element) {
|
|
904
|
+
this._eventEmitter.emit(EVENT_PORT_MOUSE_UP, port, element);
|
|
905
|
+
};
|
|
885
906
|
EditorContext.prototype.onPortMoved = function (callback) {
|
|
886
907
|
return this.addEventListener(EVENT_PORT_MOVED, callback);
|
|
887
908
|
};
|
|
@@ -924,6 +945,27 @@ var EditorContext = /** @class */ (function () {
|
|
|
924
945
|
EditorContext.prototype.onElementSelectedHandler = function (element) {
|
|
925
946
|
this._eventEmitter.emit(EVENT_ELEMENT_SELECTED, element);
|
|
926
947
|
};
|
|
948
|
+
EditorContext.prototype.onElementMouseMove = function (callback) {
|
|
949
|
+
return this.addEventListener(EVENT_ELEMENT_MOUSE_MOVE, callback);
|
|
950
|
+
};
|
|
951
|
+
/** @internal */
|
|
952
|
+
EditorContext.prototype.onElementMouseMoveHandler = function (ev, element) {
|
|
953
|
+
this._eventEmitter.emit(EVENT_ELEMENT_MOUSE_MOVE, ev, element);
|
|
954
|
+
};
|
|
955
|
+
EditorContext.prototype.onElementMouseLeave = function (callback) {
|
|
956
|
+
return this.addEventListener(EVENT_ELEMENT_MOUSE_LEAVE, callback);
|
|
957
|
+
};
|
|
958
|
+
/** @internal */
|
|
959
|
+
EditorContext.prototype.onElementMouseLeaveHandler = function (ev, element) {
|
|
960
|
+
this._eventEmitter.emit(EVENT_ELEMENT_MOUSE_LEAVE, ev, element);
|
|
961
|
+
};
|
|
962
|
+
EditorContext.prototype.onElementMouseUp = function (callback) {
|
|
963
|
+
return this.addEventListener(EVENT_ELEMENT_MOUSE_UP, callback);
|
|
964
|
+
};
|
|
965
|
+
/** @internal */
|
|
966
|
+
EditorContext.prototype.onElementMouseUpHandler = function (ev, element) {
|
|
967
|
+
this._eventEmitter.emit(EVENT_ELEMENT_MOUSE_UP, ev, element);
|
|
968
|
+
};
|
|
927
969
|
EditorContext.prototype.onLinkSelected = function (callback) {
|
|
928
970
|
return this.addEventListener(EVENT_LINK_SELECTED, callback);
|
|
929
971
|
};
|
|
@@ -939,27 +981,21 @@ var EditorContext = /** @class */ (function () {
|
|
|
939
981
|
this._eventEmitter.emit(EVENT_TEXT_SELECTED, text);
|
|
940
982
|
};
|
|
941
983
|
EditorContext.prototype.triggerRenderElement = function (elementId) {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
984
|
+
this._eventEmitter.emit(EVENT_MANUALLY_RENDER_ELEMENT, elementId);
|
|
985
|
+
};
|
|
986
|
+
EditorContext.prototype.onManuallyTriggerRenderElement = function (callback) {
|
|
987
|
+
return this.addEventListener(EVENT_MANUALLY_RENDER_ELEMENT, callback);
|
|
947
988
|
};
|
|
948
989
|
EditorContext.prototype.triggerRenderPort = function (portId, elementId) {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
var port = (_a = element.ports) === null || _a === void 0 ? void 0 : _a.find(function (p) { return p.id === portId; });
|
|
954
|
-
if (port) {
|
|
955
|
-
port.manuallyTriggerRender();
|
|
956
|
-
}
|
|
957
|
-
}
|
|
990
|
+
this._eventEmitter.emit(EVENT_MANUALLY_RENDER_PORT, portId, elementId);
|
|
991
|
+
};
|
|
992
|
+
EditorContext.prototype.onManuallyTriggerRenderPort = function (callback) {
|
|
993
|
+
return this.addEventListener(EVENT_MANUALLY_RENDER_PORT, callback);
|
|
958
994
|
};
|
|
959
995
|
return EditorContext;
|
|
960
996
|
}());
|
|
961
997
|
|
|
962
|
-
var Circle = React
|
|
998
|
+
var Circle = React.forwardRef(function (props, ref) {
|
|
963
999
|
var s = { height: 100, width: 100 };
|
|
964
1000
|
if (props.r) {
|
|
965
1001
|
s.height = props.r * 2;
|
|
@@ -972,11 +1008,11 @@ var Circle = React$1.forwardRef(function (props, ref) {
|
|
|
972
1008
|
s.height = props.height;
|
|
973
1009
|
s.width = props.width;
|
|
974
1010
|
}
|
|
975
|
-
return (React
|
|
976
|
-
React
|
|
1011
|
+
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height, ref: ref }),
|
|
1012
|
+
React.createElement("circle", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", cx: 50, cy: 50, r: 50, fill: props.fill || 'transparent', stroke: props.stroke || "none", strokeWidth: props.strokeWidth })));
|
|
977
1013
|
});
|
|
978
1014
|
|
|
979
|
-
var Crescent = React
|
|
1015
|
+
var Crescent = React.forwardRef(function (props, ref) {
|
|
980
1016
|
var s = { height: 100, width: 100 };
|
|
981
1017
|
if (props.r) {
|
|
982
1018
|
s.height = props.r * 2;
|
|
@@ -990,12 +1026,12 @@ var Crescent = React$1.forwardRef(function (props, ref) {
|
|
|
990
1026
|
s.width = props.width;
|
|
991
1027
|
}
|
|
992
1028
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
993
|
-
return (React
|
|
994
|
-
React
|
|
995
|
-
React
|
|
1029
|
+
return (React.createElement(ShapeWrapper, __assign({ ref: ref, viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
1030
|
+
React.createElement("rect", { width: 100, height: 100, stroke: "transparent", fill: 'transparent' }),
|
|
1031
|
+
React.createElement("path", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", d: "M 0 75 A 50 50 0 1 1 100 75 Z", fill: props.fill || 'none', stroke: props.stroke || 'none', strokeWidth: sw })));
|
|
996
1032
|
});
|
|
997
1033
|
|
|
998
|
-
var Rectangle = React
|
|
1034
|
+
var Rectangle = React.forwardRef(function (props, ref) {
|
|
999
1035
|
var scaledWidth = props.width;
|
|
1000
1036
|
var scaledHeight = props.height;
|
|
1001
1037
|
if (props.width > 100 || props.height > 100) {
|
|
@@ -1011,11 +1047,11 @@ var Rectangle = React$1.forwardRef(function (props, ref) {
|
|
|
1011
1047
|
}
|
|
1012
1048
|
}
|
|
1013
1049
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
1014
|
-
return (React
|
|
1015
|
-
React
|
|
1050
|
+
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
1051
|
+
React.createElement("rect", { className: "rect-border ".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", width: scaledWidth, height: scaledHeight, fill: props.fill || "transparent", stroke: props.stroke || "none", strokeWidth: sw })));
|
|
1016
1052
|
});
|
|
1017
1053
|
|
|
1018
|
-
var RectangularFrame = React
|
|
1054
|
+
var RectangularFrame = React.forwardRef(function (props, ref) {
|
|
1019
1055
|
var scaledWidth = props.width;
|
|
1020
1056
|
var scaledHeight = props.height;
|
|
1021
1057
|
if (props.width > 100 || props.height > 100) {
|
|
@@ -1035,10 +1071,10 @@ var RectangularFrame = React$1.forwardRef(function (props, ref) {
|
|
|
1035
1071
|
var fw = props.frameColor ? (props.frameWidth || 1) : 0;
|
|
1036
1072
|
var scaledFw = scaledWidth / props.width * fw;
|
|
1037
1073
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
1038
|
-
return (React
|
|
1039
|
-
React
|
|
1040
|
-
React
|
|
1041
|
-
React
|
|
1074
|
+
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref, height: props.height, width: props.width }),
|
|
1075
|
+
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className: "rectangular-frame-outer-border ".concat(props.portMoveableAreaCssClass), x: vbX, y: vbY, width: scaledWidth, height: scaledHeight, fill: "none", stroke: props.stroke || "none", strokeWidth: sw }),
|
|
1076
|
+
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className: 'rectangular-frame-hallway', x: vbX + scaledFw / 2, y: vbY + scaledFw / 2, width: scaledWidth - scaledFw, height: scaledHeight - scaledFw, stroke: props.frameColor || "none", strokeWidth: fw, fill: props.fill || "transparent" }),
|
|
1077
|
+
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className: 'rectangular-frame-inner-border', x: vbX + scaledFw, y: vbY + scaledFw, width: scaledWidth - scaledFw * 2, height: scaledHeight - scaledFw * 2, stroke: props.stroke || "none", strokeWidth: sw, fill: props.fill || "transparent" })));
|
|
1042
1078
|
});
|
|
1043
1079
|
|
|
1044
1080
|
var createRoot;
|
|
@@ -1120,17 +1156,17 @@ var PORT_DEFAULT_SIZE = 20;
|
|
|
1120
1156
|
var SelectionFrame = function (props) {
|
|
1121
1157
|
var _a;
|
|
1122
1158
|
var bbox = (_a = props.targetSVGElement) === null || _a === void 0 ? void 0 : _a.getBBox();
|
|
1123
|
-
var _b = React
|
|
1124
|
-
var _c = React
|
|
1159
|
+
var _b = React.useState(props.width || (bbox === null || bbox === void 0 ? void 0 : bbox.width) || MIN_ELEMENT_SIZE), width = _b[0], setWidth = _b[1];
|
|
1160
|
+
var _c = React.useState(props.height || (bbox === null || bbox === void 0 ? void 0 : bbox.height) || MIN_ELEMENT_SIZE), height = _c[0], setHeight = _c[1];
|
|
1125
1161
|
var x = 0;
|
|
1126
1162
|
var y = 0;
|
|
1127
1163
|
var framePadding = props.framePadding || 0;
|
|
1128
1164
|
var r = 5;
|
|
1129
|
-
var _d = React
|
|
1130
|
-
var _e = React
|
|
1131
|
-
var _f = React
|
|
1132
|
-
var _g = React
|
|
1133
|
-
var _h = React
|
|
1165
|
+
var _d = React.useState(false), draggingRect = _d[0], setDraggingRect = _d[1];
|
|
1166
|
+
var _e = React.useState(false), draggingCircle = _e[0], setDraggingCircle = _e[1];
|
|
1167
|
+
var _f = React.useState(0), startX = _f[0], setStartX = _f[1];
|
|
1168
|
+
var _g = React.useState(0), startY = _g[0], setStartY = _g[1];
|
|
1169
|
+
var _h = React.useState(0), lastMoveTime = _h[0], setLastMoveTime = _h[1];
|
|
1134
1170
|
var addRectHandleMouseDown = function (event) {
|
|
1135
1171
|
event.stopPropagation();
|
|
1136
1172
|
if (!draggingCircle) {
|
|
@@ -1140,7 +1176,7 @@ var SelectionFrame = function (props) {
|
|
|
1140
1176
|
setStartY(event.clientY);
|
|
1141
1177
|
}
|
|
1142
1178
|
};
|
|
1143
|
-
var rectHandleMouseMove = React
|
|
1179
|
+
var rectHandleMouseMove = React.useCallback(function (event) {
|
|
1144
1180
|
var mouseEvent = event;
|
|
1145
1181
|
if (draggingRect) {
|
|
1146
1182
|
var offsetX = mouseEvent.clientX - startX;
|
|
@@ -1163,7 +1199,7 @@ var SelectionFrame = function (props) {
|
|
|
1163
1199
|
}
|
|
1164
1200
|
}
|
|
1165
1201
|
}, [draggingRect, props.onMove, props.movingRate, startX, startY, lastMoveTime]);
|
|
1166
|
-
React
|
|
1202
|
+
React.useEffect(function () {
|
|
1167
1203
|
var addRectHandleMouseUp = function () {
|
|
1168
1204
|
//mouse up
|
|
1169
1205
|
setDraggingRect(false);
|
|
@@ -1188,7 +1224,7 @@ var SelectionFrame = function (props) {
|
|
|
1188
1224
|
setDraggingCircle(true);
|
|
1189
1225
|
}
|
|
1190
1226
|
};
|
|
1191
|
-
React
|
|
1227
|
+
React.useEffect(function () {
|
|
1192
1228
|
var circleHandleMouseMove = function (event) {
|
|
1193
1229
|
var mouseEvent = event;
|
|
1194
1230
|
if (draggingCircle) {
|
|
@@ -1244,15 +1280,15 @@ var SelectionFrame = function (props) {
|
|
|
1244
1280
|
leftX -= rectangleSize / 2;
|
|
1245
1281
|
topY -= rectangleSize / 2;
|
|
1246
1282
|
}
|
|
1247
|
-
return (React
|
|
1248
|
-
props.dragDropHandlerElement && React
|
|
1249
|
-
React
|
|
1283
|
+
return (React.createElement(React.Fragment, null,
|
|
1284
|
+
props.dragDropHandlerElement && React.createElement(props.dragDropHandlerElement, { dragging: draggingRect, onMouseDown: addRectHandleMouseDown }),
|
|
1285
|
+
React.createElement("rect", { vectorEffect: "non-scaling-stroke", x: leftX, y: topY, width: width, height: height, fill: 'none', stroke: 'blue', strokeWidth: props.strokeWidth || 5, cursor: draggingRect ? 'grabbing' : 'grab', onMouseDown: addRectHandleMouseDown }),
|
|
1250
1286
|
props.resizability.enabled ?
|
|
1251
|
-
(React
|
|
1287
|
+
(React.createElement("circle", { cursor: 'se-resize', cx: leftX + width, cy: topY + height, r: r, fill: 'blue', stroke: 'blue', onMouseDown: circleHandleMouseDown })) : null));
|
|
1252
1288
|
};
|
|
1253
1289
|
|
|
1254
1290
|
var useSelectionFrame = function (props) {
|
|
1255
|
-
React
|
|
1291
|
+
React.useEffect(function () {
|
|
1256
1292
|
if (props.targetSVGElement && props.container) {
|
|
1257
1293
|
//render SelectionFrame component to the parent element of the targetSVGElement
|
|
1258
1294
|
if (props.container) {
|
|
@@ -1261,7 +1297,7 @@ var useSelectionFrame = function (props) {
|
|
|
1261
1297
|
svg_1.style.outline = 'none';
|
|
1262
1298
|
props.targetSVGElement.appendChild(svg_1);
|
|
1263
1299
|
var root_1 = createRoot(svg_1);
|
|
1264
|
-
root_1.render(React
|
|
1300
|
+
root_1.render(React.createElement(SelectionFrame, __assign({}, props, { container: props.container })));
|
|
1265
1301
|
return function () {
|
|
1266
1302
|
root_1.unmount();
|
|
1267
1303
|
if (props.targetSVGElement) {
|
|
@@ -1478,7 +1514,7 @@ var onTextSelected = function (callback) {
|
|
|
1478
1514
|
off: off
|
|
1479
1515
|
};
|
|
1480
1516
|
};
|
|
1481
|
-
var paperEventEmitterContext = React
|
|
1517
|
+
var paperEventEmitterContext = React.createContext({
|
|
1482
1518
|
emitter: eventEmitter,
|
|
1483
1519
|
emitPaperClicked: emitPaperClicked,
|
|
1484
1520
|
onPaperClicked: onPaperClicked,
|
|
@@ -1516,13 +1552,13 @@ var paperEventEmitterContext = React$1.createContext({
|
|
|
1516
1552
|
onCommandRenderPort: onCommandRenderPort,
|
|
1517
1553
|
});
|
|
1518
1554
|
|
|
1519
|
-
var Text = React
|
|
1520
|
-
var id = _a.id, content = _a.content, x = _a.x, y = _a.y, width = _a.width, height = _a.height, _b = _a.align, align = _b === void 0 ? exports.TextAlign.left : _b, fontSizeProp = _a.fontSize, border = _a.border, container = _a.container, onSelected = _a.onSelected, onMoved = _a.onMoved, onResized = _a.onResized, onContentChanged = _a.onContentChanged;
|
|
1521
|
-
var _c = React
|
|
1522
|
-
var _d = React
|
|
1523
|
-
var svgRef = React
|
|
1524
|
-
var _e = React
|
|
1525
|
-
React
|
|
1555
|
+
var Text = React.forwardRef(function (_a, ref) {
|
|
1556
|
+
var id = _a.id, content = _a.content, x = _a.x, y = _a.y, width = _a.width, height = _a.height, editable = _a.editable, _b = _a.align, align = _b === void 0 ? exports.TextAlign.left : _b, fontSizeProp = _a.fontSize, border = _a.border, container = _a.container, onSelected = _a.onSelected, onMoved = _a.onMoved, onResized = _a.onResized, onContentChanged = _a.onContentChanged;
|
|
1557
|
+
var _c = React.useState(false), isSelected = _c[0], setIsSelected = _c[1];
|
|
1558
|
+
var _d = React.useState(false), isEditing = _d[0], setIsEditing = _d[1];
|
|
1559
|
+
var svgRef = React.useRef();
|
|
1560
|
+
var _e = React.useContext(paperEventEmitterContext), onPaperClicked = _e.onPaperClicked, emitTextSelected = _e.emitTextSelected, onPortSelected = _e.onPortSelected, onElementSelected = _e.onElementSelected, onTextSelected = _e.onTextSelected;
|
|
1561
|
+
React.useEffect(function () {
|
|
1526
1562
|
var paperClickListener = onPaperClicked(function (ev) {
|
|
1527
1563
|
var _a;
|
|
1528
1564
|
var textareaELe = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('textarea');
|
|
@@ -1566,13 +1602,16 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1566
1602
|
size: {
|
|
1567
1603
|
width: width,
|
|
1568
1604
|
height: height,
|
|
1569
|
-
}
|
|
1605
|
+
},
|
|
1606
|
+
editable: editable
|
|
1570
1607
|
};
|
|
1571
1608
|
setIsSelected(true);
|
|
1572
1609
|
onSelected && onSelected(text);
|
|
1573
1610
|
emitTextSelected(text);
|
|
1574
1611
|
};
|
|
1575
1612
|
var handleChangeText = function (ev) {
|
|
1613
|
+
if (!editable)
|
|
1614
|
+
return;
|
|
1576
1615
|
onContentChanged === null || onContentChanged === void 0 ? void 0 : onContentChanged(ev, ev.target.value);
|
|
1577
1616
|
};
|
|
1578
1617
|
useSelectionFrame({
|
|
@@ -1587,7 +1626,7 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1587
1626
|
strokeWidth: 3,
|
|
1588
1627
|
movingOffsetThreshold: TEXT_MOVING_OFFSET_THRESHOLD,
|
|
1589
1628
|
});
|
|
1590
|
-
var textAlign = React
|
|
1629
|
+
var textAlign = React.useMemo(function () {
|
|
1591
1630
|
switch (align) {
|
|
1592
1631
|
case exports.TextAlign.left:
|
|
1593
1632
|
return 'left';
|
|
@@ -1601,7 +1640,7 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1601
1640
|
}, [align]);
|
|
1602
1641
|
var fontSize = fontSizeProp || TEXT_FONT_SIZE;
|
|
1603
1642
|
var borderStyle = border || 'none';
|
|
1604
|
-
return (React
|
|
1643
|
+
return (React.createElement("svg", { style: { overflow: "visible" }, x: x, y: y, ref: function (node) {
|
|
1605
1644
|
svgRef.current = node;
|
|
1606
1645
|
if (typeof ref === 'function') {
|
|
1607
1646
|
ref(node);
|
|
@@ -1610,13 +1649,13 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1610
1649
|
ref.current = node;
|
|
1611
1650
|
}
|
|
1612
1651
|
}, onClick: handleClick },
|
|
1613
|
-
React
|
|
1652
|
+
React.createElement("foreignObject", { width: width, height: height, style: {
|
|
1614
1653
|
overflow: 'visible',
|
|
1615
1654
|
userSelect: 'none',
|
|
1616
1655
|
WebkitUserSelect: 'none',
|
|
1617
1656
|
msUserSelect: 'none'
|
|
1618
1657
|
} },
|
|
1619
|
-
React
|
|
1658
|
+
React.createElement("div", { style: {
|
|
1620
1659
|
width: '100%',
|
|
1621
1660
|
height: '100%',
|
|
1622
1661
|
borderWidth: '1px',
|
|
@@ -1625,7 +1664,7 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1625
1664
|
// whiteSpace: 'pre-wrap',
|
|
1626
1665
|
boxSizing: 'border-box',
|
|
1627
1666
|
} },
|
|
1628
|
-
React
|
|
1667
|
+
React.createElement("textarea", { style: {
|
|
1629
1668
|
fontFamily: 'initial',
|
|
1630
1669
|
display: 'inline-block',
|
|
1631
1670
|
width: '100%',
|
|
@@ -1638,52 +1677,54 @@ var Text = React$1.forwardRef(function (_a, ref) {
|
|
|
1638
1677
|
textAlign: textAlign,
|
|
1639
1678
|
fontSize: fontSize,
|
|
1640
1679
|
}, readOnly: !isEditing, onDoubleClick: function () {
|
|
1641
|
-
if (
|
|
1680
|
+
if (editable) {
|
|
1642
1681
|
setIsEditing(true);
|
|
1643
1682
|
}
|
|
1644
1683
|
}, value: content, onChange: handleChangeText })))));
|
|
1645
1684
|
});
|
|
1646
|
-
var Text$1 = React
|
|
1647
|
-
|
|
1648
|
-
var Port1 = React
|
|
1649
|
-
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, container = props.container, label = props.label, onPortLabelMoved = props.onPortLabelMoved, onPortLabelResized = props.onPortLabelResized, onPortLabelContentChanged = props.onPortLabelContentChanged, onSelected = props.onSelected, onMouseDown = props.onMouseDown, onMouseUp = props.onMouseUp, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, onMouseMove = props.onMouseMove, calculateRotationAngle = props.calculateRotationAngle,
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
React
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1685
|
+
var Text$1 = React.memo(Text);
|
|
1686
|
+
|
|
1687
|
+
var Port1 = React.forwardRef(function (props, ref) {
|
|
1688
|
+
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, container = props.container, label = props.label, onPortLabelMoved = props.onPortLabelMoved, onPortLabelResized = props.onPortLabelResized, onPortLabelContentChanged = props.onPortLabelContentChanged, onSelected = props.onSelected, onMouseDown = props.onMouseDown, onMouseUp = props.onMouseUp, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, onMouseMove = props.onMouseMove, calculateRotationAngle = props.calculateRotationAngle,
|
|
1689
|
+
// onManuallyTriggerRenderHandler,
|
|
1690
|
+
renderShape = props.renderShape;
|
|
1691
|
+
var _a = React.useState(false); _a[0]; _a[1];
|
|
1692
|
+
var textRef = React.useRef(null);
|
|
1693
|
+
// useEffect(() => {
|
|
1694
|
+
// const off = onManuallyTriggerRenderHandler?.(() => {
|
|
1695
|
+
// setUpdated(prev => !prev);
|
|
1696
|
+
// });
|
|
1697
|
+
// return () => {
|
|
1698
|
+
// off?.();
|
|
1699
|
+
// }
|
|
1700
|
+
// }, [])
|
|
1701
|
+
var rotationAngle = React.useMemo(function () {
|
|
1661
1702
|
if (!calculateRotationAngle)
|
|
1662
1703
|
return 0;
|
|
1663
1704
|
return calculateRotationAngle(x, y);
|
|
1664
1705
|
}, [calculateRotationAngle, x, y]);
|
|
1665
|
-
React
|
|
1706
|
+
React.useEffect(function () {
|
|
1666
1707
|
console.info('Testing - rendering Port ' + id);
|
|
1667
1708
|
});
|
|
1668
1709
|
var renderLabel = function (label) {
|
|
1669
1710
|
var content = label.content, size = label.size;
|
|
1670
1711
|
var position = label.position || PORT_LABEL_POSITION;
|
|
1671
|
-
return React
|
|
1712
|
+
return React.createElement(Text$1, { id: label.id, ref: textRef, x: x + position.x, y: y + position.y, width: size.width, height: size.height, editable: label.editable, content: content, fontSize: label.fontSize, border: label.border, container: container, onMoved: function (x, y) { return onPortLabelMoved === null || onPortLabelMoved === void 0 ? void 0 : onPortLabelMoved(x, y, id); }, onResized: function (width, height) { return onPortLabelResized === null || onPortLabelResized === void 0 ? void 0 : onPortLabelResized(width, height, id); }, onContentChanged: function (ev, newValue) { return onPortLabelContentChanged === null || onPortLabelContentChanged === void 0 ? void 0 : onPortLabelContentChanged(ev, newValue, id); } });
|
|
1672
1713
|
};
|
|
1673
|
-
var renderedShape = React
|
|
1714
|
+
var renderedShape = React.useMemo(function () {
|
|
1674
1715
|
if (renderShape) {
|
|
1675
1716
|
var RenderShape = renderShape;
|
|
1676
|
-
return (React
|
|
1717
|
+
return (React.createElement(RenderShape, __assign({ ref: ref }, props, { rotation: rotationAngle })));
|
|
1677
1718
|
}
|
|
1678
1719
|
else {
|
|
1679
|
-
return React
|
|
1720
|
+
return React.createElement(Circle, { onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(id, e); }, onMouseUp: function (e) { return onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(id, e); }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseMove: function (e) { return onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove(id, e); }, onClick: function (e) { return onSelected === null || onSelected === void 0 ? void 0 : onSelected(id, e); }, ref: ref, x: x, y: y, positioningAnchor: exports.PositioningAnchor.Center, height: height, width: width, stroke: "black", fill: "black" });
|
|
1680
1721
|
}
|
|
1681
1722
|
}, [props]);
|
|
1682
|
-
return (React
|
|
1723
|
+
return (React.createElement(React.Fragment, null,
|
|
1683
1724
|
renderedShape,
|
|
1684
1725
|
label && renderLabel(label)));
|
|
1685
1726
|
});
|
|
1686
|
-
var Port = React
|
|
1727
|
+
var Port = React.memo(Port1);
|
|
1687
1728
|
|
|
1688
1729
|
// Render the svg <path> element
|
|
1689
1730
|
function getCurvePathData(points, smoothing, closed) {
|
|
@@ -1844,14 +1885,14 @@ function calculateAngleWithOx(pStart, pEnd) {
|
|
|
1844
1885
|
//Defined remove icon for element link, shown when element link is selected.
|
|
1845
1886
|
function CloseIcon(_a) {
|
|
1846
1887
|
var onClick = _a.onClick;
|
|
1847
|
-
return (React
|
|
1848
|
-
React
|
|
1849
|
-
React
|
|
1850
|
-
React
|
|
1851
|
-
React
|
|
1852
|
-
React
|
|
1853
|
-
React
|
|
1854
|
-
React
|
|
1888
|
+
return (React.createElement("svg", { width: 20, height: 20, viewBox: "0 0 24.00 24.00", xmlns: "http://www.w3.org/2000/svg", fill: "#ff0000", transform: "rotate(0)", onMouseDown: function (ev) { ev.stopPropagation(); }, onClick: onClick, cursor: 'pointer' },
|
|
1889
|
+
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0", transform: "translate(3.84,3.84), scale(0.68)" },
|
|
1890
|
+
React.createElement("rect", { x: "0", y: "0", width: "24.00", height: "24.00", rx: "12", fill: "#ffffff", strokeWidth: "0" })),
|
|
1891
|
+
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round", stroke: "#CCCCCC", "stroke-width": "0.048" }),
|
|
1892
|
+
React.createElement("g", { id: "SVGRepo_iconCarrier" },
|
|
1893
|
+
React.createElement("g", null,
|
|
1894
|
+
React.createElement("path", { fill: "none", d: "M0 0h24v24H0z" }),
|
|
1895
|
+
React.createElement("path", { d: "M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-11.414L9.172 7.757 7.757 9.172 10.586 12l-2.829 2.828 1.415 1.415L12 13.414l2.828 2.829 1.415-1.415L13.414 12l2.829-2.828-1.415-1.415L12 10.586z" })))));
|
|
1855
1896
|
}
|
|
1856
1897
|
|
|
1857
1898
|
/**
|
|
@@ -7388,6 +7429,12 @@ var flattenJs = f;
|
|
|
7388
7429
|
|
|
7389
7430
|
var Flatten$1 = /*@__PURE__*/getDefaultExportFromCjs(flattenJs);
|
|
7390
7431
|
|
|
7432
|
+
var checkPositionOnLine = function (position, line) {
|
|
7433
|
+
var point = Flatten$1.point(position.x, position.y);
|
|
7434
|
+
var _line = Flatten$1.segment(Flatten$1.point(line[0].x, line[0].y), Flatten$1.point(line[1].x, line[1].y));
|
|
7435
|
+
return _line.contains(point);
|
|
7436
|
+
};
|
|
7437
|
+
|
|
7391
7438
|
/**
|
|
7392
7439
|
* Check if position 1 is within the radius r of position 2
|
|
7393
7440
|
* @returns boolean
|
|
@@ -7414,17 +7461,56 @@ var findNearestPosition = function (listPositions, targetPosition) {
|
|
|
7414
7461
|
}
|
|
7415
7462
|
return nearestPoint;
|
|
7416
7463
|
};
|
|
7464
|
+
/**
|
|
7465
|
+
* From one point find projected Point on the line segment.
|
|
7466
|
+
* @param position
|
|
7467
|
+
* @param linePoints
|
|
7468
|
+
* @returns
|
|
7469
|
+
*/
|
|
7470
|
+
var findNearestPointOnSegment = function (position, linePoints) {
|
|
7471
|
+
var beginPosition = linePoints[0], endPosition = linePoints[1];
|
|
7472
|
+
var point = Flatten$1.point(position.x, position.y);
|
|
7473
|
+
var segment = Flatten$1.segment(Flatten$1.point(beginPosition.x, beginPosition.y), Flatten$1.point(endPosition.x, endPosition.y));
|
|
7474
|
+
var _a = point.distanceTo(segment); _a[0]; var segmentFromPointToSegment = _a[1];
|
|
7475
|
+
return {
|
|
7476
|
+
x: segmentFromPointToSegment.pe.x,
|
|
7477
|
+
y: segmentFromPointToSegment.pe.y
|
|
7478
|
+
};
|
|
7479
|
+
};
|
|
7480
|
+
/**
|
|
7481
|
+
* From 1 point find projected Point on the line segments so that the distance between 2 points is shortest.
|
|
7482
|
+
* @param position
|
|
7483
|
+
* @param lines
|
|
7484
|
+
* @returns
|
|
7485
|
+
*/
|
|
7486
|
+
var findNearestProjectedPoint = function (position, lines) {
|
|
7487
|
+
var possiblePoints = lines.map(function (p) { return findNearestPointOnSegment(position, p); });
|
|
7488
|
+
var nearestPoint = findNearestPosition(possiblePoints, position);
|
|
7489
|
+
return nearestPoint;
|
|
7490
|
+
};
|
|
7491
|
+
/**
|
|
7492
|
+
* Check if a point is inside a polygon
|
|
7493
|
+
* @param position
|
|
7494
|
+
* @param polygonPoints
|
|
7495
|
+
* @returns
|
|
7496
|
+
*/
|
|
7497
|
+
var checkPointContainsPolygon = function (position, polygonPoints) {
|
|
7498
|
+
var polygon = new Flatten$1.Polygon();
|
|
7499
|
+
polygon.addFace(polygonPoints.map(function (p) { return Flatten$1.point(p.x, p.y); }));
|
|
7500
|
+
return polygon.contains(Flatten$1.point(position.x, position.y));
|
|
7501
|
+
};
|
|
7417
7502
|
/**
|
|
7418
7503
|
* @param ele : IElement
|
|
7419
7504
|
* @returns Flatten.Polygon
|
|
7420
7505
|
*/
|
|
7421
7506
|
var makePolygonOfElement = function (ele) {
|
|
7422
7507
|
var polygon = new Flatten$1.Polygon();
|
|
7508
|
+
var strokeWidthOffset = 1;
|
|
7423
7509
|
polygon.addFace([
|
|
7424
|
-
Flatten$1.point(ele.position.x, ele.position.y),
|
|
7425
|
-
Flatten$1.point(ele.position.x + ele.size.width, ele.position.y),
|
|
7426
|
-
Flatten$1.point(ele.position.x + ele.size.width, ele.position.y + ele.size.height),
|
|
7427
|
-
Flatten$1.point(ele.position.x, ele.position.y + ele.size.height),
|
|
7510
|
+
Flatten$1.point(ele.position.x + strokeWidthOffset, ele.position.y + strokeWidthOffset),
|
|
7511
|
+
Flatten$1.point(ele.position.x + ele.size.width - strokeWidthOffset, ele.position.y + strokeWidthOffset),
|
|
7512
|
+
Flatten$1.point(ele.position.x + ele.size.width - strokeWidthOffset, ele.position.y + ele.size.height - strokeWidthOffset),
|
|
7513
|
+
Flatten$1.point(ele.position.x + strokeWidthOffset, ele.position.y + ele.size.height - strokeWidthOffset),
|
|
7428
7514
|
]);
|
|
7429
7515
|
return polygon;
|
|
7430
7516
|
};
|
|
@@ -7466,44 +7552,53 @@ var getFirstIntersection = function (startPosition, endPosition, elements) {
|
|
|
7466
7552
|
//Find a point next to an element from a point on the element
|
|
7467
7553
|
var generateSubstitutePosition = function (intersectedPosition, targetPosition, ele) {
|
|
7468
7554
|
var translationOffset = 20;
|
|
7555
|
+
var strokeWidthOffset = 1;
|
|
7469
7556
|
var vertex1Position = {
|
|
7470
|
-
x: ele.position.x,
|
|
7471
|
-
y: ele.position.y,
|
|
7557
|
+
x: ele.position.x + strokeWidthOffset,
|
|
7558
|
+
y: ele.position.y + strokeWidthOffset,
|
|
7472
7559
|
};
|
|
7473
7560
|
var vertex2Position = {
|
|
7474
|
-
x: ele.position.x + ele.size.width,
|
|
7475
|
-
y: ele.position.y,
|
|
7561
|
+
x: ele.position.x + ele.size.width - strokeWidthOffset,
|
|
7562
|
+
y: ele.position.y + strokeWidthOffset,
|
|
7476
7563
|
};
|
|
7477
7564
|
var vertex3Position = {
|
|
7478
|
-
x: ele.position.x + ele.size.width,
|
|
7479
|
-
y: ele.position.y + ele.size.height,
|
|
7565
|
+
x: ele.position.x + ele.size.width - strokeWidthOffset,
|
|
7566
|
+
y: ele.position.y + ele.size.height - strokeWidthOffset,
|
|
7480
7567
|
};
|
|
7481
7568
|
var vertex4Position = {
|
|
7482
|
-
x: ele.position.x,
|
|
7483
|
-
y: ele.position.y + ele.size.height,
|
|
7569
|
+
x: ele.position.x + strokeWidthOffset,
|
|
7570
|
+
y: ele.position.y + ele.size.height - strokeWidthOffset,
|
|
7484
7571
|
};
|
|
7485
7572
|
var replacementPosition = null;
|
|
7486
|
-
if (checkSamePosition(vertex1Position, intersectedPosition,
|
|
7573
|
+
if (checkSamePosition(vertex1Position, intersectedPosition, 3)) {
|
|
7487
7574
|
//Cut at vertex 1 of bbox, move out a distance x,y
|
|
7488
|
-
replacementPosition
|
|
7489
|
-
|
|
7575
|
+
replacementPosition = {
|
|
7576
|
+
x: vertex1Position.x - translationOffset,
|
|
7577
|
+
y: vertex1Position.y - translationOffset,
|
|
7578
|
+
};
|
|
7490
7579
|
}
|
|
7491
|
-
else if (checkSamePosition(vertex2Position, intersectedPosition,
|
|
7580
|
+
else if (checkSamePosition(vertex2Position, intersectedPosition, 3)) {
|
|
7492
7581
|
//Cut at vertex 2 of bbox, move out a distance x,y
|
|
7493
|
-
replacementPosition
|
|
7494
|
-
|
|
7582
|
+
replacementPosition = {
|
|
7583
|
+
x: vertex2Position.x + translationOffset,
|
|
7584
|
+
y: vertex2Position.y - translationOffset,
|
|
7585
|
+
};
|
|
7495
7586
|
}
|
|
7496
|
-
else if (checkSamePosition(vertex3Position, intersectedPosition,
|
|
7587
|
+
else if (checkSamePosition(vertex3Position, intersectedPosition, 3)) {
|
|
7497
7588
|
//Cut at vertex 3 of bbox, move out a distance x,y
|
|
7498
|
-
replacementPosition
|
|
7499
|
-
|
|
7589
|
+
replacementPosition = {
|
|
7590
|
+
x: vertex3Position.x + translationOffset,
|
|
7591
|
+
y: vertex3Position.y + translationOffset,
|
|
7592
|
+
};
|
|
7500
7593
|
}
|
|
7501
|
-
else if (checkSamePosition(vertex4Position, intersectedPosition,
|
|
7594
|
+
else if (checkSamePosition(vertex4Position, intersectedPosition, 3)) {
|
|
7502
7595
|
//Cut at vertex 4 of bbox, move out a distance x,y
|
|
7503
|
-
replacementPosition
|
|
7504
|
-
|
|
7596
|
+
replacementPosition = {
|
|
7597
|
+
x: vertex4Position.x - translationOffset,
|
|
7598
|
+
y: vertex4Position.y + translationOffset,
|
|
7599
|
+
};
|
|
7505
7600
|
}
|
|
7506
|
-
else if (intersectedPosition
|
|
7601
|
+
else if (checkPositionOnLine(intersectedPosition, [vertex1Position, vertex2Position])) {
|
|
7507
7602
|
//cut top edge, move left or right
|
|
7508
7603
|
var lineOfVertex12 = Flatten$1.line(Flatten$1.point(vertex1Position.x, vertex1Position.y), Flatten$1.point(vertex2Position.x, vertex2Position.y));
|
|
7509
7604
|
//Check if the line lies on the edge of the bbox then move the starting point out 1 distance perpendicular to the edge.
|
|
@@ -7527,7 +7622,7 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7527
7622
|
replacementPosition = findNearestPosition([leftPosition, rightPosition], targetPosition);
|
|
7528
7623
|
}
|
|
7529
7624
|
}
|
|
7530
|
-
else if (intersectedPosition
|
|
7625
|
+
else if (checkPositionOnLine(intersectedPosition, [vertex3Position, vertex4Position])) {
|
|
7531
7626
|
//cut bottom edge, move left or right
|
|
7532
7627
|
var lineOfVertex34 = Flatten$1.line(Flatten$1.point(vertex3Position.x, vertex3Position.y), Flatten$1.point(vertex4Position.x, vertex4Position.y));
|
|
7533
7628
|
if (Flatten$1.point(intersectedPosition.x, intersectedPosition.y).distanceTo(lineOfVertex34)[0] === 0 &&
|
|
@@ -7550,7 +7645,7 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7550
7645
|
replacementPosition = findNearestPosition([leftPosition, rightPosition], targetPosition);
|
|
7551
7646
|
}
|
|
7552
7647
|
}
|
|
7553
|
-
else if (intersectedPosition
|
|
7648
|
+
else if (checkPositionOnLine(intersectedPosition, [vertex1Position, vertex4Position])) {
|
|
7554
7649
|
//cut left edge, move up or down
|
|
7555
7650
|
var lineOfVertex14 = Flatten$1.line(Flatten$1.point(vertex1Position.x, vertex1Position.y), Flatten$1.point(vertex4Position.x, vertex4Position.y));
|
|
7556
7651
|
if (Flatten$1.point(intersectedPosition.x, intersectedPosition.y).distanceTo(lineOfVertex14)[0] === 0 &&
|
|
@@ -7573,7 +7668,7 @@ var generateSubstitutePosition = function (intersectedPosition, targetPosition,
|
|
|
7573
7668
|
replacementPosition = findNearestPosition([topPosition, bottomPosition], targetPosition);
|
|
7574
7669
|
}
|
|
7575
7670
|
}
|
|
7576
|
-
else if (intersectedPosition
|
|
7671
|
+
else if (checkPositionOnLine(intersectedPosition, [vertex2Position, vertex3Position])) {
|
|
7577
7672
|
//cut right edge, move up or down
|
|
7578
7673
|
var lineOfVertex23 = Flatten$1.line(Flatten$1.point(vertex2Position.x, vertex2Position.y), Flatten$1.point(vertex3Position.x, vertex3Position.y));
|
|
7579
7674
|
if (Flatten$1.point(intersectedPosition.x, intersectedPosition.y).distanceTo(lineOfVertex23)[0] === 0 &&
|
|
@@ -7606,25 +7701,25 @@ var getRelativePosition = function (clientPosition, relativeElement) {
|
|
|
7606
7701
|
};
|
|
7607
7702
|
};
|
|
7608
7703
|
|
|
7609
|
-
var makerStart = React
|
|
7610
|
-
var makerEnd = React
|
|
7704
|
+
var makerStart = React.createElement("circle", { cx: 10, cy: 10, r: 10, fill: "blue" });
|
|
7705
|
+
var makerEnd = React.createElement("path", { d: "M0 0 L 20 10 L0 20 Z", fill: "blue" }); //<path d="M0 0 L 10 5 L0 10 Z"></path>
|
|
7611
7706
|
var IElementLink = function (_a) {
|
|
7612
7707
|
var _b, _c;
|
|
7613
7708
|
var id = _a.id, path = _a.path, stroke = _a.stroke, _d = _a.strokeWidth, strokeWidth = _d === void 0 ? 4 : _d, pointsProp = _a.points, sourcePosition = _a.sourcePosition, targetPosition = _a.targetPosition, onPathChanged = _a.onPathChanged, onClickDelete = _a.onClickDelete, onSelected = _a.onSelected, onDeselected = _a.onDeselected, container = _a.container, _e = _a.markerStart, markerStart = _e === void 0 ? makerStart : _e, _f = _a.markerEnd, markerEnd = _f === void 0 ? makerEnd : _f, _g = _a.markerDistanceFromPort, markerDistanceFromPort = _g === void 0 ? LINK_MARKER_DISTANCE_FROM_PORT : _g, _h = _a.markerSize, markerSize = _h === void 0 ? LINK_MARKER_SIZE : _h, label = _a.label, sourceLabel = _a.sourceLabel, targetLabel = _a.targetLabel, onLabelMoved = _a.onLabelMoved, onLabelResized = _a.onLabelResized, onLabelContentChanged = _a.onLabelContentChanged;
|
|
7614
|
-
var _j = React
|
|
7615
|
-
var _k = React
|
|
7616
|
-
var _l = React
|
|
7617
|
-
var _m = React
|
|
7618
|
-
var _o = React
|
|
7709
|
+
var _j = React.useState(path), pathStr = _j[0], setPathStr = _j[1];
|
|
7710
|
+
var _k = React.useState(pointsProp !== null && pointsProp !== void 0 ? pointsProp : []), points = _k[0], setPoints = _k[1];
|
|
7711
|
+
var _l = React.useState(false), isDragging = _l[0], setIsDragging = _l[1];
|
|
7712
|
+
var _m = React.useState(), draggingPointIndex = _m[0], setDraggingPointIndex = _m[1];
|
|
7713
|
+
var _o = React.useState({
|
|
7619
7714
|
current: null,
|
|
7620
7715
|
}), selectedLabelRef = _o[0], setSelectedLabelRef = _o[1];
|
|
7621
|
-
var _p = React
|
|
7622
|
-
var _q = React
|
|
7623
|
-
var pathRef = React
|
|
7624
|
-
var labelRef = React
|
|
7625
|
-
var sourceLabelRef = React
|
|
7626
|
-
var targetLabelRef = React
|
|
7627
|
-
React
|
|
7716
|
+
var _p = React.useState(false), isSelectedLink = _p[0], setIsSelectedLink = _p[1];
|
|
7717
|
+
var _q = React.useContext(paperEventEmitterContext), onPaperClicked = _q.onPaperClicked, onElementSelected = _q.onElementSelected;
|
|
7718
|
+
var pathRef = React.useRef(null);
|
|
7719
|
+
var labelRef = React.useRef(null);
|
|
7720
|
+
var sourceLabelRef = React.useRef(null);
|
|
7721
|
+
var targetLabelRef = React.useRef(null);
|
|
7722
|
+
React.useEffect(function () {
|
|
7628
7723
|
var paperClickListener = onPaperClicked(function () {
|
|
7629
7724
|
setSelectedLabelRef({
|
|
7630
7725
|
current: null,
|
|
@@ -7636,7 +7731,7 @@ var IElementLink = function (_a) {
|
|
|
7636
7731
|
paperClickListener.off();
|
|
7637
7732
|
};
|
|
7638
7733
|
}, []);
|
|
7639
|
-
React
|
|
7734
|
+
React.useEffect(function () {
|
|
7640
7735
|
var elementSelectedListener = onElementSelected(function () {
|
|
7641
7736
|
setSelectedLabelRef({
|
|
7642
7737
|
current: null,
|
|
@@ -7648,17 +7743,17 @@ var IElementLink = function (_a) {
|
|
|
7648
7743
|
elementSelectedListener.off();
|
|
7649
7744
|
};
|
|
7650
7745
|
}, []);
|
|
7651
|
-
React
|
|
7746
|
+
React.useLayoutEffect(function () {
|
|
7652
7747
|
var pointsList = __spreadArray(__spreadArray([sourcePosition], points, true), [targetPosition], false);
|
|
7653
7748
|
var _pathStr = createSmoothPathString(pointsList, undefined);
|
|
7654
7749
|
setPathStr(_pathStr);
|
|
7655
7750
|
}, [sourcePosition, points, targetPosition]);
|
|
7656
|
-
React
|
|
7751
|
+
React.useEffect(function () {
|
|
7657
7752
|
if (!pathStr)
|
|
7658
7753
|
return;
|
|
7659
7754
|
onPathChanged === null || onPathChanged === void 0 ? void 0 : onPathChanged(pathStr, id);
|
|
7660
7755
|
}, [pathStr, id]);
|
|
7661
|
-
React
|
|
7756
|
+
React.useLayoutEffect(function () {
|
|
7662
7757
|
//handle when creating and moving point
|
|
7663
7758
|
var handleMouseMove = function (ev) {
|
|
7664
7759
|
var mouseEvent = ev;
|
|
@@ -7814,7 +7909,7 @@ var IElementLink = function (_a) {
|
|
|
7814
7909
|
x: relativePosition.x + relativePositionTo.x,
|
|
7815
7910
|
y: relativePosition.y + relativePositionTo.y,
|
|
7816
7911
|
};
|
|
7817
|
-
return (React
|
|
7912
|
+
return (React.createElement(Text$1, { id: label.id, x: position.x, y: position.y, width: size.width, height: size.height, editable: label.editable, content: content, fontSize: label.fontSize, border: label.border, ref: curLabelRef, container: container, onSelected: function () { return setSelectedLabelRef(curLabelRef); }, onMoved: handleLabelMoved, onResized: handleLabelResized, onContentChanged: handleLabelContentChanged }));
|
|
7818
7913
|
};
|
|
7819
7914
|
var angleMarkerStart = '0';
|
|
7820
7915
|
var angleMarkerEnd = '0';
|
|
@@ -7832,28 +7927,28 @@ var IElementLink = function (_a) {
|
|
|
7832
7927
|
}
|
|
7833
7928
|
centerPathPosition = (_c = pathRef.current) === null || _c === void 0 ? void 0 : _c.getPointAtLength(pathRef.current.getTotalLength() / 2);
|
|
7834
7929
|
}
|
|
7835
|
-
return (React
|
|
7836
|
-
React
|
|
7837
|
-
React
|
|
7838
|
-
isSelectedLink && centerPathPosition && React
|
|
7839
|
-
React
|
|
7930
|
+
return (React.createElement("g", null,
|
|
7931
|
+
React.createElement("path", { ref: pathRef, d: pathStr, className: isSelectedLink ? CSS_CLASS_LINK_SELECTED : '', fill: "none", stroke: stroke || LINK_DEFAULT_COLOR, strokeWidth: strokeWidth }),
|
|
7932
|
+
React.createElement("path", { d: pathStr, fill: "none", stroke: 'transparent', strokeWidth: LINK_CLICKABLE_STROKE_WIDTH, onClick: handleClickPath, onMouseDown: handleMouseDownOnPath }),
|
|
7933
|
+
isSelectedLink && centerPathPosition && React.createElement("svg", { x: centerPathPosition.x - 10, y: centerPathPosition.y - 10 },
|
|
7934
|
+
React.createElement(CloseIcon, { onClick: onClickDelete })),
|
|
7840
7935
|
label && renderLabel(label, 'middle', centerPathPosition),
|
|
7841
7936
|
sourceLabel && renderLabel(sourceLabel, 'source', sourcePosition),
|
|
7842
7937
|
targetLabel && renderLabel(targetLabel, 'target', targetPosition),
|
|
7843
|
-
markerStartPosition && React
|
|
7844
|
-
React
|
|
7845
|
-
markerEndPosition && React
|
|
7846
|
-
React
|
|
7938
|
+
markerStartPosition && React.createElement("g", { transform: "rotate(".concat(angleMarkerStart, ")"), style: { transformOrigin: 'center', transformBox: 'content-box' } },
|
|
7939
|
+
React.createElement("svg", { x: markerStartPosition.x - markerSize / 2, y: markerStartPosition.y - markerSize / 2, width: markerSize, height: markerSize }, markerStart)),
|
|
7940
|
+
markerEndPosition && React.createElement("g", { transform: "rotate(".concat(angleMarkerEnd, ")"), style: { transformOrigin: 'center', transformBox: 'content-box' } },
|
|
7941
|
+
React.createElement("svg", { x: markerEndPosition.x - markerSize / 2, y: markerEndPosition.y - markerSize / 2, width: markerSize, height: markerSize }, markerEnd))));
|
|
7847
7942
|
};
|
|
7848
|
-
var ElementLink = React
|
|
7943
|
+
var ElementLink = React.memo(IElementLink);
|
|
7849
7944
|
|
|
7850
7945
|
var Ruler = function (_a) {
|
|
7851
7946
|
var squareSize = _a.squareSize, border = _a.border;
|
|
7852
7947
|
var numColumns = Math.ceil(3000 / squareSize);
|
|
7853
7948
|
var numRows = Math.ceil(3000 / squareSize);
|
|
7854
7949
|
var tableWidth = numColumns * squareSize;
|
|
7855
|
-
return (React
|
|
7856
|
-
React
|
|
7950
|
+
return (React.createElement("table", { style: { position: 'absolute', zIndex: -1, top: 0, left: 0, borderCollapse: 'collapse', width: tableWidth } },
|
|
7951
|
+
React.createElement("tbody", null, Array.from({ length: numRows }).map(function (_, rowIndex) { return (React.createElement("tr", { key: rowIndex, style: { margin: 0, padding: 0 } }, Array.from({ length: numColumns }).map(function (_, colIndex) { return (React.createElement("td", { key: colIndex, style: {
|
|
7857
7952
|
width: squareSize,
|
|
7858
7953
|
height: squareSize,
|
|
7859
7954
|
border: border,
|
|
@@ -7864,11 +7959,11 @@ var Ruler = function (_a) {
|
|
|
7864
7959
|
position: 'relative',
|
|
7865
7960
|
fontSize: 12,
|
|
7866
7961
|
} },
|
|
7867
|
-
rowIndex === 0 ? React
|
|
7868
|
-
colIndex === 0 ? React
|
|
7962
|
+
rowIndex === 0 ? React.createElement("span", { style: { marginLeft: "-12px" } }, colIndex * squareSize) : "",
|
|
7963
|
+
colIndex === 0 ? React.createElement("span", { style: { top: "-9px", position: "absolute" } }, rowIndex * squareSize) : "")); }))); }))));
|
|
7869
7964
|
};
|
|
7870
7965
|
|
|
7871
|
-
var ElementWrapper = React
|
|
7966
|
+
var ElementWrapper = React.forwardRef(function (_a, ref) {
|
|
7872
7967
|
var x = _a.x, y = _a.y, cssClass = _a.cssClass, children = _a.children; _a.portPlaceholders; _a.ports; var onClick = _a.onClick, onContextMenu = _a.onContextMenu, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onMouseUp = _a.onMouseUp;
|
|
7873
7968
|
var handleMouseDown = function (ev) {
|
|
7874
7969
|
ev.stopPropagation();
|
|
@@ -7883,7 +7978,7 @@ var ElementWrapper = React$1.forwardRef(function (_a, ref) {
|
|
|
7883
7978
|
onContextMenu(ev);
|
|
7884
7979
|
}
|
|
7885
7980
|
};
|
|
7886
|
-
return (React
|
|
7981
|
+
return (React.createElement("svg", { className: cssClass, x: x, y: y, onClick: handleClick, onContextMenu: handleClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
|
|
7887
7982
|
});
|
|
7888
7983
|
|
|
7889
7984
|
// Calculate the position of the 4 vertices of a rectangle relative to its parent svg
|
|
@@ -7923,1267 +8018,50 @@ var getElementRotationInfo = function (element) {
|
|
|
7923
8018
|
return rotationAngle;
|
|
7924
8019
|
};
|
|
7925
8020
|
|
|
7926
|
-
var checkPositionOnLine = function (position, line) {
|
|
7927
|
-
var point = Flatten$1.point(position.x, position.y);
|
|
7928
|
-
var _line = Flatten$1.segment(Flatten$1.point(line[0].x, line[0].y), Flatten$1.point(line[1].x, line[1].y));
|
|
7929
|
-
return _line.contains(point);
|
|
7930
|
-
};
|
|
7931
|
-
|
|
7932
|
-
var bundle = {exports: {}};
|
|
7933
|
-
|
|
7934
|
-
var cssLayout = {exports: {}};
|
|
7935
|
-
|
|
7936
|
-
(function (module, exports) {
|
|
7937
|
-
// UMD (Universal Module Definition)
|
|
7938
|
-
// See https://github.com/umdjs/umd for reference
|
|
7939
|
-
//
|
|
7940
|
-
// This file uses the following specific UMD implementation:
|
|
7941
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7942
|
-
(function(root, factory) {
|
|
7943
|
-
{
|
|
7944
|
-
// Node. Does not work with strict CommonJS, but
|
|
7945
|
-
// only CommonJS-like environments that support module.exports,
|
|
7946
|
-
// like Node.
|
|
7947
|
-
module.exports = factory();
|
|
7948
|
-
}
|
|
7949
|
-
}(commonjsGlobal, function() {
|
|
7950
|
-
/**
|
|
7951
|
-
* Copyright (c) 2014, Facebook, Inc.
|
|
7952
|
-
* All rights reserved.
|
|
7953
|
-
*
|
|
7954
|
-
* This source code is licensed under the BSD-style license found in the
|
|
7955
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7956
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
7957
|
-
*/
|
|
7958
|
-
|
|
7959
|
-
var computeLayout = (function() {
|
|
7960
|
-
|
|
7961
|
-
var CSS_UNDEFINED;
|
|
7962
|
-
|
|
7963
|
-
var CSS_DIRECTION_INHERIT = 'inherit';
|
|
7964
|
-
var CSS_DIRECTION_LTR = 'ltr';
|
|
7965
|
-
var CSS_DIRECTION_RTL = 'rtl';
|
|
7966
|
-
|
|
7967
|
-
var CSS_FLEX_DIRECTION_ROW = 'row';
|
|
7968
|
-
var CSS_FLEX_DIRECTION_ROW_REVERSE = 'row-reverse';
|
|
7969
|
-
var CSS_FLEX_DIRECTION_COLUMN = 'column';
|
|
7970
|
-
var CSS_FLEX_DIRECTION_COLUMN_REVERSE = 'column-reverse';
|
|
7971
|
-
|
|
7972
|
-
var CSS_JUSTIFY_FLEX_START = 'flex-start';
|
|
7973
|
-
var CSS_JUSTIFY_CENTER = 'center';
|
|
7974
|
-
var CSS_JUSTIFY_FLEX_END = 'flex-end';
|
|
7975
|
-
var CSS_JUSTIFY_SPACE_BETWEEN = 'space-between';
|
|
7976
|
-
var CSS_JUSTIFY_SPACE_AROUND = 'space-around';
|
|
7977
|
-
|
|
7978
|
-
var CSS_ALIGN_FLEX_START = 'flex-start';
|
|
7979
|
-
var CSS_ALIGN_CENTER = 'center';
|
|
7980
|
-
var CSS_ALIGN_FLEX_END = 'flex-end';
|
|
7981
|
-
var CSS_ALIGN_STRETCH = 'stretch';
|
|
7982
|
-
|
|
7983
|
-
var CSS_POSITION_RELATIVE = 'relative';
|
|
7984
|
-
var CSS_POSITION_ABSOLUTE = 'absolute';
|
|
7985
|
-
|
|
7986
|
-
var leading = {
|
|
7987
|
-
'row': 'left',
|
|
7988
|
-
'row-reverse': 'right',
|
|
7989
|
-
'column': 'top',
|
|
7990
|
-
'column-reverse': 'bottom'
|
|
7991
|
-
};
|
|
7992
|
-
var trailing = {
|
|
7993
|
-
'row': 'right',
|
|
7994
|
-
'row-reverse': 'left',
|
|
7995
|
-
'column': 'bottom',
|
|
7996
|
-
'column-reverse': 'top'
|
|
7997
|
-
};
|
|
7998
|
-
var pos = {
|
|
7999
|
-
'row': 'left',
|
|
8000
|
-
'row-reverse': 'right',
|
|
8001
|
-
'column': 'top',
|
|
8002
|
-
'column-reverse': 'bottom'
|
|
8003
|
-
};
|
|
8004
|
-
var dim = {
|
|
8005
|
-
'row': 'width',
|
|
8006
|
-
'row-reverse': 'width',
|
|
8007
|
-
'column': 'height',
|
|
8008
|
-
'column-reverse': 'height'
|
|
8009
|
-
};
|
|
8010
|
-
|
|
8011
|
-
// When transpiled to Java / C the node type has layout, children and style
|
|
8012
|
-
// properties. For the JavaScript version this function adds these properties
|
|
8013
|
-
// if they don't already exist.
|
|
8014
|
-
function fillNodes(node) {
|
|
8015
|
-
if (!node.layout || node.isDirty) {
|
|
8016
|
-
node.layout = {
|
|
8017
|
-
width: undefined,
|
|
8018
|
-
height: undefined,
|
|
8019
|
-
top: 0,
|
|
8020
|
-
left: 0,
|
|
8021
|
-
right: 0,
|
|
8022
|
-
bottom: 0
|
|
8023
|
-
};
|
|
8024
|
-
}
|
|
8025
|
-
|
|
8026
|
-
if (!node.style) {
|
|
8027
|
-
node.style = {};
|
|
8028
|
-
}
|
|
8029
|
-
|
|
8030
|
-
if (!node.children) {
|
|
8031
|
-
node.children = [];
|
|
8032
|
-
}
|
|
8033
|
-
node.children.forEach(fillNodes);
|
|
8034
|
-
return node;
|
|
8035
|
-
}
|
|
8036
|
-
|
|
8037
|
-
function isUndefined(value) {
|
|
8038
|
-
return value === undefined;
|
|
8039
|
-
}
|
|
8040
|
-
|
|
8041
|
-
function isRowDirection(flexDirection) {
|
|
8042
|
-
return flexDirection === CSS_FLEX_DIRECTION_ROW ||
|
|
8043
|
-
flexDirection === CSS_FLEX_DIRECTION_ROW_REVERSE;
|
|
8044
|
-
}
|
|
8045
|
-
|
|
8046
|
-
function isColumnDirection(flexDirection) {
|
|
8047
|
-
return flexDirection === CSS_FLEX_DIRECTION_COLUMN ||
|
|
8048
|
-
flexDirection === CSS_FLEX_DIRECTION_COLUMN_REVERSE;
|
|
8049
|
-
}
|
|
8050
|
-
|
|
8051
|
-
function getLeadingMargin(node, axis) {
|
|
8052
|
-
if (node.style.marginStart !== undefined && isRowDirection(axis)) {
|
|
8053
|
-
return node.style.marginStart;
|
|
8054
|
-
}
|
|
8055
|
-
|
|
8056
|
-
var value = null;
|
|
8057
|
-
switch (axis) {
|
|
8058
|
-
case 'row': value = node.style.marginLeft; break;
|
|
8059
|
-
case 'row-reverse': value = node.style.marginRight; break;
|
|
8060
|
-
case 'column': value = node.style.marginTop; break;
|
|
8061
|
-
case 'column-reverse': value = node.style.marginBottom; break;
|
|
8062
|
-
}
|
|
8063
|
-
|
|
8064
|
-
if (value !== undefined) {
|
|
8065
|
-
return value;
|
|
8066
|
-
}
|
|
8067
|
-
|
|
8068
|
-
if (node.style.margin !== undefined) {
|
|
8069
|
-
return node.style.margin;
|
|
8070
|
-
}
|
|
8071
|
-
|
|
8072
|
-
return 0;
|
|
8073
|
-
}
|
|
8074
|
-
|
|
8075
|
-
function getTrailingMargin(node, axis) {
|
|
8076
|
-
if (node.style.marginEnd !== undefined && isRowDirection(axis)) {
|
|
8077
|
-
return node.style.marginEnd;
|
|
8078
|
-
}
|
|
8079
|
-
|
|
8080
|
-
var value = null;
|
|
8081
|
-
switch (axis) {
|
|
8082
|
-
case 'row': value = node.style.marginRight; break;
|
|
8083
|
-
case 'row-reverse': value = node.style.marginLeft; break;
|
|
8084
|
-
case 'column': value = node.style.marginBottom; break;
|
|
8085
|
-
case 'column-reverse': value = node.style.marginTop; break;
|
|
8086
|
-
}
|
|
8087
|
-
|
|
8088
|
-
if (value != null) {
|
|
8089
|
-
return value;
|
|
8090
|
-
}
|
|
8091
|
-
|
|
8092
|
-
if (node.style.margin !== undefined) {
|
|
8093
|
-
return node.style.margin;
|
|
8094
|
-
}
|
|
8095
|
-
|
|
8096
|
-
return 0;
|
|
8097
|
-
}
|
|
8098
|
-
|
|
8099
|
-
function getLeadingPadding(node, axis) {
|
|
8100
|
-
if (node.style.paddingStart !== undefined && node.style.paddingStart >= 0
|
|
8101
|
-
&& isRowDirection(axis)) {
|
|
8102
|
-
return node.style.paddingStart;
|
|
8103
|
-
}
|
|
8104
|
-
|
|
8105
|
-
var value = null;
|
|
8106
|
-
switch (axis) {
|
|
8107
|
-
case 'row': value = node.style.paddingLeft; break;
|
|
8108
|
-
case 'row-reverse': value = node.style.paddingRight; break;
|
|
8109
|
-
case 'column': value = node.style.paddingTop; break;
|
|
8110
|
-
case 'column-reverse': value = node.style.paddingBottom; break;
|
|
8111
|
-
}
|
|
8112
|
-
|
|
8113
|
-
if (value != null && value >= 0) {
|
|
8114
|
-
return value;
|
|
8115
|
-
}
|
|
8116
|
-
|
|
8117
|
-
if (node.style.padding !== undefined && node.style.padding >= 0) {
|
|
8118
|
-
return node.style.padding;
|
|
8119
|
-
}
|
|
8120
|
-
|
|
8121
|
-
return 0;
|
|
8122
|
-
}
|
|
8123
|
-
|
|
8124
|
-
function getTrailingPadding(node, axis) {
|
|
8125
|
-
if (node.style.paddingEnd !== undefined && node.style.paddingEnd >= 0
|
|
8126
|
-
&& isRowDirection(axis)) {
|
|
8127
|
-
return node.style.paddingEnd;
|
|
8128
|
-
}
|
|
8129
|
-
|
|
8130
|
-
var value = null;
|
|
8131
|
-
switch (axis) {
|
|
8132
|
-
case 'row': value = node.style.paddingRight; break;
|
|
8133
|
-
case 'row-reverse': value = node.style.paddingLeft; break;
|
|
8134
|
-
case 'column': value = node.style.paddingBottom; break;
|
|
8135
|
-
case 'column-reverse': value = node.style.paddingTop; break;
|
|
8136
|
-
}
|
|
8137
|
-
|
|
8138
|
-
if (value != null && value >= 0) {
|
|
8139
|
-
return value;
|
|
8140
|
-
}
|
|
8141
|
-
|
|
8142
|
-
if (node.style.padding !== undefined && node.style.padding >= 0) {
|
|
8143
|
-
return node.style.padding;
|
|
8144
|
-
}
|
|
8145
|
-
|
|
8146
|
-
return 0;
|
|
8147
|
-
}
|
|
8148
|
-
|
|
8149
|
-
function getLeadingBorder(node, axis) {
|
|
8150
|
-
if (node.style.borderStartWidth !== undefined && node.style.borderStartWidth >= 0
|
|
8151
|
-
&& isRowDirection(axis)) {
|
|
8152
|
-
return node.style.borderStartWidth;
|
|
8153
|
-
}
|
|
8154
|
-
|
|
8155
|
-
var value = null;
|
|
8156
|
-
switch (axis) {
|
|
8157
|
-
case 'row': value = node.style.borderLeftWidth; break;
|
|
8158
|
-
case 'row-reverse': value = node.style.borderRightWidth; break;
|
|
8159
|
-
case 'column': value = node.style.borderTopWidth; break;
|
|
8160
|
-
case 'column-reverse': value = node.style.borderBottomWidth; break;
|
|
8161
|
-
}
|
|
8162
|
-
|
|
8163
|
-
if (value != null && value >= 0) {
|
|
8164
|
-
return value;
|
|
8165
|
-
}
|
|
8166
|
-
|
|
8167
|
-
if (node.style.borderWidth !== undefined && node.style.borderWidth >= 0) {
|
|
8168
|
-
return node.style.borderWidth;
|
|
8169
|
-
}
|
|
8170
|
-
|
|
8171
|
-
return 0;
|
|
8172
|
-
}
|
|
8173
|
-
|
|
8174
|
-
function getTrailingBorder(node, axis) {
|
|
8175
|
-
if (node.style.borderEndWidth !== undefined && node.style.borderEndWidth >= 0
|
|
8176
|
-
&& isRowDirection(axis)) {
|
|
8177
|
-
return node.style.borderEndWidth;
|
|
8178
|
-
}
|
|
8179
|
-
|
|
8180
|
-
var value = null;
|
|
8181
|
-
switch (axis) {
|
|
8182
|
-
case 'row': value = node.style.borderRightWidth; break;
|
|
8183
|
-
case 'row-reverse': value = node.style.borderLeftWidth; break;
|
|
8184
|
-
case 'column': value = node.style.borderBottomWidth; break;
|
|
8185
|
-
case 'column-reverse': value = node.style.borderTopWidth; break;
|
|
8186
|
-
}
|
|
8187
|
-
|
|
8188
|
-
if (value != null && value >= 0) {
|
|
8189
|
-
return value;
|
|
8190
|
-
}
|
|
8191
|
-
|
|
8192
|
-
if (node.style.borderWidth !== undefined && node.style.borderWidth >= 0) {
|
|
8193
|
-
return node.style.borderWidth;
|
|
8194
|
-
}
|
|
8195
|
-
|
|
8196
|
-
return 0;
|
|
8197
|
-
}
|
|
8198
|
-
|
|
8199
|
-
function getLeadingPaddingAndBorder(node, axis) {
|
|
8200
|
-
return getLeadingPadding(node, axis) + getLeadingBorder(node, axis);
|
|
8201
|
-
}
|
|
8202
|
-
|
|
8203
|
-
function getTrailingPaddingAndBorder(node, axis) {
|
|
8204
|
-
return getTrailingPadding(node, axis) + getTrailingBorder(node, axis);
|
|
8205
|
-
}
|
|
8206
|
-
|
|
8207
|
-
function getBorderAxis(node, axis) {
|
|
8208
|
-
return getLeadingBorder(node, axis) + getTrailingBorder(node, axis);
|
|
8209
|
-
}
|
|
8210
|
-
|
|
8211
|
-
function getMarginAxis(node, axis) {
|
|
8212
|
-
return getLeadingMargin(node, axis) + getTrailingMargin(node, axis);
|
|
8213
|
-
}
|
|
8214
|
-
|
|
8215
|
-
function getPaddingAndBorderAxis(node, axis) {
|
|
8216
|
-
return getLeadingPaddingAndBorder(node, axis) +
|
|
8217
|
-
getTrailingPaddingAndBorder(node, axis);
|
|
8218
|
-
}
|
|
8219
|
-
|
|
8220
|
-
function getJustifyContent(node) {
|
|
8221
|
-
if (node.style.justifyContent) {
|
|
8222
|
-
return node.style.justifyContent;
|
|
8223
|
-
}
|
|
8224
|
-
return 'flex-start';
|
|
8225
|
-
}
|
|
8226
|
-
|
|
8227
|
-
function getAlignContent(node) {
|
|
8228
|
-
if (node.style.alignContent) {
|
|
8229
|
-
return node.style.alignContent;
|
|
8230
|
-
}
|
|
8231
|
-
return 'flex-start';
|
|
8232
|
-
}
|
|
8233
|
-
|
|
8234
|
-
function getAlignItem(node, child) {
|
|
8235
|
-
if (child.style.alignSelf) {
|
|
8236
|
-
return child.style.alignSelf;
|
|
8237
|
-
}
|
|
8238
|
-
if (node.style.alignItems) {
|
|
8239
|
-
return node.style.alignItems;
|
|
8240
|
-
}
|
|
8241
|
-
return 'stretch';
|
|
8242
|
-
}
|
|
8243
|
-
|
|
8244
|
-
function resolveAxis(axis, direction) {
|
|
8245
|
-
if (direction === CSS_DIRECTION_RTL) {
|
|
8246
|
-
if (axis === CSS_FLEX_DIRECTION_ROW) {
|
|
8247
|
-
return CSS_FLEX_DIRECTION_ROW_REVERSE;
|
|
8248
|
-
} else if (axis === CSS_FLEX_DIRECTION_ROW_REVERSE) {
|
|
8249
|
-
return CSS_FLEX_DIRECTION_ROW;
|
|
8250
|
-
}
|
|
8251
|
-
}
|
|
8252
|
-
|
|
8253
|
-
return axis;
|
|
8254
|
-
}
|
|
8255
|
-
|
|
8256
|
-
function resolveDirection(node, parentDirection) {
|
|
8257
|
-
var direction;
|
|
8258
|
-
if (node.style.direction) {
|
|
8259
|
-
direction = node.style.direction;
|
|
8260
|
-
} else {
|
|
8261
|
-
direction = CSS_DIRECTION_INHERIT;
|
|
8262
|
-
}
|
|
8263
|
-
|
|
8264
|
-
if (direction === CSS_DIRECTION_INHERIT) {
|
|
8265
|
-
direction = (parentDirection === undefined ? CSS_DIRECTION_LTR : parentDirection);
|
|
8266
|
-
}
|
|
8267
|
-
|
|
8268
|
-
return direction;
|
|
8269
|
-
}
|
|
8270
|
-
|
|
8271
|
-
function getFlexDirection(node) {
|
|
8272
|
-
if (node.style.flexDirection) {
|
|
8273
|
-
return node.style.flexDirection;
|
|
8274
|
-
}
|
|
8275
|
-
return CSS_FLEX_DIRECTION_COLUMN;
|
|
8276
|
-
}
|
|
8277
|
-
|
|
8278
|
-
function getCrossFlexDirection(flexDirection, direction) {
|
|
8279
|
-
if (isColumnDirection(flexDirection)) {
|
|
8280
|
-
return resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
|
|
8281
|
-
} else {
|
|
8282
|
-
return CSS_FLEX_DIRECTION_COLUMN;
|
|
8283
|
-
}
|
|
8284
|
-
}
|
|
8285
|
-
|
|
8286
|
-
function getPositionType(node) {
|
|
8287
|
-
if (node.style.position) {
|
|
8288
|
-
return node.style.position;
|
|
8289
|
-
}
|
|
8290
|
-
return 'relative';
|
|
8291
|
-
}
|
|
8292
|
-
|
|
8293
|
-
function isFlex(node) {
|
|
8294
|
-
return (
|
|
8295
|
-
getPositionType(node) === CSS_POSITION_RELATIVE &&
|
|
8296
|
-
node.style.flex > 0
|
|
8297
|
-
);
|
|
8298
|
-
}
|
|
8299
|
-
|
|
8300
|
-
function isFlexWrap(node) {
|
|
8301
|
-
return node.style.flexWrap === 'wrap';
|
|
8302
|
-
}
|
|
8303
|
-
|
|
8304
|
-
function getDimWithMargin(node, axis) {
|
|
8305
|
-
return node.layout[dim[axis]] + getMarginAxis(node, axis);
|
|
8306
|
-
}
|
|
8307
|
-
|
|
8308
|
-
function isDimDefined(node, axis) {
|
|
8309
|
-
return node.style[dim[axis]] !== undefined && node.style[dim[axis]] >= 0;
|
|
8310
|
-
}
|
|
8311
|
-
|
|
8312
|
-
function isPosDefined(node, pos) {
|
|
8313
|
-
return node.style[pos] !== undefined;
|
|
8314
|
-
}
|
|
8315
|
-
|
|
8316
|
-
function isMeasureDefined(node) {
|
|
8317
|
-
return node.style.measure !== undefined;
|
|
8318
|
-
}
|
|
8319
|
-
|
|
8320
|
-
function getPosition(node, pos) {
|
|
8321
|
-
if (node.style[pos] !== undefined) {
|
|
8322
|
-
return node.style[pos];
|
|
8323
|
-
}
|
|
8324
|
-
return 0;
|
|
8325
|
-
}
|
|
8326
|
-
|
|
8327
|
-
function boundAxis(node, axis, value) {
|
|
8328
|
-
var min = {
|
|
8329
|
-
'row': node.style.minWidth,
|
|
8330
|
-
'row-reverse': node.style.minWidth,
|
|
8331
|
-
'column': node.style.minHeight,
|
|
8332
|
-
'column-reverse': node.style.minHeight
|
|
8333
|
-
}[axis];
|
|
8334
|
-
|
|
8335
|
-
var max = {
|
|
8336
|
-
'row': node.style.maxWidth,
|
|
8337
|
-
'row-reverse': node.style.maxWidth,
|
|
8338
|
-
'column': node.style.maxHeight,
|
|
8339
|
-
'column-reverse': node.style.maxHeight
|
|
8340
|
-
}[axis];
|
|
8341
|
-
|
|
8342
|
-
var boundValue = value;
|
|
8343
|
-
if (max !== undefined && max >= 0 && boundValue > max) {
|
|
8344
|
-
boundValue = max;
|
|
8345
|
-
}
|
|
8346
|
-
if (min !== undefined && min >= 0 && boundValue < min) {
|
|
8347
|
-
boundValue = min;
|
|
8348
|
-
}
|
|
8349
|
-
return boundValue;
|
|
8350
|
-
}
|
|
8351
|
-
|
|
8352
|
-
function fmaxf(a, b) {
|
|
8353
|
-
if (a > b) {
|
|
8354
|
-
return a;
|
|
8355
|
-
}
|
|
8356
|
-
return b;
|
|
8357
|
-
}
|
|
8358
|
-
|
|
8359
|
-
// When the user specifically sets a value for width or height
|
|
8360
|
-
function setDimensionFromStyle(node, axis) {
|
|
8361
|
-
// The parent already computed us a width or height. We just skip it
|
|
8362
|
-
if (node.layout[dim[axis]] !== undefined) {
|
|
8363
|
-
return;
|
|
8364
|
-
}
|
|
8365
|
-
// We only run if there's a width or height defined
|
|
8366
|
-
if (!isDimDefined(node, axis)) {
|
|
8367
|
-
return;
|
|
8368
|
-
}
|
|
8369
|
-
|
|
8370
|
-
// The dimensions can never be smaller than the padding and border
|
|
8371
|
-
node.layout[dim[axis]] = fmaxf(
|
|
8372
|
-
boundAxis(node, axis, node.style[dim[axis]]),
|
|
8373
|
-
getPaddingAndBorderAxis(node, axis)
|
|
8374
|
-
);
|
|
8375
|
-
}
|
|
8376
|
-
|
|
8377
|
-
function setTrailingPosition(node, child, axis) {
|
|
8378
|
-
child.layout[trailing[axis]] = node.layout[dim[axis]] -
|
|
8379
|
-
child.layout[dim[axis]] - child.layout[pos[axis]];
|
|
8380
|
-
}
|
|
8381
|
-
|
|
8382
|
-
// If both left and right are defined, then use left. Otherwise return
|
|
8383
|
-
// +left or -right depending on which is defined.
|
|
8384
|
-
function getRelativePosition(node, axis) {
|
|
8385
|
-
if (node.style[leading[axis]] !== undefined) {
|
|
8386
|
-
return getPosition(node, leading[axis]);
|
|
8387
|
-
}
|
|
8388
|
-
return -getPosition(node, trailing[axis]);
|
|
8389
|
-
}
|
|
8390
|
-
|
|
8391
|
-
function layoutNodeImpl(node, parentMaxWidth, /*css_direction_t*/parentDirection) {
|
|
8392
|
-
var/*css_direction_t*/ direction = resolveDirection(node, parentDirection);
|
|
8393
|
-
var/*(c)!css_flex_direction_t*//*(java)!int*/ mainAxis = resolveAxis(getFlexDirection(node), direction);
|
|
8394
|
-
var/*(c)!css_flex_direction_t*//*(java)!int*/ crossAxis = getCrossFlexDirection(mainAxis, direction);
|
|
8395
|
-
var/*(c)!css_flex_direction_t*//*(java)!int*/ resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
|
|
8396
|
-
|
|
8397
|
-
// Handle width and height style attributes
|
|
8398
|
-
setDimensionFromStyle(node, mainAxis);
|
|
8399
|
-
setDimensionFromStyle(node, crossAxis);
|
|
8400
|
-
|
|
8401
|
-
// Set the resolved resolution in the node's layout
|
|
8402
|
-
node.layout.direction = direction;
|
|
8403
|
-
|
|
8404
|
-
// The position is set by the parent, but we need to complete it with a
|
|
8405
|
-
// delta composed of the margin and left/top/right/bottom
|
|
8406
|
-
node.layout[leading[mainAxis]] += getLeadingMargin(node, mainAxis) +
|
|
8407
|
-
getRelativePosition(node, mainAxis);
|
|
8408
|
-
node.layout[trailing[mainAxis]] += getTrailingMargin(node, mainAxis) +
|
|
8409
|
-
getRelativePosition(node, mainAxis);
|
|
8410
|
-
node.layout[leading[crossAxis]] += getLeadingMargin(node, crossAxis) +
|
|
8411
|
-
getRelativePosition(node, crossAxis);
|
|
8412
|
-
node.layout[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) +
|
|
8413
|
-
getRelativePosition(node, crossAxis);
|
|
8414
|
-
|
|
8415
|
-
// Inline immutable values from the target node to avoid excessive method
|
|
8416
|
-
// invocations during the layout calculation.
|
|
8417
|
-
var/*int*/ childCount = node.children.length;
|
|
8418
|
-
var/*float*/ paddingAndBorderAxisResolvedRow = getPaddingAndBorderAxis(node, resolvedRowAxis);
|
|
8419
|
-
|
|
8420
|
-
if (isMeasureDefined(node)) {
|
|
8421
|
-
var/*bool*/ isResolvedRowDimDefined = !isUndefined(node.layout[dim[resolvedRowAxis]]);
|
|
8422
|
-
|
|
8423
|
-
var/*float*/ width = CSS_UNDEFINED;
|
|
8424
|
-
if (isDimDefined(node, resolvedRowAxis)) {
|
|
8425
|
-
width = node.style.width;
|
|
8426
|
-
} else if (isResolvedRowDimDefined) {
|
|
8427
|
-
width = node.layout[dim[resolvedRowAxis]];
|
|
8428
|
-
} else {
|
|
8429
|
-
width = parentMaxWidth -
|
|
8430
|
-
getMarginAxis(node, resolvedRowAxis);
|
|
8431
|
-
}
|
|
8432
|
-
width -= paddingAndBorderAxisResolvedRow;
|
|
8433
|
-
|
|
8434
|
-
// We only need to give a dimension for the text if we haven't got any
|
|
8435
|
-
// for it computed yet. It can either be from the style attribute or because
|
|
8436
|
-
// the element is flexible.
|
|
8437
|
-
var/*bool*/ isRowUndefined = !isDimDefined(node, resolvedRowAxis) && !isResolvedRowDimDefined;
|
|
8438
|
-
var/*bool*/ isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) &&
|
|
8439
|
-
isUndefined(node.layout[dim[CSS_FLEX_DIRECTION_COLUMN]]);
|
|
8440
|
-
|
|
8441
|
-
// Let's not measure the text if we already know both dimensions
|
|
8442
|
-
if (isRowUndefined || isColumnUndefined) {
|
|
8443
|
-
var/*css_dim_t*/ measureDim = node.style.measure(
|
|
8444
|
-
/*(c)!node->context,*/
|
|
8445
|
-
/*(java)!layoutContext.measureOutput,*/
|
|
8446
|
-
width
|
|
8447
|
-
);
|
|
8448
|
-
if (isRowUndefined) {
|
|
8449
|
-
node.layout.width = measureDim.width +
|
|
8450
|
-
paddingAndBorderAxisResolvedRow;
|
|
8451
|
-
}
|
|
8452
|
-
if (isColumnUndefined) {
|
|
8453
|
-
node.layout.height = measureDim.height +
|
|
8454
|
-
getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN);
|
|
8455
|
-
}
|
|
8456
|
-
}
|
|
8457
|
-
if (childCount === 0) {
|
|
8458
|
-
return;
|
|
8459
|
-
}
|
|
8460
|
-
}
|
|
8461
|
-
|
|
8462
|
-
var/*bool*/ isNodeFlexWrap = isFlexWrap(node);
|
|
8463
|
-
|
|
8464
|
-
var/*css_justify_t*/ justifyContent = getJustifyContent(node);
|
|
8465
|
-
|
|
8466
|
-
var/*float*/ leadingPaddingAndBorderMain = getLeadingPaddingAndBorder(node, mainAxis);
|
|
8467
|
-
var/*float*/ leadingPaddingAndBorderCross = getLeadingPaddingAndBorder(node, crossAxis);
|
|
8468
|
-
var/*float*/ paddingAndBorderAxisMain = getPaddingAndBorderAxis(node, mainAxis);
|
|
8469
|
-
var/*float*/ paddingAndBorderAxisCross = getPaddingAndBorderAxis(node, crossAxis);
|
|
8470
|
-
|
|
8471
|
-
var/*bool*/ isMainDimDefined = !isUndefined(node.layout[dim[mainAxis]]);
|
|
8472
|
-
var/*bool*/ isCrossDimDefined = !isUndefined(node.layout[dim[crossAxis]]);
|
|
8473
|
-
var/*bool*/ isMainRowDirection = isRowDirection(mainAxis);
|
|
8474
|
-
|
|
8475
|
-
var/*int*/ i;
|
|
8476
|
-
var/*int*/ ii;
|
|
8477
|
-
var/*css_node_t**/ child;
|
|
8478
|
-
var/*(c)!css_flex_direction_t*//*(java)!int*/ axis;
|
|
8479
|
-
|
|
8480
|
-
var/*css_node_t**/ firstAbsoluteChild = null;
|
|
8481
|
-
var/*css_node_t**/ currentAbsoluteChild = null;
|
|
8482
|
-
|
|
8483
|
-
var/*float*/ definedMainDim = CSS_UNDEFINED;
|
|
8484
|
-
if (isMainDimDefined) {
|
|
8485
|
-
definedMainDim = node.layout[dim[mainAxis]] - paddingAndBorderAxisMain;
|
|
8486
|
-
}
|
|
8487
|
-
|
|
8488
|
-
// We want to execute the next two loops one per line with flex-wrap
|
|
8489
|
-
var/*int*/ startLine = 0;
|
|
8490
|
-
var/*int*/ endLine = 0;
|
|
8491
|
-
// var/*int*/ nextOffset = 0;
|
|
8492
|
-
var/*int*/ alreadyComputedNextLayout = 0;
|
|
8493
|
-
// We aggregate the total dimensions of the container in those two variables
|
|
8494
|
-
var/*float*/ linesCrossDim = 0;
|
|
8495
|
-
var/*float*/ linesMainDim = 0;
|
|
8496
|
-
var/*int*/ linesCount = 0;
|
|
8497
|
-
while (endLine < childCount) {
|
|
8498
|
-
// <Loop A> Layout non flexible children and count children by type
|
|
8499
|
-
|
|
8500
|
-
// mainContentDim is accumulation of the dimensions and margin of all the
|
|
8501
|
-
// non flexible children. This will be used in order to either set the
|
|
8502
|
-
// dimensions of the node if none already exist, or to compute the
|
|
8503
|
-
// remaining space left for the flexible children.
|
|
8504
|
-
var/*float*/ mainContentDim = 0;
|
|
8505
|
-
|
|
8506
|
-
// There are three kind of children, non flexible, flexible and absolute.
|
|
8507
|
-
// We need to know how many there are in order to distribute the space.
|
|
8508
|
-
var/*int*/ flexibleChildrenCount = 0;
|
|
8509
|
-
var/*float*/ totalFlexible = 0;
|
|
8510
|
-
var/*int*/ nonFlexibleChildrenCount = 0;
|
|
8511
|
-
|
|
8512
|
-
// Use the line loop to position children in the main axis for as long
|
|
8513
|
-
// as they are using a simple stacking behaviour. Children that are
|
|
8514
|
-
// immediately stacked in the initial loop will not be touched again
|
|
8515
|
-
// in <Loop C>.
|
|
8516
|
-
var/*bool*/ isSimpleStackMain =
|
|
8517
|
-
(isMainDimDefined && justifyContent === CSS_JUSTIFY_FLEX_START) ||
|
|
8518
|
-
(!isMainDimDefined && justifyContent !== CSS_JUSTIFY_CENTER);
|
|
8519
|
-
var/*int*/ firstComplexMain = (isSimpleStackMain ? childCount : startLine);
|
|
8520
|
-
|
|
8521
|
-
// Use the initial line loop to position children in the cross axis for
|
|
8522
|
-
// as long as they are relatively positioned with alignment STRETCH or
|
|
8523
|
-
// FLEX_START. Children that are immediately stacked in the initial loop
|
|
8524
|
-
// will not be touched again in <Loop D>.
|
|
8525
|
-
var/*bool*/ isSimpleStackCross = true;
|
|
8526
|
-
var/*int*/ firstComplexCross = childCount;
|
|
8527
|
-
|
|
8528
|
-
var/*css_node_t**/ firstFlexChild = null;
|
|
8529
|
-
var/*css_node_t**/ currentFlexChild = null;
|
|
8530
|
-
|
|
8531
|
-
var/*float*/ mainDim = leadingPaddingAndBorderMain;
|
|
8532
|
-
var/*float*/ crossDim = 0;
|
|
8533
|
-
|
|
8534
|
-
var/*float*/ maxWidth;
|
|
8535
|
-
for (i = startLine; i < childCount; ++i) {
|
|
8536
|
-
child = node.children[i];
|
|
8537
|
-
child.lineIndex = linesCount;
|
|
8538
|
-
|
|
8539
|
-
child.nextAbsoluteChild = null;
|
|
8540
|
-
child.nextFlexChild = null;
|
|
8541
|
-
|
|
8542
|
-
var/*css_align_t*/ alignItem = getAlignItem(node, child);
|
|
8543
|
-
|
|
8544
|
-
// Pre-fill cross axis dimensions when the child is using stretch before
|
|
8545
|
-
// we call the recursive layout pass
|
|
8546
|
-
if (alignItem === CSS_ALIGN_STRETCH &&
|
|
8547
|
-
getPositionType(child) === CSS_POSITION_RELATIVE &&
|
|
8548
|
-
isCrossDimDefined &&
|
|
8549
|
-
!isDimDefined(child, crossAxis)) {
|
|
8550
|
-
child.layout[dim[crossAxis]] = fmaxf(
|
|
8551
|
-
boundAxis(child, crossAxis, node.layout[dim[crossAxis]] -
|
|
8552
|
-
paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)),
|
|
8553
|
-
// You never want to go smaller than padding
|
|
8554
|
-
getPaddingAndBorderAxis(child, crossAxis)
|
|
8555
|
-
);
|
|
8556
|
-
} else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) {
|
|
8557
|
-
// Store a private linked list of absolutely positioned children
|
|
8558
|
-
// so that we can efficiently traverse them later.
|
|
8559
|
-
if (firstAbsoluteChild === null) {
|
|
8560
|
-
firstAbsoluteChild = child;
|
|
8561
|
-
}
|
|
8562
|
-
if (currentAbsoluteChild !== null) {
|
|
8563
|
-
currentAbsoluteChild.nextAbsoluteChild = child;
|
|
8564
|
-
}
|
|
8565
|
-
currentAbsoluteChild = child;
|
|
8566
|
-
|
|
8567
|
-
// Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both
|
|
8568
|
-
// left and right or top and bottom).
|
|
8569
|
-
for (ii = 0; ii < 2; ii++) {
|
|
8570
|
-
axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
|
8571
|
-
if (!isUndefined(node.layout[dim[axis]]) &&
|
|
8572
|
-
!isDimDefined(child, axis) &&
|
|
8573
|
-
isPosDefined(child, leading[axis]) &&
|
|
8574
|
-
isPosDefined(child, trailing[axis])) {
|
|
8575
|
-
child.layout[dim[axis]] = fmaxf(
|
|
8576
|
-
boundAxis(child, axis, node.layout[dim[axis]] -
|
|
8577
|
-
getPaddingAndBorderAxis(node, axis) -
|
|
8578
|
-
getMarginAxis(child, axis) -
|
|
8579
|
-
getPosition(child, leading[axis]) -
|
|
8580
|
-
getPosition(child, trailing[axis])),
|
|
8581
|
-
// You never want to go smaller than padding
|
|
8582
|
-
getPaddingAndBorderAxis(child, axis)
|
|
8583
|
-
);
|
|
8584
|
-
}
|
|
8585
|
-
}
|
|
8586
|
-
}
|
|
8587
|
-
|
|
8588
|
-
var/*float*/ nextContentDim = 0;
|
|
8589
|
-
|
|
8590
|
-
// It only makes sense to consider a child flexible if we have a computed
|
|
8591
|
-
// dimension for the node.
|
|
8592
|
-
if (isMainDimDefined && isFlex(child)) {
|
|
8593
|
-
flexibleChildrenCount++;
|
|
8594
|
-
totalFlexible += child.style.flex;
|
|
8595
|
-
|
|
8596
|
-
// Store a private linked list of flexible children so that we can
|
|
8597
|
-
// efficiently traverse them later.
|
|
8598
|
-
if (firstFlexChild === null) {
|
|
8599
|
-
firstFlexChild = child;
|
|
8600
|
-
}
|
|
8601
|
-
if (currentFlexChild !== null) {
|
|
8602
|
-
currentFlexChild.nextFlexChild = child;
|
|
8603
|
-
}
|
|
8604
|
-
currentFlexChild = child;
|
|
8605
|
-
|
|
8606
|
-
// Even if we don't know its exact size yet, we already know the padding,
|
|
8607
|
-
// border and margin. We'll use this partial information, which represents
|
|
8608
|
-
// the smallest possible size for the child, to compute the remaining
|
|
8609
|
-
// available space.
|
|
8610
|
-
nextContentDim = getPaddingAndBorderAxis(child, mainAxis) +
|
|
8611
|
-
getMarginAxis(child, mainAxis);
|
|
8612
|
-
|
|
8613
|
-
} else {
|
|
8614
|
-
maxWidth = CSS_UNDEFINED;
|
|
8615
|
-
if (!isMainRowDirection) {
|
|
8616
|
-
if (isDimDefined(node, resolvedRowAxis)) {
|
|
8617
|
-
maxWidth = node.layout[dim[resolvedRowAxis]] -
|
|
8618
|
-
paddingAndBorderAxisResolvedRow;
|
|
8619
|
-
} else {
|
|
8620
|
-
maxWidth = parentMaxWidth -
|
|
8621
|
-
getMarginAxis(node, resolvedRowAxis) -
|
|
8622
|
-
paddingAndBorderAxisResolvedRow;
|
|
8623
|
-
}
|
|
8624
|
-
}
|
|
8625
|
-
|
|
8626
|
-
// This is the main recursive call. We layout non flexible children.
|
|
8627
|
-
if (alreadyComputedNextLayout === 0) {
|
|
8628
|
-
layoutNode(/*(java)!layoutContext, */child, maxWidth, direction);
|
|
8629
|
-
}
|
|
8630
|
-
|
|
8631
|
-
// Absolute positioned elements do not take part of the layout, so we
|
|
8632
|
-
// don't use them to compute mainContentDim
|
|
8633
|
-
if (getPositionType(child) === CSS_POSITION_RELATIVE) {
|
|
8634
|
-
nonFlexibleChildrenCount++;
|
|
8635
|
-
// At this point we know the final size and margin of the element.
|
|
8636
|
-
nextContentDim = getDimWithMargin(child, mainAxis);
|
|
8637
|
-
}
|
|
8638
|
-
}
|
|
8639
|
-
|
|
8640
|
-
// The element we are about to add would make us go to the next line
|
|
8641
|
-
if (isNodeFlexWrap &&
|
|
8642
|
-
isMainDimDefined &&
|
|
8643
|
-
mainContentDim + nextContentDim > definedMainDim &&
|
|
8644
|
-
// If there's only one element, then it's bigger than the content
|
|
8645
|
-
// and needs its own line
|
|
8646
|
-
i !== startLine) {
|
|
8647
|
-
nonFlexibleChildrenCount--;
|
|
8648
|
-
alreadyComputedNextLayout = 1;
|
|
8649
|
-
break;
|
|
8650
|
-
}
|
|
8651
|
-
|
|
8652
|
-
// Disable simple stacking in the main axis for the current line as
|
|
8653
|
-
// we found a non-trivial child. The remaining children will be laid out
|
|
8654
|
-
// in <Loop C>.
|
|
8655
|
-
if (isSimpleStackMain &&
|
|
8656
|
-
(getPositionType(child) !== CSS_POSITION_RELATIVE || isFlex(child))) {
|
|
8657
|
-
isSimpleStackMain = false;
|
|
8658
|
-
firstComplexMain = i;
|
|
8659
|
-
}
|
|
8660
|
-
|
|
8661
|
-
// Disable simple stacking in the cross axis for the current line as
|
|
8662
|
-
// we found a non-trivial child. The remaining children will be laid out
|
|
8663
|
-
// in <Loop D>.
|
|
8664
|
-
if (isSimpleStackCross &&
|
|
8665
|
-
(getPositionType(child) !== CSS_POSITION_RELATIVE ||
|
|
8666
|
-
(alignItem !== CSS_ALIGN_STRETCH && alignItem !== CSS_ALIGN_FLEX_START) ||
|
|
8667
|
-
isUndefined(child.layout[dim[crossAxis]]))) {
|
|
8668
|
-
isSimpleStackCross = false;
|
|
8669
|
-
firstComplexCross = i;
|
|
8670
|
-
}
|
|
8671
|
-
|
|
8672
|
-
if (isSimpleStackMain) {
|
|
8673
|
-
child.layout[pos[mainAxis]] += mainDim;
|
|
8674
|
-
if (isMainDimDefined) {
|
|
8675
|
-
setTrailingPosition(node, child, mainAxis);
|
|
8676
|
-
}
|
|
8677
|
-
|
|
8678
|
-
mainDim += getDimWithMargin(child, mainAxis);
|
|
8679
|
-
crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis)));
|
|
8680
|
-
}
|
|
8681
|
-
|
|
8682
|
-
if (isSimpleStackCross) {
|
|
8683
|
-
child.layout[pos[crossAxis]] += linesCrossDim + leadingPaddingAndBorderCross;
|
|
8684
|
-
if (isCrossDimDefined) {
|
|
8685
|
-
setTrailingPosition(node, child, crossAxis);
|
|
8686
|
-
}
|
|
8687
|
-
}
|
|
8688
|
-
|
|
8689
|
-
alreadyComputedNextLayout = 0;
|
|
8690
|
-
mainContentDim += nextContentDim;
|
|
8691
|
-
endLine = i + 1;
|
|
8692
|
-
}
|
|
8693
|
-
|
|
8694
|
-
// <Loop B> Layout flexible children and allocate empty space
|
|
8695
|
-
|
|
8696
|
-
// In order to position the elements in the main axis, we have two
|
|
8697
|
-
// controls. The space between the beginning and the first element
|
|
8698
|
-
// and the space between each two elements.
|
|
8699
|
-
var/*float*/ leadingMainDim = 0;
|
|
8700
|
-
var/*float*/ betweenMainDim = 0;
|
|
8701
|
-
|
|
8702
|
-
// The remaining available space that needs to be allocated
|
|
8703
|
-
var/*float*/ remainingMainDim = 0;
|
|
8704
|
-
if (isMainDimDefined) {
|
|
8705
|
-
remainingMainDim = definedMainDim - mainContentDim;
|
|
8706
|
-
} else {
|
|
8707
|
-
remainingMainDim = fmaxf(mainContentDim, 0) - mainContentDim;
|
|
8708
|
-
}
|
|
8709
|
-
|
|
8710
|
-
// If there are flexible children in the mix, they are going to fill the
|
|
8711
|
-
// remaining space
|
|
8712
|
-
if (flexibleChildrenCount !== 0) {
|
|
8713
|
-
var/*float*/ flexibleMainDim = remainingMainDim / totalFlexible;
|
|
8714
|
-
var/*float*/ baseMainDim;
|
|
8715
|
-
var/*float*/ boundMainDim;
|
|
8716
|
-
|
|
8717
|
-
// If the flex share of remaining space doesn't meet min/max bounds,
|
|
8718
|
-
// remove this child from flex calculations.
|
|
8719
|
-
currentFlexChild = firstFlexChild;
|
|
8720
|
-
while (currentFlexChild !== null) {
|
|
8721
|
-
baseMainDim = flexibleMainDim * currentFlexChild.style.flex +
|
|
8722
|
-
getPaddingAndBorderAxis(currentFlexChild, mainAxis);
|
|
8723
|
-
boundMainDim = boundAxis(currentFlexChild, mainAxis, baseMainDim);
|
|
8724
|
-
|
|
8725
|
-
if (baseMainDim !== boundMainDim) {
|
|
8726
|
-
remainingMainDim -= boundMainDim;
|
|
8727
|
-
totalFlexible -= currentFlexChild.style.flex;
|
|
8728
|
-
}
|
|
8729
|
-
|
|
8730
|
-
currentFlexChild = currentFlexChild.nextFlexChild;
|
|
8731
|
-
}
|
|
8732
|
-
flexibleMainDim = remainingMainDim / totalFlexible;
|
|
8733
|
-
|
|
8734
|
-
// The non flexible children can overflow the container, in this case
|
|
8735
|
-
// we should just assume that there is no space available.
|
|
8736
|
-
if (flexibleMainDim < 0) {
|
|
8737
|
-
flexibleMainDim = 0;
|
|
8738
|
-
}
|
|
8739
|
-
|
|
8740
|
-
currentFlexChild = firstFlexChild;
|
|
8741
|
-
while (currentFlexChild !== null) {
|
|
8742
|
-
// At this point we know the final size of the element in the main
|
|
8743
|
-
// dimension
|
|
8744
|
-
currentFlexChild.layout[dim[mainAxis]] = boundAxis(currentFlexChild, mainAxis,
|
|
8745
|
-
flexibleMainDim * currentFlexChild.style.flex +
|
|
8746
|
-
getPaddingAndBorderAxis(currentFlexChild, mainAxis)
|
|
8747
|
-
);
|
|
8748
|
-
|
|
8749
|
-
maxWidth = CSS_UNDEFINED;
|
|
8750
|
-
if (isDimDefined(node, resolvedRowAxis)) {
|
|
8751
|
-
maxWidth = node.layout[dim[resolvedRowAxis]] -
|
|
8752
|
-
paddingAndBorderAxisResolvedRow;
|
|
8753
|
-
} else if (!isMainRowDirection) {
|
|
8754
|
-
maxWidth = parentMaxWidth -
|
|
8755
|
-
getMarginAxis(node, resolvedRowAxis) -
|
|
8756
|
-
paddingAndBorderAxisResolvedRow;
|
|
8757
|
-
}
|
|
8758
|
-
|
|
8759
|
-
// And we recursively call the layout algorithm for this child
|
|
8760
|
-
layoutNode(/*(java)!layoutContext, */currentFlexChild, maxWidth, direction);
|
|
8761
|
-
|
|
8762
|
-
child = currentFlexChild;
|
|
8763
|
-
currentFlexChild = currentFlexChild.nextFlexChild;
|
|
8764
|
-
child.nextFlexChild = null;
|
|
8765
|
-
}
|
|
8766
|
-
|
|
8767
|
-
// We use justifyContent to figure out how to allocate the remaining
|
|
8768
|
-
// space available
|
|
8769
|
-
} else if (justifyContent !== CSS_JUSTIFY_FLEX_START) {
|
|
8770
|
-
if (justifyContent === CSS_JUSTIFY_CENTER) {
|
|
8771
|
-
leadingMainDim = remainingMainDim / 2;
|
|
8772
|
-
} else if (justifyContent === CSS_JUSTIFY_FLEX_END) {
|
|
8773
|
-
leadingMainDim = remainingMainDim;
|
|
8774
|
-
} else if (justifyContent === CSS_JUSTIFY_SPACE_BETWEEN) {
|
|
8775
|
-
remainingMainDim = fmaxf(remainingMainDim, 0);
|
|
8776
|
-
if (flexibleChildrenCount + nonFlexibleChildrenCount - 1 !== 0) {
|
|
8777
|
-
betweenMainDim = remainingMainDim /
|
|
8778
|
-
(flexibleChildrenCount + nonFlexibleChildrenCount - 1);
|
|
8779
|
-
} else {
|
|
8780
|
-
betweenMainDim = 0;
|
|
8781
|
-
}
|
|
8782
|
-
} else if (justifyContent === CSS_JUSTIFY_SPACE_AROUND) {
|
|
8783
|
-
// Space on the edges is half of the space between elements
|
|
8784
|
-
betweenMainDim = remainingMainDim /
|
|
8785
|
-
(flexibleChildrenCount + nonFlexibleChildrenCount);
|
|
8786
|
-
leadingMainDim = betweenMainDim / 2;
|
|
8787
|
-
}
|
|
8788
|
-
}
|
|
8789
|
-
|
|
8790
|
-
// <Loop C> Position elements in the main axis and compute dimensions
|
|
8791
|
-
|
|
8792
|
-
// At this point, all the children have their dimensions set. We need to
|
|
8793
|
-
// find their position. In order to do that, we accumulate data in
|
|
8794
|
-
// variables that are also useful to compute the total dimensions of the
|
|
8795
|
-
// container!
|
|
8796
|
-
mainDim += leadingMainDim;
|
|
8797
|
-
|
|
8798
|
-
for (i = firstComplexMain; i < endLine; ++i) {
|
|
8799
|
-
child = node.children[i];
|
|
8800
|
-
|
|
8801
|
-
if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&
|
|
8802
|
-
isPosDefined(child, leading[mainAxis])) {
|
|
8803
|
-
// In case the child is position absolute and has left/top being
|
|
8804
|
-
// defined, we override the position to whatever the user said
|
|
8805
|
-
// (and margin/border).
|
|
8806
|
-
child.layout[pos[mainAxis]] = getPosition(child, leading[mainAxis]) +
|
|
8807
|
-
getLeadingBorder(node, mainAxis) +
|
|
8808
|
-
getLeadingMargin(child, mainAxis);
|
|
8809
|
-
} else {
|
|
8810
|
-
// If the child is position absolute (without top/left) or relative,
|
|
8811
|
-
// we put it at the current accumulated offset.
|
|
8812
|
-
child.layout[pos[mainAxis]] += mainDim;
|
|
8813
|
-
|
|
8814
|
-
// Define the trailing position accordingly.
|
|
8815
|
-
if (isMainDimDefined) {
|
|
8816
|
-
setTrailingPosition(node, child, mainAxis);
|
|
8817
|
-
}
|
|
8818
|
-
|
|
8819
|
-
// Now that we placed the element, we need to update the variables
|
|
8820
|
-
// We only need to do that for relative elements. Absolute elements
|
|
8821
|
-
// do not take part in that phase.
|
|
8822
|
-
if (getPositionType(child) === CSS_POSITION_RELATIVE) {
|
|
8823
|
-
// The main dimension is the sum of all the elements dimension plus
|
|
8824
|
-
// the spacing.
|
|
8825
|
-
mainDim += betweenMainDim + getDimWithMargin(child, mainAxis);
|
|
8826
|
-
// The cross dimension is the max of the elements dimension since there
|
|
8827
|
-
// can only be one element in that cross dimension.
|
|
8828
|
-
crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis)));
|
|
8829
|
-
}
|
|
8830
|
-
}
|
|
8831
|
-
}
|
|
8832
|
-
|
|
8833
|
-
var/*float*/ containerCrossAxis = node.layout[dim[crossAxis]];
|
|
8834
|
-
if (!isCrossDimDefined) {
|
|
8835
|
-
containerCrossAxis = fmaxf(
|
|
8836
|
-
// For the cross dim, we add both sides at the end because the value
|
|
8837
|
-
// is aggregate via a max function. Intermediate negative values
|
|
8838
|
-
// can mess this computation otherwise
|
|
8839
|
-
boundAxis(node, crossAxis, crossDim + paddingAndBorderAxisCross),
|
|
8840
|
-
paddingAndBorderAxisCross
|
|
8841
|
-
);
|
|
8842
|
-
}
|
|
8843
|
-
|
|
8844
|
-
// <Loop D> Position elements in the cross axis
|
|
8845
|
-
for (i = firstComplexCross; i < endLine; ++i) {
|
|
8846
|
-
child = node.children[i];
|
|
8847
|
-
|
|
8848
|
-
if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&
|
|
8849
|
-
isPosDefined(child, leading[crossAxis])) {
|
|
8850
|
-
// In case the child is absolutely positionned and has a
|
|
8851
|
-
// top/left/bottom/right being set, we override all the previously
|
|
8852
|
-
// computed positions to set it correctly.
|
|
8853
|
-
child.layout[pos[crossAxis]] = getPosition(child, leading[crossAxis]) +
|
|
8854
|
-
getLeadingBorder(node, crossAxis) +
|
|
8855
|
-
getLeadingMargin(child, crossAxis);
|
|
8856
|
-
|
|
8857
|
-
} else {
|
|
8858
|
-
var/*float*/ leadingCrossDim = leadingPaddingAndBorderCross;
|
|
8859
|
-
|
|
8860
|
-
// For a relative children, we're either using alignItems (parent) or
|
|
8861
|
-
// alignSelf (child) in order to determine the position in the cross axis
|
|
8862
|
-
if (getPositionType(child) === CSS_POSITION_RELATIVE) {
|
|
8863
|
-
/*eslint-disable */
|
|
8864
|
-
// This variable is intentionally re-defined as the code is transpiled to a block scope language
|
|
8865
|
-
var/*css_align_t*/ alignItem = getAlignItem(node, child);
|
|
8866
|
-
/*eslint-enable */
|
|
8867
|
-
if (alignItem === CSS_ALIGN_STRETCH) {
|
|
8868
|
-
// You can only stretch if the dimension has not already been set
|
|
8869
|
-
// previously.
|
|
8870
|
-
if (isUndefined(child.layout[dim[crossAxis]])) {
|
|
8871
|
-
child.layout[dim[crossAxis]] = fmaxf(
|
|
8872
|
-
boundAxis(child, crossAxis, containerCrossAxis -
|
|
8873
|
-
paddingAndBorderAxisCross - getMarginAxis(child, crossAxis)),
|
|
8874
|
-
// You never want to go smaller than padding
|
|
8875
|
-
getPaddingAndBorderAxis(child, crossAxis)
|
|
8876
|
-
);
|
|
8877
|
-
}
|
|
8878
|
-
} else if (alignItem !== CSS_ALIGN_FLEX_START) {
|
|
8879
|
-
// The remaining space between the parent dimensions+padding and child
|
|
8880
|
-
// dimensions+margin.
|
|
8881
|
-
var/*float*/ remainingCrossDim = containerCrossAxis -
|
|
8882
|
-
paddingAndBorderAxisCross - getDimWithMargin(child, crossAxis);
|
|
8883
|
-
|
|
8884
|
-
if (alignItem === CSS_ALIGN_CENTER) {
|
|
8885
|
-
leadingCrossDim += remainingCrossDim / 2;
|
|
8886
|
-
} else { // CSS_ALIGN_FLEX_END
|
|
8887
|
-
leadingCrossDim += remainingCrossDim;
|
|
8888
|
-
}
|
|
8889
|
-
}
|
|
8890
|
-
}
|
|
8891
|
-
|
|
8892
|
-
// And we apply the position
|
|
8893
|
-
child.layout[pos[crossAxis]] += linesCrossDim + leadingCrossDim;
|
|
8894
|
-
|
|
8895
|
-
// Define the trailing position accordingly.
|
|
8896
|
-
if (isCrossDimDefined) {
|
|
8897
|
-
setTrailingPosition(node, child, crossAxis);
|
|
8898
|
-
}
|
|
8899
|
-
}
|
|
8900
|
-
}
|
|
8901
|
-
|
|
8902
|
-
linesCrossDim += crossDim;
|
|
8903
|
-
linesMainDim = fmaxf(linesMainDim, mainDim);
|
|
8904
|
-
linesCount += 1;
|
|
8905
|
-
startLine = endLine;
|
|
8906
|
-
}
|
|
8907
|
-
|
|
8908
|
-
// <Loop E>
|
|
8909
|
-
//
|
|
8910
|
-
// Note(prenaux): More than one line, we need to layout the crossAxis
|
|
8911
|
-
// according to alignContent.
|
|
8912
|
-
//
|
|
8913
|
-
// Note that we could probably remove <Loop D> and handle the one line case
|
|
8914
|
-
// here too, but for the moment this is safer since it won't interfere with
|
|
8915
|
-
// previously working code.
|
|
8916
|
-
//
|
|
8917
|
-
// See specs:
|
|
8918
|
-
// http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm
|
|
8919
|
-
// section 9.4
|
|
8920
|
-
//
|
|
8921
|
-
if (linesCount > 1 && isCrossDimDefined) {
|
|
8922
|
-
var/*float*/ nodeCrossAxisInnerSize = node.layout[dim[crossAxis]] -
|
|
8923
|
-
paddingAndBorderAxisCross;
|
|
8924
|
-
var/*float*/ remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim;
|
|
8925
|
-
|
|
8926
|
-
var/*float*/ crossDimLead = 0;
|
|
8927
|
-
var/*float*/ currentLead = leadingPaddingAndBorderCross;
|
|
8928
|
-
|
|
8929
|
-
var/*css_align_t*/ alignContent = getAlignContent(node);
|
|
8930
|
-
if (alignContent === CSS_ALIGN_FLEX_END) {
|
|
8931
|
-
currentLead += remainingAlignContentDim;
|
|
8932
|
-
} else if (alignContent === CSS_ALIGN_CENTER) {
|
|
8933
|
-
currentLead += remainingAlignContentDim / 2;
|
|
8934
|
-
} else if (alignContent === CSS_ALIGN_STRETCH) {
|
|
8935
|
-
if (nodeCrossAxisInnerSize > linesCrossDim) {
|
|
8936
|
-
crossDimLead = (remainingAlignContentDim / linesCount);
|
|
8937
|
-
}
|
|
8938
|
-
}
|
|
8939
|
-
|
|
8940
|
-
var/*int*/ endIndex = 0;
|
|
8941
|
-
for (i = 0; i < linesCount; ++i) {
|
|
8942
|
-
var/*int*/ startIndex = endIndex;
|
|
8943
|
-
|
|
8944
|
-
// compute the line's height and find the endIndex
|
|
8945
|
-
var/*float*/ lineHeight = 0;
|
|
8946
|
-
for (ii = startIndex; ii < childCount; ++ii) {
|
|
8947
|
-
child = node.children[ii];
|
|
8948
|
-
if (getPositionType(child) !== CSS_POSITION_RELATIVE) {
|
|
8949
|
-
continue;
|
|
8950
|
-
}
|
|
8951
|
-
if (child.lineIndex !== i) {
|
|
8952
|
-
break;
|
|
8953
|
-
}
|
|
8954
|
-
if (!isUndefined(child.layout[dim[crossAxis]])) {
|
|
8955
|
-
lineHeight = fmaxf(
|
|
8956
|
-
lineHeight,
|
|
8957
|
-
child.layout[dim[crossAxis]] + getMarginAxis(child, crossAxis)
|
|
8958
|
-
);
|
|
8959
|
-
}
|
|
8960
|
-
}
|
|
8961
|
-
endIndex = ii;
|
|
8962
|
-
lineHeight += crossDimLead;
|
|
8963
|
-
|
|
8964
|
-
for (ii = startIndex; ii < endIndex; ++ii) {
|
|
8965
|
-
child = node.children[ii];
|
|
8966
|
-
if (getPositionType(child) !== CSS_POSITION_RELATIVE) {
|
|
8967
|
-
continue;
|
|
8968
|
-
}
|
|
8969
|
-
|
|
8970
|
-
var/*css_align_t*/ alignContentAlignItem = getAlignItem(node, child);
|
|
8971
|
-
if (alignContentAlignItem === CSS_ALIGN_FLEX_START) {
|
|
8972
|
-
child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);
|
|
8973
|
-
} else if (alignContentAlignItem === CSS_ALIGN_FLEX_END) {
|
|
8974
|
-
child.layout[pos[crossAxis]] = currentLead + lineHeight - getTrailingMargin(child, crossAxis) - child.layout[dim[crossAxis]];
|
|
8975
|
-
} else if (alignContentAlignItem === CSS_ALIGN_CENTER) {
|
|
8976
|
-
var/*float*/ childHeight = child.layout[dim[crossAxis]];
|
|
8977
|
-
child.layout[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2;
|
|
8978
|
-
} else if (alignContentAlignItem === CSS_ALIGN_STRETCH) {
|
|
8979
|
-
child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);
|
|
8980
|
-
// TODO(prenaux): Correctly set the height of items with undefined
|
|
8981
|
-
// (auto) crossAxis dimension.
|
|
8982
|
-
}
|
|
8983
|
-
}
|
|
8984
|
-
|
|
8985
|
-
currentLead += lineHeight;
|
|
8986
|
-
}
|
|
8987
|
-
}
|
|
8988
|
-
|
|
8989
|
-
var/*bool*/ needsMainTrailingPos = false;
|
|
8990
|
-
var/*bool*/ needsCrossTrailingPos = false;
|
|
8991
|
-
|
|
8992
|
-
// If the user didn't specify a width or height, and it has not been set
|
|
8993
|
-
// by the container, then we set it via the children.
|
|
8994
|
-
if (!isMainDimDefined) {
|
|
8995
|
-
node.layout[dim[mainAxis]] = fmaxf(
|
|
8996
|
-
// We're missing the last padding at this point to get the final
|
|
8997
|
-
// dimension
|
|
8998
|
-
boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)),
|
|
8999
|
-
// We can never assign a width smaller than the padding and borders
|
|
9000
|
-
paddingAndBorderAxisMain
|
|
9001
|
-
);
|
|
9002
|
-
|
|
9003
|
-
if (mainAxis === CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
|
9004
|
-
mainAxis === CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
|
9005
|
-
needsMainTrailingPos = true;
|
|
9006
|
-
}
|
|
9007
|
-
}
|
|
9008
|
-
|
|
9009
|
-
if (!isCrossDimDefined) {
|
|
9010
|
-
node.layout[dim[crossAxis]] = fmaxf(
|
|
9011
|
-
// For the cross dim, we add both sides at the end because the value
|
|
9012
|
-
// is aggregate via a max function. Intermediate negative values
|
|
9013
|
-
// can mess this computation otherwise
|
|
9014
|
-
boundAxis(node, crossAxis, linesCrossDim + paddingAndBorderAxisCross),
|
|
9015
|
-
paddingAndBorderAxisCross
|
|
9016
|
-
);
|
|
9017
|
-
|
|
9018
|
-
if (crossAxis === CSS_FLEX_DIRECTION_ROW_REVERSE ||
|
|
9019
|
-
crossAxis === CSS_FLEX_DIRECTION_COLUMN_REVERSE) {
|
|
9020
|
-
needsCrossTrailingPos = true;
|
|
9021
|
-
}
|
|
9022
|
-
}
|
|
9023
|
-
|
|
9024
|
-
// <Loop F> Set trailing position if necessary
|
|
9025
|
-
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
|
9026
|
-
for (i = 0; i < childCount; ++i) {
|
|
9027
|
-
child = node.children[i];
|
|
9028
|
-
|
|
9029
|
-
if (needsMainTrailingPos) {
|
|
9030
|
-
setTrailingPosition(node, child, mainAxis);
|
|
9031
|
-
}
|
|
9032
|
-
|
|
9033
|
-
if (needsCrossTrailingPos) {
|
|
9034
|
-
setTrailingPosition(node, child, crossAxis);
|
|
9035
|
-
}
|
|
9036
|
-
}
|
|
9037
|
-
}
|
|
9038
|
-
|
|
9039
|
-
// <Loop G> Calculate dimensions for absolutely positioned elements
|
|
9040
|
-
currentAbsoluteChild = firstAbsoluteChild;
|
|
9041
|
-
while (currentAbsoluteChild !== null) {
|
|
9042
|
-
// Pre-fill dimensions when using absolute position and both offsets for
|
|
9043
|
-
// the axis are defined (either both left and right or top and bottom).
|
|
9044
|
-
for (ii = 0; ii < 2; ii++) {
|
|
9045
|
-
axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
|
9046
|
-
|
|
9047
|
-
if (!isUndefined(node.layout[dim[axis]]) &&
|
|
9048
|
-
!isDimDefined(currentAbsoluteChild, axis) &&
|
|
9049
|
-
isPosDefined(currentAbsoluteChild, leading[axis]) &&
|
|
9050
|
-
isPosDefined(currentAbsoluteChild, trailing[axis])) {
|
|
9051
|
-
currentAbsoluteChild.layout[dim[axis]] = fmaxf(
|
|
9052
|
-
boundAxis(currentAbsoluteChild, axis, node.layout[dim[axis]] -
|
|
9053
|
-
getBorderAxis(node, axis) -
|
|
9054
|
-
getMarginAxis(currentAbsoluteChild, axis) -
|
|
9055
|
-
getPosition(currentAbsoluteChild, leading[axis]) -
|
|
9056
|
-
getPosition(currentAbsoluteChild, trailing[axis])
|
|
9057
|
-
),
|
|
9058
|
-
// You never want to go smaller than padding
|
|
9059
|
-
getPaddingAndBorderAxis(currentAbsoluteChild, axis)
|
|
9060
|
-
);
|
|
9061
|
-
}
|
|
9062
|
-
|
|
9063
|
-
if (isPosDefined(currentAbsoluteChild, trailing[axis]) &&
|
|
9064
|
-
!isPosDefined(currentAbsoluteChild, leading[axis])) {
|
|
9065
|
-
currentAbsoluteChild.layout[leading[axis]] =
|
|
9066
|
-
node.layout[dim[axis]] -
|
|
9067
|
-
currentAbsoluteChild.layout[dim[axis]] -
|
|
9068
|
-
getPosition(currentAbsoluteChild, trailing[axis]);
|
|
9069
|
-
}
|
|
9070
|
-
}
|
|
9071
|
-
|
|
9072
|
-
child = currentAbsoluteChild;
|
|
9073
|
-
currentAbsoluteChild = currentAbsoluteChild.nextAbsoluteChild;
|
|
9074
|
-
child.nextAbsoluteChild = null;
|
|
9075
|
-
}
|
|
9076
|
-
}
|
|
9077
|
-
|
|
9078
|
-
function layoutNode(node, parentMaxWidth, parentDirection) {
|
|
9079
|
-
node.shouldUpdate = true;
|
|
9080
|
-
|
|
9081
|
-
var direction = node.style.direction || CSS_DIRECTION_LTR;
|
|
9082
|
-
var skipLayout =
|
|
9083
|
-
!node.isDirty &&
|
|
9084
|
-
node.lastLayout &&
|
|
9085
|
-
node.lastLayout.requestedHeight === node.layout.height &&
|
|
9086
|
-
node.lastLayout.requestedWidth === node.layout.width &&
|
|
9087
|
-
node.lastLayout.parentMaxWidth === parentMaxWidth &&
|
|
9088
|
-
node.lastLayout.direction === direction;
|
|
9089
|
-
|
|
9090
|
-
if (skipLayout) {
|
|
9091
|
-
node.layout.width = node.lastLayout.width;
|
|
9092
|
-
node.layout.height = node.lastLayout.height;
|
|
9093
|
-
node.layout.top = node.lastLayout.top;
|
|
9094
|
-
node.layout.left = node.lastLayout.left;
|
|
9095
|
-
} else {
|
|
9096
|
-
if (!node.lastLayout) {
|
|
9097
|
-
node.lastLayout = {};
|
|
9098
|
-
}
|
|
9099
|
-
|
|
9100
|
-
node.lastLayout.requestedWidth = node.layout.width;
|
|
9101
|
-
node.lastLayout.requestedHeight = node.layout.height;
|
|
9102
|
-
node.lastLayout.parentMaxWidth = parentMaxWidth;
|
|
9103
|
-
node.lastLayout.direction = direction;
|
|
9104
|
-
|
|
9105
|
-
// Reset child layouts
|
|
9106
|
-
node.children.forEach(function(child) {
|
|
9107
|
-
child.layout.width = undefined;
|
|
9108
|
-
child.layout.height = undefined;
|
|
9109
|
-
child.layout.top = 0;
|
|
9110
|
-
child.layout.left = 0;
|
|
9111
|
-
});
|
|
9112
|
-
|
|
9113
|
-
layoutNodeImpl(node, parentMaxWidth, parentDirection);
|
|
9114
|
-
|
|
9115
|
-
node.lastLayout.width = node.layout.width;
|
|
9116
|
-
node.lastLayout.height = node.layout.height;
|
|
9117
|
-
node.lastLayout.top = node.layout.top;
|
|
9118
|
-
node.lastLayout.left = node.layout.left;
|
|
9119
|
-
}
|
|
9120
|
-
}
|
|
9121
|
-
|
|
9122
|
-
return {
|
|
9123
|
-
layoutNodeImpl: layoutNodeImpl,
|
|
9124
|
-
computeLayout: layoutNode,
|
|
9125
|
-
fillNodes: fillNodes
|
|
9126
|
-
};
|
|
9127
|
-
})();
|
|
9128
|
-
|
|
9129
|
-
// This module export is only used for the purposes of unit testing this file. When
|
|
9130
|
-
// the library is packaged this file is included within css-layout.js which forms
|
|
9131
|
-
// the public API.
|
|
9132
|
-
{
|
|
9133
|
-
module.exports = computeLayout;
|
|
9134
|
-
}
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
return function(node) {
|
|
9138
|
-
/*eslint-disable */
|
|
9139
|
-
// disabling ESLint because this code relies on the above include
|
|
9140
|
-
computeLayout.fillNodes(node);
|
|
9141
|
-
computeLayout.computeLayout(node);
|
|
9142
|
-
/*eslint-enable */
|
|
9143
|
-
};
|
|
9144
|
-
}));
|
|
9145
|
-
} (cssLayout));
|
|
9146
|
-
|
|
9147
|
-
var cssLayoutExports = cssLayout.exports;
|
|
9148
|
-
|
|
9149
|
-
function _interopDefault$1(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault$1(React$1),reactDom=require$$0,computeLayout=_interopDefault$1(cssLayoutExports);function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_defineProperty(e,t,r[t]);});}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),e}function _typeof2(e){return (_typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _typeof(e){return (_typeof="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(e){return _typeof2(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_typeof2(e)})(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){return !t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _getPrototypeOf(e){return (_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return (_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t);}var Flexbox=function(e){function t(){var e;return _classCallCheck(this,t),(e=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this))).childRefs=[],e.shouldUpdateAgain=!1,e.state={layout:{children:[]}},e}return _inherits(t,React.Component),_createClass(t,[{key:"componentDidMount",value:function(){this.forceUpdate();}},{key:"componentDidUpdate",value:function(){if(this.shouldUpdateAgain=!this.shouldUpdateAgain,this.shouldUpdateAgain){var e=this.props,t=e.children,r=e.onLayout,n=e.style,o=this.getChildrenMeasured(this.childRefs),i=this.getFlattenedChildren(t),u=this.getChildrenAsMergedStyles(i,o),c=this.getComputedLayout(u,n);r(c),this.setState({layout:c});}}},{key:"getFlattenedChildren",value:function(e){return e.filter(function(e){return e}).filter(function(e){return "string"!=typeof e}).map(function(e){return Array.isArray(e)?e:[e]}).reduce(function(e,t){return e.concat(t)},[])}},{key:"getChildrenAsMergedStyles",value:function(e,t){return t.map(function(t,r){var n=e[r]||{},o=n&&n.props?n.props.style:{};return {style:_objectSpread({},o,{height:t.height||o.height,width:t.width||o.width})}})}},{key:"getChildrenMeasured",value:function(e){return e&&e.length?e.map(function(e){return e.getBBox?e.getBBox():reactDom.findDOMNode(e).getBBox()}):[]}},{key:"getComputedLayout",value:function(e,t){var r={children:Array.from(e||[]),style:_objectSpread({},t)};return computeLayout(r),r}},{key:"getLayoutChildren",value:function(e){return e&&e.children&&e.children.length?e.children:[]}},{key:"getLayoutAttributesForChild",value:function(e,t){if(t&&t.layout){var r=t.layout,n=r.left,o=r.top;switch(e.type){case"circle":var i=e.props.r||0;return {cx:n+i,cy:o+i};case"ellipse":return {cx:n+(e.props.rx||0),cy:o+(e.props.ry||0)};case"g":case"path":case"polygon":case"polyline":return {transform:"translate(".concat(n," ").concat(o,")")};default:return {x:n,y:o}}}return {}}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,n=t.className,o=t.x,i=t.y,u=this.state.layout;this.childRefs=[];var c=this.getFlattenedChildren(r),a=this.getLayoutChildren(u);return React.createElement("g",{className:n,transform:"translate(".concat(o," ").concat(i,")")},c.map(function(t,r){return React.cloneElement(t,_objectSpread({},t.props,e.getLayoutAttributesForChild(t,a[r]),{key:"child-".concat(r),ref:function(t){return t?e.childRefs.push(t):null}}))}))}}]),t}();Flexbox.defaultProps={children:[],className:null,onLayout:function(){},style:{},x:0,y:0},bundle.exports=Flexbox;
|
|
9150
|
-
|
|
9151
|
-
var bundleExports = bundle.exports;
|
|
9152
|
-
var Flexbox$1 = /*@__PURE__*/getDefaultExportFromCjs(bundleExports);
|
|
9153
|
-
|
|
9154
8021
|
var Element = function (props) {
|
|
9155
|
-
var _a, _b
|
|
9156
|
-
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, cssClass = props.cssClass, portPlaceholderShape = props.portPlaceholderShape, children = props.children, container = props.container
|
|
9157
|
-
var
|
|
9158
|
-
var
|
|
9159
|
-
var
|
|
9160
|
-
var
|
|
9161
|
-
var
|
|
9162
|
-
var
|
|
9163
|
-
var
|
|
9164
|
-
var
|
|
9165
|
-
var
|
|
9166
|
-
|
|
8022
|
+
var _a, _b;
|
|
8023
|
+
var id = props.id, x = props.x, y = props.y, width = props.width, height = props.height, cssClass = props.cssClass, portPlaceholderShape = props.portPlaceholderShape, children = props.children, container = props.container; props.textsPlaceHolderFlexStyle; props.textsPlaceHolderFlexboxPosition; props.textsPlaceHolderClassName; var texts = props.texts, portSlideRailSVGClassName = props.portSlideRailSVGClassName, portMoveableAreas = props.portMoveableAreas, portDirection = props.portDirection, defaultPortSize = props.defaultPortSize, onClick = props.onClick, onContextMenu = props.onContextMenu, renderShape = props.renderShape; props.onMoved; var onPortMoved = props.onPortMoved; props.onResized; var onPortMouseDown = props.onPortMouseDown, onPortMouseUp = props.onPortMouseUp, onMouseMove = props.onMouseMove, onMouseLeave = props.onMouseLeave, onMouseUp = props.onMouseUp, onMouseUpAtLinkedPortPlaceholder = props.onMouseUpAtLinkedPortPlaceholder, onTextUpdated = props.onTextUpdated;
|
|
8024
|
+
var _c = React.useState(), selectedPort = _c[0], setSelectedPort = _c[1];
|
|
8025
|
+
var _d = React.useState(), hoveredPort = _d[0], setHoveredPort = _d[1];
|
|
8026
|
+
var _e = React.useState([]), ports = _e[0], setPorts = _e[1];
|
|
8027
|
+
var _f = React.useState(false), someElementLinkStarted = _f[0], setSomeElementLinkStarted = _f[1];
|
|
8028
|
+
var _g = React.useState(), potentialPortPosition = _g[0], setPotentialPortPosition = _g[1];
|
|
8029
|
+
var _paperEventEmitterContext = React.useContext(paperEventEmitterContext);
|
|
8030
|
+
var elementRef = React.useRef(null);
|
|
8031
|
+
var elementLinkStarted = React.useRef();
|
|
8032
|
+
var portsRef = React.useRef(ports);
|
|
8033
|
+
React.useEffect(function () {
|
|
8034
|
+
console.log('changed props.children', texts === null || texts === void 0 ? void 0 : texts[0].content);
|
|
8035
|
+
}, [props.children]);
|
|
8036
|
+
React.useEffect(function () {
|
|
8037
|
+
return function () {
|
|
8038
|
+
var _a;
|
|
8039
|
+
console.log('un mount', (_a = texts === null || texts === void 0 ? void 0 : texts[0]) === null || _a === void 0 ? void 0 : _a.content);
|
|
8040
|
+
};
|
|
8041
|
+
}, []);
|
|
9167
8042
|
//Listen to manually trigger render event
|
|
9168
|
-
React
|
|
9169
|
-
var
|
|
9170
|
-
|
|
9171
|
-
|
|
8043
|
+
React.useEffect(function () {
|
|
8044
|
+
var _a;
|
|
8045
|
+
var off = (_a = props.onManuallyTriggerRenderPort) === null || _a === void 0 ? void 0 : _a.call(props, function (portId, elementId) {
|
|
8046
|
+
if (elementId !== id)
|
|
8047
|
+
return;
|
|
8048
|
+
console.log('onManuallyTriggerRenderPort', id);
|
|
8049
|
+
setPorts(function (prev) { return __spreadArray([], prev, true); });
|
|
9172
8050
|
});
|
|
9173
8051
|
return function () {
|
|
9174
8052
|
off === null || off === void 0 ? void 0 : off();
|
|
9175
8053
|
};
|
|
9176
|
-
}, []);
|
|
8054
|
+
}, [props.onManuallyTriggerRenderPort]);
|
|
9177
8055
|
//Update portsRef when ports changed
|
|
9178
|
-
React
|
|
8056
|
+
React.useEffect(function () {
|
|
9179
8057
|
portsRef.current = ports;
|
|
9180
8058
|
}, [ports]);
|
|
9181
|
-
React
|
|
8059
|
+
React.useEffect(function () {
|
|
9182
8060
|
var _a;
|
|
9183
|
-
console.info('Rendering Element ' +
|
|
8061
|
+
console.info('Rendering Element ' + ((_a = texts === null || texts === void 0 ? void 0 : texts[0]) === null || _a === void 0 ? void 0 : _a.content) || id);
|
|
9184
8062
|
});
|
|
9185
8063
|
//Listen a new port is created, after add new port to ports state
|
|
9186
|
-
React
|
|
8064
|
+
React.useEffect(function () {
|
|
9187
8065
|
console.info('Ports changed', props.ports);
|
|
9188
8066
|
setPorts(function (prev) {
|
|
9189
8067
|
var _a, _b;
|
|
@@ -9203,14 +8081,14 @@ var Element = function (props) {
|
|
|
9203
8081
|
onPortMoved === null || onPortMoved === void 0 ? void 0 : onPortMoved(p, id, newPortState.position, newPosition);
|
|
9204
8082
|
_paperEventEmitterContext.emitPortMoved(p, id, newPortState.position, newPosition);
|
|
9205
8083
|
newPortState.position = newPosition;
|
|
9206
|
-
newPortState.ref = React
|
|
8084
|
+
newPortState.ref = React.createRef();
|
|
9207
8085
|
}
|
|
9208
8086
|
return newPortState;
|
|
9209
8087
|
})) !== null && _b !== void 0 ? _b : [];
|
|
9210
8088
|
});
|
|
9211
8089
|
}, [props.ports]);
|
|
9212
8090
|
//Listen trigger of Delete key, handle delete port is selected
|
|
9213
|
-
React
|
|
8091
|
+
React.useEffect(function () {
|
|
9214
8092
|
var listener = _paperEventEmitterContext.onCommandDeleteSelectedPort(function () {
|
|
9215
8093
|
if (selectedPort) {
|
|
9216
8094
|
setPorts(function (prev) { return prev.filter(function (p) { return p.id !== selectedPort.id; }); });
|
|
@@ -9221,7 +8099,7 @@ var Element = function (props) {
|
|
|
9221
8099
|
listener.off();
|
|
9222
8100
|
};
|
|
9223
8101
|
}, [selectedPort]);
|
|
9224
|
-
React
|
|
8102
|
+
React.useEffect(function () {
|
|
9225
8103
|
//Listener onMouseDown event on #paper-container
|
|
9226
8104
|
var eventListener = _paperEventEmitterContext.onPaperClicked(function (ev) {
|
|
9227
8105
|
setSelectedPort(undefined);
|
|
@@ -9245,7 +8123,7 @@ var Element = function (props) {
|
|
|
9245
8123
|
};
|
|
9246
8124
|
}, [onPortMoved]);
|
|
9247
8125
|
//Listen creating element link started, ended.
|
|
9248
|
-
React
|
|
8126
|
+
React.useEffect(function () {
|
|
9249
8127
|
var elementStartedListener = _paperEventEmitterContext.onElementLinkStarted(function (tempLink) {
|
|
9250
8128
|
elementLinkStarted.current = tempLink;
|
|
9251
8129
|
setSomeElementLinkStarted(true);
|
|
@@ -9262,7 +8140,7 @@ var Element = function (props) {
|
|
|
9262
8140
|
};
|
|
9263
8141
|
}, []);
|
|
9264
8142
|
//Listen another port is selected
|
|
9265
|
-
React
|
|
8143
|
+
React.useEffect(function () {
|
|
9266
8144
|
var portSelectedListener = _paperEventEmitterContext.onPortSelected(function (port, elementId) {
|
|
9267
8145
|
if (elementId !== id) {
|
|
9268
8146
|
setSelectedPort(undefined);
|
|
@@ -9273,7 +8151,7 @@ var Element = function (props) {
|
|
|
9273
8151
|
};
|
|
9274
8152
|
}, []);
|
|
9275
8153
|
//Listen text is selected
|
|
9276
|
-
React
|
|
8154
|
+
React.useEffect(function () {
|
|
9277
8155
|
var textSelectedListener = _paperEventEmitterContext.onTextSelected(function (text) {
|
|
9278
8156
|
setSelectedPort(undefined);
|
|
9279
8157
|
});
|
|
@@ -9282,7 +8160,7 @@ var Element = function (props) {
|
|
|
9282
8160
|
};
|
|
9283
8161
|
}, []);
|
|
9284
8162
|
//Listen another element is selected
|
|
9285
|
-
React
|
|
8163
|
+
React.useEffect(function () {
|
|
9286
8164
|
var portSelectedListener = _paperEventEmitterContext.onElementSelected(function (element) {
|
|
9287
8165
|
setSelectedPort(undefined);
|
|
9288
8166
|
});
|
|
@@ -9290,7 +8168,7 @@ var Element = function (props) {
|
|
|
9290
8168
|
portSelectedListener.off();
|
|
9291
8169
|
};
|
|
9292
8170
|
}, []);
|
|
9293
|
-
var handleSelectedPort = React
|
|
8171
|
+
var handleSelectedPort = React.useCallback(function (portId, e) {
|
|
9294
8172
|
e.stopPropagation();
|
|
9295
8173
|
var port = portsRef.current.find(function (p) { return p.id === portId; });
|
|
9296
8174
|
if (!port)
|
|
@@ -9298,29 +8176,6 @@ var Element = function (props) {
|
|
|
9298
8176
|
setSelectedPort(port);
|
|
9299
8177
|
_paperEventEmitterContext.emitPortSelected(port, id);
|
|
9300
8178
|
}, [_paperEventEmitterContext]);
|
|
9301
|
-
//From one point find another point on the line segment so that the distance between the two points is the shortest.
|
|
9302
|
-
var findNearestPointOnSegment = function (position, linePoints) {
|
|
9303
|
-
var beginPosition = linePoints[0], endPosition = linePoints[1];
|
|
9304
|
-
var point = Flatten$1.point(position.x, position.y);
|
|
9305
|
-
var segment = Flatten$1.segment(Flatten$1.point(beginPosition.x, beginPosition.y), Flatten$1.point(endPosition.x, endPosition.y));
|
|
9306
|
-
var _a = point.distanceTo(segment); _a[0]; var segmentFromPointToSegment = _a[1];
|
|
9307
|
-
return {
|
|
9308
|
-
x: segmentFromPointToSegment.pe.x,
|
|
9309
|
-
y: segmentFromPointToSegment.pe.y
|
|
9310
|
-
};
|
|
9311
|
-
};
|
|
9312
|
-
//From 1 point find another point on the line segment so that the distance between 2 points is shortest.
|
|
9313
|
-
var findNearestProjectedPoint = function (position, linePositions) {
|
|
9314
|
-
var possiblePoints = linePositions.map(function (p) { return findNearestPointOnSegment(position, p); });
|
|
9315
|
-
var nearestPoint = findNearestPosition(possiblePoints, position);
|
|
9316
|
-
return nearestPoint;
|
|
9317
|
-
};
|
|
9318
|
-
//Check if a point is inside a polygon
|
|
9319
|
-
var checkPointContainsPolygon = function (position, polygonPoints) {
|
|
9320
|
-
var polygon = new Flatten$1.Polygon();
|
|
9321
|
-
polygon.addFace(polygonPoints.map(function (p) { return Flatten$1.point(p.x, p.y); }));
|
|
9322
|
-
return polygon.contains(Flatten$1.point(position.x, position.y));
|
|
9323
|
-
};
|
|
9324
8179
|
//Normalize a point so that it can lie exactly on an area
|
|
9325
8180
|
var normalizePortPositionOnMoveableAreas = function (moveableAreas, position) {
|
|
9326
8181
|
var lines = moveableAreas.filter(function (area) { return area.length === 2; });
|
|
@@ -9355,7 +8210,7 @@ var Element = function (props) {
|
|
|
9355
8210
|
}
|
|
9356
8211
|
return coordinates;
|
|
9357
8212
|
};
|
|
9358
|
-
var getSlideRailSVG = React
|
|
8213
|
+
var getSlideRailSVG = React.useCallback(function (portSlideRailSVGClassName) {
|
|
9359
8214
|
var _a;
|
|
9360
8215
|
var slideRailSVG = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(portSlideRailSVGClassName));
|
|
9361
8216
|
return slideRailSVG;
|
|
@@ -9420,7 +8275,7 @@ var Element = function (props) {
|
|
|
9420
8275
|
}
|
|
9421
8276
|
};
|
|
9422
8277
|
//Handle when mouse down on port
|
|
9423
|
-
var handlePortMouseDown = React
|
|
8278
|
+
var handlePortMouseDown = React.useCallback(function (portId, e) {
|
|
9424
8279
|
e.stopPropagation();
|
|
9425
8280
|
var port = portsRef.current.find(function (p) { return p.id === portId; });
|
|
9426
8281
|
if (!port)
|
|
@@ -9429,7 +8284,7 @@ var Element = function (props) {
|
|
|
9429
8284
|
onPortMouseDown === null || onPortMouseDown === void 0 ? void 0 : onPortMouseDown(e, port, id);
|
|
9430
8285
|
}, [_paperEventEmitterContext]);
|
|
9431
8286
|
//Handle when mouse up on port
|
|
9432
|
-
var handlePortMouseUp = React
|
|
8287
|
+
var handlePortMouseUp = React.useCallback(function (portId, e) {
|
|
9433
8288
|
e.stopPropagation();
|
|
9434
8289
|
var port = portsRef.current.find(function (p) { return p.id === portId; });
|
|
9435
8290
|
if (!port)
|
|
@@ -9442,7 +8297,7 @@ var Element = function (props) {
|
|
|
9442
8297
|
}
|
|
9443
8298
|
}, [_paperEventEmitterContext, potentialPortPosition]);
|
|
9444
8299
|
//Update state when label of port is moved
|
|
9445
|
-
var handlePortLabelMoved = React
|
|
8300
|
+
var handlePortLabelMoved = React.useCallback(function (offsetX, offsetY, portId) {
|
|
9446
8301
|
setPorts(function (prevPorts) {
|
|
9447
8302
|
return prevPorts.map(function (p) {
|
|
9448
8303
|
if (p.id === portId && p.label) {
|
|
@@ -9457,7 +8312,7 @@ var Element = function (props) {
|
|
|
9457
8312
|
});
|
|
9458
8313
|
}, []);
|
|
9459
8314
|
//Update state when label of port is resized
|
|
9460
|
-
var handlePortLabelResized = React
|
|
8315
|
+
var handlePortLabelResized = React.useCallback(function (width, height, portId) {
|
|
9461
8316
|
setPorts(function (prevPorts) {
|
|
9462
8317
|
return prevPorts.map(function (p) {
|
|
9463
8318
|
if (p.id === portId && p.label) {
|
|
@@ -9471,7 +8326,7 @@ var Element = function (props) {
|
|
|
9471
8326
|
});
|
|
9472
8327
|
}, []);
|
|
9473
8328
|
//Update state when label of port is changed content
|
|
9474
|
-
var handlePortLabelContentChanged = React
|
|
8329
|
+
var handlePortLabelContentChanged = React.useCallback(function (ev, newValue, portId) {
|
|
9475
8330
|
setPorts(function (prevPorts) {
|
|
9476
8331
|
return prevPorts.map(function (p) {
|
|
9477
8332
|
if (p.id === portId && p.label) {
|
|
@@ -9483,6 +8338,7 @@ var Element = function (props) {
|
|
|
9483
8338
|
}, []);
|
|
9484
8339
|
function handleElementMouseMove(ev) {
|
|
9485
8340
|
//ev.stopPropagation(); //Can't use stopPropagation here, because do not create tempLink
|
|
8341
|
+
onMouseMove === null || onMouseMove === void 0 ? void 0 : onMouseMove(ev, id);
|
|
9486
8342
|
if (someElementLinkStarted && elementRef.current) {
|
|
9487
8343
|
//If an element link is being created, calculate the potential port position when the mouse moves over the element.
|
|
9488
8344
|
if (hoveredPort) {
|
|
@@ -9517,12 +8373,14 @@ var Element = function (props) {
|
|
|
9517
8373
|
}
|
|
9518
8374
|
function handleElementMouseLeave(ev) {
|
|
9519
8375
|
ev.stopPropagation();
|
|
8376
|
+
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(ev, id);
|
|
9520
8377
|
if (someElementLinkStarted) { //If an element link is being created, clear the placeholder when the mouse leaves the element.
|
|
9521
8378
|
setPotentialPortPosition(undefined);
|
|
9522
8379
|
}
|
|
9523
8380
|
}
|
|
9524
8381
|
var handleElementMouseUp = function (ev) {
|
|
9525
8382
|
ev.stopPropagation();
|
|
8383
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(ev, id);
|
|
9526
8384
|
//If an element link is being created, trigger onMouseUpAtLinkedPortPlaceholder when the mouse up the element.
|
|
9527
8385
|
if (potentialPortPosition && elementLinkStarted.current) {
|
|
9528
8386
|
var newElementLink = __assign(__assign({}, elementLinkStarted.current), { tempTargetPosition: undefined });
|
|
@@ -9531,7 +8389,7 @@ var Element = function (props) {
|
|
|
9531
8389
|
}
|
|
9532
8390
|
};
|
|
9533
8391
|
//Handle when mouse move on port
|
|
9534
|
-
var handlePortMouseMove = React
|
|
8392
|
+
var handlePortMouseMove = React.useCallback(function (portId) {
|
|
9535
8393
|
if (someElementLinkStarted) {
|
|
9536
8394
|
var port = portsRef.current.find(function (p) { return p.id === portId; });
|
|
9537
8395
|
if (!port)
|
|
@@ -9540,12 +8398,12 @@ var Element = function (props) {
|
|
|
9540
8398
|
}
|
|
9541
8399
|
}, [someElementLinkStarted]);
|
|
9542
8400
|
//Handle when mouse leave on port
|
|
9543
|
-
var handlePortMouseLeave = React
|
|
8401
|
+
var handlePortMouseLeave = React.useCallback(function () {
|
|
9544
8402
|
if (someElementLinkStarted)
|
|
9545
8403
|
setHoveredPort(undefined);
|
|
9546
8404
|
}, [someElementLinkStarted]);
|
|
9547
8405
|
//Get rotate angle of port by port direction is defined.
|
|
9548
|
-
var rotatePort = React
|
|
8406
|
+
var rotatePort = React.useCallback(function (x, y) {
|
|
9549
8407
|
// console.info('calculating port rotation', x, y)
|
|
9550
8408
|
if (!portSlideRailSVGClassName)
|
|
9551
8409
|
return 0;
|
|
@@ -9585,7 +8443,7 @@ var Element = function (props) {
|
|
|
9585
8443
|
}
|
|
9586
8444
|
return rotationAngle;
|
|
9587
8445
|
}, [portSlideRailSVGClassName, portDirection, getSlideRailSVG]);
|
|
9588
|
-
var renderedShape = React
|
|
8446
|
+
var renderedShape = React.useMemo(function () {
|
|
9589
8447
|
if (renderShape)
|
|
9590
8448
|
return renderShape(props);
|
|
9591
8449
|
return null;
|
|
@@ -9593,7 +8451,7 @@ var Element = function (props) {
|
|
|
9593
8451
|
//Re-render port again after rendered to automation rotate port
|
|
9594
8452
|
//Because elementRef.current equals null in first render so automation rotate port is incorrect.
|
|
9595
8453
|
//TODO: check if this is still needed -> Still needed
|
|
9596
|
-
React
|
|
8454
|
+
React.useLayoutEffect(function () {
|
|
9597
8455
|
if (elementRef.current) {
|
|
9598
8456
|
setPorts(function (prev) { return __spreadArray([], prev, true); });
|
|
9599
8457
|
}
|
|
@@ -9601,7 +8459,7 @@ var Element = function (props) {
|
|
|
9601
8459
|
//use selection frame
|
|
9602
8460
|
useSelectionFrame({
|
|
9603
8461
|
container: container,
|
|
9604
|
-
targetSVGElement: ((
|
|
8462
|
+
targetSVGElement: ((_a = selectedPort === null || selectedPort === void 0 ? void 0 : selectedPort.ref) === null || _a === void 0 ? void 0 : _a.current) || undefined,
|
|
9605
8463
|
resizability: {
|
|
9606
8464
|
enabled: false,
|
|
9607
8465
|
keepRatio: false
|
|
@@ -9613,34 +8471,36 @@ var Element = function (props) {
|
|
|
9613
8471
|
});
|
|
9614
8472
|
useSelectionFrame({
|
|
9615
8473
|
container: container,
|
|
9616
|
-
targetSVGElement: ((
|
|
8474
|
+
targetSVGElement: ((_b = hoveredPort === null || hoveredPort === void 0 ? void 0 : hoveredPort.ref) === null || _b === void 0 ? void 0 : _b.current) || undefined,
|
|
9617
8475
|
resizability: {
|
|
9618
8476
|
enabled: false,
|
|
9619
8477
|
keepRatio: false
|
|
9620
8478
|
},
|
|
9621
8479
|
});
|
|
9622
|
-
return (React
|
|
8480
|
+
return (React.createElement(ElementWrapper, { ref: elementRef, x: x, y: y, cssClass: cssClass, onClick: function (e) { return onClick ? onClick(id, e, elementRef.current) : true; }, onMouseMove: handleElementMouseMove, onMouseLeave: handleElementMouseLeave, onMouseUp: handleElementMouseUp, onContextMenu: function (e) { return onContextMenu ? onContextMenu(id, e, elementRef.current) : true; } },
|
|
9623
8481
|
renderedShape,
|
|
9624
8482
|
potentialPortPosition && (portPlaceholderShape
|
|
9625
|
-
? React
|
|
9626
|
-
: React
|
|
8483
|
+
? React.createElement("svg", { x: potentialPortPosition.x, y: potentialPortPosition.y }, portPlaceholderShape)
|
|
8484
|
+
: React.createElement("rect", { x: potentialPortPosition.x - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, y: potentialPortPosition.y - PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH / 2, width: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, height: PORT_PLACEHOLDER_DEFAULT_STROKE_WIDTH, rx: PORT_PLACEHOLDER_DEFAULT_SIZE, ry: PORT_PLACEHOLDER_DEFAULT_SIZE, stroke: PORT_PLACEHOLDER_DEFAULT_STROKE, fill: "none", strokeWidth: 3 })), ports === null || ports === void 0 ? void 0 :
|
|
9627
8485
|
ports.map(function (p, index) {
|
|
9628
|
-
var _a, _b, _c, _d, _e, _f
|
|
9629
|
-
return React
|
|
8486
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8487
|
+
return React.createElement(Port, { key: p.id, ref: p.ref, id: p.id, x: p.position.x, y: p.position.y, width: (_c = (_b = (_a = p.size) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : defaultPortSize) !== null && _c !== void 0 ? _c : PORT_DEFAULT_SIZE, height: (_f = (_e = (_d = p.size) === null || _d === void 0 ? void 0 : _d.height) !== null && _e !== void 0 ? _e : defaultPortSize) !== null && _f !== void 0 ? _f : PORT_DEFAULT_SIZE, container: container,
|
|
9630
8488
|
// rotation={rotatePort(p)}
|
|
9631
8489
|
calculateRotationAngle: rotatePort, label: p.label, onPortLabelMoved: handlePortLabelMoved, onPortLabelResized: handlePortLabelResized, onPortLabelContentChanged: handlePortLabelContentChanged, onSelected: handleSelectedPort, onMouseDown: handlePortMouseDown, onMouseUp: handlePortMouseUp, onMouseMove: handlePortMouseMove,
|
|
9632
8490
|
// onMouseEnter={() => {
|
|
9633
8491
|
// if (someElementLinkStarted) setHoveredPort(p)
|
|
9634
8492
|
// }}
|
|
9635
|
-
onMouseLeave: handlePortMouseLeave,
|
|
9636
|
-
|
|
9637
|
-
|
|
8493
|
+
onMouseLeave: handlePortMouseLeave,
|
|
8494
|
+
// onManuallyTriggerRenderHandler={p.manuallyTriggerRenderHandler?.bind(p)}
|
|
8495
|
+
renderShape: p.renderShape });
|
|
8496
|
+
}), texts === null || texts === void 0 ? void 0 :
|
|
8497
|
+
texts.map(function (t, index) {
|
|
9638
8498
|
var _a, _b;
|
|
9639
|
-
return React
|
|
9640
|
-
})
|
|
8499
|
+
return React.createElement(Text$1, { id: t.id, key: index, content: t.content, x: (_a = t.position) === null || _a === void 0 ? void 0 : _a.x, y: (_b = t.position) === null || _b === void 0 ? void 0 : _b.y, width: t.size.width, height: t.size.height, editable: t.editable, align: t.align, fontSize: t.fontSize, border: t.border, container: container, style: t.style, onContentChanged: function (ev, newContent) { return onTextUpdated === null || onTextUpdated === void 0 ? void 0 : onTextUpdated(id, t.id, newContent); } });
|
|
8500
|
+
}),
|
|
9641
8501
|
children));
|
|
9642
8502
|
};
|
|
9643
|
-
var Element$1 = React
|
|
8503
|
+
var Element$1 = React.memo(Element);
|
|
9644
8504
|
|
|
9645
8505
|
var createRect = function (x, y, width, height, strokeWidth, transformOrigin, transform) {
|
|
9646
8506
|
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
@@ -9658,9 +8518,9 @@ var createRect = function (x, y, width, height, strokeWidth, transformOrigin, tr
|
|
|
9658
8518
|
};
|
|
9659
8519
|
function BBoxDebugger(_a) {
|
|
9660
8520
|
var elementSVG = _a.elementSVG;
|
|
9661
|
-
var _b = React
|
|
9662
|
-
var displayedBBoxDebug = React
|
|
9663
|
-
React
|
|
8521
|
+
var _b = React.useState(false), isTurnOn = _b[0], setIsTurnOn = _b[1];
|
|
8522
|
+
var displayedBBoxDebug = React.useRef([]);
|
|
8523
|
+
React.useEffect(function () {
|
|
9664
8524
|
var keyPress = function (ev) {
|
|
9665
8525
|
if (ev.ctrlKey && ev.key === 'b') {
|
|
9666
8526
|
setIsTurnOn(function (prev) { return !prev; });
|
|
@@ -9740,7 +8600,7 @@ function BBoxDebugger(_a) {
|
|
|
9740
8600
|
}, 1000);
|
|
9741
8601
|
return intervalId;
|
|
9742
8602
|
};
|
|
9743
|
-
React
|
|
8603
|
+
React.useEffect(function () {
|
|
9744
8604
|
if (!isTurnOn || !elementSVG)
|
|
9745
8605
|
return;
|
|
9746
8606
|
var listChildrenGroupByLevel = getListChildrenAndGroupSameLevel(elementSVG);
|
|
@@ -9752,12 +8612,12 @@ function BBoxDebugger(_a) {
|
|
|
9752
8612
|
clearBBoxDebugger(displayedBBoxDebug.current);
|
|
9753
8613
|
};
|
|
9754
8614
|
}, [isTurnOn, elementSVG]);
|
|
9755
|
-
return (React
|
|
8615
|
+
return (React.createElement("div", { style: {
|
|
9756
8616
|
position: 'fixed',
|
|
9757
8617
|
top: 20,
|
|
9758
8618
|
right: 20
|
|
9759
8619
|
} },
|
|
9760
|
-
React
|
|
8620
|
+
React.createElement("div", { style: {
|
|
9761
8621
|
backgroundColor: 'white',
|
|
9762
8622
|
boxShadow: '0px 1px 4px 1px',
|
|
9763
8623
|
borderRadius: 4,
|
|
@@ -9781,9 +8641,9 @@ var createDebuggerPoint = function (cx, cy) {
|
|
|
9781
8641
|
};
|
|
9782
8642
|
var LinkDebugger = function (_a) {
|
|
9783
8643
|
var links = _a.links, svgContainer = _a.svgContainer;
|
|
9784
|
-
var _b = React
|
|
9785
|
-
var displayedDebuggerPoint = React
|
|
9786
|
-
React
|
|
8644
|
+
var _b = React.useState(false), isTurnOn = _b[0], setIsTurnOn = _b[1];
|
|
8645
|
+
var displayedDebuggerPoint = React.useRef([]);
|
|
8646
|
+
React.useEffect(function () {
|
|
9787
8647
|
var keyPress = function (ev) {
|
|
9788
8648
|
if (ev.ctrlKey && ev.key === 'l') {
|
|
9789
8649
|
setIsTurnOn(function (prev) { return !prev; });
|
|
@@ -9800,7 +8660,7 @@ var LinkDebugger = function (_a) {
|
|
|
9800
8660
|
ele === null || ele === void 0 ? void 0 : ele.remove();
|
|
9801
8661
|
}
|
|
9802
8662
|
};
|
|
9803
|
-
React
|
|
8663
|
+
React.useEffect(function () {
|
|
9804
8664
|
if (isTurnOn) {
|
|
9805
8665
|
links.forEach(function (link) {
|
|
9806
8666
|
var _a;
|
|
@@ -9815,13 +8675,13 @@ var LinkDebugger = function (_a) {
|
|
|
9815
8675
|
clearDebuggerPoint();
|
|
9816
8676
|
};
|
|
9817
8677
|
}, [isTurnOn, links]);
|
|
9818
|
-
return (React
|
|
8678
|
+
return (React.createElement("div", null));
|
|
9819
8679
|
};
|
|
9820
8680
|
|
|
9821
8681
|
function useKeyboardCommands(_a) {
|
|
9822
8682
|
var element = _a.element;
|
|
9823
|
-
var _b = React
|
|
9824
|
-
React
|
|
8683
|
+
var _b = React.useContext(paperEventEmitterContext), emitCommandDeleteSelectedElement = _b.emitCommandDeleteSelectedElement, emitCommandDeleteSelectedLink = _b.emitCommandDeleteSelectedLink, emitCommandDeleteSelectedPort = _b.emitCommandDeleteSelectedPort, emitCommandDeleteSelectedText = _b.emitCommandDeleteSelectedText;
|
|
8684
|
+
React.useEffect(function () {
|
|
9825
8685
|
var callback = function (ev) {
|
|
9826
8686
|
var keyboardEv = ev;
|
|
9827
8687
|
if (keyboardEv.key === "Delete") {
|
|
@@ -9870,27 +8730,44 @@ function convertElementsToTree(elements) {
|
|
|
9870
8730
|
return parsedElementsInTree;
|
|
9871
8731
|
}
|
|
9872
8732
|
var Paper = function (props) {
|
|
9873
|
-
var _a;
|
|
9874
|
-
var _b = React
|
|
9875
|
-
var _c = React
|
|
9876
|
-
var _d = React
|
|
9877
|
-
var _e = React
|
|
9878
|
-
var _f = React
|
|
9879
|
-
var _g = React
|
|
9880
|
-
var _h = React
|
|
9881
|
-
var _j = React
|
|
9882
|
-
var _k = React
|
|
9883
|
-
var
|
|
9884
|
-
var
|
|
9885
|
-
var
|
|
9886
|
-
var
|
|
9887
|
-
var elementsRef = React$1.useRef(elements); //Cache elements to avoid re-render when elements changed
|
|
8733
|
+
var _a = React.useState([]), elements = _a[0], setElements = _a[1];
|
|
8734
|
+
var _b = React.useState([]), elementsInTree = _b[0], setElementsInTree = _b[1];
|
|
8735
|
+
var _c = React.useState(), selectedElement = _c[0], setSelectedElement = _c[1];
|
|
8736
|
+
var _d = React.useState([]), links = _d[0], setLinks = _d[1];
|
|
8737
|
+
var _e = React.useState(), selectedLink = _e[0], setSelectedLink = _e[1];
|
|
8738
|
+
var _f = React.useState(null), tempLink = _f[0], setTempLink = _f[1];
|
|
8739
|
+
var _g = React.useState([]), texts = _g[0], setTexts = _g[1];
|
|
8740
|
+
var _h = React.useState(), selectedText = _h[0], setSelectedText = _h[1];
|
|
8741
|
+
var _j = React.useState(null), selectedElementSVG = _j[0], setSelectedElementSVG = _j[1];
|
|
8742
|
+
var _k = React.useState(false), mouseDownedOnPaper = _k[0], setMouseDownedOnPaper = _k[1];
|
|
8743
|
+
var paperEventEmitter = React.useContext(paperEventEmitterContext);
|
|
8744
|
+
var paperContainerRef = React.useRef(null);
|
|
8745
|
+
var tempLinkRef = React.useRef(tempLink); //Cache tempLink to avoid re-render when tempLink changed
|
|
8746
|
+
var elementsRef = React.useRef(elements); //Cache elements to avoid re-render when elements changed
|
|
9888
8747
|
var size = props.size;
|
|
9889
|
-
React
|
|
8748
|
+
React.useEffect(function () {
|
|
9890
8749
|
console.log('Render Paper');
|
|
9891
8750
|
});
|
|
8751
|
+
React.useEffect(function () {
|
|
8752
|
+
setElements(props.elements);
|
|
8753
|
+
}, [props.elements]);
|
|
8754
|
+
React.useEffect(function () {
|
|
8755
|
+
setLinks(props.links || []);
|
|
8756
|
+
}, [props.links]);
|
|
8757
|
+
React.useEffect(function () {
|
|
8758
|
+
setTexts(props.texts);
|
|
8759
|
+
}, [props.texts]);
|
|
8760
|
+
React.useEffect(function () {
|
|
8761
|
+
var off = props.onManuallyTriggerRenderElement(function (elementId) {
|
|
8762
|
+
console.log('onManuallyTriggerRenderElement');
|
|
8763
|
+
setElements(function (prev) { return __spreadArray([], prev, true); });
|
|
8764
|
+
});
|
|
8765
|
+
return function () {
|
|
8766
|
+
off();
|
|
8767
|
+
};
|
|
8768
|
+
}, [props.onManuallyTriggerRenderElement]);
|
|
9892
8769
|
//Cache elements to avoid re-render when elements changed
|
|
9893
|
-
React
|
|
8770
|
+
React.useEffect(function () {
|
|
9894
8771
|
elementsRef.current = elements;
|
|
9895
8772
|
}, [elements]);
|
|
9896
8773
|
useKeyboardCommands({
|
|
@@ -9901,11 +8778,11 @@ var Paper = function (props) {
|
|
|
9901
8778
|
setElementsInTree(parsedElementsInTree);
|
|
9902
8779
|
};
|
|
9903
8780
|
//Cache tempLink to avoid re-render when tempLink changed
|
|
9904
|
-
React
|
|
8781
|
+
React.useEffect(function () {
|
|
9905
8782
|
tempLinkRef.current = tempLink;
|
|
9906
8783
|
}, [tempLink]);
|
|
9907
8784
|
//Listen text is selected
|
|
9908
|
-
React
|
|
8785
|
+
React.useEffect(function () {
|
|
9909
8786
|
var textSelectedListener = paperEventEmitter.onTextSelected(function (text) {
|
|
9910
8787
|
var _a;
|
|
9911
8788
|
setSelectedElement(undefined);
|
|
@@ -9919,7 +8796,7 @@ var Paper = function (props) {
|
|
|
9919
8796
|
};
|
|
9920
8797
|
}, []);
|
|
9921
8798
|
//Listen port is selected
|
|
9922
|
-
React
|
|
8799
|
+
React.useEffect(function () {
|
|
9923
8800
|
var portSelectedListener = paperEventEmitter.onPortSelected(function (port, elementId) {
|
|
9924
8801
|
var _a;
|
|
9925
8802
|
setSelectedElement(undefined);
|
|
@@ -9935,11 +8812,12 @@ var Paper = function (props) {
|
|
|
9935
8812
|
portSelectedListener.off();
|
|
9936
8813
|
};
|
|
9937
8814
|
}, []);
|
|
9938
|
-
React
|
|
8815
|
+
React.useEffect(function () {
|
|
9939
8816
|
//Listen parent of elements changed, then update elements tree
|
|
9940
8817
|
var parentChangedCancelers = elementsRef.current.map(function (element) {
|
|
9941
8818
|
var _a;
|
|
9942
8819
|
return (_a = element.onParentChanged) === null || _a === void 0 ? void 0 : _a.call(element, function (newPa, oldPa) {
|
|
8820
|
+
console.log('onParentChanged');
|
|
9943
8821
|
updateElementsTree();
|
|
9944
8822
|
});
|
|
9945
8823
|
});
|
|
@@ -9963,7 +8841,7 @@ var Paper = function (props) {
|
|
|
9963
8841
|
};
|
|
9964
8842
|
}, []);
|
|
9965
8843
|
//Update elements tree when length of elements change
|
|
9966
|
-
React
|
|
8844
|
+
React.useEffect(function () {
|
|
9967
8845
|
updateElementsTree();
|
|
9968
8846
|
}, [elements]);
|
|
9969
8847
|
//Get all child elements of the deleted element
|
|
@@ -9977,7 +8855,7 @@ var Paper = function (props) {
|
|
|
9977
8855
|
return __spreadArray(__spreadArray([], childElms, true), childOfChildElements, true);
|
|
9978
8856
|
};
|
|
9979
8857
|
//Listen command delete selected for element
|
|
9980
|
-
React
|
|
8858
|
+
React.useEffect(function () {
|
|
9981
8859
|
var _a;
|
|
9982
8860
|
var listener = paperEventEmitter.onCommandDeleteSelectedElement(function () {
|
|
9983
8861
|
if (selectedElement) {
|
|
@@ -9998,7 +8876,7 @@ var Paper = function (props) {
|
|
|
9998
8876
|
};
|
|
9999
8877
|
}, [selectedElement]);
|
|
10000
8878
|
//Listen command delete selected for link
|
|
10001
|
-
React
|
|
8879
|
+
React.useEffect(function () {
|
|
10002
8880
|
var _a;
|
|
10003
8881
|
var listener = paperEventEmitter.onCommandDeleteSelectedLink(function () {
|
|
10004
8882
|
if (selectedLink) {
|
|
@@ -10015,7 +8893,7 @@ var Paper = function (props) {
|
|
|
10015
8893
|
};
|
|
10016
8894
|
}, [selectedLink]);
|
|
10017
8895
|
//Listen command delete selected for Text
|
|
10018
|
-
React
|
|
8896
|
+
React.useEffect(function () {
|
|
10019
8897
|
var _a;
|
|
10020
8898
|
var listener = paperEventEmitter.onCommandDeleteSelectedText(function () {
|
|
10021
8899
|
if (selectedText) {
|
|
@@ -10032,7 +8910,7 @@ var Paper = function (props) {
|
|
|
10032
8910
|
};
|
|
10033
8911
|
}, [selectedText]);
|
|
10034
8912
|
//Automatically add points on the link so that the link does not cross elements, default maximum 10 points
|
|
10035
|
-
var automationAddPointsToLink = React
|
|
8913
|
+
var automationAddPointsToLink = React.useCallback(function (eleLink, limitPoint) {
|
|
10036
8914
|
if (limitPoint === void 0) { limitPoint = 10; }
|
|
10037
8915
|
var sourceElement = eleLink.sourceElement, sourcePort = eleLink.sourcePort, targetElement = eleLink.targetElement, targetPort = eleLink.targetPort;
|
|
10038
8916
|
var sourcePosition = {
|
|
@@ -10127,7 +9005,7 @@ var Paper = function (props) {
|
|
|
10127
9005
|
y: ev.clientY
|
|
10128
9006
|
});
|
|
10129
9007
|
};
|
|
10130
|
-
var handlePathChange = React
|
|
9008
|
+
var handlePathChange = React.useCallback(function (path, id) {
|
|
10131
9009
|
//Update path of element link, that changed
|
|
10132
9010
|
setLinks(function (prevLinks) {
|
|
10133
9011
|
var updatedLinkIndex = prevLinks.findIndex(function (l) { return l.id === id; });
|
|
@@ -10135,7 +9013,7 @@ var Paper = function (props) {
|
|
|
10135
9013
|
return __spreadArray([], prevLinks, true);
|
|
10136
9014
|
});
|
|
10137
9015
|
}, []);
|
|
10138
|
-
var handlePortMoved = React
|
|
9016
|
+
var handlePortMoved = React.useCallback(function (port, elementId, oldPosition, newPosition) {
|
|
10139
9017
|
var element = elementsRef.current.find(function (e) { return e.id === elementId; });
|
|
10140
9018
|
if (element) {
|
|
10141
9019
|
//set links equals a clone links to re-render links with new position
|
|
@@ -10167,23 +9045,27 @@ var Paper = function (props) {
|
|
|
10167
9045
|
}
|
|
10168
9046
|
}, [props.onPortMoved]);
|
|
10169
9047
|
//Handle creating a new element link
|
|
10170
|
-
var handlePortMouseDown = React
|
|
9048
|
+
var handlePortMouseDown = React.useCallback(function (ev, port, elementId) {
|
|
9049
|
+
var _a;
|
|
10171
9050
|
ev.stopPropagation();
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
9051
|
+
var element = elementsRef.current.find(function (e) { return e.id === elementId; });
|
|
9052
|
+
//broadcast port mouse down to parent component
|
|
9053
|
+
if (element) {
|
|
9054
|
+
(_a = props.onPortMouseDown) === null || _a === void 0 ? void 0 : _a.call(props, port, element);
|
|
9055
|
+
}
|
|
9056
|
+
if (!tempLinkRef.current && element) {
|
|
9057
|
+
//handle create temp element link;
|
|
9058
|
+
var newLink = {
|
|
9059
|
+
id: generateUniqueId(),
|
|
9060
|
+
points: [],
|
|
9061
|
+
sourceElement: element,
|
|
9062
|
+
sourcePort: port,
|
|
9063
|
+
};
|
|
9064
|
+
setTempLink(newLink);
|
|
9065
|
+
paperEventEmitter.emitElementLinkStarted(newLink);
|
|
9066
|
+
}
|
|
9067
|
+
}, [paperEventEmitter, props.onPortMouseDown]);
|
|
9068
|
+
var createElementLink = React.useCallback(function (sourcePort, sourceElement, targetPort, targetElement) {
|
|
10187
9069
|
//if no onCreatingLink prop, no link will be created
|
|
10188
9070
|
if (!props.onCreatingLink) {
|
|
10189
9071
|
return null;
|
|
@@ -10197,15 +9079,21 @@ var Paper = function (props) {
|
|
|
10197
9079
|
}
|
|
10198
9080
|
return newElementLink;
|
|
10199
9081
|
}, [props.onCreatingLink, automationAddPointsToLink]);
|
|
10200
|
-
var handlePortMouseUp = React
|
|
9082
|
+
var handlePortMouseUp = React.useCallback(function (ev, port, elementId) {
|
|
9083
|
+
var _a;
|
|
10201
9084
|
ev.stopPropagation();
|
|
9085
|
+
var element = elementsRef.current.find(function (e) { return e.id === elementId; });
|
|
9086
|
+
//broadcast port mouse down to parent component
|
|
9087
|
+
if (element) {
|
|
9088
|
+
(_a = props.onPortMouseUp) === null || _a === void 0 ? void 0 : _a.call(props, port, element);
|
|
9089
|
+
}
|
|
10202
9090
|
//Create new element link, if has tempLink
|
|
10203
9091
|
if (tempLinkRef.current) {
|
|
10204
9092
|
//Check if mouse up point is mouse down point or not
|
|
10205
9093
|
var isMouseUpOnNotSelf = tempLinkRef.current.sourcePort.id !== port.id || tempLinkRef.current.sourceElement.id !== elementId;
|
|
10206
9094
|
var newElementLink_1 = null;
|
|
10207
9095
|
if (isMouseUpOnNotSelf) {
|
|
10208
|
-
var
|
|
9096
|
+
var _b = tempLinkRef.current, sourcePort = _b.sourcePort, sourceElement = _b.sourceElement;
|
|
10209
9097
|
var targetElement = elementsRef.current.find(function (e) { return e.id === elementId; });
|
|
10210
9098
|
newElementLink_1 = createElementLink(sourcePort, sourceElement, port, targetElement);
|
|
10211
9099
|
}
|
|
@@ -10218,8 +9106,8 @@ var Paper = function (props) {
|
|
|
10218
9106
|
}
|
|
10219
9107
|
setTempLink(null);
|
|
10220
9108
|
}
|
|
10221
|
-
}, [paperEventEmitter, createElementLink]);
|
|
10222
|
-
var handleLinkLabelMoved = React
|
|
9109
|
+
}, [paperEventEmitter, createElementLink, props.onPortMouseUp]);
|
|
9110
|
+
var handleLinkLabelMoved = React.useCallback(function (offsetX, offsetY, index, labelType) {
|
|
10223
9111
|
setLinks(function (prevLinks) {
|
|
10224
9112
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
10225
9113
|
var currentLink = newLinks[index];
|
|
@@ -10255,7 +9143,7 @@ var Paper = function (props) {
|
|
|
10255
9143
|
return newLinks;
|
|
10256
9144
|
});
|
|
10257
9145
|
}, []);
|
|
10258
|
-
var handleLinkLabelResized = React
|
|
9146
|
+
var handleLinkLabelResized = React.useCallback(function (width, height, index, labelType) {
|
|
10259
9147
|
setLinks(function (prevLinks) {
|
|
10260
9148
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
10261
9149
|
var currentLink = newLinks[index];
|
|
@@ -10288,7 +9176,7 @@ var Paper = function (props) {
|
|
|
10288
9176
|
return newLinks;
|
|
10289
9177
|
});
|
|
10290
9178
|
}, []);
|
|
10291
|
-
var handleLinkLabelContentChanged = React
|
|
9179
|
+
var handleLinkLabelContentChanged = React.useCallback(function (newValue, index, labelType) {
|
|
10292
9180
|
setLinks(function (prevLinks) {
|
|
10293
9181
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
10294
9182
|
var currentLink = newLinks[index];
|
|
@@ -10372,7 +9260,7 @@ var Paper = function (props) {
|
|
|
10372
9260
|
Cache to avoid re-initializing the function when the component re-renders to
|
|
10373
9261
|
avoid causing the components using it to re-render unnecessarily
|
|
10374
9262
|
*/
|
|
10375
|
-
var onLabelMoved = React
|
|
9263
|
+
var onLabelMoved = React.useCallback(function (index) {
|
|
10376
9264
|
return function (offsetX, offsetY, labelType) {
|
|
10377
9265
|
handleLinkLabelMoved(offsetX, offsetY, index, labelType);
|
|
10378
9266
|
};
|
|
@@ -10381,7 +9269,7 @@ var Paper = function (props) {
|
|
|
10381
9269
|
Cache to avoid re-initializing the function when the component re-renders to
|
|
10382
9270
|
avoid causing the components using it to re-render unnecessarily
|
|
10383
9271
|
*/
|
|
10384
|
-
var onLabelResized = React
|
|
9272
|
+
var onLabelResized = React.useCallback(function (index) {
|
|
10385
9273
|
return function (width, height, labelType) {
|
|
10386
9274
|
handleLinkLabelResized(width, height, index, labelType);
|
|
10387
9275
|
};
|
|
@@ -10390,12 +9278,12 @@ var Paper = function (props) {
|
|
|
10390
9278
|
Cache to avoid re-initializing the function when the component re-renders to
|
|
10391
9279
|
avoid causing the components using it to re-render unnecessarily
|
|
10392
9280
|
*/
|
|
10393
|
-
var onLabelContentChanged = React
|
|
9281
|
+
var onLabelContentChanged = React.useCallback(function (index) {
|
|
10394
9282
|
return function (newValue, labelType) {
|
|
10395
9283
|
handleLinkLabelContentChanged(newValue, index, labelType);
|
|
10396
9284
|
};
|
|
10397
9285
|
}, [handleLinkLabelContentChanged]);
|
|
10398
|
-
var handleClickLinkDelete = React
|
|
9286
|
+
var handleClickLinkDelete = React.useCallback(function (link, index) {
|
|
10399
9287
|
return function () {
|
|
10400
9288
|
setLinks(function (prevLinks) {
|
|
10401
9289
|
var newLinks = __spreadArray([], prevLinks, true);
|
|
@@ -10404,7 +9292,7 @@ var Paper = function (props) {
|
|
|
10404
9292
|
});
|
|
10405
9293
|
};
|
|
10406
9294
|
}, []);
|
|
10407
|
-
var handleMouseUpAtLinkedPortPlaceholder = React
|
|
9295
|
+
var handleMouseUpAtLinkedPortPlaceholder = React.useCallback(function (link, position, targetElementId) {
|
|
10408
9296
|
var targetElement = elementsRef.current.find(function (e) { return e.id === targetElementId; });
|
|
10409
9297
|
if (!targetElement)
|
|
10410
9298
|
return;
|
|
@@ -10431,7 +9319,7 @@ var Paper = function (props) {
|
|
|
10431
9319
|
setTempLink(null);
|
|
10432
9320
|
paperEventEmitter.emitElementLinkEnded();
|
|
10433
9321
|
}, [props.onCreatingPortByLinking, createElementLink, paperEventEmitter]);
|
|
10434
|
-
var handleElementTextChange = React
|
|
9322
|
+
var handleElementTextChange = React.useCallback(function (elementId, textId, newContent) {
|
|
10435
9323
|
setElements(function (prevElms) {
|
|
10436
9324
|
return prevElms.map(function (curEle) {
|
|
10437
9325
|
//Find changed text of element to update the content for it.
|
|
@@ -10445,7 +9333,7 @@ var Paper = function (props) {
|
|
|
10445
9333
|
});
|
|
10446
9334
|
});
|
|
10447
9335
|
}, []);
|
|
10448
|
-
var handleElementClicked = React
|
|
9336
|
+
var handleElementClicked = React.useCallback(function (elementId, e, ref) {
|
|
10449
9337
|
e.stopPropagation();
|
|
10450
9338
|
var tempLink = tempLinkRef.current;
|
|
10451
9339
|
if (tempLink) {
|
|
@@ -10463,7 +9351,7 @@ var Paper = function (props) {
|
|
|
10463
9351
|
}
|
|
10464
9352
|
setMouseDownedOnPaper(false);
|
|
10465
9353
|
}, [paperEventEmitter]);
|
|
10466
|
-
var handleContextMenu = React
|
|
9354
|
+
var handleContextMenu = React.useCallback(function (elementId, e, ref) {
|
|
10467
9355
|
var _a;
|
|
10468
9356
|
e.preventDefault();
|
|
10469
9357
|
var element = elementsRef.current.find(function (e) { return e.id === elementId; });
|
|
@@ -10472,28 +9360,54 @@ var Paper = function (props) {
|
|
|
10472
9360
|
(_a = props.onElementContextMenu) === null || _a === void 0 ? void 0 : _a.call(props, element, e);
|
|
10473
9361
|
}
|
|
10474
9362
|
}, [props.onElementContextMenu, handleElementClicked]);
|
|
10475
|
-
var
|
|
10476
|
-
var _a
|
|
9363
|
+
var handleMouseUp = React.useCallback(function (ev, elementId) {
|
|
9364
|
+
var _a;
|
|
9365
|
+
var element = elementsRef.current.find(function (ele) { return ele.id === elementId; });
|
|
9366
|
+
if (element) {
|
|
9367
|
+
(_a = props.onElementMouseUp) === null || _a === void 0 ? void 0 : _a.call(props, ev, element);
|
|
9368
|
+
}
|
|
9369
|
+
}, [props.onElementMouseUp]);
|
|
9370
|
+
var handleMouseMove = React.useCallback(function (ev, elementId) {
|
|
9371
|
+
var _a;
|
|
9372
|
+
var element = elementsRef.current.find(function (ele) { return ele.id === elementId; });
|
|
9373
|
+
if (element) {
|
|
9374
|
+
(_a = props.onElementMouseMove) === null || _a === void 0 ? void 0 : _a.call(props, ev, element);
|
|
9375
|
+
}
|
|
9376
|
+
}, [props.onElementMouseMove]);
|
|
9377
|
+
var handleMouseLeave = React.useCallback(function (ev, elementId) {
|
|
9378
|
+
var _a;
|
|
9379
|
+
var element = elementsRef.current.find(function (ele) { return ele.id === elementId; });
|
|
9380
|
+
if (element) {
|
|
9381
|
+
(_a = props.onElementMouseLeave) === null || _a === void 0 ? void 0 : _a.call(props, ev, element);
|
|
9382
|
+
}
|
|
9383
|
+
}, [props.onElementMouseLeave]);
|
|
9384
|
+
var renderElementInTree = React.useCallback(function (element) {
|
|
9385
|
+
var _a, _b;
|
|
10477
9386
|
//use the defined react element or the default Element component
|
|
10478
9387
|
var ReactElement = element.reactElement || Element$1;
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
React$1.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x: (_a = element.relativePosition) === null || _a === void 0 ? void 0 : _a.x, y: (_b = element.relativePosition) === null || _b === void 0 ? void 0 : _b.y, onClick: handleElementClicked, onContextMenu: handleContextMenu, container: paperContainerRef.current, renderShape: element.renderShape, cssClass: element.cssClass, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, defaultPortSize: element.defaultPortSize, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
9388
|
+
return (React.createElement("g", { key: element.id },
|
|
9389
|
+
React.createElement(ReactElement, { key: "element-".concat(element.id), id: element.id, height: element.size.height, width: element.size.width, x: (_a = element.relativePosition) === null || _a === void 0 ? void 0 : _a.x, y: (_b = element.relativePosition) === null || _b === void 0 ? void 0 : _b.y, onClick: handleElementClicked, onContextMenu: handleContextMenu, onMouseUp: handleMouseUp, onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, container: paperContainerRef.current, renderShape: element.renderShape, cssClass: element.cssClass, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, defaultPortSize: element.defaultPortSize, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
10482
9390
|
// portPlaceholderShape={(<Circle x={0} y={0} width={10} height={10} fill='red' positioningAnchor={PositioningAnchor.Center} />)}
|
|
10483
|
-
onMouseUpAtLinkedPortPlaceholder: handleMouseUpAtLinkedPortPlaceholder, onTextUpdated: handleElementTextChange,
|
|
10484
|
-
}, [handleElementClicked, handleContextMenu, handlePortMoved, handlePortMouseDown, handlePortMouseUp, handleMouseUpAtLinkedPortPlaceholder, handleElementTextChange]);
|
|
10485
|
-
|
|
9391
|
+
onMouseUpAtLinkedPortPlaceholder: handleMouseUpAtLinkedPortPlaceholder, onTextUpdated: handleElementTextChange, onManuallyTriggerRenderPort: props.onManuallyTriggerRenderPort, textsPlaceHolderClassName: element.textsPlaceHolderClassName, textsPlaceHolderFlexStyle: element.textsPlaceHolderFlexStyle, textsPlaceHolderFlexboxPosition: element.textsPlaceHolderFlexboxPosition }, element.childrenElements && element.childrenElements.map(renderElementInTree))));
|
|
9392
|
+
}, [handleElementClicked, handleContextMenu, handlePortMoved, handlePortMouseDown, handlePortMouseUp, handleMouseUpAtLinkedPortPlaceholder, handleElementTextChange, handleMouseUp, handleMouseMove, handleMouseLeave]);
|
|
9393
|
+
React.useEffect(function () {
|
|
9394
|
+
console.log('elementsInTree');
|
|
9395
|
+
}, [elementsInTree]);
|
|
9396
|
+
React.useEffect(function () {
|
|
9397
|
+
console.log('renderElementInTree');
|
|
9398
|
+
}, [renderElementInTree]);
|
|
9399
|
+
var ElementsInTree = React.useMemo(function () {
|
|
10486
9400
|
return elementsInTree.map(function (element, index) {
|
|
10487
9401
|
return renderElementInTree(element);
|
|
10488
9402
|
});
|
|
10489
9403
|
}, [elementsInTree, renderElementInTree]);
|
|
10490
|
-
return (React
|
|
10491
|
-
React
|
|
10492
|
-
React
|
|
9404
|
+
return (React.createElement("div", { style: { position: "relative" } },
|
|
9405
|
+
React.createElement(Ruler, { squareSize: 100, border: '1px dashed grey' }),
|
|
9406
|
+
React.createElement("svg", { tabIndex: 0, width: size.width, height: size.height, ref: paperContainerRef, id: "paper-container", onMouseMove: handlePaperMouseMove, onMouseDown: handleMouseDownOnPaper, onMouseUp: handleMouseUpOnPaper },
|
|
10493
9407
|
paperContainerRef.current ? ElementsInTree : "",
|
|
10494
9408
|
links && links.map(function (link, index) {
|
|
10495
9409
|
var _a, _b, _c, _d;
|
|
10496
|
-
return (React
|
|
9410
|
+
return (React.createElement(ElementLink, { key: link.id, id: link.id, path: link.path, sourcePosition: {
|
|
10497
9411
|
x: link.sourceElement.position.x + link.sourcePort.position.x,
|
|
10498
9412
|
y: link.sourceElement.position.y + link.sourcePort.position.y
|
|
10499
9413
|
}, targetPosition: {
|
|
@@ -10501,78 +9415,116 @@ var Paper = function (props) {
|
|
|
10501
9415
|
y: ((_c = link.targetElement) === null || _c === void 0 ? void 0 : _c.position.y) + ((_d = link.targetPort) === null || _d === void 0 ? void 0 : _d.position.y)
|
|
10502
9416
|
}, points: link.points, onPathChanged: handlePathChange, onClickDelete: handleClickLinkDelete(link, index), onSelected: function () { return handleSelectLink(link); }, onDeselected: function () { return handleDeselectLink(); }, container: paperContainerRef.current, markerStart: link.markerStart, markerEnd: link.markerEnd, markerDistanceFromPort: link.markerDistanceFromPort, markerSize: link.markerSize, label: link.label, sourceLabel: link.sourceLabel, targetLabel: link.targetLabel, onLabelMoved: onLabelMoved(index), onLabelResized: onLabelResized(index), onLabelContentChanged: onLabelContentChanged(index) }));
|
|
10503
9417
|
}),
|
|
10504
|
-
(tempLink === null || tempLink === void 0 ? void 0 : tempLink.tempTargetPosition) && React
|
|
9418
|
+
(tempLink === null || tempLink === void 0 ? void 0 : tempLink.tempTargetPosition) && React.createElement(ElementLink, { id: tempLink.id, points: tempLink.points, sourcePosition: {
|
|
10505
9419
|
x: tempLink.sourceElement.position.x + tempLink.sourcePort.position.x,
|
|
10506
9420
|
y: tempLink.sourceElement.position.y + tempLink.sourcePort.position.y
|
|
10507
9421
|
}, targetPosition: tempLink.tempTargetPosition, container: paperContainerRef.current, markerStart: tempLink.markerStart, markerEnd: tempLink.markerEnd, markerDistanceFromPort: tempLink.markerDistanceFromPort, markerSize: tempLink.markerSize }),
|
|
10508
|
-
texts.map(function (text, index) { return (React
|
|
9422
|
+
texts.map(function (text, index) { return (React.createElement(Text$1, { key: text.id, id: text.id, x: text.position.x, y: text.position.y, width: text.size.width, height: text.size.height, editable: text.editable, fontSize: text.fontSize, border: text.border, container: paperContainerRef.current, content: text.content, align: text.align, onSelected: function () {
|
|
10509
9423
|
setSelectedText(text);
|
|
10510
9424
|
} })); })),
|
|
10511
|
-
React
|
|
10512
|
-
React
|
|
9425
|
+
React.createElement(BBoxDebugger, { elementSVG: selectedElementSVG }),
|
|
9426
|
+
React.createElement(LinkDebugger, { links: links, svgContainer: paperContainerRef.current })));
|
|
10513
9427
|
};
|
|
10514
|
-
var Paper$1 = React
|
|
9428
|
+
var Paper$1 = React.memo(Paper);
|
|
10515
9429
|
|
|
10516
|
-
function
|
|
9430
|
+
var Editor = function (_a) {
|
|
10517
9431
|
var editorContext = _a.editorContext, width = _a.width, height = _a.height;
|
|
9432
|
+
var _b = React.useState([]), elements = _b[0], setElements = _b[1];
|
|
9433
|
+
var _c = React.useState([]), links = _c[0], setLinks = _c[1];
|
|
9434
|
+
var _d = React.useState([]), texts = _d[0], setTexts = _d[1];
|
|
10518
9435
|
if (!width) {
|
|
10519
9436
|
width = 3000;
|
|
10520
9437
|
}
|
|
10521
9438
|
if (!height) {
|
|
10522
9439
|
height = 3000;
|
|
10523
9440
|
}
|
|
10524
|
-
var
|
|
9441
|
+
var setEditorStates = React.useCallback(function (ctx) {
|
|
9442
|
+
setElements(__spreadArray([], ctx.elements, true));
|
|
9443
|
+
setLinks(__spreadArray([], ctx.links, true));
|
|
9444
|
+
setTexts(__spreadArray([], ctx.texts, true));
|
|
9445
|
+
}, []);
|
|
9446
|
+
React.useEffect(function () {
|
|
9447
|
+
if (editorContext) {
|
|
9448
|
+
setEditorStates(editorContext);
|
|
9449
|
+
}
|
|
9450
|
+
}, [editorContext, setEditorStates]);
|
|
9451
|
+
React.useEffect(function () {
|
|
9452
|
+
var offs = [];
|
|
9453
|
+
if (editorContext) {
|
|
9454
|
+
offs.push(editorContext.onEditorContextUpdated(function () {
|
|
9455
|
+
console.log("onEditorContextUpdated");
|
|
9456
|
+
setEditorStates(editorContext);
|
|
9457
|
+
}));
|
|
9458
|
+
}
|
|
9459
|
+
return function () {
|
|
9460
|
+
offs.forEach(function (off) { return off(); });
|
|
9461
|
+
};
|
|
9462
|
+
}, [editorContext, setEditorStates]);
|
|
9463
|
+
var handlePaperClicked = React.useCallback(function (position) {
|
|
10525
9464
|
editorContext.onPaperClickedHandler(position);
|
|
10526
9465
|
}, [editorContext]);
|
|
10527
|
-
var
|
|
9466
|
+
var handlePortMouseDown = React.useCallback(function (port, element) {
|
|
9467
|
+
editorContext.onPortMouseDownHandler(port, element);
|
|
9468
|
+
}, [editorContext]);
|
|
9469
|
+
var handlePortMouseUp = React.useCallback(function (port, element) {
|
|
9470
|
+
editorContext.onPortMouseUpHandler(port, element);
|
|
9471
|
+
}, [editorContext]);
|
|
9472
|
+
var handlePortMoved = React.useCallback(function (position, port, element) {
|
|
10528
9473
|
editorContext.onPortMovedHandler(position, port, element);
|
|
10529
9474
|
}, [editorContext]);
|
|
10530
|
-
var handlePortSelected = React
|
|
9475
|
+
var handlePortSelected = React.useCallback(function (port, element) {
|
|
10531
9476
|
editorContext.onPortSelectedHandler(port, element);
|
|
10532
9477
|
}, [editorContext]);
|
|
10533
|
-
var handleElementContextMenu = React
|
|
9478
|
+
var handleElementContextMenu = React.useCallback(function (element, event) {
|
|
10534
9479
|
editorContext.onElementContextMenuHandler(element, event);
|
|
10535
9480
|
}, [editorContext]);
|
|
10536
|
-
var handleElementMoved = React
|
|
9481
|
+
var handleElementMoved = React.useCallback(function (position, element) {
|
|
10537
9482
|
editorContext.onElementMovedHandler(position, element);
|
|
10538
9483
|
}, [editorContext]);
|
|
10539
|
-
var handleElementResized = React
|
|
9484
|
+
var handleElementResized = React.useCallback(function (size, element) {
|
|
10540
9485
|
editorContext.onElementResizedHandler(size, element);
|
|
10541
9486
|
}, [editorContext]);
|
|
10542
|
-
var handleElementSelected = React
|
|
9487
|
+
var handleElementSelected = React.useCallback(function (element) {
|
|
10543
9488
|
editorContext.onElementSelectedHandler(element);
|
|
10544
9489
|
}, [editorContext]);
|
|
10545
|
-
var
|
|
9490
|
+
var handleElementMouseLeave = React.useCallback(function (ev, element) {
|
|
9491
|
+
editorContext.onElementMouseLeaveHandler(ev, element);
|
|
9492
|
+
}, [editorContext]);
|
|
9493
|
+
var handleElementMouseMove = React.useCallback(function (ev, element) {
|
|
9494
|
+
editorContext.onElementMouseMoveHandler(ev, element);
|
|
9495
|
+
}, [editorContext]);
|
|
9496
|
+
var handleElementMouseUp = React.useCallback(function (ev, element) {
|
|
9497
|
+
editorContext.onElementMouseUpHandler(ev, element);
|
|
9498
|
+
}, [editorContext]);
|
|
9499
|
+
var handleLinkSelected = React.useCallback(function (link) {
|
|
10546
9500
|
editorContext.onLinkSelectedHandler(link);
|
|
10547
9501
|
}, [editorContext]);
|
|
10548
|
-
var handleTextSelected = React
|
|
9502
|
+
var handleTextSelected = React.useCallback(function (text) {
|
|
10549
9503
|
editorContext.onTextSelectedHandler(text);
|
|
10550
9504
|
}, [editorContext]);
|
|
10551
|
-
var handleOnCreatingLink = React
|
|
9505
|
+
var handleOnCreatingLink = React.useCallback(function (sourcePort, sourceElement, targetPort, targetElement) {
|
|
10552
9506
|
if (editorContext.onCreatingLinkHandler) {
|
|
10553
9507
|
return editorContext.onCreatingLinkHandler(sourcePort, sourceElement, targetPort, targetElement);
|
|
10554
9508
|
}
|
|
10555
9509
|
return null;
|
|
10556
9510
|
}, [editorContext]);
|
|
10557
|
-
var handleOnCreatingPortByLinking = React
|
|
9511
|
+
var handleOnCreatingPortByLinking = React.useCallback(function (sourceElement, sourcePort, targetElement, position) {
|
|
10558
9512
|
if (editorContext.onCreatingPortByLinkingHandler) {
|
|
10559
9513
|
return editorContext.onCreatingPortByLinkingHandler(sourceElement, sourcePort, targetElement, position);
|
|
10560
9514
|
}
|
|
10561
9515
|
return null;
|
|
10562
9516
|
}, [editorContext]);
|
|
10563
|
-
var handlePaperMouseMoved = React
|
|
9517
|
+
var handlePaperMouseMoved = React.useCallback(function (position) {
|
|
10564
9518
|
editorContext.onPaperMouseMovedHandler(position);
|
|
10565
9519
|
}, [editorContext]);
|
|
10566
|
-
var handlePaperMouseDown = React
|
|
9520
|
+
var handlePaperMouseDown = React.useCallback(function (position) {
|
|
10567
9521
|
editorContext.onPaperMouseDownHandler(position);
|
|
10568
9522
|
}, [editorContext]);
|
|
10569
|
-
var handlePaperMouseUp = React
|
|
9523
|
+
var handlePaperMouseUp = React.useCallback(function (position) {
|
|
10570
9524
|
editorContext.onPaperMouseUpHandler(position);
|
|
10571
9525
|
}, [editorContext]);
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
return null;
|
|
10575
|
-
}
|
|
9526
|
+
return (React.createElement(Paper$1, { key: "paper", size: { width: width, height: height }, elements: elements, links: links, texts: texts, onPaperClicked: handlePaperClicked, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp, onPortMoved: handlePortMoved, onPortSelected: handlePortSelected, onElementContextMenu: handleElementContextMenu, onElementMoved: handleElementMoved, onElementResized: handleElementResized, onElementSelected: handleElementSelected, onElementMouseLeave: handleElementMouseLeave, onElementMouseMove: handleElementMouseMove, onElementMouseUp: handleElementMouseUp, onCreatingLink: handleOnCreatingLink, onCreatingPortByLinking: handleOnCreatingPortByLinking, onLinkSelected: handleLinkSelected, onTextSelected: handleTextSelected, onPaperMouseMoved: handlePaperMouseMoved, onPaperMouseUp: handlePaperMouseUp, onPaperMouseDown: handlePaperMouseDown, onManuallyTriggerRenderElement: editorContext.onManuallyTriggerRenderElement.bind(editorContext), onManuallyTriggerRenderPort: editorContext.onManuallyTriggerRenderPort.bind(editorContext) }));
|
|
9527
|
+
};
|
|
10576
9528
|
|
|
10577
9529
|
exports.CircleRC = Circle;
|
|
10578
9530
|
exports.CrescentRC = Crescent;
|