orcasvn-react-diagrams 0.1.0 → 0.1.1
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 +348 -187
- package/dist/cjs/types/models/index.d.ts +5 -1
- package/dist/esm/index.js +349 -189
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/models/index.d.ts +5 -1
- package/dist/index.d.ts +15 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -36,63 +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
39
|
/******************************************************************************
|
|
97
40
|
Copyright (c) Microsoft Corporation.
|
|
98
41
|
|
|
@@ -109,6 +52,20 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
109
52
|
***************************************************************************** */
|
|
110
53
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
111
54
|
|
|
55
|
+
var extendStatics = function(d, b) {
|
|
56
|
+
extendStatics = Object.setPrototypeOf ||
|
|
57
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
58
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
59
|
+
return extendStatics(d, b);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function __extends(d, b) {
|
|
63
|
+
if (typeof b !== "function" && b !== null)
|
|
64
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
65
|
+
extendStatics(d, b);
|
|
66
|
+
function __() { this.constructor = d; }
|
|
67
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
68
|
+
}
|
|
112
69
|
|
|
113
70
|
var __assign = function() {
|
|
114
71
|
__assign = Object.assign || function __assign(t) {
|
|
@@ -136,35 +93,140 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
136
93
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
137
94
|
};
|
|
138
95
|
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
};
|
|
96
|
+
var ShapeWrapper = React.forwardRef(function (shapeProps, ref) {
|
|
97
|
+
//if direction is provided, rotation is based on direction
|
|
98
|
+
var rotation = shapeProps.rotation || 0;
|
|
99
|
+
if (shapeProps.direction) {
|
|
100
|
+
switch (shapeProps.direction) {
|
|
101
|
+
case 'left':
|
|
102
|
+
rotation = -90;
|
|
103
|
+
break;
|
|
104
|
+
case 'right':
|
|
105
|
+
rotation = 90;
|
|
106
|
+
break;
|
|
107
|
+
case 'down':
|
|
108
|
+
rotation = 180;
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
rotation = 0;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
var position = { x: shapeProps.x, y: shapeProps.y };
|
|
116
|
+
var transformOrigin = "center";
|
|
117
|
+
if (typeof shapeProps.positioningAnchor === 'object') {
|
|
118
|
+
position.x = position.x - shapeProps.positioningAnchor.x / 100 * shapeProps.width;
|
|
119
|
+
position.y = position.y - shapeProps.positioningAnchor.y / 100 * shapeProps.height;
|
|
120
|
+
transformOrigin = "".concat(shapeProps.positioningAnchor.x, "% ").concat(shapeProps.positioningAnchor.y, "%");
|
|
121
|
+
}
|
|
122
|
+
else if (shapeProps.positioningAnchor === exports.PositioningAnchor.Center) {
|
|
123
|
+
position.x = position.x - shapeProps.width / 2;
|
|
124
|
+
position.y = position.y - shapeProps.height / 2;
|
|
125
|
+
}
|
|
126
|
+
var objectOfAllEventAttributes = React.useMemo(function () {
|
|
127
|
+
var arrayOfAllEventAttributes = Object.entries(shapeProps).filter(function (_a) {
|
|
128
|
+
var k = _a[0]; _a[1];
|
|
129
|
+
return k.startsWith('on');
|
|
130
|
+
});
|
|
131
|
+
return Object.fromEntries(arrayOfAllEventAttributes);
|
|
132
|
+
}, [shapeProps]);
|
|
133
|
+
var viewboxWidth = shapeProps.width > shapeProps.height ? 100 : shapeProps.width / shapeProps.height * 100;
|
|
134
|
+
var viewBoxHeight = shapeProps.height > shapeProps.width ? 100 : shapeProps.height / shapeProps.width * 100;
|
|
135
|
+
var viewBox = shapeProps.viewBox || "0 0 ".concat(viewboxWidth, " ").concat(viewBoxHeight);
|
|
136
|
+
return (React.createElement("g", { transform: "rotate(".concat(rotation, ")"), style: { transformOrigin: transformOrigin, transformBox: "content-box" } },
|
|
137
|
+
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)));
|
|
138
|
+
});
|
|
159
139
|
|
|
160
|
-
var
|
|
161
|
-
|
|
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));
|
|
140
|
+
var CustomShape = React.forwardRef(function (props, ref) {
|
|
141
|
+
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
166
142
|
});
|
|
167
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
146
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
147
|
+
*/
|
|
148
|
+
var byteToHex = [];
|
|
149
|
+
for (var i$1 = 0; i$1 < 256; ++i$1) {
|
|
150
|
+
byteToHex.push((i$1 + 0x100).toString(16).slice(1));
|
|
151
|
+
}
|
|
152
|
+
function unsafeStringify(arr, offset = 0) {
|
|
153
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
154
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
155
|
+
//
|
|
156
|
+
// Note to future-self: No, you can't remove the `toLowerCase()` call.
|
|
157
|
+
// REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
|
|
158
|
+
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();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
162
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
163
|
+
// generators (like Math.random()).
|
|
164
|
+
|
|
165
|
+
var getRandomValues;
|
|
166
|
+
var rnds8 = new Uint8Array(16);
|
|
167
|
+
function rng() {
|
|
168
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
169
|
+
if (!getRandomValues) {
|
|
170
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
171
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
172
|
+
if (!getRandomValues) {
|
|
173
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return getRandomValues(rnds8);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
180
|
+
var native = {
|
|
181
|
+
randomUUID
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
function v4(options, buf, offset) {
|
|
185
|
+
if (native.randomUUID && !buf && !options) {
|
|
186
|
+
return native.randomUUID();
|
|
187
|
+
}
|
|
188
|
+
options = options || {};
|
|
189
|
+
var rnds = options.random || (options.rng || rng)();
|
|
190
|
+
|
|
191
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
192
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
193
|
+
rnds[8] = rnds[8] & 0x3f | 0x80;
|
|
194
|
+
return unsafeStringify(rnds);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function generateUniqueId() {
|
|
198
|
+
return v4();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var Port$1 = /** @class */ (function () {
|
|
202
|
+
function Port(x, y, width, height, label, renderShape) {
|
|
203
|
+
this._id = generateUniqueId();
|
|
204
|
+
this.position = { x: x, y: y };
|
|
205
|
+
this.size = { width: width, height: height };
|
|
206
|
+
this.label = label;
|
|
207
|
+
this.renderShape = renderShape;
|
|
208
|
+
}
|
|
209
|
+
Object.defineProperty(Port.prototype, "id", {
|
|
210
|
+
get: function () {
|
|
211
|
+
return this._id;
|
|
212
|
+
},
|
|
213
|
+
enumerable: false,
|
|
214
|
+
configurable: true
|
|
215
|
+
});
|
|
216
|
+
return Port;
|
|
217
|
+
}());
|
|
218
|
+
|
|
219
|
+
var CustomPort = /** @class */ (function (_super) {
|
|
220
|
+
__extends(CustomPort, _super);
|
|
221
|
+
function CustomPort(x, y, width, height, renderShape, shapePositioningAnchor, label) {
|
|
222
|
+
var _this = _super.call(this, x, y, width, height, label, React.forwardRef(function (props, ref) {
|
|
223
|
+
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));
|
|
224
|
+
})) || this;
|
|
225
|
+
return _this;
|
|
226
|
+
}
|
|
227
|
+
return CustomPort;
|
|
228
|
+
}(Port$1));
|
|
229
|
+
|
|
168
230
|
function getDefaultExportFromCjs (x) {
|
|
169
231
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
170
232
|
}
|
|
@@ -512,6 +574,205 @@ var eventemitter3 = {exports: {}};
|
|
|
512
574
|
var eventemitter3Exports = eventemitter3.exports;
|
|
513
575
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
514
576
|
|
|
577
|
+
/** @class */ ((function () {
|
|
578
|
+
function Element(x, y, width, height, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
|
|
579
|
+
if (portMovealeAreas === void 0) { portMovealeAreas = []; }
|
|
580
|
+
this.resizability = {
|
|
581
|
+
enabled: true,
|
|
582
|
+
keepRatio: false
|
|
583
|
+
};
|
|
584
|
+
//internal properties
|
|
585
|
+
this._eventEmitter = new EventEmitter();
|
|
586
|
+
this._id = generateUniqueId();
|
|
587
|
+
this._position = { x: x, y: y };
|
|
588
|
+
this._size = { width: width, height: height };
|
|
589
|
+
this.renderShape = renderShape;
|
|
590
|
+
this.texts = texts;
|
|
591
|
+
this.ports = ports;
|
|
592
|
+
this.portMoveableAreas = portMovealeAreas;
|
|
593
|
+
this.portSlideRailSVGClassName = portSlideRailSVGClassName;
|
|
594
|
+
this.portDirection = portDirection;
|
|
595
|
+
}
|
|
596
|
+
Object.defineProperty(Element.prototype, "id", {
|
|
597
|
+
get: function () {
|
|
598
|
+
return this._id;
|
|
599
|
+
},
|
|
600
|
+
enumerable: false,
|
|
601
|
+
configurable: true
|
|
602
|
+
});
|
|
603
|
+
Object.defineProperty(Element.prototype, "size", {
|
|
604
|
+
get: function () {
|
|
605
|
+
return this._size;
|
|
606
|
+
},
|
|
607
|
+
set: function (value) {
|
|
608
|
+
this._size = value;
|
|
609
|
+
if (this.onResized)
|
|
610
|
+
this.onResized(value.width, value.height);
|
|
611
|
+
},
|
|
612
|
+
enumerable: false,
|
|
613
|
+
configurable: true
|
|
614
|
+
});
|
|
615
|
+
Object.defineProperty(Element.prototype, "position", {
|
|
616
|
+
get: function () {
|
|
617
|
+
return this._position;
|
|
618
|
+
},
|
|
619
|
+
set: function (value) {
|
|
620
|
+
this._position = value;
|
|
621
|
+
if (this.onMoved)
|
|
622
|
+
this.onMoved(value.x, value.y);
|
|
623
|
+
},
|
|
624
|
+
enumerable: false,
|
|
625
|
+
configurable: true
|
|
626
|
+
});
|
|
627
|
+
Object.defineProperty(Element.prototype, "parentElement", {
|
|
628
|
+
get: function () {
|
|
629
|
+
return this._parentElement;
|
|
630
|
+
},
|
|
631
|
+
set: function (value) {
|
|
632
|
+
var oldParent = this._parentElement;
|
|
633
|
+
this._parentElement = value;
|
|
634
|
+
this._eventEmitter.emit('parentChanged', oldParent, value);
|
|
635
|
+
},
|
|
636
|
+
enumerable: false,
|
|
637
|
+
configurable: true
|
|
638
|
+
});
|
|
639
|
+
Element.prototype.onParentChanged = function (callback) {
|
|
640
|
+
var _this = this;
|
|
641
|
+
this._eventEmitter.on('parentChanged', callback);
|
|
642
|
+
var canceller = function () {
|
|
643
|
+
_this._eventEmitter.off('parentChanged', callback);
|
|
644
|
+
};
|
|
645
|
+
return canceller;
|
|
646
|
+
};
|
|
647
|
+
Element.prototype.addPort = function (newPort) {
|
|
648
|
+
if (this.ports) {
|
|
649
|
+
this.ports.push(newPort);
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
this.ports = [newPort];
|
|
653
|
+
}
|
|
654
|
+
this._eventEmitter.emit('addedPort', newPort);
|
|
655
|
+
};
|
|
656
|
+
Element.prototype.onAddedPort = function (callback) {
|
|
657
|
+
var _this = this;
|
|
658
|
+
this._eventEmitter.on('addedPort', callback);
|
|
659
|
+
var canceller = function () {
|
|
660
|
+
_this._eventEmitter.off('addedPort', callback);
|
|
661
|
+
};
|
|
662
|
+
return canceller;
|
|
663
|
+
};
|
|
664
|
+
Element.prototype.deletePort = function (id) {
|
|
665
|
+
if (!this.ports)
|
|
666
|
+
return;
|
|
667
|
+
var index = this.ports.findIndex(function (p) { return p.id === id; });
|
|
668
|
+
if (index === -1) {
|
|
669
|
+
throw new Error("Port with id ".concat(id, " is not found"));
|
|
670
|
+
}
|
|
671
|
+
this.ports.splice(index, 1);
|
|
672
|
+
this._eventEmitter.emit('deletedPort', id);
|
|
673
|
+
};
|
|
674
|
+
Element.prototype.onDeletedPort = function (callback) {
|
|
675
|
+
var _this = this;
|
|
676
|
+
this._eventEmitter.on('deletedPort', callback);
|
|
677
|
+
var canceller = function () {
|
|
678
|
+
_this._eventEmitter.off('deletedPort', callback);
|
|
679
|
+
};
|
|
680
|
+
return canceller;
|
|
681
|
+
};
|
|
682
|
+
Element.prototype.getPort = function (id) {
|
|
683
|
+
if (!this.ports)
|
|
684
|
+
return undefined;
|
|
685
|
+
return this.ports.find(function (p) { return p.id === id; });
|
|
686
|
+
};
|
|
687
|
+
return Element;
|
|
688
|
+
})());
|
|
689
|
+
|
|
690
|
+
var EditorContext = /** @class */ (function () {
|
|
691
|
+
function EditorContext(elements, links, texts) {
|
|
692
|
+
this._elements = elements;
|
|
693
|
+
this._links = links;
|
|
694
|
+
this._texts = texts;
|
|
695
|
+
}
|
|
696
|
+
Object.defineProperty(EditorContext.prototype, "elements", {
|
|
697
|
+
get: function () {
|
|
698
|
+
return this._elements;
|
|
699
|
+
},
|
|
700
|
+
enumerable: false,
|
|
701
|
+
configurable: true
|
|
702
|
+
});
|
|
703
|
+
Object.defineProperty(EditorContext.prototype, "links", {
|
|
704
|
+
get: function () {
|
|
705
|
+
return this._links;
|
|
706
|
+
},
|
|
707
|
+
enumerable: false,
|
|
708
|
+
configurable: true
|
|
709
|
+
});
|
|
710
|
+
Object.defineProperty(EditorContext.prototype, "texts", {
|
|
711
|
+
get: function () {
|
|
712
|
+
return this._texts;
|
|
713
|
+
},
|
|
714
|
+
enumerable: false,
|
|
715
|
+
configurable: true
|
|
716
|
+
});
|
|
717
|
+
EditorContext.prototype.getElement = function (elementId) {
|
|
718
|
+
return this._elements.find(function (e) { return e.id === elementId; });
|
|
719
|
+
};
|
|
720
|
+
EditorContext.prototype.addElement = function (element) {
|
|
721
|
+
this._elements.push(element);
|
|
722
|
+
};
|
|
723
|
+
EditorContext.prototype.removeElement = function (elementId) {
|
|
724
|
+
this._elements = this._elements.filter(function (e) { return e.id !== elementId; });
|
|
725
|
+
};
|
|
726
|
+
EditorContext.prototype.getLink = function (linkId) {
|
|
727
|
+
return this._links.find(function (l) { return l.id === linkId; });
|
|
728
|
+
};
|
|
729
|
+
EditorContext.prototype.addLink = function (link) {
|
|
730
|
+
this._links.push(link);
|
|
731
|
+
};
|
|
732
|
+
EditorContext.prototype.removeLink = function (linkId) {
|
|
733
|
+
this._links = this._links.filter(function (l) { return l.id !== linkId; });
|
|
734
|
+
};
|
|
735
|
+
EditorContext.prototype.getText = function (textId) {
|
|
736
|
+
return this._texts.find(function (t) { return t.id === textId; });
|
|
737
|
+
};
|
|
738
|
+
EditorContext.prototype.addText = function (text) {
|
|
739
|
+
this._texts.push(text);
|
|
740
|
+
};
|
|
741
|
+
EditorContext.prototype.removeText = function (textId) {
|
|
742
|
+
this._texts = this._texts.filter(function (t) { return t.id !== textId; });
|
|
743
|
+
};
|
|
744
|
+
return EditorContext;
|
|
745
|
+
}());
|
|
746
|
+
|
|
747
|
+
var Ruler = function (_a) {
|
|
748
|
+
var squareSize = _a.squareSize, border = _a.border;
|
|
749
|
+
var numColumns = Math.ceil(3000 / squareSize);
|
|
750
|
+
var numRows = Math.ceil(3000 / squareSize);
|
|
751
|
+
var tableWidth = numColumns * squareSize;
|
|
752
|
+
return (React.createElement("table", { style: { position: 'absolute', zIndex: -1, top: 0, left: 0, borderCollapse: 'collapse', width: tableWidth } },
|
|
753
|
+
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: {
|
|
754
|
+
width: squareSize,
|
|
755
|
+
height: squareSize,
|
|
756
|
+
border: border,
|
|
757
|
+
margin: 0,
|
|
758
|
+
padding: 0,
|
|
759
|
+
boxSizing: 'border-box',
|
|
760
|
+
verticalAlign: 'top',
|
|
761
|
+
position: 'relative',
|
|
762
|
+
fontSize: 12,
|
|
763
|
+
} },
|
|
764
|
+
rowIndex === 0 ? React.createElement("span", { style: { marginLeft: "-12px" } }, colIndex * squareSize) : "",
|
|
765
|
+
colIndex === 0 ? React.createElement("span", { style: { top: "-9px", position: "absolute" } }, rowIndex * squareSize) : "")); }))); }))));
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
var ElementWrapper = React.forwardRef(function (_a, ref) {
|
|
769
|
+
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;
|
|
770
|
+
var handleMouseDown = function (ev) {
|
|
771
|
+
ev.stopPropagation();
|
|
772
|
+
};
|
|
773
|
+
return (React.createElement("svg", { x: x, y: y, onClick: onClick, onMouseDown: handleMouseDown, ref: ref, style: { overflow: "visible" }, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, onMouseUp: onMouseUp }, children));
|
|
774
|
+
});
|
|
775
|
+
|
|
515
776
|
var MIN_ELEMENT_SIZE = 20;
|
|
516
777
|
//naming convention: [element type]_[element action]
|
|
517
778
|
//element types: paper, port, element
|
|
@@ -6585,13 +6846,13 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
6585
6846
|
createRoot = m.createRoot;
|
|
6586
6847
|
m.hydrateRoot;
|
|
6587
6848
|
} else {
|
|
6588
|
-
var i
|
|
6849
|
+
var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
6589
6850
|
createRoot = function(c, o) {
|
|
6590
|
-
i
|
|
6851
|
+
i.usingClientEntryPoint = true;
|
|
6591
6852
|
try {
|
|
6592
6853
|
return m.createRoot(c, o);
|
|
6593
6854
|
} finally {
|
|
6594
|
-
i
|
|
6855
|
+
i.usingClientEntryPoint = false;
|
|
6595
6856
|
}
|
|
6596
6857
|
};
|
|
6597
6858
|
}
|
|
@@ -6869,50 +7130,6 @@ var checkPositionOnLine = function (position, line) {
|
|
|
6869
7130
|
return _line.contains(point);
|
|
6870
7131
|
};
|
|
6871
7132
|
|
|
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
7133
|
var Circle = React.forwardRef(function (props, ref) {
|
|
6917
7134
|
var s = { height: 100, width: 100 };
|
|
6918
7135
|
if (props.r) {
|
|
@@ -7869,63 +8086,6 @@ function useKeyboardCommands(_a) {
|
|
|
7869
8086
|
}, [element]);
|
|
7870
8087
|
}
|
|
7871
8088
|
|
|
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
8089
|
function convertElementsToTree(elements) {
|
|
7930
8090
|
//Find child elements in the child elements, that is possible child of element, then return element with child of it.
|
|
7931
8091
|
function findChildElementsOfNode(elementNodeInTree, possibleChildElements) {
|
|
@@ -8487,5 +8647,6 @@ function Editor(_a) {
|
|
|
8487
8647
|
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
8648
|
}
|
|
8489
8649
|
|
|
8650
|
+
exports.CustomPort = CustomPort;
|
|
8490
8651
|
exports.EditorContext = EditorContext;
|
|
8491
8652
|
exports.default = Editor;
|
|
@@ -12,7 +12,11 @@ import type IText from "./IText";
|
|
|
12
12
|
import type ITextProps from "./ITextProps";
|
|
13
13
|
export * from './enums';
|
|
14
14
|
export * from './callbackTypes';
|
|
15
|
+
export * from './implementations/CustomPort';
|
|
16
|
+
export * from './implementations/Element';
|
|
17
|
+
export * from './implementations/ElementLink';
|
|
18
|
+
export * from './implementations/Port';
|
|
15
19
|
export * from './implementations/EditorContext';
|
|
16
20
|
export * from './IText';
|
|
17
21
|
export * from './IPortProps';
|
|
18
|
-
export { IElement, IElementLink, IElementLinkProps, IElementProps, IPort, IPosition, IResizability, ISelectionFrameProps, IShape, ISize, IText, ITextProps
|
|
22
|
+
export { IElement, IElementLink, IElementLinkProps, IElementProps, IPort, IPosition, IResizability, ISelectionFrameProps, IShape, ISize, IText, ITextProps };
|