orcasvn-react-diagrams 0.1.4 → 0.1.6
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 +8 -7
- package/dist/cjs/types/main.d.ts +4 -0
- package/dist/cjs/types/models/IElement.d.ts +1 -0
- package/dist/cjs/types/models/IElementProps.d.ts +1 -0
- package/dist/cjs/types/models/IShape.d.ts +2 -0
- package/dist/cjs/types/models/implementations/Element.d.ts +2 -1
- package/dist/cjs/types/models/implementations/Text.d.ts +15 -0
- package/dist/cjs/types/models/implementations/diamondElement.d.ts +1 -1
- package/dist/cjs/types/models/implementations/rectangularFrameElement.d.ts +1 -1
- package/dist/esm/index.js +8 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/main.d.ts +4 -0
- package/dist/esm/types/models/IElement.d.ts +1 -0
- package/dist/esm/types/models/IElementProps.d.ts +1 -0
- package/dist/esm/types/models/IShape.d.ts +2 -0
- package/dist/esm/types/models/implementations/Element.d.ts +2 -1
- package/dist/esm/types/models/implementations/Text.d.ts +15 -0
- package/dist/esm/types/models/implementations/diamondElement.d.ts +1 -1
- package/dist/esm/types/models/implementations/rectangularFrameElement.d.ts +1 -1
- package/dist/index.d.ts +6 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -441,7 +441,7 @@ function generateUniqueId() {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
var Element$1 = /** @class */ (function () {
|
|
444
|
-
function Element(x, y, width, height, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
|
|
444
|
+
function Element(x, y, width, height, cssClass, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
|
|
445
445
|
if (portMovealeAreas === void 0) { portMovealeAreas = []; }
|
|
446
446
|
this.resizability = {
|
|
447
447
|
enabled: true,
|
|
@@ -452,6 +452,7 @@ var Element$1 = /** @class */ (function () {
|
|
|
452
452
|
this._id = generateUniqueId();
|
|
453
453
|
this._position = { x: x, y: y };
|
|
454
454
|
this._size = { width: width, height: height };
|
|
455
|
+
this.cssClass = cssClass;
|
|
455
456
|
this.renderShape = renderShape;
|
|
456
457
|
this.texts = texts;
|
|
457
458
|
this.ports = ports;
|
|
@@ -764,7 +765,7 @@ var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
|
|
|
764
765
|
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
765
766
|
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
766
767
|
return (React.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
767
|
-
React.createElement("svg", __assign({ ref: ref, style: { overflow: "visible" }, x: position.x, y: position.y, width: shapeProps.width, height: shapeProps.height, viewBox: viewBox }, objectOfAllEventAttributes), shapeProps.children)));
|
|
768
|
+
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)));
|
|
768
769
|
});
|
|
769
770
|
|
|
770
771
|
var CustomShape = React.forwardRef(function (props, ref) {
|
|
@@ -796,7 +797,7 @@ var Circle = React.forwardRef(function (props, ref) {
|
|
|
796
797
|
s.width = props.width;
|
|
797
798
|
}
|
|
798
799
|
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height, ref: ref }),
|
|
799
|
-
React.createElement("circle", { vectorEffect: "non-scaling-stroke", cx: 50, cy: 50, r: 50, fill: props.fill || 'transparent', stroke: props.stroke || "none", strokeWidth: props.strokeWidth })));
|
|
800
|
+
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 })));
|
|
800
801
|
});
|
|
801
802
|
|
|
802
803
|
var Crescent = function (props) {
|
|
@@ -814,7 +815,7 @@ var Crescent = function (props) {
|
|
|
814
815
|
}
|
|
815
816
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
816
817
|
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
817
|
-
React.createElement("path", { vectorEffect: "non-scaling-stroke", d: "M0,75 A50,50 0 1,1 100,75 Z", fill: props.fill || 'none', stroke: props.stroke || 'none', strokeWidth: sw })));
|
|
818
|
+
React.createElement("path", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", d: "M0,75 A50,50 0 1,1 100,75 Z", fill: props.fill || 'none', stroke: props.stroke || 'none', strokeWidth: sw })));
|
|
818
819
|
};
|
|
819
820
|
|
|
820
821
|
var Rectangle = function (props) {
|
|
@@ -834,7 +835,7 @@ var Rectangle = function (props) {
|
|
|
834
835
|
}
|
|
835
836
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
836
837
|
return (React.createElement(ShapeWrapper, __assign({}, props, { height: props.height, width: props.width }),
|
|
837
|
-
React.createElement("rect", { className:
|
|
838
|
+
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 })));
|
|
838
839
|
};
|
|
839
840
|
|
|
840
841
|
var RectangularFrame = function (props) {
|
|
@@ -858,7 +859,7 @@ var RectangularFrame = function (props) {
|
|
|
858
859
|
var scaledFw = scaledWidth / props.width * fw;
|
|
859
860
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
860
861
|
return (React.createElement(ShapeWrapper, __assign({}, props, { height: props.height, width: props.width }),
|
|
861
|
-
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className:
|
|
862
|
+
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 }),
|
|
862
863
|
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" }),
|
|
863
864
|
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" })));
|
|
864
865
|
};
|
|
@@ -8712,7 +8713,7 @@ var Paper = function (props) {
|
|
|
8712
8713
|
setSelectedElementSVG(ref);
|
|
8713
8714
|
setSelectedElement(element);
|
|
8714
8715
|
setMouseDownedOnPaper(false);
|
|
8715
|
-
}, container: paperContainerRef.current, renderShape: element.renderShape, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
8716
|
+
}, container: paperContainerRef.current, renderShape: element.renderShape, cssClass: element.cssClass, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
8716
8717
|
// portPlaceholderShape={(<Circle x={0} y={0} width={10} height={10} fill='red' positioningAnchor={PositioningAnchor.Center} />)}
|
|
8717
8718
|
onMouseUpAtLinkedPortPlaceholder: function (elementLink, position) { return handleMouseUpAtLinkedPortPlaceholder(elementLink, position, element); }, onTextUpdated: function (textId, newContent) { return handleElementTextChange(element, textId, newContent); } }, element.childrenElements && element.childrenElements.map(renderElementInTree))));
|
|
8718
8719
|
};
|
package/dist/cjs/types/main.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export default interface IElement {
|
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated This property is deprecated and will be removed in future versions.
|
|
15
15
|
*/
|
|
16
|
+
cssClass?: string;
|
|
16
17
|
reactElement?: React.FC<IElementProps> | React.ComponentClass<IElementProps>;
|
|
17
18
|
renderShape?: (props: IElementProps) => JSX.Element;
|
|
18
19
|
resizability: IResizability;
|
|
@@ -10,6 +10,8 @@ export default interface IShape extends DOMAttributes<SVGElement>, React.RefAttr
|
|
|
10
10
|
strokeWidth?: number;
|
|
11
11
|
fill?: string;
|
|
12
12
|
rotation?: number;
|
|
13
|
+
cssClass?: string;
|
|
14
|
+
portMoveableAreaCssClass?: string;
|
|
13
15
|
direction?: 'left' | 'right' | 'up' | 'down';
|
|
14
16
|
positioningAnchor?: PositioningAnchor | IPosition;
|
|
15
17
|
onClick?: (e: React.MouseEvent<SVGElement>) => void;
|
|
@@ -13,6 +13,7 @@ export default class Element implements IElement {
|
|
|
13
13
|
protected _position: IPosition;
|
|
14
14
|
protected _size: ISize;
|
|
15
15
|
private _parentElement?;
|
|
16
|
+
cssClass?: string;
|
|
16
17
|
/**
|
|
17
18
|
* @deprecated This property is deprecated and will be removed in future versions.
|
|
18
19
|
*/
|
|
@@ -27,7 +28,7 @@ export default class Element implements IElement {
|
|
|
27
28
|
onResized?: ((width: number, height: number) => void) | undefined;
|
|
28
29
|
onMoved?: ((x: number, y: number) => void) | undefined;
|
|
29
30
|
_eventEmitter: EventEmitter;
|
|
30
|
-
constructor(x: number, y: number, width: number, height: number, renderShape?: (props: IElementProps) => JSX.Element, texts?: IText[], ports?: IPort[], portMovealeAreas?: IPosition[][], portSlideRailSVGClassName?: string, portDirection?: SubObjectDirection);
|
|
31
|
+
constructor(x: number, y: number, width: number, height: number, cssClass?: string, renderShape?: (props: IElementProps) => JSX.Element, texts?: IText[], ports?: IPort[], portMovealeAreas?: IPosition[][], portSlideRailSVGClassName?: string, portDirection?: SubObjectDirection);
|
|
31
32
|
get id(): string;
|
|
32
33
|
get size(): ISize;
|
|
33
34
|
set size(value: ISize);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TextAlign } from "../enums";
|
|
2
|
+
import IText from "../IText";
|
|
3
|
+
import IPosition from "../position";
|
|
4
|
+
import ISize from "../size";
|
|
5
|
+
export default class Text implements IText {
|
|
6
|
+
private readonly _id;
|
|
7
|
+
content: string;
|
|
8
|
+
size: ISize;
|
|
9
|
+
position?: IPosition;
|
|
10
|
+
align?: TextAlign;
|
|
11
|
+
fontSize?: number;
|
|
12
|
+
border?: string;
|
|
13
|
+
constructor(content: string, width: number, height: number, x?: number, y?: number, align?: TextAlign, fontSize?: number, border?: string);
|
|
14
|
+
get id(): string;
|
|
15
|
+
}
|
|
@@ -7,5 +7,5 @@ export default class DiamondElement extends Element {
|
|
|
7
7
|
resizability: IResizability;
|
|
8
8
|
get size(): ISize;
|
|
9
9
|
set size(value: ISize);
|
|
10
|
-
constructor(x: number, y: number, width: number, height: number, texts?: IText[], ports?: IPort[]);
|
|
10
|
+
constructor(x: number, y: number, width: number, height: number, cssClass?: string, texts?: IText[], ports?: IPort[]);
|
|
11
11
|
}
|
|
@@ -4,5 +4,5 @@ import IPort from "../IPort";
|
|
|
4
4
|
import IText from "../IText";
|
|
5
5
|
export default class RectangularFrameElement extends Element {
|
|
6
6
|
resizability: IResizability;
|
|
7
|
-
constructor(x: number, y: number, width: number, height: number, texts?: IText[], ports?: IPort[]);
|
|
7
|
+
constructor(x: number, y: number, width: number, height: number, cssClass?: string, texts?: IText[], ports?: IPort[]);
|
|
8
8
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -437,7 +437,7 @@ function generateUniqueId() {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
var Element$1 = /** @class */ (function () {
|
|
440
|
-
function Element(x, y, width, height, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
|
|
440
|
+
function Element(x, y, width, height, cssClass, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
|
|
441
441
|
if (portMovealeAreas === void 0) { portMovealeAreas = []; }
|
|
442
442
|
this.resizability = {
|
|
443
443
|
enabled: true,
|
|
@@ -448,6 +448,7 @@ var Element$1 = /** @class */ (function () {
|
|
|
448
448
|
this._id = generateUniqueId();
|
|
449
449
|
this._position = { x: x, y: y };
|
|
450
450
|
this._size = { width: width, height: height };
|
|
451
|
+
this.cssClass = cssClass;
|
|
451
452
|
this.renderShape = renderShape;
|
|
452
453
|
this.texts = texts;
|
|
453
454
|
this.ports = ports;
|
|
@@ -760,7 +761,7 @@ var ShapeWrapper = forwardRef(function (shapeProps, ref) {
|
|
|
760
761
|
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
761
762
|
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
762
763
|
return (React.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
763
|
-
React.createElement("svg", __assign({ ref: ref, style: { overflow: "visible" }, x: position.x, y: position.y, width: shapeProps.width, height: shapeProps.height, viewBox: viewBox }, objectOfAllEventAttributes), shapeProps.children)));
|
|
764
|
+
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)));
|
|
764
765
|
});
|
|
765
766
|
|
|
766
767
|
var CustomShape = forwardRef(function (props, ref) {
|
|
@@ -792,7 +793,7 @@ var Circle = forwardRef(function (props, ref) {
|
|
|
792
793
|
s.width = props.width;
|
|
793
794
|
}
|
|
794
795
|
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height, ref: ref }),
|
|
795
|
-
React.createElement("circle", { vectorEffect: "non-scaling-stroke", cx: 50, cy: 50, r: 50, fill: props.fill || 'transparent', stroke: props.stroke || "none", strokeWidth: props.strokeWidth })));
|
|
796
|
+
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 })));
|
|
796
797
|
});
|
|
797
798
|
|
|
798
799
|
var Crescent = function (props) {
|
|
@@ -810,7 +811,7 @@ var Crescent = function (props) {
|
|
|
810
811
|
}
|
|
811
812
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
812
813
|
return (React.createElement(ShapeWrapper, __assign({ viewBox: '0 0 100 100' }, props, { width: s.width, height: s.height }),
|
|
813
|
-
React.createElement("path", { vectorEffect: "non-scaling-stroke", d: "M0,75 A50,50 0 1,1 100,75 Z", fill: props.fill || 'none', stroke: props.stroke || 'none', strokeWidth: sw })));
|
|
814
|
+
React.createElement("path", { className: "".concat(props.portMoveableAreaCssClass), vectorEffect: "non-scaling-stroke", d: "M0,75 A50,50 0 1,1 100,75 Z", fill: props.fill || 'none', stroke: props.stroke || 'none', strokeWidth: sw })));
|
|
814
815
|
};
|
|
815
816
|
|
|
816
817
|
var Rectangle = function (props) {
|
|
@@ -830,7 +831,7 @@ var Rectangle = function (props) {
|
|
|
830
831
|
}
|
|
831
832
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
832
833
|
return (React.createElement(ShapeWrapper, __assign({}, props, { height: props.height, width: props.width }),
|
|
833
|
-
React.createElement("rect", { className:
|
|
834
|
+
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 })));
|
|
834
835
|
};
|
|
835
836
|
|
|
836
837
|
var RectangularFrame = function (props) {
|
|
@@ -854,7 +855,7 @@ var RectangularFrame = function (props) {
|
|
|
854
855
|
var scaledFw = scaledWidth / props.width * fw;
|
|
855
856
|
var sw = props.stroke ? (props.strokeWidth || 1) : 0;
|
|
856
857
|
return (React.createElement(ShapeWrapper, __assign({}, props, { height: props.height, width: props.width }),
|
|
857
|
-
React.createElement("rect", { vectorEffect: "non-scaling-stroke", className:
|
|
858
|
+
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 }),
|
|
858
859
|
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" }),
|
|
859
860
|
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" })));
|
|
860
861
|
};
|
|
@@ -8708,7 +8709,7 @@ var Paper = function (props) {
|
|
|
8708
8709
|
setSelectedElementSVG(ref);
|
|
8709
8710
|
setSelectedElement(element);
|
|
8710
8711
|
setMouseDownedOnPaper(false);
|
|
8711
|
-
}, container: paperContainerRef.current, renderShape: element.renderShape, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
8712
|
+
}, container: paperContainerRef.current, renderShape: element.renderShape, cssClass: element.cssClass, texts: element.texts, ports: element.ports, portMoveableAreas: element.portMoveableAreas, portSlideRailSVGClassName: element.portSlideRailSVGClassName, portDirection: element.portDirection, onPortMoved: handlePortMoved, onPortMouseDown: handlePortMouseDown, onPortMouseUp: handlePortMouseUp,
|
|
8712
8713
|
// portPlaceholderShape={(<Circle x={0} y={0} width={10} height={10} fill='red' positioningAnchor={PositioningAnchor.Center} />)}
|
|
8713
8714
|
onMouseUpAtLinkedPortPlaceholder: function (elementLink, position) { return handleMouseUpAtLinkedPortPlaceholder(elementLink, position, element); }, onTextUpdated: function (textId, newContent) { return handleElementTextChange(element, textId, newContent); } }, element.childrenElements && element.childrenElements.map(renderElementInTree))));
|
|
8714
8715
|
};
|