orcasvn-react-diagrams 0.1.1 → 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 +234 -193
- package/dist/cjs/types/models/implementations/index.d.ts +6 -0
- package/dist/cjs/types/models/index.d.ts +1 -5
- package/dist/esm/index.js +232 -194
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/models/implementations/index.d.ts +6 -0
- package/dist/esm/types/models/index.d.ts +1 -5
- package/dist/index.d.ts +59 -4
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -36,197 +36,6 @@ exports.TextAlign = void 0;
|
|
|
36
36
|
TextAlign[TextAlign["center"] = 2] = "center";
|
|
37
37
|
})(exports.TextAlign || (exports.TextAlign = {}));
|
|
38
38
|
|
|
39
|
-
/******************************************************************************
|
|
40
|
-
Copyright (c) Microsoft Corporation.
|
|
41
|
-
|
|
42
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
43
|
-
purpose with or without fee is hereby granted.
|
|
44
|
-
|
|
45
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
46
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
47
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
48
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
49
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
50
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
51
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
52
|
-
***************************************************************************** */
|
|
53
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
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
|
-
}
|
|
69
|
-
|
|
70
|
-
var __assign = function() {
|
|
71
|
-
__assign = Object.assign || function __assign(t) {
|
|
72
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
73
|
-
s = arguments[i];
|
|
74
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
75
|
-
}
|
|
76
|
-
return t;
|
|
77
|
-
};
|
|
78
|
-
return __assign.apply(this, arguments);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
function __spreadArray(to, from, pack) {
|
|
82
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
83
|
-
if (ar || !(i in from)) {
|
|
84
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
85
|
-
ar[i] = from[i];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
92
|
-
var e = new Error(message);
|
|
93
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
94
|
-
};
|
|
95
|
-
|
|
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
|
-
});
|
|
139
|
-
|
|
140
|
-
var CustomShape = React.forwardRef(function (props, ref) {
|
|
141
|
-
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
142
|
-
});
|
|
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
|
-
|
|
230
39
|
function getDefaultExportFromCjs (x) {
|
|
231
40
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
232
41
|
}
|
|
@@ -574,7 +383,64 @@ var eventemitter3 = {exports: {}};
|
|
|
574
383
|
var eventemitter3Exports = eventemitter3.exports;
|
|
575
384
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
576
385
|
|
|
577
|
-
/**
|
|
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 () {
|
|
578
444
|
function Element(x, y, width, height, renderShape, texts, ports, portMovealeAreas, portSlideRailSVGClassName, portDirection) {
|
|
579
445
|
if (portMovealeAreas === void 0) { portMovealeAreas = []; }
|
|
580
446
|
this.resizability = {
|
|
@@ -685,7 +551,63 @@ var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
|
685
551
|
return this.ports.find(function (p) { return p.id === id; });
|
|
686
552
|
};
|
|
687
553
|
return Element;
|
|
688
|
-
}
|
|
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
|
+
}());
|
|
689
611
|
|
|
690
612
|
var EditorContext = /** @class */ (function () {
|
|
691
613
|
function EditorContext(elements, links, texts) {
|
|
@@ -744,6 +666,122 @@ var EditorContext = /** @class */ (function () {
|
|
|
744
666
|
return EditorContext;
|
|
745
667
|
}());
|
|
746
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
|
+
};
|
|
725
|
+
|
|
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
|
+
});
|
|
769
|
+
|
|
770
|
+
var CustomShape = React.forwardRef(function (props, ref) {
|
|
771
|
+
return (React.createElement(ShapeWrapper, __assign({}, props, { ref: ref }), props.children));
|
|
772
|
+
});
|
|
773
|
+
|
|
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));
|
|
784
|
+
|
|
747
785
|
var Ruler = function (_a) {
|
|
748
786
|
var squareSize = _a.squareSize, border = _a.border;
|
|
749
787
|
var numColumns = Math.ceil(3000 / squareSize);
|
|
@@ -8649,4 +8687,7 @@ function Editor(_a) {
|
|
|
8649
8687
|
|
|
8650
8688
|
exports.CustomPort = CustomPort;
|
|
8651
8689
|
exports.EditorContext = EditorContext;
|
|
8690
|
+
exports.Element = Element$1;
|
|
8691
|
+
exports.ElementLink = ElementLink$1;
|
|
8692
|
+
exports.Port = Port$1;
|
|
8652
8693
|
exports.default = Editor;
|
|
@@ -11,12 +11,8 @@ import type ISize from "./size";
|
|
|
11
11
|
import type IText from "./IText";
|
|
12
12
|
import type ITextProps from "./ITextProps";
|
|
13
13
|
export * from './enums';
|
|
14
|
+
export * from './implementations';
|
|
14
15
|
export * from './callbackTypes';
|
|
15
|
-
export * from './implementations/CustomPort';
|
|
16
|
-
export * from './implementations/Element';
|
|
17
|
-
export * from './implementations/ElementLink';
|
|
18
|
-
export * from './implementations/Port';
|
|
19
|
-
export * from './implementations/EditorContext';
|
|
20
16
|
export * from './IText';
|
|
21
17
|
export * from './IPortProps';
|
|
22
18
|
export { IElement, IElementLink, IElementLinkProps, IElementProps, IPort, IPosition, IResizability, ISelectionFrameProps, IShape, ISize, IText, ITextProps };
|