orcasvn-react-diagrams 0.1.3 → 0.1.5

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 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: 'rect-border', vectorEffect: "non-scaling-stroke", width: scaledWidth, height: scaledHeight, fill: props.fill || "transparent", stroke: props.stroke || "none", strokeWidth: sw })));
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: 'rectangular-frame-outer-border', x: vbX, y: vbY, width: scaledWidth, height: scaledHeight, fill: "none", stroke: props.stroke || "none", strokeWidth: sw }),
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
  };
@@ -910,7 +911,7 @@ var EVENT_NAME = {
910
911
  ELEMENT_LINK_ENDED: 'element_link_ended',
911
912
  };
912
913
  //ELEMENT
913
- var ELEMENT_MOVING_OFFSET_THRESHOLD = 10;
914
+ //export const ELEMENT_MOVING_OFFSET_THRESHOLD = 10;
914
915
  //ELEMENT LINK
915
916
  var MIN_DISTANCE_BETWEEN_KNOTS_ON_LINK = 30;
916
917
  var MAX_LINK_KNOT_COUNT = 10;
@@ -8595,7 +8596,7 @@ var Paper = function (props) {
8595
8596
  },
8596
8597
  width: selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.size.width,
8597
8598
  height: selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.size.height,
8598
- movingOffsetThreshold: ELEMENT_MOVING_OFFSET_THRESHOLD,
8599
+ //movingOffsetThreshold: ELEMENT_MOVING_OFFSET_THRESHOLD,
8599
8600
  onMove: function (offsetX, offsetY) {
8600
8601
  if (!selectedElement)
8601
8602
  return;
@@ -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
  };
@@ -1,2 +1,6 @@
1
1
  export * from './models';
2
+ export * from './components/shapes';
3
+ export * from './components/ports';
4
+ export * from './components/links';
5
+ export * from './components/texts';
2
6
  export { default } from './components/editor';
@@ -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;
@@ -11,6 +11,7 @@ interface IElementProps {
11
11
  y: number;
12
12
  width: number;
13
13
  height: number;
14
+ cssClass?: string;
14
15
  renderShape?: (props: IElementProps) => JSX.Element;
15
16
  children?: React.ReactNode;
16
17
  ports?: IPort[];
@@ -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);
@@ -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
  }
@@ -16,7 +16,6 @@ export declare const EVENT_NAME: {
16
16
  ELEMENT_LINK_STARTED: string;
17
17
  ELEMENT_LINK_ENDED: string;
18
18
  };
19
- export declare const ELEMENT_MOVING_OFFSET_THRESHOLD = 10;
20
19
  export declare const MIN_DISTANCE_BETWEEN_KNOTS_ON_LINK = 30;
21
20
  export declare const MAX_LINK_KNOT_COUNT = 10;
22
21
  export declare const LINK_MARKER_DISTANCE_FROM_PORT = 20;
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: 'rect-border', vectorEffect: "non-scaling-stroke", width: scaledWidth, height: scaledHeight, fill: props.fill || "transparent", stroke: props.stroke || "none", strokeWidth: sw })));
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: 'rectangular-frame-outer-border', x: vbX, y: vbY, width: scaledWidth, height: scaledHeight, fill: "none", stroke: props.stroke || "none", strokeWidth: sw }),
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
  };
@@ -906,7 +907,7 @@ var EVENT_NAME = {
906
907
  ELEMENT_LINK_ENDED: 'element_link_ended',
907
908
  };
908
909
  //ELEMENT
909
- var ELEMENT_MOVING_OFFSET_THRESHOLD = 10;
910
+ //export const ELEMENT_MOVING_OFFSET_THRESHOLD = 10;
910
911
  //ELEMENT LINK
911
912
  var MIN_DISTANCE_BETWEEN_KNOTS_ON_LINK = 30;
912
913
  var MAX_LINK_KNOT_COUNT = 10;
@@ -8591,7 +8592,7 @@ var Paper = function (props) {
8591
8592
  },
8592
8593
  width: selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.size.width,
8593
8594
  height: selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.size.height,
8594
- movingOffsetThreshold: ELEMENT_MOVING_OFFSET_THRESHOLD,
8595
+ //movingOffsetThreshold: ELEMENT_MOVING_OFFSET_THRESHOLD,
8595
8596
  onMove: function (offsetX, offsetY) {
8596
8597
  if (!selectedElement)
8597
8598
  return;
@@ -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
  };