1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424 | 1×
1×
1×
21060×
21060×
21060×
21060×
109459×
109459×
109459×
109459×
109459×
4159×
4159×
105300×
21060×
1×
1×
1×
1×
163×
11×
11×
11×
10×
1×
152×
1×
1×
918017×
918017×
918005×
918005×
918005×
918005×
918005×
918005×
918005×
918005×
918005×
1×
1×
523181×
523181×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
120259×
120259×
120259×
120259×
120259×
120259×
120259×
120259×
120259×
120259×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
523169×
1×
1×
338239×
338239×
338239×
338239×
338213×
338213×
338213×
338213×
338213×
338213×
338213×
259052×
259052×
28×
259024×
259052×
338213×
338213×
338213×
2375359×
2375359×
2375313×
2351667×
2351667×
2351667×
128523×
2223144×
28×
2223116×
266381×
1956735×
23646×
23581×
338239×
1×
1×
338213×
9697×
6356×
1622×
6525×
16138×
58×
297817×
1×
1×
128525×
128525×
128524×
128524×
53698×
1×
53697×
34350×
19347×
128525×
1×
1×
6489×
6489×
6489×
1333×
6489×
9872×
9872×
471×
471×
458×
9401×
1×
9400×
1226×
1226×
1033×
1226×
8174×
6489×
1×
1×
472×
472×
472×
427×
472×
459×
472×
315×
1×
1×
1×
314×
313×
313×
300×
1×
472×
1×
1×
31910×
31910×
31307×
31307×
547×
547×
22×
22×
34×
34×
31910×
1×
1×
31913×
31913×
1581×
1581×
605×
605×
29724×
29724×
3×
3×
31913×
1×
1×
48747×
48747×
48747×
48747×
48747×
48747×
48747×
48747×
48747×
1×
1×
10×
10×
10×
1×
1×
6×
6×
6×
6×
6×
6×
6×
6×
10×
4×
10×
10×
10×
6×
6×
64×
64×
64×
4×
4×
6×
3×
3×
3×
6×
1×
1×
31967×
31967×
31967×
25×
25×
31799×
31799×
143×
143×
31967×
1×
1×
123852×
123852×
123852×
123852×
123852×
123852×
123852×
123852×
123852×
123852×
123852×
1×
1×
1382242×
20638×
20638×
20638×
1361604×
1×
1×
248909×
248909×
248909×
1×
1×
379190×
28090×
70×
379190×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../primitives/rect", "../primitives/size", "../primitives/matrix", "@syncfusion/ej2-base", "./dom-util"], function (require, exports, ej2_base_1, rect_1, size_1, matrix_1, ej2_base_2, dom_util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function randomId() {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
var id = '';
var num;
for (var i = 0; i < 5; i++) {
Eif (typeof window !== 'undefined' && 'crypto' in window && 'getRandomValues' in crypto) {
var count = new Uint16Array(1);
var intCrypto = window.msCrypto || window.crypto;
num = intCrypto.getRandomValues(count)[0] % (chars.length - 1);
}
else {
num = Math.floor(Math.random() * chars.length);
}
if (i === 0 && num < 10) {
i--;
continue;
}
id += chars.substring(num, num + 1);
}
return id;
}
exports.randomId = randomId;
function getIndex(comp, id) {
if (comp.nodes && comp.nodes.length > 0) {
for (var i = 0; i < comp.nodes.length; i++) {
if (comp.nodes[parseInt(i.toString(), 10)].id === id) {
return i;
}
}
}
if (comp.connectors && comp.connectors.length > 0) {
for (var i = 0; i < comp.connectors.length; i++) {
if (comp.connectors[parseInt(i.toString(), 10)].id === id) {
return i;
}
}
}
return null;
}
exports.getIndex = getIndex;
function templateCompiler(template) {
if (template) {
var e = void 0;
try {
if (typeof template !== 'function' && document.querySelectorAll(template).length) {
return ej2_base_1.compile(document.querySelector(template).innerHTML.trim());
}
else {
return ej2_base_1.compile(template);
}
}
catch (e) {
return ej2_base_1.compile(template);
}
}
return undefined;
}
exports.templateCompiler = templateCompiler;
function cornersPointsBeforeRotation(ele) {
var bounds = new rect_1.Rect();
var top = ele.offsetY - ele.actualSize.height * ele.pivot.y;
var bottom = ele.offsetY + ele.actualSize.height * (1 - ele.pivot.y);
var left = ele.offsetX - ele.actualSize.width * ele.pivot.x;
var right = ele.offsetX + ele.actualSize.width * (1 - ele.pivot.x);
var topLeft = { x: left, y: top };
var topRight = { x: right, y: top };
var bottomLeft = { x: left, y: bottom };
var bottomRight = { x: right, y: bottom };
bounds = rect_1.Rect.toBounds([topLeft, topRight, bottomLeft, bottomRight]);
return bounds;
}
exports.cornersPointsBeforeRotation = cornersPointsBeforeRotation;
function getBounds(element) {
var bounds = new rect_1.Rect();
var corners = cornersPointsBeforeRotation(element);
var middleLeft = corners.middleLeft;
var topCenter = corners.topCenter;
var bottomCenter = corners.bottomCenter;
var middleRight = corners.middleRight;
var topLeft = corners.topLeft;
var topRight = corners.topRight;
var bottomLeft = corners.bottomLeft;
var bottomRight = corners.bottomRight;
element.corners = {
topLeft: topLeft, topCenter: topCenter, topRight: topRight, middleLeft: middleLeft,
middleRight: middleRight, bottomLeft: bottomLeft, bottomCenter: bottomCenter, bottomRight: bottomRight
};
if (element.rotateAngle !== 0 || element.parentTransform !== 0) {
var matrix = matrix_1.identityMatrix();
matrix_1.rotateMatrix(matrix, element.rotateAngle + element.parentTransform, element.offsetX, element.offsetY);
element.corners.topLeft = topLeft = matrix_1.transformPointByMatrix(matrix, topLeft);
element.corners.topCenter = topCenter = matrix_1.transformPointByMatrix(matrix, topCenter);
element.corners.topRight = topRight = matrix_1.transformPointByMatrix(matrix, topRight);
element.corners.middleLeft = middleLeft = matrix_1.transformPointByMatrix(matrix, middleLeft);
element.corners.middleRight = middleRight = matrix_1.transformPointByMatrix(matrix, middleRight);
element.corners.bottomLeft = bottomLeft = matrix_1.transformPointByMatrix(matrix, bottomLeft);
element.corners.bottomCenter = bottomCenter = matrix_1.transformPointByMatrix(matrix, bottomCenter);
element.corners.bottomRight = bottomRight = matrix_1.transformPointByMatrix(matrix, bottomRight);
}
bounds = rect_1.Rect.toBounds([topLeft, topRight, bottomLeft, bottomRight]);
element.corners.left = bounds.left;
element.corners.right = bounds.right;
element.corners.top = bounds.top;
element.corners.bottom = bounds.bottom;
element.corners.center = bounds.center;
element.corners.width = bounds.width;
element.corners.height = bounds.height;
return bounds;
}
exports.getBounds = getBounds;
function cloneObject(obj, additionalProp, key, cloneBlazorProp) {
var newObject = {};
var keys = 'properties';
var prop = 'propName';
if (obj) {
key = obj["" + prop];
var sourceObject = obj["" + keys] || obj;
var properties = [];
properties = properties.concat(Object.keys(sourceObject));
var customProperties = [];
properties.push('version');
if (key) {
var propAdditional = getFunction(additionalProp);
if (propAdditional) {
customProperties = propAdditional(key);
}
else {
customProperties = [];
}
properties = properties.concat(customProperties);
}
var internalProp = getInternalProperties(key);
properties = properties.concat(internalProp);
for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {
var property = properties_1[_i];
if (property !== 'historyManager') {
if (property !== 'wrapper') {
var isEventEmmitter = obj["" + property] && obj.hasOwnProperty('observers') ? true : false;
Eif (!isEventEmmitter) {
if (obj["" + property] instanceof Array) {
newObject["" + property] = cloneArray((internalProp.indexOf(property) === -1 && obj["" + keys]) ? obj["" + keys]["" + property] : obj["" + property], additionalProp, property, cloneBlazorProp);
}
else if (obj["" + property] instanceof Array === false && obj["" + property] instanceof HTMLElement) {
newObject["" + property] = obj["" + property].cloneNode(true).innerHTML;
}
else if (obj["" + property] instanceof Array === false && obj["" + property] instanceof Object) {
newObject["" + property] = cloneObject((internalProp.indexOf(property) === -1 && obj["" + keys]) ? obj["" + keys]["" + property] : obj["" + property], undefined, undefined, cloneBlazorProp);
}
else {
newObject["" + property] = obj["" + property];
}
}
}
else {
if (obj["" + property]) {
newObject["" + property] = {
actualSize: {
width: obj["" + property].actualSize.width, height: obj["" + property].actualSize.height
}, offsetX: obj["" + property].offsetX, offsetY: obj["" + property].offsetY
};
}
}
}
}
}
return newObject;
}
exports.cloneObject = cloneObject;
function getInternalProperties(propName) {
switch (propName) {
case 'nodes':
case 'children':
return ['inEdges', 'outEdges', 'parentId', 'processId', 'nodeId', 'umlIndex', 'isPhase', 'isLane'];
case 'connectors':
return ['parentId'];
case 'annotation':
return ['nodeId'];
case 'annotations':
return ['nodeId'];
case 'shape':
return ['hasHeader'];
case 'layers':
return ['objectZIndex'];
}
return [];
}
exports.getInternalProperties = getInternalProperties;
function cloneArray(sourceArray, additionalProp, key, cloneBlazorProp) {
var clonedArray;
if (sourceArray) {
clonedArray = [];
for (var i = 0; i < sourceArray.length; i++) {
if (sourceArray[parseInt(i.toString(), 10)] instanceof Array) {
clonedArray.push(sourceArray[parseInt(i.toString(), 10)]);
}
else if (sourceArray[parseInt(i.toString(), 10)] instanceof Object) {
clonedArray.push(cloneObject(sourceArray[parseInt(i.toString(), 10)], additionalProp, key, cloneBlazorProp));
}
else {
clonedArray.push(sourceArray[parseInt(i.toString(), 10)]);
}
}
}
return clonedArray;
}
exports.cloneArray = cloneArray;
function extendObject(options, childObject) {
var properties = 'properties';
Eif (options) {
if (!childObject) {
childObject = { properties: {} };
}
for (var _i = 0, _a = Object.keys(options); _i < _a.length; _i++) {
var property = _a[_i];
if (options["" + property] instanceof Array) {
var extendeArray = extendArray(options["" + property], childObject["" + properties]["" + property]);
if (!childObject["" + properties]["" + property] || !childObject["" + properties]["" + property].length) {
childObject["" + property] = extendeArray;
}
}
else if (options["" + property] instanceof Array === false && options["" + property] instanceof HTMLElement) {
childObject["" + property] = options["" + property].cloneNode(true).innerHtml;
}
else if (options["" + property] instanceof Array === false && options["" + property] instanceof Object) {
var extendedObject = extendObject(options["" + property], childObject["" + properties]["" + property]);
if (extendedObject["" + properties] && !Object.keys(extendedObject["" + properties]).length) {
delete extendedObject["" + properties];
}
childObject["" + property] = extendedObject;
}
else {
childObject["" + property] = childObject["" + properties]["" + property] !== undefined ?
childObject["" + property] : options["" + property];
}
}
}
return childObject;
}
exports.extendObject = extendObject;
function extendArray(sourceArray, childArray) {
var clonedArray = [];
var reset = false;
if (!childArray) {
childArray = [];
}
if (!childArray.length) {
reset = true;
}
for (var i = 0; i < sourceArray.length; i++) {
if (sourceArray[parseInt(i.toString(), 10)] instanceof Array) {
var extendedArray = extendArray(sourceArray[parseInt(i.toString(), 10)], childArray[parseInt(i.toString(), 10)]);
Eif (reset) {
clonedArray.push(extendArray);
}
}
else if (sourceArray[parseInt(i.toString(), 10)] instanceof Object) {
var extendedObject = extendObject(sourceArray[parseInt(i.toString(), 10)], childArray[parseInt(i.toString(), 10)]);
if (reset) {
clonedArray.push(extendedObject);
}
}
else {
clonedArray.push(sourceArray[parseInt(i.toString(), 10)]);
}
}
return clonedArray;
}
exports.extendArray = extendArray;
function textAlignToString(value) {
var state = '';
switch (value) {
case 'Center':
state = 'center';
break;
case 'Left':
state = 'left';
break;
case 'Right':
state = 'right';
break;
case 'Justify':
state = 'justify';
break;
}
return state;
}
exports.textAlignToString = textAlignToString;
function wordBreakToString(value) {
var state = '';
switch (value) {
case 'Wrap':
state = 'breakall';
break;
case 'NoWrap':
state = 'keepall';
break;
case 'WrapWithOverflow':
state = 'normal';
break;
case 'LineThrough':
state = 'line-through';
break;
}
return state;
}
exports.wordBreakToString = wordBreakToString;
function bBoxText(textContent, options) {
var measureWindowElement = 'measureElement';
window["" + measureWindowElement].style.visibility = 'visible';
var svg = window["" + measureWindowElement].children[2];
var text = dom_util_1.getChildNode(svg)[1];
text.textContent = textContent;
dom_util_1.applyStyleAgainstCsp(text, 'font-size:' + options.fontSize + 'px; font-family:'
+ options.fontFamily + ';font-weight:' + (options.bold ? 'bold' : 'normal'));
var bBox = text.getBBox().width;
window["" + measureWindowElement].style.visibility = 'hidden';
return bBox;
}
exports.bBoxText = bBoxText;
function middleElement(i, j) {
var m = 0;
m = (i + j) / 2;
return m;
}
exports.middleElement = middleElement;
function overFlow(text, options) {
var i = 0;
var j = 0;
var middle = 0;
var bounds = 0;
var temp = '';
j = text.length;
var t = 0;
do {
if (bounds > 0) {
i = middle;
}
middle = Math.floor(middleElement(i, j));
temp += text.substr(i, middle);
bounds = bBoxText(temp, options);
} while (bounds <= options.width);
temp = temp.substr(0, i);
for (t = i; t < j; t++) {
temp += text[parseInt(t.toString(), 10)];
bounds = bBoxText(temp, options);
if (bounds >= options.width) {
text = text.substr(0, temp.length - 1);
break;
}
}
if (options.textOverflow === 'Ellipsis') {
text = text.substr(0, text.length - 3);
text += '...';
}
else {
text = text.substr(0, text.length);
}
return text;
}
exports.overFlow = overFlow;
function whiteSpaceToString(value, wrap) {
Iif (wrap === 'NoWrap' && value === 'PreserveAll') {
return 'pre';
}
var state = '';
switch (value) {
case 'CollapseAll':
state = 'nowrap';
break;
case 'CollapseSpace':
state = 'pre-line';
break;
case 'PreserveAll':
state = 'pre-wrap';
break;
}
return state;
}
exports.whiteSpaceToString = whiteSpaceToString;
function rotateSize(size, angle) {
var matrix = matrix_1.identityMatrix();
matrix_1.rotateMatrix(matrix, angle, 0, 0);
var topLeft = matrix_1.transformPointByMatrix(matrix, { x: 0, y: 0 });
var topRight = matrix_1.transformPointByMatrix(matrix, { x: size.width, y: 0 });
var bottomLeft = matrix_1.transformPointByMatrix(matrix, { x: 0, y: size.height });
var bottomRight = matrix_1.transformPointByMatrix(matrix, { x: size.width, y: size.height });
var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
var minY = Math.min(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
var maxY = Math.max(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
return new size_1.Size(maxX - minX, maxY - minY);
}
exports.rotateSize = rotateSize;
function rotatePoint(angle, pivotX, pivotY, point) {
if (angle !== 0) {
var matrix = matrix_1.identityMatrix();
matrix_1.rotateMatrix(matrix, angle, pivotX, pivotY);
return matrix_1.transformPointByMatrix(matrix, point);
}
return point;
}
exports.rotatePoint = rotatePoint;
function getOffset(topLeft, obj) {
var offX = topLeft.x + obj.desiredSize.width * obj.pivot.x;
var offY = topLeft.y + obj.desiredSize.height * obj.pivot.y;
return {
x: offX, y: offY
};
}
exports.getOffset = getOffset;
function getFunction(value) {
if (value !== undefined) {
if (typeof value === 'string') {
value = ej2_base_2.getValue(value, window);
}
}
return value;
}
exports.getFunction = getFunction;
});
|