orcasvn-react-diagrams 0.1.0 → 0.1.2

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
@@ -36,135 +36,6 @@ exports.TextAlign = void 0;
36
36
  TextAlign[TextAlign["center"] = 2] = "center";
37
37
  })(exports.TextAlign || (exports.TextAlign = {}));
38
38
 
39
- var EditorContext = /** @class */ (function () {
40
- function EditorContext(elements, links, texts) {
41
- this._elements = elements;
42
- this._links = links;
43
- this._texts = texts;
44
- }
45
- Object.defineProperty(EditorContext.prototype, "elements", {
46
- get: function () {
47
- return this._elements;
48
- },
49
- enumerable: false,
50
- configurable: true
51
- });
52
- Object.defineProperty(EditorContext.prototype, "links", {
53
- get: function () {
54
- return this._links;
55
- },
56
- enumerable: false,
57
- configurable: true
58
- });
59
- Object.defineProperty(EditorContext.prototype, "texts", {
60
- get: function () {
61
- return this._texts;
62
- },
63
- enumerable: false,
64
- configurable: true
65
- });
66
- EditorContext.prototype.getElement = function (elementId) {
67
- return this._elements.find(function (e) { return e.id === elementId; });
68
- };
69
- EditorContext.prototype.addElement = function (element) {
70
- this._elements.push(element);
71
- };
72
- EditorContext.prototype.removeElement = function (elementId) {
73
- this._elements = this._elements.filter(function (e) { return e.id !== elementId; });
74
- };
75
- EditorContext.prototype.getLink = function (linkId) {
76
- return this._links.find(function (l) { return l.id === linkId; });
77
- };
78
- EditorContext.prototype.addLink = function (link) {
79
- this._links.push(link);
80
- };
81
- EditorContext.prototype.removeLink = function (linkId) {
82
- this._links = this._links.filter(function (l) { return l.id !== linkId; });
83
- };
84
- EditorContext.prototype.getText = function (textId) {
85
- return this._texts.find(function (t) { return t.id === textId; });
86
- };
87
- EditorContext.prototype.addText = function (text) {
88
- this._texts.push(text);
89
- };
90
- EditorContext.prototype.removeText = function (textId) {
91
- this._texts = this._texts.filter(function (t) { return t.id !== textId; });
92
- };
93
- return EditorContext;
94
- }());
95
-
96
- /******************************************************************************
97
- Copyright (c) Microsoft Corporation.
98
-
99
- Permission to use, copy, modify, and/or distribute this software for any
100
- purpose with or without fee is hereby granted.
101
-
102
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
103
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
104
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
105
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
106
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
107
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
108
- PERFORMANCE OF THIS SOFTWARE.
109
- ***************************************************************************** */
110
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
111
-
112
-
113
- var __assign = function() {
114
- __assign = Object.assign || function __assign(t) {
115
- for (var s, i = 1, n = arguments.length; i < n; i++) {
116
- s = arguments[i];
117
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
118
- }
119
- return t;
120
- };
121
- return __assign.apply(this, arguments);
122
- };
123
-
124
- function __spreadArray(to, from, pack) {
125
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
126
- if (ar || !(i in from)) {
127
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
128
- ar[i] = from[i];
129
- }
130
- }
131
- return to.concat(ar || Array.prototype.slice.call(from));
132
- }
133
-
134
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
135
- var e = new Error(message);
136
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
137
- };
138
-
139
- var Ruler = function (_a) {
140
- var squareSize = _a.squareSize, border = _a.border;
141
- var numColumns = Math.ceil(3000 / squareSize);
142
- var numRows = Math.ceil(3000 / squareSize);
143
- var tableWidth = numColumns * squareSize;
144
- return (React.createElement("table", { style: { position: 'absolute', zIndex: -1, top: 0, left: 0, borderCollapse: 'collapse', width: tableWidth } },
145
- 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: {
146
- width: squareSize,
147
- height: squareSize,
148
- border: border,
149
- margin: 0,
150
- padding: 0,
151
- boxSizing: 'border-box',
152
- verticalAlign: 'top',
153
- position: 'relative',
154
- fontSize: 12,
155
- } },
156
- rowIndex === 0 ? React.createElement("span", { style: { marginLeft: "-12px" } }, colIndex * squareSize) : "",
157
- colIndex === 0 ? React.createElement("span", { style: { top: "-9px", position: "absolute" } }, rowIndex * squareSize) : "")); }))); }))));
158
- };
159
-
160
- var ElementWrapper = React.forwardRef(function (_a, ref) {
161
- var x = _a.x, y = _a.y, children = _a.children; _a.portPlaceholders; _a.ports; var onClick = _a.onClick, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onMouseUp = _a.onMouseUp;
162
- var handleMouseDown = function (ev) {
163
- ev.stopPropagation();
164
- };
165
- return (React.createElement("svg", { x: x, y: y, onClick: onClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
166
- });
167
-
168
39
  function getDefaultExportFromCjs (x) {
169
40
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
170
41
  }
@@ -482,35 +353,463 @@ var eventemitter3 = {exports: {}};
482
353
  this._eventsCount = 0;
483
354
  }
484
355
 
485
- return this;
486
- };
356
+ return this;
357
+ };
358
+
359
+ //
360
+ // Alias methods names because people roll like that.
361
+ //
362
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
363
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
364
+
365
+ //
366
+ // Expose the prefix.
367
+ //
368
+ EventEmitter.prefixed = prefix;
369
+
370
+ //
371
+ // Allow `EventEmitter` to be imported as module namespace.
372
+ //
373
+ EventEmitter.EventEmitter = EventEmitter;
374
+
375
+ //
376
+ // Expose the module.
377
+ //
378
+ {
379
+ module.exports = EventEmitter;
380
+ }
381
+ } (eventemitter3));
382
+
383
+ var eventemitter3Exports = eventemitter3.exports;
384
+ var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
385
+
386
+ /**
387
+ * Convert array of 16 byte values to UUID string format of the form:
388
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
389
+ */
390
+ var byteToHex = [];
391
+ for (var i$1 = 0; i$1 < 256; ++i$1) {
392
+ byteToHex.push((i$1 + 0x100).toString(16).slice(1));
393
+ }
394
+ function unsafeStringify(arr, offset = 0) {
395
+ // Note: Be careful editing this code! It's been tuned for performance
396
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
397
+ //
398
+ // Note to future-self: No, you can't remove the `toLowerCase()` call.
399
+ // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
400
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
401
+ }
402
+
403
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
404
+ // require the crypto API and do not support built-in fallback to lower quality random number
405
+ // generators (like Math.random()).
406
+
407
+ var getRandomValues;
408
+ var rnds8 = new Uint8Array(16);
409
+ function rng() {
410
+ // lazy load so that environments that need to polyfill have a chance to do so
411
+ if (!getRandomValues) {
412
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
413
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
414
+ if (!getRandomValues) {
415
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
416
+ }
417
+ }
418
+ return getRandomValues(rnds8);
419
+ }
420
+
421
+ var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
422
+ var native = {
423
+ randomUUID
424
+ };
425
+
426
+ function v4(options, buf, offset) {
427
+ if (native.randomUUID && !buf && !options) {
428
+ return native.randomUUID();
429
+ }
430
+ options = options || {};
431
+ var rnds = options.random || (options.rng || rng)();
432
+
433
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
434
+ rnds[6] = rnds[6] & 0x0f | 0x40;
435
+ rnds[8] = rnds[8] & 0x3f | 0x80;
436
+ return unsafeStringify(rnds);
437
+ }
438
+
439
+ function generateUniqueId() {
440
+ return v4();
441
+ }
442
+
443
+ var Element$1 = /** @class */ (function () {
444
+ function Element(x, y, width, height, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
445
+ if (portMovealeAreas === void 0) { portMovealeAreas = []; }
446
+ this.resizability = {
447
+ enabled: true,
448
+ keepRatio: false
449
+ };
450
+ //internal properties
451
+ this._eventEmitter = new EventEmitter();
452
+ this._id = generateUniqueId();
453
+ this._position = { x: x, y: y };
454
+ this._size = { width: width, height: height };
455
+ this.renderShape = renderShape;
456
+ this.texts = texts;
457
+ this.ports = ports;
458
+ this.portMoveableAreas = portMovealeAreas;
459
+ this.portSlideRailSVGClassName = portSlideRailSVGClassName;
460
+ this.portDirection = portDirection;
461
+ }
462
+ Object.defineProperty(Element.prototype, "id", {
463
+ get: function () {
464
+ return this._id;
465
+ },
466
+ enumerable: false,
467
+ configurable: true
468
+ });
469
+ Object.defineProperty(Element.prototype, "size", {
470
+ get: function () {
471
+ return this._size;
472
+ },
473
+ set: function (value) {
474
+ this._size = value;
475
+ if (this.onResized)
476
+ this.onResized(value.width, value.height);
477
+ },
478
+ enumerable: false,
479
+ configurable: true
480
+ });
481
+ Object.defineProperty(Element.prototype, "position", {
482
+ get: function () {
483
+ return this._position;
484
+ },
485
+ set: function (value) {
486
+ this._position = value;
487
+ if (this.onMoved)
488
+ this.onMoved(value.x, value.y);
489
+ },
490
+ enumerable: false,
491
+ configurable: true
492
+ });
493
+ Object.defineProperty(Element.prototype, "parentElement", {
494
+ get: function () {
495
+ return this._parentElement;
496
+ },
497
+ set: function (value) {
498
+ var oldParent = this._parentElement;
499
+ this._parentElement = value;
500
+ this._eventEmitter.emit('parentChanged', oldParent, value);
501
+ },
502
+ enumerable: false,
503
+ configurable: true
504
+ });
505
+ Element.prototype.onParentChanged = function (callback) {
506
+ var _this = this;
507
+ this._eventEmitter.on('parentChanged', callback);
508
+ var canceller = function () {
509
+ _this._eventEmitter.off('parentChanged', callback);
510
+ };
511
+ return canceller;
512
+ };
513
+ Element.prototype.addPort = function (newPort) {
514
+ if (this.ports) {
515
+ this.ports.push(newPort);
516
+ }
517
+ else {
518
+ this.ports = [newPort];
519
+ }
520
+ this._eventEmitter.emit('addedPort', newPort);
521
+ };
522
+ Element.prototype.onAddedPort = function (callback) {
523
+ var _this = this;
524
+ this._eventEmitter.on('addedPort', callback);
525
+ var canceller = function () {
526
+ _this._eventEmitter.off('addedPort', callback);
527
+ };
528
+ return canceller;
529
+ };
530
+ Element.prototype.deletePort = function (id) {
531
+ if (!this.ports)
532
+ return;
533
+ var index = this.ports.findIndex(function (p) { return p.id === id; });
534
+ if (index === -1) {
535
+ throw new Error("Port with id ".concat(id, " is not found"));
536
+ }
537
+ this.ports.splice(index, 1);
538
+ this._eventEmitter.emit('deletedPort', id);
539
+ };
540
+ Element.prototype.onDeletedPort = function (callback) {
541
+ var _this = this;
542
+ this._eventEmitter.on('deletedPort', callback);
543
+ var canceller = function () {
544
+ _this._eventEmitter.off('deletedPort', callback);
545
+ };
546
+ return canceller;
547
+ };
548
+ Element.prototype.getPort = function (id) {
549
+ if (!this.ports)
550
+ return undefined;
551
+ return this.ports.find(function (p) { return p.id === id; });
552
+ };
553
+ return Element;
554
+ }());
555
+
556
+ var Port$1 = /** @class */ (function () {
557
+ function Port(x, y, width, height, label, renderShape) {
558
+ this._id = generateUniqueId();
559
+ this.position = { x: x, y: y };
560
+ this.size = { width: width, height: height };
561
+ this.label = label;
562
+ this.renderShape = renderShape;
563
+ }
564
+ Object.defineProperty(Port.prototype, "id", {
565
+ get: function () {
566
+ return this._id;
567
+ },
568
+ enumerable: false,
569
+ configurable: true
570
+ });
571
+ return Port;
572
+ }());
573
+
574
+ var ElementLink$1 = /** @class */ (function () {
575
+ function ElementLink(sourceElement, sourcePort, targetElement, targetPort, tempTargetPosition, points, path, markerStart, markerEnd, markerDistanceFromPort, markerSize, label, sourceLabel, targetLabel) {
576
+ this.id = generateUniqueId();
577
+ this.sourceElement = sourceElement;
578
+ this.sourcePort = sourcePort;
579
+ if (tempTargetPosition) {
580
+ this.tempTargetPosition = tempTargetPosition;
581
+ }
582
+ if (points) {
583
+ this.points = points;
584
+ }
585
+ else {
586
+ this.points = [];
587
+ }
588
+ if (targetElement)
589
+ this.targetElement = targetElement;
590
+ if (targetPort)
591
+ this.targetPort = targetPort;
592
+ if (path)
593
+ this.path = path;
594
+ if (markerStart)
595
+ this.markerStart = markerStart;
596
+ if (markerEnd)
597
+ this.markerEnd = markerEnd;
598
+ if (markerDistanceFromPort)
599
+ this.markerDistanceFromPort = markerDistanceFromPort;
600
+ if (markerSize)
601
+ this.markerSize = markerSize;
602
+ if (label)
603
+ this.label = label;
604
+ if (sourceLabel)
605
+ this.sourceLabel = sourceLabel;
606
+ if (targetLabel)
607
+ this.targetLabel = targetLabel;
608
+ }
609
+ return ElementLink;
610
+ }());
611
+
612
+ var EditorContext = /** @class */ (function () {
613
+ function EditorContext(elements, links, texts) {
614
+ this._elements = elements;
615
+ this._links = links;
616
+ this._texts = texts;
617
+ }
618
+ Object.defineProperty(EditorContext.prototype, "elements", {
619
+ get: function () {
620
+ return this._elements;
621
+ },
622
+ enumerable: false,
623
+ configurable: true
624
+ });
625
+ Object.defineProperty(EditorContext.prototype, "links", {
626
+ get: function () {
627
+ return this._links;
628
+ },
629
+ enumerable: false,
630
+ configurable: true
631
+ });
632
+ Object.defineProperty(EditorContext.prototype, "texts", {
633
+ get: function () {
634
+ return this._texts;
635
+ },
636
+ enumerable: false,
637
+ configurable: true
638
+ });
639
+ EditorContext.prototype.getElement = function (elementId) {
640
+ return this._elements.find(function (e) { return e.id === elementId; });
641
+ };
642
+ EditorContext.prototype.addElement = function (element) {
643
+ this._elements.push(element);
644
+ };
645
+ EditorContext.prototype.removeElement = function (elementId) {
646
+ this._elements = this._elements.filter(function (e) { return e.id !== elementId; });
647
+ };
648
+ EditorContext.prototype.getLink = function (linkId) {
649
+ return this._links.find(function (l) { return l.id === linkId; });
650
+ };
651
+ EditorContext.prototype.addLink = function (link) {
652
+ this._links.push(link);
653
+ };
654
+ EditorContext.prototype.removeLink = function (linkId) {
655
+ this._links = this._links.filter(function (l) { return l.id !== linkId; });
656
+ };
657
+ EditorContext.prototype.getText = function (textId) {
658
+ return this._texts.find(function (t) { return t.id === textId; });
659
+ };
660
+ EditorContext.prototype.addText = function (text) {
661
+ this._texts.push(text);
662
+ };
663
+ EditorContext.prototype.removeText = function (textId) {
664
+ this._texts = this._texts.filter(function (t) { return t.id !== textId; });
665
+ };
666
+ return EditorContext;
667
+ }());
668
+
669
+ /******************************************************************************
670
+ Copyright (c) Microsoft Corporation.
671
+
672
+ Permission to use, copy, modify, and/or distribute this software for any
673
+ purpose with or without fee is hereby granted.
674
+
675
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
676
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
677
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
678
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
679
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
680
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
681
+ PERFORMANCE OF THIS SOFTWARE.
682
+ ***************************************************************************** */
683
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
684
+
685
+ var extendStatics = function(d, b) {
686
+ extendStatics = Object.setPrototypeOf ||
687
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
688
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
689
+ return extendStatics(d, b);
690
+ };
691
+
692
+ function __extends(d, b) {
693
+ if (typeof b !== "function" && b !== null)
694
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
695
+ extendStatics(d, b);
696
+ function __() { this.constructor = d; }
697
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
698
+ }
699
+
700
+ var __assign = function() {
701
+ __assign = Object.assign || function __assign(t) {
702
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
703
+ s = arguments[i];
704
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
705
+ }
706
+ return t;
707
+ };
708
+ return __assign.apply(this, arguments);
709
+ };
710
+
711
+ function __spreadArray(to, from, pack) {
712
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
713
+ if (ar || !(i in from)) {
714
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
715
+ ar[i] = from[i];
716
+ }
717
+ }
718
+ return to.concat(ar || Array.prototype.slice.call(from));
719
+ }
720
+
721
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
722
+ var e = new Error(message);
723
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
724
+ };
487
725
 
488
- //
489
- // Alias methods names because people roll like that.
490
- //
491
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
492
- EventEmitter.prototype.addListener = EventEmitter.prototype.on;
726
+ var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
727
+ //if direction is provided, rotation is based on direction
728
+ var rotation = shapeProps.rotation || 0;
729
+ if (shapeProps.direction) {
730
+ switch (shapeProps.direction) {
731
+ case 'left':
732
+ rotation = -90;
733
+ break;
734
+ case 'right':
735
+ rotation = 90;
736
+ break;
737
+ case 'down':
738
+ rotation = 180;
739
+ break;
740
+ default:
741
+ rotation = 0;
742
+ break;
743
+ }
744
+ }
745
+ var position = { x: shapeProps.x, y: shapeProps.y };
746
+ var transformOrigin = "center";
747
+ if (typeof shapeProps.positioningAnchor === 'object') {
748
+ position.x = position.x - shapeProps.positioningAnchor.x / 100 * shapeProps.width;
749
+ position.y = position.y - shapeProps.positioningAnchor.y / 100 * shapeProps.height;
750
+ transformOrigin = "".concat(shapeProps.positioningAnchor.x, "% ").concat(shapeProps.positioningAnchor.y, "%");
751
+ }
752
+ else if (shapeProps.positioningAnchor === exports.PositioningAnchor.Center) {
753
+ position.x = position.x - shapeProps.width / 2;
754
+ position.y = position.y - shapeProps.height / 2;
755
+ }
756
+ var objectOfAllEventAttributes = React.useMemo(function () {
757
+ var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
758
+ var k = _a[0]; _a[1];
759
+ return k.startsWith('on');
760
+ });
761
+ return Object.fromEntries(arrayOfAllEventAttributes);
762
+ }, [shapeProps]);
763
+ var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
764
+ var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
765
+ var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
766
+ 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
+ });
493
769
 
494
- //
495
- // Expose the prefix.
496
- //
497
- EventEmitter.prefixed = prefix;
770
+ var CustomShape = React.forwardRef(function (props, ref) {
771
+ return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
772
+ });
498
773
 
499
- //
500
- // Allow `EventEmitter` to be imported as module namespace.
501
- //
502
- EventEmitter.EventEmitter = EventEmitter;
774
+ var CustomPort = /** @class */ (function (_super) {
775
+ __extends(CustomPort, _super);
776
+ function CustomPort(x, y, width, height, renderShape, shapePositioningAnchor, label) {
777
+ var _this = _super.call(this, x, y, width, height, label, React.forwardRef(function (props, ref) {
778
+ return (React.createElement(CustomShape, { ref: ref, x: props.x, y: props.y, width: props.width, height: props.height, rotation: props.rotation, positioningAnchor: shapePositioningAnchor, 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); } }, renderShape));
779
+ })) || this;
780
+ return _this;
781
+ }
782
+ return CustomPort;
783
+ }(Port$1));
503
784
 
504
- //
505
- // Expose the module.
506
- //
507
- {
508
- module.exports = EventEmitter;
509
- }
510
- } (eventemitter3));
785
+ var Ruler = function (_a) {
786
+ var squareSize = _a.squareSize, border = _a.border;
787
+ var numColumns = Math.ceil(3000 / squareSize);
788
+ var numRows = Math.ceil(3000 / squareSize);
789
+ var tableWidth = numColumns * squareSize;
790
+ return (React.createElement("table", { style: { position: 'absolute', zIndex: -1, top: 0, left: 0, borderCollapse: 'collapse', width: tableWidth } },
791
+ 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: {
792
+ width: squareSize,
793
+ height: squareSize,
794
+ border: border,
795
+ margin: 0,
796
+ padding: 0,
797
+ boxSizing: 'border-box',
798
+ verticalAlign: 'top',
799
+ position: 'relative',
800
+ fontSize: 12,
801
+ } },
802
+ rowIndex === 0 ? React.createElement("span", { style: { marginLeft: "-12px" } }, colIndex * squareSize) : "",
803
+ colIndex === 0 ? React.createElement("span", { style: { top: "-9px", position: "absolute" } }, rowIndex * squareSize) : "")); }))); }))));
804
+ };
511
805
 
512
- var eventemitter3Exports = eventemitter3.exports;
513
- var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
806
+ var ElementWrapper = React.forwardRef(function (_a, ref) {
807
+ var x = _a.x, y = _a.y, children = _a.children; _a.portPlaceholders; _a.ports; var onClick = _a.onClick, onMouseMove = _a.onMouseMove, onMouseLeave = _a.onMouseLeave, onMouseUp = _a.onMouseUp;
808
+ var handleMouseDown = function (ev) {
809
+ ev.stopPropagation();
810
+ };
811
+ return (React.createElement("svg", { x: x, y: y, onClick: onClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
812
+ });
514
813
 
515
814
  var MIN_ELEMENT_SIZE = 20;
516
815
  //naming convention: [element type]_[element action]
@@ -6585,13 +6884,13 @@ if (process.env.NODE_ENV === 'production') {
6585
6884
  createRoot = m.createRoot;
6586
6885
  m.hydrateRoot;
6587
6886
  } else {
6588
- var i$1 = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
6887
+ var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
6589
6888
  createRoot = function(c, o) {
6590
- i$1.usingClientEntryPoint = true;
6889
+ i.usingClientEntryPoint = true;
6591
6890
  try {
6592
6891
  return m.createRoot(c, o);
6593
6892
  } finally {
6594
- i$1.usingClientEntryPoint = false;
6893
+ i.usingClientEntryPoint = false;
6595
6894
  }
6596
6895
  };
6597
6896
  }
@@ -6869,50 +7168,6 @@ var checkPositionOnLine = function (position, line) {
6869
7168
  return _line.contains(point);
6870
7169
  };
6871
7170
 
6872
- var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
6873
- //if direction is provided, rotation is based on direction
6874
- var rotation = shapeProps.rotation || 0;
6875
- if (shapeProps.direction) {
6876
- switch (shapeProps.direction) {
6877
- case 'left':
6878
- rotation = -90;
6879
- break;
6880
- case 'right':
6881
- rotation = 90;
6882
- break;
6883
- case 'down':
6884
- rotation = 180;
6885
- break;
6886
- default:
6887
- rotation = 0;
6888
- break;
6889
- }
6890
- }
6891
- var position = { x: shapeProps.x, y: shapeProps.y };
6892
- var transformOrigin = "center";
6893
- if (typeof shapeProps.positioningAnchor === 'object') {
6894
- position.x = position.x - shapeProps.positioningAnchor.x / 100 * shapeProps.width;
6895
- position.y = position.y - shapeProps.positioningAnchor.y / 100 * shapeProps.height;
6896
- transformOrigin = "".concat(shapeProps.positioningAnchor.x, "% ").concat(shapeProps.positioningAnchor.y, "%");
6897
- }
6898
- else if (shapeProps.positioningAnchor === exports.PositioningAnchor.Center) {
6899
- position.x = position.x - shapeProps.width / 2;
6900
- position.y = position.y - shapeProps.height / 2;
6901
- }
6902
- var objectOfAllEventAttributes = React.useMemo(function () {
6903
- var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
6904
- var k = _a[0]; _a[1];
6905
- return k.startsWith('on');
6906
- });
6907
- return Object.fromEntries(arrayOfAllEventAttributes);
6908
- }, [shapeProps]);
6909
- var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
6910
- var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
6911
- var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
6912
- return (React.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
6913
- 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)));
6914
- });
6915
-
6916
7171
  var Circle = React.forwardRef(function (props, ref) {
6917
7172
  var s = { height: 100, width: 100 };
6918
7173
  if (props.r) {
@@ -7869,63 +8124,6 @@ function useKeyboardCommands(_a) {
7869
8124
  }, [element]);
7870
8125
  }
7871
8126
 
7872
- /**
7873
- * Convert array of 16 byte values to UUID string format of the form:
7874
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
7875
- */
7876
- var byteToHex = [];
7877
- for (var i = 0; i < 256; ++i) {
7878
- byteToHex.push((i + 0x100).toString(16).slice(1));
7879
- }
7880
- function unsafeStringify(arr, offset = 0) {
7881
- // Note: Be careful editing this code! It's been tuned for performance
7882
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
7883
- //
7884
- // Note to future-self: No, you can't remove the `toLowerCase()` call.
7885
- // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
7886
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
7887
- }
7888
-
7889
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
7890
- // require the crypto API and do not support built-in fallback to lower quality random number
7891
- // generators (like Math.random()).
7892
-
7893
- var getRandomValues;
7894
- var rnds8 = new Uint8Array(16);
7895
- function rng() {
7896
- // lazy load so that environments that need to polyfill have a chance to do so
7897
- if (!getRandomValues) {
7898
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
7899
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
7900
- if (!getRandomValues) {
7901
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
7902
- }
7903
- }
7904
- return getRandomValues(rnds8);
7905
- }
7906
-
7907
- var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
7908
- var native = {
7909
- randomUUID
7910
- };
7911
-
7912
- function v4(options, buf, offset) {
7913
- if (native.randomUUID && !buf && !options) {
7914
- return native.randomUUID();
7915
- }
7916
- options = options || {};
7917
- var rnds = options.random || (options.rng || rng)();
7918
-
7919
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
7920
- rnds[6] = rnds[6] & 0x0f | 0x40;
7921
- rnds[8] = rnds[8] & 0x3f | 0x80;
7922
- return unsafeStringify(rnds);
7923
- }
7924
-
7925
- function generateUniqueId() {
7926
- return v4();
7927
- }
7928
-
7929
8127
  function convertElementsToTree(elements) {
7930
8128
  //Find child elements in the child elements, that is possible child of element, then return element with child of it.
7931
8129
  function findChildElementsOfNode(elementNodeInTree, possibleChildElements) {
@@ -8487,5 +8685,9 @@ function Editor(_a) {
8487
8685
  React.createElement(Paper, { size: { width: 3000, height: 3000 }, elements: editorContext.elements, links: editorContext.links, texts: editorContext.texts, onPaperClicked: editorContext.onPaperClicked, onPortMoved: editorContext.onPortMoved, onElementMoved: editorContext.onElementMoved, onElementResized: editorContext.onElementResized, onLinkValidation: editorContext.validateLink, onCreatingLink: editorContext.onCreatingLink, onCreatingPortByLinking: editorContext.onCreatingPortByLinking })));
8488
8686
  }
8489
8687
 
8688
+ exports.CustomPort = CustomPort;
8490
8689
  exports.EditorContext = EditorContext;
8690
+ exports.Element = Element$1;
8691
+ exports.ElementLink = ElementLink$1;
8692
+ exports.Port = Port$1;
8491
8693
  exports.default = Editor;