@esfaenza/es-diagrams 12.2.13 → 13.1.3

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.
Files changed (50) hide show
  1. package/esfaenza-es-diagrams.d.ts +1 -5
  2. package/esm2020/esfaenza-es-diagrams.mjs +5 -0
  3. package/esm2020/lib/components/es-diagram.component.mjs +519 -0
  4. package/esm2020/lib/esdiagram.module.mjs +33 -0
  5. package/esm2020/lib/extensions/ReactiveExtensions.mjs +36 -0
  6. package/{esm2015/lib/extensions/ResizeSensor.js → esm2020/lib/extensions/ResizeSensor.mjs} +0 -0
  7. package/{esm2015/lib/models/EsDiagramModuleConfig.js → esm2020/lib/models/EsDiagramModuleConfig.mjs} +0 -0
  8. package/{esm2015/lib/models/component/contextmenu/ContextMenuCommand.js → esm2020/lib/models/component/contextmenu/ContextMenuCommand.mjs} +0 -0
  9. package/{esm2015/lib/models/component/contextmenu/ContextMenuOptions.js → esm2020/lib/models/component/contextmenu/ContextMenuOptions.mjs} +0 -0
  10. package/{esm2015/lib/models/component/grouping/ExpandCollapseOptions.js → esm2020/lib/models/component/grouping/ExpandCollapseOptions.mjs} +0 -0
  11. package/{esm2015/lib/models/component/nodes/NodeHTMLTemplate.js → esm2020/lib/models/component/nodes/NodeHTMLTemplate.mjs} +0 -0
  12. package/{esm2015/lib/models/component/nodes/NodeTemplate.js → esm2020/lib/models/component/nodes/NodeTemplate.mjs} +0 -0
  13. package/{esm2015/lib/models/component/nodes/ZoomLevelBasedTemplate.js → esm2020/lib/models/component/nodes/ZoomLevelBasedTemplate.mjs} +0 -0
  14. package/{esm2015/lib/models/layouts/BreadthFirstLayoutOptionsImpl.js → esm2020/lib/models/layouts/BreadthFirstLayoutOptionsImpl.mjs} +0 -0
  15. package/{esm2015/lib/models/layouts/CircleLayoutOptionsImpl.js → esm2020/lib/models/layouts/CircleLayoutOptionsImpl.mjs} +0 -0
  16. package/{esm2015/lib/models/layouts/ConcentricLayoutOptionsImpl.js → esm2020/lib/models/layouts/ConcentricLayoutOptionsImpl.mjs} +0 -0
  17. package/{esm2015/lib/models/layouts/CoseLayoutOptionsImpl.js → esm2020/lib/models/layouts/CoseLayoutOptionsImpl.mjs} +0 -0
  18. package/{esm2015/lib/models/layouts/DagreLayoutOptionsImpl.js → esm2020/lib/models/layouts/DagreLayoutOptionsImpl.mjs} +0 -0
  19. package/{esm2015/lib/models/layouts/GridLayoutOptionsImpl.js → esm2020/lib/models/layouts/GridLayoutOptionsImpl.mjs} +0 -0
  20. package/{esm2015/lib/models/layouts/NullLayoutOptionsImpl.js → esm2020/lib/models/layouts/NullLayoutOptionsImpl.mjs} +0 -0
  21. package/{esm2015/lib/models/layouts/PresetLayoutOptionsImpl.js → esm2020/lib/models/layouts/PresetLayoutOptionsImpl.mjs} +0 -0
  22. package/{esm2015/lib/models/layouts/RandomLayoutOptionsImpl.js → esm2020/lib/models/layouts/RandomLayoutOptionsImpl.mjs} +0 -0
  23. package/{esm2015/lib/models/layouts/base/AnimateLayoutOptionsImpl.js → esm2020/lib/models/layouts/base/AnimateLayoutOptionsImpl.mjs} +0 -0
  24. package/{esm2015/lib/models/layouts/base/BaseLayoutOptionsImpl.js → esm2020/lib/models/layouts/base/BaseLayoutOptionsImpl.mjs} +0 -0
  25. package/{esm2015/lib/models/layouts/base/ShapedLayoutOptionsImpl.js → esm2020/lib/models/layouts/base/ShapedLayoutOptionsImpl.mjs} +0 -0
  26. package/esm2020/lib/services/es-diagram.dispatcher.mjs +89 -0
  27. package/{esm2015/lib/services/es-diagram.loc.js → esm2020/lib/services/es-diagram.loc.mjs} +0 -0
  28. package/esm2020/lib/services/es-diagram.service.mjs +112 -0
  29. package/{esm2015/lib/tokens.js → esm2020/lib/tokens.mjs} +0 -0
  30. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  31. package/fesm2015/{esfaenza-es-diagrams.js → esfaenza-es-diagrams.mjs} +180 -136
  32. package/fesm2015/esfaenza-es-diagrams.mjs.map +1 -0
  33. package/fesm2020/esfaenza-es-diagrams.mjs +1391 -0
  34. package/fesm2020/esfaenza-es-diagrams.mjs.map +1 -0
  35. package/lib/components/es-diagram.component.d.ts +3 -0
  36. package/lib/esdiagram.module.d.ts +7 -0
  37. package/lib/extensions/ReactiveExtensions.d.ts +3 -0
  38. package/lib/services/es-diagram.dispatcher.d.ts +3 -0
  39. package/lib/services/es-diagram.service.d.ts +3 -0
  40. package/package.json +21 -9
  41. package/bundles/esfaenza-es-diagrams.umd.js +0 -1856
  42. package/bundles/esfaenza-es-diagrams.umd.js.map +0 -1
  43. package/esfaenza-es-diagrams.metadata.json +0 -1
  44. package/esm2015/esfaenza-es-diagrams.js +0 -10
  45. package/esm2015/lib/components/es-diagram.component.js +0 -503
  46. package/esm2015/lib/esdiagram.module.js +0 -28
  47. package/esm2015/lib/extensions/ReactiveExtensions.js +0 -34
  48. package/esm2015/lib/services/es-diagram.dispatcher.js +0 -86
  49. package/esm2015/lib/services/es-diagram.service.js +0 -106
  50. package/fesm2015/esfaenza-es-diagrams.js.map +0 -1
@@ -1,1856 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('cytoscape'), require('@angular/forms'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('@esfaenza/es-diagrams', ['exports', '@angular/core', 'cytoscape', '@angular/forms', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza['es-diagrams'] = {}), global.ng.core, global.cy_, global.ng.forms, global.ng.common));
5
- }(this, (function (exports, i0, cy_, forms, common) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var cy___namespace = /*#__PURE__*/_interopNamespace(cy_);
29
-
30
- /**
31
- * Definizione di un comando del Context menù
32
- */
33
- var ContextMenuCommand = /** @class */ (function () {
34
- function ContextMenuCommand() {
35
- }
36
- return ContextMenuCommand;
37
- }());
38
-
39
- /**
40
- * Opzioni che gestiscono il context menu. Quando una di queste opzioni non viene assegnata viene mantenuto il default, assicurarsi quindi di modificare solo
41
- * le proprietà che si vogliono effettivamente cambiare rispetto ai default
42
- */
43
- var ContextMenuOptions = /** @class */ (function () {
44
- function ContextMenuOptions() {
45
- }
46
- return ContextMenuOptions;
47
- }());
48
-
49
- /**
50
- * Opzioni native per l'estensione expand-collapse di cytoscape
51
- */
52
- var ExpandCollapseOptions = /** @class */ (function () {
53
- function ExpandCollapseOptions() {
54
- }
55
- return ExpandCollapseOptions;
56
- }());
57
-
58
- /**
59
- * Classe che indica per una data query quali template applicare
60
- */
61
- var NodeHTMLTemplate = /** @class */ (function () {
62
- function NodeHTMLTemplate() {
63
- }
64
- return NodeHTMLTemplate;
65
- }());
66
-
67
- /**
68
- * Classe che rappresenta un template HTML applicabile ad un nodo
69
- */
70
- var NodeTemplate = /** @class */ (function () {
71
- function NodeTemplate() {
72
- }
73
- return NodeTemplate;
74
- }());
75
-
76
- /**
77
- * Classe che rappresenta il template HTML di un nodo da utilizzare per un certo livello di zoom
78
- */
79
- var ZoomLevelBasedTemplate = /** @class */ (function () {
80
- function ZoomLevelBasedTemplate() {
81
- }
82
- return ZoomLevelBasedTemplate;
83
- }());
84
-
85
- /**
86
- * Opzioni di layout di base che si collegano al **ready** e allo **stop** eventualmente per aggiungere del log addizionale
87
- */
88
- var BaseLayoutOptionsImpl = /** @class */ (function () {
89
- function BaseLayoutOptionsImpl() {
90
- }
91
- /**
92
- * Per ora ignoro lato documentale dato che sono placholder
93
- * @ignore
94
- */
95
- BaseLayoutOptionsImpl.prototype.ready = function (e) {
96
- };
97
- /**
98
- * Per ora ignoro lato documentale dato che sono placholder
99
- * @ignore
100
- */
101
- BaseLayoutOptionsImpl.prototype.stop = function (e) {
102
- };
103
- return BaseLayoutOptionsImpl;
104
- }());
105
-
106
- /*! *****************************************************************************
107
- Copyright (c) Microsoft Corporation.
108
-
109
- Permission to use, copy, modify, and/or distribute this software for any
110
- purpose with or without fee is hereby granted.
111
-
112
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
113
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
114
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
115
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
116
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
117
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
118
- PERFORMANCE OF THIS SOFTWARE.
119
- ***************************************************************************** */
120
- /* global Reflect, Promise */
121
- var extendStatics = function (d, b) {
122
- extendStatics = Object.setPrototypeOf ||
123
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
124
- function (d, b) { for (var p in b)
125
- if (Object.prototype.hasOwnProperty.call(b, p))
126
- d[p] = b[p]; };
127
- return extendStatics(d, b);
128
- };
129
- function __extends(d, b) {
130
- if (typeof b !== "function" && b !== null)
131
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
132
- extendStatics(d, b);
133
- function __() { this.constructor = d; }
134
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
135
- }
136
- var __assign = function () {
137
- __assign = Object.assign || function __assign(t) {
138
- for (var s, i = 1, n = arguments.length; i < n; i++) {
139
- s = arguments[i];
140
- for (var p in s)
141
- if (Object.prototype.hasOwnProperty.call(s, p))
142
- t[p] = s[p];
143
- }
144
- return t;
145
- };
146
- return __assign.apply(this, arguments);
147
- };
148
- function __rest(s, e) {
149
- var t = {};
150
- for (var p in s)
151
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
152
- t[p] = s[p];
153
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
154
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
155
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
156
- t[p[i]] = s[p[i]];
157
- }
158
- return t;
159
- }
160
- function __decorate(decorators, target, key, desc) {
161
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
162
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
163
- r = Reflect.decorate(decorators, target, key, desc);
164
- else
165
- for (var i = decorators.length - 1; i >= 0; i--)
166
- if (d = decorators[i])
167
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
168
- return c > 3 && r && Object.defineProperty(target, key, r), r;
169
- }
170
- function __param(paramIndex, decorator) {
171
- return function (target, key) { decorator(target, key, paramIndex); };
172
- }
173
- function __metadata(metadataKey, metadataValue) {
174
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
175
- return Reflect.metadata(metadataKey, metadataValue);
176
- }
177
- function __awaiter(thisArg, _arguments, P, generator) {
178
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
179
- return new (P || (P = Promise))(function (resolve, reject) {
180
- function fulfilled(value) { try {
181
- step(generator.next(value));
182
- }
183
- catch (e) {
184
- reject(e);
185
- } }
186
- function rejected(value) { try {
187
- step(generator["throw"](value));
188
- }
189
- catch (e) {
190
- reject(e);
191
- } }
192
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
193
- step((generator = generator.apply(thisArg, _arguments || [])).next());
194
- });
195
- }
196
- function __generator(thisArg, body) {
197
- var _ = { label: 0, sent: function () { if (t[0] & 1)
198
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
199
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
200
- function verb(n) { return function (v) { return step([n, v]); }; }
201
- function step(op) {
202
- if (f)
203
- throw new TypeError("Generator is already executing.");
204
- while (_)
205
- try {
206
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
207
- return t;
208
- if (y = 0, t)
209
- op = [op[0] & 2, t.value];
210
- switch (op[0]) {
211
- case 0:
212
- case 1:
213
- t = op;
214
- break;
215
- case 4:
216
- _.label++;
217
- return { value: op[1], done: false };
218
- case 5:
219
- _.label++;
220
- y = op[1];
221
- op = [0];
222
- continue;
223
- case 7:
224
- op = _.ops.pop();
225
- _.trys.pop();
226
- continue;
227
- default:
228
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
229
- _ = 0;
230
- continue;
231
- }
232
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
233
- _.label = op[1];
234
- break;
235
- }
236
- if (op[0] === 6 && _.label < t[1]) {
237
- _.label = t[1];
238
- t = op;
239
- break;
240
- }
241
- if (t && _.label < t[2]) {
242
- _.label = t[2];
243
- _.ops.push(op);
244
- break;
245
- }
246
- if (t[2])
247
- _.ops.pop();
248
- _.trys.pop();
249
- continue;
250
- }
251
- op = body.call(thisArg, _);
252
- }
253
- catch (e) {
254
- op = [6, e];
255
- y = 0;
256
- }
257
- finally {
258
- f = t = 0;
259
- }
260
- if (op[0] & 5)
261
- throw op[1];
262
- return { value: op[0] ? op[1] : void 0, done: true };
263
- }
264
- }
265
- var __createBinding = Object.create ? (function (o, m, k, k2) {
266
- if (k2 === undefined)
267
- k2 = k;
268
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
269
- }) : (function (o, m, k, k2) {
270
- if (k2 === undefined)
271
- k2 = k;
272
- o[k2] = m[k];
273
- });
274
- function __exportStar(m, o) {
275
- for (var p in m)
276
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
277
- __createBinding(o, m, p);
278
- }
279
- function __values(o) {
280
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
281
- if (m)
282
- return m.call(o);
283
- if (o && typeof o.length === "number")
284
- return {
285
- next: function () {
286
- if (o && i >= o.length)
287
- o = void 0;
288
- return { value: o && o[i++], done: !o };
289
- }
290
- };
291
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
292
- }
293
- function __read(o, n) {
294
- var m = typeof Symbol === "function" && o[Symbol.iterator];
295
- if (!m)
296
- return o;
297
- var i = m.call(o), r, ar = [], e;
298
- try {
299
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
300
- ar.push(r.value);
301
- }
302
- catch (error) {
303
- e = { error: error };
304
- }
305
- finally {
306
- try {
307
- if (r && !r.done && (m = i["return"]))
308
- m.call(i);
309
- }
310
- finally {
311
- if (e)
312
- throw e.error;
313
- }
314
- }
315
- return ar;
316
- }
317
- /** @deprecated */
318
- function __spread() {
319
- for (var ar = [], i = 0; i < arguments.length; i++)
320
- ar = ar.concat(__read(arguments[i]));
321
- return ar;
322
- }
323
- /** @deprecated */
324
- function __spreadArrays() {
325
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
326
- s += arguments[i].length;
327
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
328
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
329
- r[k] = a[j];
330
- return r;
331
- }
332
- function __spreadArray(to, from, pack) {
333
- if (pack || arguments.length === 2)
334
- for (var i = 0, l = from.length, ar; i < l; i++) {
335
- if (ar || !(i in from)) {
336
- if (!ar)
337
- ar = Array.prototype.slice.call(from, 0, i);
338
- ar[i] = from[i];
339
- }
340
- }
341
- return to.concat(ar || Array.prototype.slice.call(from));
342
- }
343
- function __await(v) {
344
- return this instanceof __await ? (this.v = v, this) : new __await(v);
345
- }
346
- function __asyncGenerator(thisArg, _arguments, generator) {
347
- if (!Symbol.asyncIterator)
348
- throw new TypeError("Symbol.asyncIterator is not defined.");
349
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
350
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
351
- function verb(n) { if (g[n])
352
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
353
- function resume(n, v) { try {
354
- step(g[n](v));
355
- }
356
- catch (e) {
357
- settle(q[0][3], e);
358
- } }
359
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
360
- function fulfill(value) { resume("next", value); }
361
- function reject(value) { resume("throw", value); }
362
- function settle(f, v) { if (f(v), q.shift(), q.length)
363
- resume(q[0][0], q[0][1]); }
364
- }
365
- function __asyncDelegator(o) {
366
- var i, p;
367
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
368
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
369
- }
370
- function __asyncValues(o) {
371
- if (!Symbol.asyncIterator)
372
- throw new TypeError("Symbol.asyncIterator is not defined.");
373
- var m = o[Symbol.asyncIterator], i;
374
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
375
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
376
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
377
- }
378
- function __makeTemplateObject(cooked, raw) {
379
- if (Object.defineProperty) {
380
- Object.defineProperty(cooked, "raw", { value: raw });
381
- }
382
- else {
383
- cooked.raw = raw;
384
- }
385
- return cooked;
386
- }
387
- ;
388
- var __setModuleDefault = Object.create ? (function (o, v) {
389
- Object.defineProperty(o, "default", { enumerable: true, value: v });
390
- }) : function (o, v) {
391
- o["default"] = v;
392
- };
393
- function __importStar(mod) {
394
- if (mod && mod.__esModule)
395
- return mod;
396
- var result = {};
397
- if (mod != null)
398
- for (var k in mod)
399
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
400
- __createBinding(result, mod, k);
401
- __setModuleDefault(result, mod);
402
- return result;
403
- }
404
- function __importDefault(mod) {
405
- return (mod && mod.__esModule) ? mod : { default: mod };
406
- }
407
- function __classPrivateFieldGet(receiver, state, kind, f) {
408
- if (kind === "a" && !f)
409
- throw new TypeError("Private accessor was defined without a getter");
410
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
411
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
412
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
413
- }
414
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
415
- if (kind === "m")
416
- throw new TypeError("Private method is not writable");
417
- if (kind === "a" && !f)
418
- throw new TypeError("Private accessor was defined without a setter");
419
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
420
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
421
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
422
- }
423
-
424
- /**
425
- * Classe base con le opzioni di layout valide per tutti i layout animati
426
- */
427
- var AnimateLayoutOptionsImpl = /** @class */ (function (_super) {
428
- __extends(AnimateLayoutOptionsImpl, _super);
429
- /** @ignore */
430
- function AnimateLayoutOptionsImpl() {
431
- var _this = _super.call(this) || this;
432
- /**
433
- * Livello di zoom da impostare (si consiglia fit = **false** se viene impostato)
434
- */
435
- _this.zoom = null;
436
- /**
437
- * Livello di pan da impostare (si consiglia fit = **false** se viene impostato)
438
- */
439
- _this.pan = null;
440
- /**
441
- * Indica se animare il cambio di posizione dei nodi
442
- */
443
- _this.animate = false;
444
- /**
445
- * Con **animate** a true indica la durata dell'animazione
446
- */
447
- _this.animationDuration = 500;
448
- /**
449
- * Abilita o no l'easing dell'animazione, può essere una stringa come ad esempio "ease-in-out-cubic" o altre funzioni scritte allo stesso modo prese da https://easings.net/
450
- */
451
- _this.animationEasing = undefined;
452
- /**
453
- * Funzione che indica se un nodo dev'essere animato o no.
454
- * Tutti i nodi sono animati di default.
455
- * Tutti i nodi che non vengono animati verranno posizionati appena inizia l'animazione
456
- *
457
- * @param {any} node Nodo per cui decidere se abilitare l'animazione o no
458
- * @param {number} i Indice del nodo corrente
459
- *
460
- * @returns {boolean} **true** se il nodo dev'essere animato, **false** altrimenti
461
- */
462
- _this.animateFilter = function (node, i) { return true; };
463
- return _this;
464
- }
465
- return AnimateLayoutOptionsImpl;
466
- }(BaseLayoutOptionsImpl));
467
-
468
- /**
469
- * Classe base per gli algoritmi "Shaped"
470
- */
471
- var ShapedLayoutOptionsImpl = /** @class */ (function (_super) {
472
- __extends(ShapedLayoutOptionsImpl, _super);
473
- /** @ignore */
474
- function ShapedLayoutOptionsImpl() {
475
- var _this = _super.call(this) || this;
476
- /**
477
- * Indica se adattare al contenitore
478
- */
479
- _this.fit = true;
480
- /**
481
- * Padding rispetto al contenitore
482
- */
483
- _this.padding = 30;
484
- /**
485
- * Specifica le dimensioni esatte al cui interno effettuare il layouting, specificato come **{ x1, y1, x2, y2 }** o **{ x1, y1, w, h }**
486
- */
487
- _this.boundingBox = null;
488
- /**
489
- * Fa in modo che i nodi non si accavallino, ma se il contenitore non ha abbastanza spazio potrebbero andare in overflow
490
- */
491
- _this.avoidOverlap = true;
492
- /**
493
- * Include o esclude le dimensioni delle label dei nodi nel calcolo delle posizioni
494
- */
495
- _this.nodeDimensionsIncludeLabels = false;
496
- /**
497
- * Moltiplicatore delle dimensioni per espandere/restringere le dimensioni globali del diagramma
498
- */
499
- _this.spacingFactor = 1;
500
- /**
501
- * Funzione di ordinamento per ordinare i nodi
502
- */
503
- _this.sort = null;
504
- /**
505
- * Funzione per la trasformazione delle posizioni dei nodi
506
- *
507
- * @param {any} node Nodo
508
- * @param {any} position Posizione iniziale
509
- *
510
- * @returns {any} Posizione finale
511
- */
512
- _this.transform = function (node, position) { return position; };
513
- return _this;
514
- }
515
- return ShapedLayoutOptionsImpl;
516
- }(AnimateLayoutOptionsImpl));
517
-
518
- /**
519
- * Default per l'implementazione dell'algoritmo Breadth First
520
- */
521
- var BreadthFirstLayoutOptionsImpl = /** @class */ (function (_super) {
522
- __extends(BreadthFirstLayoutOptionsImpl, _super);
523
- /** @ignore */
524
- function BreadthFirstLayoutOptionsImpl() {
525
- var _this = _super.call(this) || this;
526
- /**
527
- * Nome dell'algoritmo di layouting
528
- */
529
- _this.name = 'breadthfirst';
530
- /**
531
- * Indica se l'albero è diretto in basso. Se false i collegamenti fra i nodi possono andare in qualsiasi direzione
532
- */
533
- _this.directed = false;
534
- /**
535
- * Se **true** i livelli vengono ordinati in cerchi concentrici, se **false** vengono oridnati dall'alto al basso
536
- */
537
- _this.circle = false;
538
- /**
539
- * Indica che i nodi verranno shiftati in base al proprio livello in modo da evitare collegamenti inversi (solo per i DAG)
540
- */
541
- _this.maximal = false;
542
- /**
543
- * Indica se creare una griglia in cui ordinare i nodi del DAG (Solo quando la proprietà **circle** è a **false**)
544
- */
545
- _this.grid = false;
546
- /**
547
- * Indica se escludere le label dei nodi quando vengono calcolati i limiti del layout
548
- */
549
- _this.nodeDimensionsIncludeLabels = false;
550
- return _this;
551
- }
552
- return BreadthFirstLayoutOptionsImpl;
553
- }(ShapedLayoutOptionsImpl));
554
-
555
- /**
556
- * Default per l'implementazione dell'algoritmo Circle
557
- */
558
- var CircleLayoutOptionsImpl = /** @class */ (function (_super) {
559
- __extends(CircleLayoutOptionsImpl, _super);
560
- /** @ignore */
561
- function CircleLayoutOptionsImpl() {
562
- var _this = _super.call(this) || this;
563
- /**
564
- * Nome dell'algoritmo di layouting
565
- */
566
- _this.name = 'circle';
567
- /**
568
- * Angolo da cui i nodi partono, in radianti (Default: **3 / 2 * Math.PI**)
569
- */
570
- _this.startAngle = 3 / 2 * Math.PI;
571
- /**
572
- * Numero di radianti fra il primo e l'ultimo nodo. Di default viene utilizzata l'intera circonferenza
573
- */
574
- _this.sweep = null;
575
- /**
576
- * Indica se andare in senso orario (**true**) o antiorario (**false**)
577
- */
578
- _this.clockwise = true; // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false)
579
- return _this;
580
- }
581
- return CircleLayoutOptionsImpl;
582
- }(ShapedLayoutOptionsImpl));
583
-
584
- /**
585
- * Default per l'implementazione dell'algoritmo Concentric
586
- */
587
- var ConcentricLayoutOptionsImpl = /** @class */ (function () {
588
- function ConcentricLayoutOptionsImpl() {
589
- /**
590
- * Nome dell'algoritmo di layouting
591
- */
592
- this.name = 'concentric';
593
- /**
594
- * Angolo da cui i nodi partono, in radianti (Default: **3 / 2 * Math.PI**)
595
- */
596
- this.startAngle = 3 / 2 * Math.PI;
597
- /**
598
- * Include o esclude le dimensioni delle label dei nodi nel calcolo delle posizioni
599
- */
600
- this.nodeDimensionsIncludeLabels = true;
601
- /**
602
- * Indica se i livelli devono essere o non essere equidistanti, potrebbe causare overflow dal contenitore
603
- */
604
- this.equidistant = false;
605
- /**
606
- * Distanza minima dall'esterno dei nodi, utilizzato per aggiustare il raggio
607
- */
608
- this.minNodeSpacingnumber = 10;
609
- /**
610
- * Specifica le dimensioni esatte al cui interno effettuare il layouting, specificato come **{ x1, y1, x2, y2 }** o **{ x1, y1, w, h }**
611
- */
612
- this.boundingBox = null;
613
- /**
614
- * Altezza dell'area di layout (sovrascrive quella del contenitore)
615
- */
616
- this.height = null;
617
- /**
618
- * Larghezza dell'area di layout (sovrascrive quella del contenitore)
619
- */
620
- this.width = null;
621
- /**
622
- * Moltiplicatore delle dimensioni per espandere/restringere le dimensioni globali del diagramma
623
- */
624
- this.spacingFactor = 1;
625
- }
626
- /**
627
- * Funzione di cui si può fare override per assegnare un valore ad ogni nodo. I nodi con valore più alto saranno piazzati verso il centro
628
- *
629
- * @param {any} node Nodo
630
- *
631
- * @returns {number} Valore su cui ordinare i nodi verso il centro
632
- */
633
- ConcentricLayoutOptionsImpl.prototype.concentric = function (node) {
634
- return node.degree();
635
- };
636
- /**
637
- * Funzione di cui si può fare override per calcolare la variazione dei valori concentrici per ogni livello
638
- *
639
- * @param {any} nodes Gruppo di nodi del livello
640
- *
641
- * @returns {number} Variazione dei valori concentrici
642
- */
643
- ConcentricLayoutOptionsImpl.prototype.levelWidth = function (nodes) {
644
- return nodes.maxDegree() / 4;
645
- };
646
- return ConcentricLayoutOptionsImpl;
647
- }());
648
-
649
- /**
650
- * Default per l'implementazione dell'algoritmo Cose
651
- */
652
- var CoseLayoutOptionsImpl = /** @class */ (function (_super) {
653
- __extends(CoseLayoutOptionsImpl, _super);
654
- /** @ignore */
655
- function CoseLayoutOptionsImpl() {
656
- var _this = _super.call(this) || this;
657
- /**
658
- * Nome dell'algoritmo di layouting
659
- */
660
- _this.name = 'cose';
661
- /**
662
- * Se **animate** è **true**, l'animazione parte solo dopo questo numero di millisecondi (Evita flickering su animazioni veloci)
663
- */
664
- _this.animationThreshold = 250;
665
- /**
666
- * Numero di iterazioni fra aggiornamenti consecutivi della posizione a schermo
667
- */
668
- _this.refresh = 20;
669
- /**
670
- * Se **true** la posizione iniziale dei nodi è casuale, se **false** utilizza la posizione originale
671
- */
672
- _this.randomize = false;
673
- /**
674
- * Spazio extra fra i componenti di un grafo non-compound
675
- */
676
- _this.componentSpacing = 40;
677
- /**
678
- * Moltiplicatore della repulsione fra nodi in caso di overlap
679
- */
680
- _this.nodeOverlap = 4;
681
- /**
682
- * Moltiplicatore di nesting per il calcolo della lunghezza ideale dei collegamenti nested
683
- */
684
- _this.nestingFactor = 1.2;
685
- /**
686
- * Costante di gravità
687
- */
688
- _this.gravity = 1;
689
- /**
690
- * Numero massimo di iterazioni da eseguire
691
- */
692
- _this.numIter = 1000;
693
- /**
694
- * Temperatura iniziale (massima distanza fra i nodi)
695
- */
696
- _this.initialTemp = 1000;
697
- /**
698
- * Fattore di raffreddamento. Ad ogni iterazione verrà sottratto ad **initialTemp**
699
- */
700
- _this.coolingFactor = 0.99;
701
- /**
702
- * Soglia minima di temperatura. Una volta raggiunta il layout si considera terminato
703
- */
704
- _this.minTemp = 1.0;
705
- /**
706
- * Moltiplicatore della repulsione fra nodi in caso di assenza di overlap. Funzione overrideabile per ogni node
707
- *
708
- * @param {any} node Nodo
709
- *
710
- * @returns {number} Moltiplicazione di repulsione
711
- */
712
- _this.nodeRepulsion = function (node) { return 2048; };
713
- /**
714
- * Lunghezza ideale dei collegamenti non nested. Funzione overrideabile per ogni collegamento
715
- *
716
- * @param {any} edge Collegamento
717
- *
718
- * @returns {number} Lunghezza ideale
719
- */
720
- _this.idealEdgeLength = function (edge) { return 32; };
721
- /**
722
- * Divisore per calcolare le forze applicate ad un collegamento. Funzione overrideabile per ogni collegamento
723
- *
724
- * @param {any} edge Collegamento
725
- *
726
- * @returns {number} Indice di elasticità
727
- */
728
- _this.edgeElasticity = function (edge) { return 32; };
729
- return _this;
730
- }
731
- return CoseLayoutOptionsImpl;
732
- }(ShapedLayoutOptionsImpl));
733
-
734
- /**
735
- * Default per l'implementazione dell'algoritmo Dagre
736
- */
737
- var DagreLayoutOptionsImpl = /** @class */ (function (_super) {
738
- __extends(DagreLayoutOptionsImpl, _super);
739
- /** @ignore */
740
- function DagreLayoutOptionsImpl() {
741
- var _this = _super.call(this) || this;
742
- /**
743
- * Nome dell'algoritmo di layouting
744
- */
745
- _this.name = 'dagre';
746
- /**
747
- * Distanza fra nodi adiacenti dello stesso rango
748
- */
749
- _this.nodeSep = null;
750
- /**
751
- * Distanza fra collegamenti adiacenti nello stesso rango
752
- */
753
- _this.edgeSep = null;
754
- /**
755
- * Distanza fra ogni rango
756
- */
757
- _this.rankSep = null;
758
- // TB for top to bottom flow, 'LR' for left to right
759
- /**
760
- * Direzione di disegno: LR = Sinistra a Destra, TB = Sopra a Sotto
761
- */
762
- _this.rankDir = 'TB';
763
- /**
764
- * Algoritmo che si occupa di assegnare un rango ad ogni nodo
765
- */
766
- _this.ranker = null;
767
- /**
768
- * Numero di ranghi fra la sorgente e la destinazione di un collegamento
769
- *
770
- * @param {any} edge Collegamento di cui calcolare la differenza di rango
771
- *
772
- * @returns {number} Differenza di rango
773
- */
774
- _this.minLen = function (edge) { return 1; };
775
- /**
776
- * Peso del collegamento, più è alto più generalmente risulterà corto
777
- *
778
- * @param {any} edge Collegamento di cui calcolare il peso
779
- *
780
- * @returns {number} Peso
781
- */
782
- _this.edgeWeight = function (edge) { return 1; };
783
- return _this;
784
- }
785
- return DagreLayoutOptionsImpl;
786
- }(ShapedLayoutOptionsImpl));
787
-
788
- /**
789
- * Default per l'implementazione dell'algoritmo Grid
790
- */
791
- var GridLayoutOptionsImpl = /** @class */ (function (_super) {
792
- __extends(GridLayoutOptionsImpl, _super);
793
- /** @ignore */
794
- function GridLayoutOptionsImpl() {
795
- var _this = _super.call(this) || this;
796
- /**
797
- * Nome dell'algoritmo di layouting
798
- */
799
- _this.name = 'grid';
800
- /**
801
- * Spazio extra attorno ai nodi quando **avoidOverlap** è **true**
802
- */
803
- _this.avoidOverlapPadding = 10;
804
- /**
805
- * Se **true** cerca di utilizzare il minor spazio possibile, se **false** usa tutto lo spazio che ha a disposizione
806
- */
807
- _this.condense = false;
808
- /**
809
- * Forzatura del numero di righe della griglia
810
- */
811
- _this.rows = null;
812
- /**
813
- * Forzatura del numero di colonne della griglia
814
- */
815
- _this.cols = null;
816
- /**
817
- * Dato un nodo restituisce un indice di riga e di colonna della griglia in cui metterlo
818
- *
819
- * @param {NodeSingular} node Nodo
820
- * @returns {{ row: number, col: number }} Oggetto che identifica una posizione della griglia
821
- */
822
- _this.position = null;
823
- return _this;
824
- }
825
- return GridLayoutOptionsImpl;
826
- }(ShapedLayoutOptionsImpl));
827
-
828
- /**
829
- * Pseudo implementazione di un algoritmo vuoto che non fa nulla
830
- */
831
- var NullLayoutOptionsImpl = /** @class */ (function (_super) {
832
- __extends(NullLayoutOptionsImpl, _super);
833
- /** @ignore */
834
- function NullLayoutOptionsImpl() {
835
- var _this = _super.call(this) || this;
836
- /**
837
- * Nome dell'algoritmo di layouting
838
- */
839
- _this.name = 'null';
840
- return _this;
841
- }
842
- return NullLayoutOptionsImpl;
843
- }(BaseLayoutOptionsImpl));
844
-
845
- /**
846
- * Default per l'implementazione dell'algoritmo Preset (Posiziona i nodi in base alla loro proprietà **position**)
847
- */
848
- var PresetLayoutOptionsImpl = /** @class */ (function (_super) {
849
- __extends(PresetLayoutOptionsImpl, _super);
850
- /** @ignore */
851
- function PresetLayoutOptionsImpl() {
852
- var _this = _super.call(this) || this;
853
- /**
854
- * Nome dell'algoritmo di layouting
855
- */
856
- _this.name = 'preset';
857
- /**
858
- * Funzione per la trasformazione delle posizioni dei nodi
859
- *
860
- * @param {any} node Nodo
861
- * @param {any} position Posizione iniziale
862
- *
863
- * @returns {any} Posizione finale
864
- */
865
- _this.transform = function (node, position) { return position; };
866
- return _this;
867
- }
868
- return PresetLayoutOptionsImpl;
869
- }(AnimateLayoutOptionsImpl));
870
-
871
- /**
872
- * Default per l'implementazione dell'algoritmo Random
873
- */
874
- var RandomLayoutOptionsImpl = /** @class */ (function (_super) {
875
- __extends(RandomLayoutOptionsImpl, _super);
876
- /** @ignore */
877
- function RandomLayoutOptionsImpl() {
878
- var _this = _super.call(this) || this;
879
- /**
880
- * Nome dell'algoritmo di layouting
881
- */
882
- _this.name = 'random';
883
- /**
884
- * Indica se adattare al contenitore
885
- */
886
- _this.fit = true;
887
- /**
888
- * Padding rispetto al contenitore
889
- */
890
- _this.padding = 20;
891
- /**
892
- * Specifica le dimensioni esatte al cui interno effettuare il layouting, specificato come **{ x1, y1, x2, y2 }** o **{ x1, y1, w, h }**
893
- */
894
- _this.boundingBox = null;
895
- /**
896
- * Funzione per la trasformazione delle posizioni dei nodi
897
- *
898
- * @param {any} node Nodo
899
- * @param {any} position Posizione iniziale
900
- *
901
- * @returns {any} Posizione finale
902
- */
903
- _this.transform = function (node, position) { return position; };
904
- return _this;
905
- }
906
- return RandomLayoutOptionsImpl;
907
- }(AnimateLayoutOptionsImpl));
908
-
909
- /**
910
- * Classe di configurazione per il Modulo
911
- */
912
- var EsDiagramModuleConfig = /** @class */ (function () {
913
- function EsDiagramModuleConfig() {
914
- }
915
- return EsDiagramModuleConfig;
916
- }());
917
-
918
- /**
919
- * Token che indica la lingua da utilizzare, sono supportate "it-IT" ed "en-US"
920
- */
921
- var DIA_LOCALE = new i0.InjectionToken('DIA_LOCALE');
922
- /**
923
- * Token che indica se attivare la modalità di debug (messaggi a console)
924
- */
925
- var DIA_DEBUG_MODE = new i0.InjectionToken('DIA_DEBUG_MODE');
926
-
927
- /**
928
- * Oggetto statico di localizzazione per i messaggi
929
- */
930
- var Loc = {
931
- "Module": { "en-US": "Module", "it-IT": "Il Modulo" },
932
- "Received an undefined module. Make sure you are correctly loading it": { "en-US": "Received an undefined module. Make sure you are correctly loading it", "it-IT": "Ricevuto modulo non definito. Assicurati di caricarlo correttamente" },
933
- "Module not available. Loading it now": { "en-US": "Module not available. Loading it now", "it-IT": "Modulo non disponibile. Lo carico ora" },
934
- "Module already loaded": { "en-US": "Module already loaded", "it-IT": "Modulo già caricato" },
935
- "Diagram container size has changed, redrawing": { "en-US": "Diagram container size has changed, redrawing", "it-IT": "La dimensione del contenitore del diagramma è cambiata, ridisegno" },
936
- "Module cannot be loaded": { "en-US": "Module cannot be loaded", "it-IT": "Impossibile caricare il modulo" },
937
- "Redraw based on dynamic Input change is supported only for 'Elements' and 'Layout' inputs, please destroy the component and recreate it with the new settings": { "en-US": "Redraw based on dynamic Input change is supported only for 'Elements' and 'Layout' inputs, please destroy the component and recreate it with the new settings", "it-IT": "Il cambio e aggiornamento dinamico degli Input è supportato solo per gli Input 'Elements' e 'Layout', distruggi il componente e ricrealo con le nuove impostazioni", },
938
- "is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options": { "en-US": "is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options", "it-IT": "viene caricato e gestito nativamente dalla libreria. Non c'è bisogno di reimportarlo, né di configurarlo (usare le opzioni specifiche)" },
939
- "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}": { "en-US": "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}", "it-IT": "Se non è specificata una sorgente e una destinazione per il collegamento è opportuno scriverne l'id nel formato {sorgente}-{destinazione}" },
940
- "Elements have been changed after diagram initialization": { "en-US": "Elements have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Elementi dopo l'inizializzazione del Diagramma" },
941
- "Layout have been changed after diagram initialization": { "en-US": "Layout have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Layout dopo l'inizializzazione del Diagramma" },
942
- "Cannot update NodeHTMLTemplates as they don't seem to be used": { "en-US": "Cannot update NodeHTMLTemplates as they don't seem to be used", "it-IT": "Impossibile aggiornare i NodeHTMLTemplates dato che non sembra siano utilizzati" }
943
- };
944
-
945
- /** @ignore */ var cytoscape$1 = cy___namespace;
946
- /**
947
- * Loader dei moduli di Cytoscape. Utilizza una cache per tenerseli in memoria a livello di applicazione
948
- * in modo da non dover ricaricare nulla dopo avere usato un modulo almeno una volta
949
- */
950
- var EsDiagramService = /** @class */ (function () {
951
- /**
952
- * Costruttore
953
- *
954
- * @ignore
955
- */
956
- function EsDiagramService(DIA_LOCALE, DIA_DEBUG_MODE) {
957
- this.DIA_LOCALE = DIA_LOCALE;
958
- this.DIA_DEBUG_MODE = DIA_DEBUG_MODE;
959
- /**
960
- * Cache dei moduli caricati
961
- */
962
- this.modulesCache = {};
963
- }
964
- /**
965
- * Permette di importare, se serve un dato tema o localizzazione
966
- *
967
- * @param {'cytoscape-expand-collapse' | 'cytoscape-cxtmenu' | 'cytoscape-html-node' | 'cytoscape-dagre'} moduleId Nome del modulo di Cytoscape da importare (dev'essere il nome della cartella in node_modules)
968
- *
969
- * @returns {Promise<void | cytoscape.Ext>} Funzione di estensione per Cytoscape presa dal modulo richiesto
970
- */
971
- EsDiagramService.prototype.importIfNeeded = function (moduleId) {
972
- return __awaiter(this, void 0, void 0, function () {
973
- var _a;
974
- var _this = this;
975
- return __generator(this, function (_b) {
976
- switch (_b.label) {
977
- case 0:
978
- if (!!this.modulesCache[moduleId]) return [3 /*break*/, 7];
979
- this.log("I", this.loc("Module not available. Loading it now") + ": " + moduleId, false);
980
- _a = moduleId;
981
- switch (_a) {
982
- case "cytoscape-cxtmenu": return [3 /*break*/, 1];
983
- case "cytoscape-expand-collapse": return [3 /*break*/, 2];
984
- case "cytoscape-html-node": return [3 /*break*/, 3];
985
- case "cytoscape-dagre": return [3 /*break*/, 4];
986
- }
987
- return [3 /*break*/, 6];
988
- case 1: return [2 /*return*/, import('cytoscape-cxtmenu').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
989
- case 2: return [2 /*return*/, import('cytoscape-expand-collapse').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
990
- case 3: return [2 /*return*/, import('@esfaenza/cytoscape-html-node').then(function (module) { return _this.modulesCache[moduleId] = module.register; }).catch(function (err) { return _this.handleError(moduleId, err); })];
991
- case 4: return [4 /*yield*/, import('dagre').catch(function (err) { return _this.handleError("dagre", err); })];
992
- case 5:
993
- _b.sent();
994
- return [2 /*return*/, import('cytoscape-dagre').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
995
- case 6: return [3 /*break*/, 8];
996
- case 7:
997
- // I moduli non devono mai essere ricaricati nel globale, quindi invece che restituire la copia della cache restituisco vuoto
998
- this.log("I", this.loc("Module already loaded") + ": " + moduleId, false);
999
- return [2 /*return*/, new Promise(function (resolve) { resolve(null); })];
1000
- case 8: return [2 /*return*/];
1001
- }
1002
- });
1003
- });
1004
- };
1005
- /**
1006
- * Gestione degli errori di caricamento dei moduli qualora qualcuno utilizzasse un modulo non installato
1007
- *
1008
- * @param {string} moduleId Nome del modulo che si è cercato di caricare
1009
- * @param {any} err Errore restituito dalla promise di caricamento
1010
- */
1011
- EsDiagramService.prototype.handleError = function (moduleId, err) {
1012
- this.log("E", this.loc("Module cannot be loaded") + ": " + moduleId + " - " + err, false);
1013
- };
1014
- /**
1015
- * Scrittore di log a console. Attivo solo quando la libreria è in modalità di Debug
1016
- *
1017
- * @param {'E' | 'I' | 'W'} severity Tipo di messaggio (Errore, Info, Warning)
1018
- * @param {string} text Testo da tradurre
1019
- * @param {boolean} requiresTranslation Indica se **text** è una frase già tradotta o se è da tradurre
1020
- */
1021
- EsDiagramService.prototype.log = function (severity, text, requiresTranslation) {
1022
- if (requiresTranslation === void 0) { requiresTranslation = true; }
1023
- if (!this.DIA_DEBUG_MODE)
1024
- return;
1025
- var message = "@esfaenza/diagrams: " + (requiresTranslation ? this.loc(text) : text);
1026
- switch (severity) {
1027
- case 'E':
1028
- console.error(message);
1029
- break;
1030
- case 'I':
1031
- console.info(message);
1032
- break;
1033
- case 'W':
1034
- console.warn(message);
1035
- break;
1036
- }
1037
- };
1038
- /**
1039
- * Metodo di localizzazione dei messaggi
1040
- *
1041
- * @param {string} text Messaggio da tradurre
1042
- *
1043
- * @returns {string} Messaggio tradotto
1044
- */
1045
- EsDiagramService.prototype.loc = function (text) {
1046
- return Loc[text][this.DIA_LOCALE];
1047
- };
1048
- return EsDiagramService;
1049
- }());
1050
- EsDiagramService.decorators = [
1051
- { type: i0.Injectable }
1052
- ];
1053
- EsDiagramService.ctorParameters = function () { return [
1054
- { type: String, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [DIA_LOCALE,] }] },
1055
- { type: String, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [DIA_DEBUG_MODE,] }] }
1056
- ]; };
1057
-
1058
- /**
1059
- * Classe che si occupa del dispatch delle operazioni di rendering degli oggetti utilizzando una coda
1060
- */
1061
- var EsDiagramDispatcher = /** @class */ (function () {
1062
- /**
1063
- * @ignore
1064
- */
1065
- function EsDiagramDispatcher(logs) {
1066
- this.logs = logs;
1067
- /**
1068
- * Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando oggetti
1069
- */
1070
- this.Initializations = [];
1071
- /**
1072
- * Lista degli oggetti inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
1073
- */
1074
- this.Initialized = [];
1075
- }
1076
- /**
1077
- * Registra un oggetto da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti gli oggetti
1078
- * precedentemente registati non hanno finito la fase di inizializzazione
1079
- *
1080
- * @param {string} name Identificativo dell'oggetto da registrare
1081
- * @param {Function} creationFunction Funzione che fisicamente dovrà occuparsi della creazione dell'oggetto
1082
- */
1083
- EsDiagramDispatcher.prototype.register = function (name, creationFunction) {
1084
- if (this.Initialized.indexOf(name) != -1)
1085
- throw "Attempting to register a duplicate object '" + name + "'. Make sure the 'name' properties of your diagram are univoque";
1086
- this.log("DISPATCHER: Registering diagram creation function execution for " + name);
1087
- this.Initializations.push({ name: name, function: creationFunction });
1088
- if (this.Initializations.length == 1) {
1089
- this.log("DISPATCHER: Initial drain started");
1090
- this.drainInitQueues();
1091
- }
1092
- };
1093
- /**
1094
- * Deregistra un oggetto presente. Chiamata generalmente al dispose dell'oggetto in questione quando non dev'essere più mostrato nella pagina corrente
1095
- *
1096
- * @param {string} name Identificativo dell'oggetto da deregistrare
1097
- */
1098
- EsDiagramDispatcher.prototype.deregister = function (name) {
1099
- var index = this.Initialized.indexOf(name);
1100
- if (index == -1) {
1101
- //Questo succede quando si cerca di distruggere l'oggetto mentre sta venendo graficato
1102
- this.log("DISPATCHER: Registration missing for object " + name + " it was probably destroyed during load");
1103
- return;
1104
- }
1105
- this.log("DISPATCHER: Object deregistered " + name);
1106
- this.Initialized.splice(index, 1);
1107
- };
1108
- /**
1109
- * Metodo che esegue in maniera sequenziale le funzioni di inizializzazione degli oggetti finché presenti
1110
- * in modo che nessun oggetto possa essere inizializzato contemporaneamente ad un altro
1111
- */
1112
- EsDiagramDispatcher.prototype.drainInitQueues = function () {
1113
- var _this = this;
1114
- var toExecute = this.Initializations[0];
1115
- this.log("DISPATCHER: Executing initialization function for object " + toExecute.name);
1116
- toExecute.function().then(function () {
1117
- _this.log("DISPATCHER: initialization for object " + toExecute.name + " is done");
1118
- _this.Initialized.push(toExecute.name);
1119
- _this.Initializations.splice(0, 1);
1120
- if (_this.Initializations.length >= 1) {
1121
- _this.log("DISPATCHER: Found queued initializations. Continuing");
1122
- _this.drainInitQueues();
1123
- }
1124
- else
1125
- _this.log("DISPATCHER: queue is over, nothing more to do");
1126
- });
1127
- };
1128
- /**
1129
- * @ignore
1130
- */
1131
- EsDiagramDispatcher.prototype.log = function (text) {
1132
- if (this.logs)
1133
- console.log("@esfaenza/es-diagrams: " + text);
1134
- };
1135
- return EsDiagramDispatcher;
1136
- }());
1137
- EsDiagramDispatcher.decorators = [
1138
- { type: i0.Injectable }
1139
- ];
1140
- EsDiagramDispatcher.ctorParameters = function () { return [
1141
- { type: Boolean, decorators: [{ type: i0.Inject, args: [DIA_DEBUG_MODE,] }] }
1142
- ]; };
1143
-
1144
- // Grabbata felicemente da amcharts, rimuovendo helper interni, cose strane e instupidendola un po':
1145
- // https://github.com/amcharts/amcharts4/blob/7fbb61e90363a2373e6130800dee06b8a62f3aab/src/.internal/core/utils/ResizeSensor.ts
1146
- /**
1147
- * Classe di utilità che tiene d'occhio i cambiamenti di dimensione di un elemento. Un **ResizeSensor** può controllare al massimo un elemento
1148
- */
1149
- var ResizeSensor = /** @class */ (function () {
1150
- /**
1151
- * Costruttore
1152
- *
1153
- * @param {HTMLElement} element Elemento HTML da controllare
1154
- * @param {Function} callback Callback da chiamare quando le dimensioni di **element** cambiano
1155
- */
1156
- function ResizeSensor(element, callback) {
1157
- /**
1158
- * Riferimento all'observer nativo
1159
- */
1160
- this.observer = null;
1161
- /**
1162
- * Indica se questo oggetto è stato distrutto o no
1163
- */
1164
- this.Disposed = false;
1165
- /**
1166
- * Elemento da controllare e callback da chiamare quando le dimensioni dell'elemento cambiano
1167
- */
1168
- this.target = null;
1169
- this.makeSensor();
1170
- this.addTarget(element, callback);
1171
- }
1172
- /**
1173
- * Distruttore
1174
- */
1175
- ResizeSensor.prototype.dispose = function () {
1176
- if (!this.Disposed) {
1177
- this.Disposed = true;
1178
- this.removeTarget();
1179
- }
1180
- };
1181
- /**
1182
- * Creazione del sensore che sarà collegato all'elemento da osservare dal metodo **addTarget**
1183
- */
1184
- ResizeSensor.prototype.makeSensor = function () {
1185
- var _this = this;
1186
- if (typeof ResizeObserver == "undefined")
1187
- throw "Resize Observer non è definito. Si prega di utilizzare un browser vero";
1188
- this.observer = new ResizeObserver(function (entries) {
1189
- for (var i = 0; i < entries.length; ++i) {
1190
- if (_this.target && _this.target.targetEl === entries[i].target)
1191
- _this.target.callback();
1192
- }
1193
- });
1194
- };
1195
- /**
1196
- * Dice al sensore di osservare l'elemento **targetEl**, richiamando **callback** qualora le dimensioni cambino
1197
- *
1198
- * @param {HTMLElement} targetEl Elemento HTML da controllare
1199
- * @param {Function} callback Callback da chiamare quando le dimensioni di **element** cambiano
1200
- */
1201
- ResizeSensor.prototype.addTarget = function (targetEl, callback) {
1202
- this.observer.observe(targetEl, { box: "content-box" });
1203
- this.target = { targetEl: targetEl, callback: callback };
1204
- };
1205
- /**
1206
- * Rimuove l'elemento HTML attuale dall'osservazione del **ResizeObserver**
1207
- */
1208
- ResizeSensor.prototype.removeTarget = function () {
1209
- if (!this.target)
1210
- return;
1211
- this.observer.unobserve(this.target.targetEl);
1212
- this.target = null;
1213
- };
1214
- return ResizeSensor;
1215
- }());
1216
-
1217
- /**
1218
- * Classe che fornisce metodi reattivi di estensione. Per ora implementato solo uno pseudo-throttle
1219
- */
1220
- var ReactiveExtensions = /** @class */ (function () {
1221
- function ReactiveExtensions() {
1222
- /**
1223
- * Cache di tutti i timer in esecuzione
1224
- */
1225
- this.executionTimers = {};
1226
- }
1227
- /**
1228
- * Esecuzione deleyata di una funzione. Se viene richiamata nuovamente prima di venire eseguita dopo il delay, il delay viene resettato
1229
- *
1230
- * @param {string} id Id per aiutare il servizio a distinguere funzioni con nome uguale chiamate da componenti diversi
1231
- * @param {Function} func Funzione da chiamare al termine del throttle
1232
- * @param {number} throttleTime Tempo di throttling in millisecondi
1233
- */
1234
- ReactiveExtensions.prototype.throttle = function (id, func, throttleTime) {
1235
- var _this = this;
1236
- if (throttleTime === void 0) { throttleTime = 0; }
1237
- var key = func.name + "_" + id;
1238
- //Se ho la funzione che vuole eseguire ripulisco quel timeout
1239
- if (this.executionTimers[key])
1240
- clearTimeout(this.executionTimers[key]);
1241
- //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
1242
- var executionTimer = setTimeout(function () { func(); _this.executionTimers[key] = null; }, throttleTime);
1243
- this.executionTimers[key] = executionTimer;
1244
- };
1245
- return ReactiveExtensions;
1246
- }());
1247
- ReactiveExtensions.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ReactiveExtensions_Factory() { return new ReactiveExtensions(); }, token: ReactiveExtensions, providedIn: "root" });
1248
- ReactiveExtensions.decorators = [
1249
- { type: i0.Injectable, args: [{ providedIn: "root" },] }
1250
- ];
1251
-
1252
- /** @ignore */ var cytoscape = cy___namespace;
1253
- /**
1254
- * Componente che si occupa di graficare un diagramma e di gestirne il ciclo di vita
1255
- */
1256
- var EsDiagramComponent = /** @class */ (function () {
1257
- /**
1258
- * Costruttore
1259
- *
1260
- * @ignore
1261
- */
1262
- function EsDiagramComponent(service, dispatcher, exts) {
1263
- this.service = service;
1264
- this.dispatcher = dispatcher;
1265
- this.exts = exts;
1266
- /**
1267
- * Nome del diagramma, fondamentale assegnarlo per permettere alla libreria di schedularne la creazione
1268
- */
1269
- this.name = "";
1270
- /**
1271
- * Indica se utilizzare il menù contestuale a ruota attorno ad ogni nodo
1272
- */
1273
- this.UseContextMenu = false;
1274
- /**
1275
- * Dice al componente se il diagramma deve utilizzare il sistema di estensione per l'expand e collapse dei gruppi
1276
- */
1277
- this.UseExpandCollapse = false;
1278
- /**
1279
- * Blocco completo delle opzioni, alternativo all'assegnazione di **Elements**, **NodeStyles**, **EdgeStyles**, e **Layout**.
1280
- *
1281
- * Qualora entrambe venissero specificate verrà effettuata un'unione fra queste opzioni e quelle specificate, dando priorità alle specificate
1282
- */
1283
- this.NativeOptions = {};
1284
- /**
1285
- * Aggiorna automaticamente le dimensioni del diagramma quando cambiano le dimensioni della finestra
1286
- */
1287
- this.AutoupdateSize = true;
1288
- /**
1289
- * Indica di mantenere la posizione dei nodi qualora venissero cambiati dall'Input **Elements**.
1290
- *
1291
- * Se l'ID di un nodo è uguale all'ID di un nodo presente in precedenza, il nuovo nodo ne erediterà la posizione
1292
- */
1293
- this.PreserveElementsPosition = true;
1294
- /**
1295
- * Qualora venisse modificato l'Input **Elements**, piuttosto che mettere semplicemente il nuovo Elemento in base al Layout precedente, applica anche un'animazione
1296
- *
1297
- * Funziona solamente se il **Layout** corrente del diagramma supporta le animazioni
1298
- */
1299
- this.AnimateLayoutChanges = true;
1300
- /**
1301
- * Attiva una modalità di selezione "smart"... o perlomeno "smarter" del default di Cytoscape.
1302
- *
1303
- * - Il click di un elemento non selezionato lo seleziona
1304
- * - Il click di un elemento selezionato lo deseleziona
1305
- * - Lo stato di selezione viene persistito sull'oggetto originale invece di rimanere in un internal
1306
- * - All'assegnazione di oggetti selezionati, questi vengono marcati correttamente con l'overlay di selezione
1307
- *
1308
- * N.B: la chiamata all'evento **onNodeClick** avviene **DOPO** la gestione della selezione
1309
- */
1310
- this.SmartSelection = false;
1311
- /**
1312
- * CSS per la graficazione della selezione dei nodi. Quando un nodo verrà selezionato avrà sopra di se un overlay che 'sborda' di **overlay-padding** pixel,
1313
- * di colore **overlay-color** e con un opacità **overlay-opacity**
1314
- *
1315
- * Assegnando "{}" a questo input, la Smart selection viene gestita ma la gestione grafica è affidata all'utente,
1316
- * ad esempio usando dei **NodeHTMLTemplates** che definiscano selettori su nodi ":selected"
1317
- *
1318
- * @default {'overlay-color':'blue','overlay-opacity':0.5,'overlay-padding':7}
1319
- */
1320
- this.SmartSelectionStyles = null;
1321
- /**
1322
- * Periodo di throttle da quando viene effettuato un resize a quando ricalcolare le dimensioni del diagramma.
1323
- *
1324
- * Può essere tenuto a 0 (redraw istantaneo) finché non ci sono problemi di prestazioni con eventualmente tanti resize a poca distanza l'uno dall'altro.
1325
- */
1326
- this.ResizeThrottleTime = 0;
1327
- /**
1328
- * Fornisce il global della libreria (namespace **cytoscape**) e si aspetta che dopo operazioni di importazione
1329
- * lasciate all'utente vengano aggiunti tutti i moduli desiderati.
1330
- *
1331
- * È **fondamentale** che il primo parametro (il nome del modulo) sia uguale a ciò di cui viene fatto il require in modo che la libreria
1332
- * possa controllare che il modulo importato non sia già stato importato in precedenza
1333
- *
1334
- * ## Esempio:
1335
- *
1336
- * ```typescript
1337
- * (global) => {
1338
- * return import("cytoscape-extension-library").then(module => global.use("cytoscape-extension-library", module.default));
1339
- *
1340
- * ...
1341
- * }
1342
- * ```
1343
- */
1344
- this.ExtensionModulesImporter = null;
1345
- /**
1346
- * Fornisce l'istanza attuale di Cytoscape da cui è possibile prendere le librerie di estensione caricate in **ExtensionModulesImporter**
1347
- * e configurarle in base ai comportamenti specifici
1348
- *
1349
- * ## Esempio:
1350
- *
1351
- * ```typescript
1352
- * (cytoscapeCore) => {
1353
- * // Fare questo lavoro per ogni estensione caricata
1354
- * let extensionConfiguration = { ... };
1355
- * let extensionInstance = cytoscapeCore.extensionLibrary(extensionConfiguration);
1356
- * extensionInstance.doSomethingSpecificToThisExtension();
1357
- *
1358
- * ...
1359
- * }
1360
- * ```
1361
- */
1362
- this.ExtensionModulesApplyer = null;
1363
- /**
1364
- * Evento lanciato al click di un nodo, contiene l'oggetto **data** del nodo in questione
1365
- */
1366
- this.onNodeClick = new i0.EventEmitter();
1367
- /**
1368
- * Evento lanciato alla selezione o deselezione di un nodo, contiene l'oggetto **data** del nodo in questione e informazioni sul suo stato di selezione
1369
- */
1370
- this.onNodeSelection = new i0.EventEmitter();
1371
- /**
1372
- * Evento lanciato al termine del Layouting. Se si vuole eseguire codice dopo che il Layout è fatto e completamente graficato, questo è il punto
1373
- */
1374
- this.onLayoutDone = new i0.EventEmitter();
1375
- /**
1376
- * Evento lanciato al termine del caricamento del diagramma
1377
- */
1378
- this.onLoaded = new i0.EventEmitter();
1379
- /**
1380
- * Indica se il rendering del diagramma è terminato
1381
- */
1382
- this.Rendered = false;
1383
- /**
1384
- * Api dell'estensione expand-collapse per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se **UseExpandCollapse** è **true**
1385
- */
1386
- this.ExpandCollapseApi = null;
1387
- /**
1388
- * Api dell'estensione html-node per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se sono impostati dei **NodeHTMLTemplates**
1389
- */
1390
- this.HtmlNodeApi = null;
1391
- }
1392
- /**
1393
- * @ignore
1394
- *
1395
- * Angular Pipeline
1396
- */
1397
- EsDiagramComponent.prototype.ngAfterViewInit = function () {
1398
- if (!this.service || !this.dispatcher)
1399
- throw "Il modulo @esfaenza/diagrams non è stato importato con il forRoot();";
1400
- this.dispatchLoadChart();
1401
- };
1402
- /**
1403
- * All'onDestroy ripulisco la memoria dal diagramma
1404
- */
1405
- EsDiagramComponent.prototype.ngOnDestroy = function () {
1406
- this.resizeObserver.dispose();
1407
- this.resizeObserver = null;
1408
- if (this.cy) {
1409
- this.service.log("I", "Diagram" + " " + this.name + ": Unloading destroyed diagram", false);
1410
- this.cy.destroy();
1411
- this.dispatcher.deregister(this.name);
1412
- }
1413
- else
1414
- this.service.log("I", "Chart " + this.name + ": Unloading uncreated chart component. It probably was a duplicated", false);
1415
- };
1416
- /**
1417
- * Registra il diagramma attuale nel Dispatcher in modo che venga caricato appena possibile
1418
- */
1419
- EsDiagramComponent.prototype.dispatchLoadChart = function () {
1420
- var _this = this;
1421
- this.dispatcher.register(this.name, function () { return _this.render(); });
1422
- };
1423
- /**
1424
- * @ignore
1425
- *
1426
- * Angular Pipeline: Gestione ri-graficazione del diagramma, se possibile
1427
- */
1428
- EsDiagramComponent.prototype.ngOnChanges = function (changes) {
1429
- var toCheck = ["Templates", "UseContextMenu", "ContextMenuOptions", "UseExpandCollapse", "ExpandCollapseOptions", "NodeStyles", "EdgeStyles", "NativeOptions"];
1430
- if (this.Rendered && toCheck.some(function (t) { return changes[t]; }))
1431
- this.service.log("W", "Redraw based on dynamic Input change is supported only for 'Elements' and 'Layout' inputs, please destroy the component and recreate it with the new settings");
1432
- var elementChanges = changes["Elements"];
1433
- var layoutChanges = changes["Layout"];
1434
- if (elementChanges && !elementChanges.firstChange) {
1435
- this.service.log("I", "Elements have been changed after diagram initialization");
1436
- // Cambiamento agli Elementi: ripulisco gli elementi vecchi, prendo i nuovi, li sistemo e li riassegno.
1437
- // Se il nuovo Input Elements è roba strana mi limito a ripulire il diagramma
1438
- // Se cytoscape aveva già degli elementi precedentemente ne prendo le posizioni in modo da ridisegnarli partendo dallo stesso punto (carino per le animazioni)
1439
- var elements = elementChanges === null || elementChanges === void 0 ? void 0 : elementChanges.currentValue;
1440
- var previous_elements = this.PreserveElementsPosition ? this.cy.nodes() : null;
1441
- this.cy.elements().remove();
1442
- if (elements && elements.length && elements.length > 0) {
1443
- this.reviewCytoscapeElements(elements, previous_elements);
1444
- this.cy.add(elements);
1445
- if (this.SmartSelection)
1446
- this.setupElementsSelectionIfNeeded();
1447
- // Se solo gli elementi cambiano, riapplico il Layout precedente
1448
- if (!layoutChanges && this.LastLayout) {
1449
- // Se devo animare le modifche al layout forzo il parametro relativo
1450
- if (this.AnimateLayoutChanges)
1451
- this.LastLayout.animate = true;
1452
- this.cy.layout(this.LastLayout).run();
1453
- }
1454
- }
1455
- }
1456
- // Se il layout cambia lo applico e me lo salvo come layout precedente per il futuro
1457
- if (layoutChanges && !layoutChanges.firstChange) {
1458
- this.service.log("I", "Layout have been changed after diagram initialization");
1459
- this.LastLayout = JSON.parse(JSON.stringify(layoutChanges.currentValue));
1460
- this.cy.layout(this.LastLayout).run();
1461
- }
1462
- };
1463
- /**
1464
- * Effettua il rendering del diagramma
1465
- */
1466
- EsDiagramComponent.prototype.render = function () {
1467
- return __awaiter(this, void 0, void 0, function () {
1468
- var cyOptions;
1469
- return __generator(this, function (_a) {
1470
- switch (_a.label) {
1471
- case 0:
1472
- cyOptions = this.getCompletedOptions();
1473
- this.NodesHierarchy = cyOptions.elements && cyOptions.elements.some(function (t) { return t.data.parent; });
1474
- // Carico eventuali classi di estensione che servono
1475
- return [4 /*yield*/, this.performModulesLoading()];
1476
- case 1:
1477
- // Carico eventuali classi di estensione che servono
1478
- _a.sent();
1479
- // Genero il diagramma
1480
- this.cy = cytoscape(cyOptions);
1481
- // Collego gli eventi al componente
1482
- this.bindCytoscapeEvents();
1483
- // Utilizzo le classi di estensione caricate precedentemente per fare il resto delle mie operazioni
1484
- this.performOperationsWithLoadedModules();
1485
- // Imposto la variabile Rendered a true in modo che se da adesso vengono fatte modifiche che dovrebbero causare un redraw posso accorgermene
1486
- // e mandare a cagare lo stronzo di turno
1487
- this.Rendered = true;
1488
- // Se devo aggiornare in automatico in base alla dimensione del contenitore collego il ResizeObserver
1489
- if (this.AutoupdateSize)
1490
- this.listenOnChanges();
1491
- if (this.SmartSelection) {
1492
- this.setupSelectionStyles();
1493
- this.setupElementsSelectionIfNeeded();
1494
- }
1495
- this.onLoaded.emit();
1496
- return [2 /*return*/];
1497
- }
1498
- });
1499
- });
1500
- };
1501
- /**
1502
- * Prende tutti gli elementi appena assegnati, e se qualcuno era selezionato la situazione viene persistita su cytoscape
1503
- */
1504
- EsDiagramComponent.prototype.setupElementsSelectionIfNeeded = function () {
1505
- for (var i = 0; i < this.Elements.length; i++) {
1506
- var eldata = this.Elements[i].data;
1507
- if (eldata.__selected) {
1508
- var el = this.cy.$id(eldata.id);
1509
- el.select();
1510
- }
1511
- }
1512
- };
1513
- /**
1514
- * Carica gli stili per mostrare carina la selezione dei nodi
1515
- */
1516
- EsDiagramComponent.prototype.setupSelectionStyles = function () {
1517
- var cssItem = this.SmartSelectionStyles || {
1518
- 'overlay-color': 'blue',
1519
- 'overlay-opacity': 0.5,
1520
- 'overlay-padding': 7
1521
- };
1522
- // Backdoor per poter assegnare "{}" a SmartSelectionStyles in modo di utilizzare la smart selection ma senza che nessuno stile venga applicato
1523
- // ad esempio qualora si volesse utilizzare l'htmlnode per gestire la grafica degli elementi selezionati
1524
- if (cssItem['overlay-color'] && cssItem['overlay-opacity'] && cssItem['overlay-padding'])
1525
- this.cy.style().selector('node:selected').css(cssItem);
1526
- };
1527
- /**
1528
- * Registra l'ascolto al contenitore del grafico e in caso di modifiche alla dimensione, al massimo una volta ogni 500 millisecondi, lo ridisegna
1529
- */
1530
- EsDiagramComponent.prototype.listenOnChanges = function () {
1531
- var _this = this;
1532
- this.resizeObserver = new ResizeSensor(this.cyGraph.nativeElement, function () {
1533
- _this.exts.throttle(_this.name, _this.onContainerSizeChanged.bind(_this), _this.ResizeThrottleTime);
1534
- });
1535
- };
1536
- /**
1537
- * Funzione che si occupa di gestire il repaint del diagramma
1538
- */
1539
- EsDiagramComponent.prototype.onContainerSizeChanged = function () {
1540
- this.service.log("I", "Diagram container size has changed, redrawing");
1541
- this.cy.resize();
1542
- this.cy.fit();
1543
- };
1544
- /**
1545
- * Collega tutti gli eventi che mi possono servire e li espone in output
1546
- */
1547
- EsDiagramComponent.prototype.bindCytoscapeEvents = function () {
1548
- var _this = this;
1549
- this.cy.bind('click', 'node', function (event) {
1550
- var targetData = event.target.data();
1551
- if (_this.SmartSelection) {
1552
- var id = targetData.id;
1553
- var el = _this.cy.$id(id);
1554
- var selected = el.selected();
1555
- el.selectify();
1556
- if (selected)
1557
- el.unselect();
1558
- else
1559
- el.select();
1560
- el.unselectify();
1561
- // Questo va anche nella lista degli elementi originali (this.Elements) dato che cytoscape li prende per riferimento (bbbbbravo cyto-chan)
1562
- el.data("__selected", !selected);
1563
- }
1564
- _this.onNodeClick.emit({ data: targetData });
1565
- });
1566
- this.cy.bind('select', 'node', function (event) {
1567
- var targetData = event.target.data();
1568
- _this.onNodeSelection.emit({ data: targetData, selected: true });
1569
- });
1570
- this.cy.bind('layoutstop', function (event) {
1571
- _this.onLayoutDone.emit();
1572
- });
1573
- this.cy.bind('unselect', 'node', function (event) {
1574
- var targetData = event.target.data();
1575
- _this.onNodeSelection.emit({ data: targetData, selected: false });
1576
- });
1577
- // Altri eventi...
1578
- };
1579
- /**
1580
- * Metodo che serve per caricare tutte le estensioni della libreria in base a ciò che viene utilizzato
1581
- */
1582
- EsDiagramComponent.prototype.performModulesLoading = function () {
1583
- return __awaiter(this, void 0, void 0, function () {
1584
- var wrappedCytoscape;
1585
- var _this = this;
1586
- return __generator(this, function (_a) {
1587
- switch (_a.label) {
1588
- case 0:
1589
- if (!(this.Layout.name == 'dagre')) return [3 /*break*/, 2];
1590
- return [4 /*yield*/, this.loadInternal("cytoscape-dagre")];
1591
- case 1:
1592
- _a.sent();
1593
- _a.label = 2;
1594
- case 2:
1595
- if (!(this.NodeHTMLTemplates && this.NodeHTMLTemplates.length > 0)) return [3 /*break*/, 4];
1596
- return [4 /*yield*/, this.loadInternal("cytoscape-html-node")];
1597
- case 3:
1598
- _a.sent();
1599
- _a.label = 4;
1600
- case 4:
1601
- if (!this.UseContextMenu) return [3 /*break*/, 6];
1602
- return [4 /*yield*/, this.loadInternal("cytoscape-cxtmenu")];
1603
- case 5:
1604
- _a.sent();
1605
- _a.label = 6;
1606
- case 6:
1607
- if (!(this.NodesHierarchy && this.UseExpandCollapse)) return [3 /*break*/, 8];
1608
- return [4 /*yield*/, this.loadInternal("cytoscape-expand-collapse")];
1609
- case 7:
1610
- _a.sent();
1611
- _a.label = 8;
1612
- case 8:
1613
- if (!this.ExtensionModulesImporter) return [3 /*break*/, 10];
1614
- wrappedCytoscape = {
1615
- use: function (moduleName, module) {
1616
- if (!module)
1617
- _this.service.log("E", _this.service.loc("Received an undefined module. Make sure you are correctly loading it") + ": " + moduleName, false);
1618
- if (["cytoscape-dagre", "cytoscape-html-node", "cytoscape-cxtmenu", "cytoscape-expand-collapse"].includes(moduleName))
1619
- _this.service.log("W", _this.service.loc("Module") + " " + moduleName + " " + _this.service.loc("is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options"), false);
1620
- else
1621
- cytoscape.use(module);
1622
- }
1623
- };
1624
- return [4 /*yield*/, this.ExtensionModulesImporter(wrappedCytoscape)];
1625
- case 9:
1626
- _a.sent();
1627
- _a.label = 10;
1628
- case 10: return [2 /*return*/];
1629
- }
1630
- });
1631
- });
1632
- };
1633
- /**
1634
- * Metodo che serve per caricare tutte le estensioni della libreria in base a ciò che viene utilizzato con le opzioni definite dagli Input
1635
- */
1636
- EsDiagramComponent.prototype.performOperationsWithLoadedModules = function () {
1637
- var anyCy = this.cy;
1638
- // Utilizzo del layout, lo salvo per poterlo riutilizzare in futuro
1639
- if (this.Layout) {
1640
- this.LastLayout = JSON.parse(JSON.stringify(this.Layout));
1641
- this.cy.layout(this.LastLayout).run();
1642
- }
1643
- // Utilizzo dell'HTML node
1644
- if (this.NodeHTMLTemplates && this.NodeHTMLTemplates.length > 0) {
1645
- this.HtmlNodeApi = anyCy.htmlnode();
1646
- this.HtmlNodeApi.createHtmlNode(cytoscape, this.cy, this.NodeHTMLTemplates);
1647
- }
1648
- // Utilizzo del Context Menu
1649
- if (this.UseContextMenu)
1650
- this.ContextMenuOptions.forEach(function (o) { anyCy.cxtmenu(o); });
1651
- // Utilizzo dell'expand collapse solo quando c'è una gerarchia di nodi
1652
- if (this.NodesHierarchy && this.UseExpandCollapse)
1653
- this.ExpandCollapseApi = anyCy.expandCollapse(this.ExpandCollapseOptions);
1654
- // Utilizzo di estensioni extra, implementazione affidata al programmatore
1655
- if (this.ExtensionModulesApplyer)
1656
- this.ExtensionModulesApplyer(this.cy);
1657
- };
1658
- EsDiagramComponent.prototype.updateCardData = function () {
1659
- if (!this.HtmlNodeApi) {
1660
- this.service.log("E", "Cannot update NodeHTMLTemplates as they don't seem to be used");
1661
- return;
1662
- }
1663
- this.HtmlNodeApi.update();
1664
- };
1665
- /**
1666
- * Metodo interno per il caricamento dei moduli di estensione
1667
- *
1668
- * @param {'cytoscape-expand-collapse' | 'cytoscape-cxtmenu' | 'cytoscape-html-node' | 'cytoscape-dagre'} moduleId Modulo da caricare
1669
- */
1670
- EsDiagramComponent.prototype.loadInternal = function (moduleId) {
1671
- return __awaiter(this, void 0, void 0, function () {
1672
- var toLoad;
1673
- return __generator(this, function (_a) {
1674
- switch (_a.label) {
1675
- case 0: return [4 /*yield*/, this.service.importIfNeeded(moduleId)];
1676
- case 1:
1677
- toLoad = _a.sent();
1678
- if (toLoad)
1679
- cytoscape.use(toLoad);
1680
- return [2 /*return*/];
1681
- }
1682
- });
1683
- });
1684
- };
1685
- /**
1686
- * Metodo che basandosi sulle opzioni native eventualmente assegnate le completa con gli Input addizionali
1687
- *
1688
- * @returns {cy_.CytoscapeOptions} Opzioni finali unite da Input ed opzioni native
1689
- */
1690
- EsDiagramComponent.prototype.getCompletedOptions = function () {
1691
- var opts = this.NativeOptions || {};
1692
- opts.container = this.cyGraph.nativeElement;
1693
- opts.style = opts.style || [];
1694
- // Per tutte le cose per cui gli Input hanno priorità sovrascrivo gli originali delle opzioni
1695
- if (this.NodeStyles || this.EdgeStyles) {
1696
- opts.style = [];
1697
- if (this.NodeStyles)
1698
- opts.style.push({ selector: 'node', css: this.NodeStyles });
1699
- if (this.EdgeStyles)
1700
- opts.style.push({ selector: 'edge', css: this.EdgeStyles });
1701
- }
1702
- if (this.Elements)
1703
- opts.elements = this.Elements;
1704
- this.reviewCytoscapeElements(opts.elements);
1705
- if (this.Layout)
1706
- opts.layout = this.Layout;
1707
- if (this.Readonly) {
1708
- // Questo coso fa effetti strani....
1709
- //opts.autolock = true;
1710
- opts.autoungrabify = true;
1711
- opts.autounselectify = false;
1712
- opts.boxSelectionEnabled = true;
1713
- opts.userZoomingEnabled = false;
1714
- opts.userPanningEnabled = false;
1715
- }
1716
- return opts;
1717
- };
1718
- /**
1719
- * Aggiustamenti degli elementi di Cytoscape.
1720
- *
1721
- * I nodi non vengono toccati.
1722
- *
1723
- * Per ogni edge viene controllato se è specificata una sorgente ed una destinazione, in caso contrario si cerca di dedurli dall'ID
1724
- *
1725
- * @param {cytoscape.ElementDefinition[]} elements Elementi da sistemare
1726
- */
1727
- EsDiagramComponent.prototype.reviewCytoscapeElements = function (elements, prevPositions) {
1728
- var hasPreviousPositions = prevPositions && prevPositions.length > 0;
1729
- var positionCache = {};
1730
- if (hasPreviousPositions) {
1731
- for (var i = 0; i < prevPositions.length; i++) {
1732
- var item = prevPositions[i];
1733
- if (!positionCache[item.data().id])
1734
- positionCache[item.data().id] = item.position();
1735
- }
1736
- }
1737
- for (var i = 0; i < elements.length; i++) {
1738
- var el = elements[i];
1739
- if (el.group == "edges" && (!el.data.source && !el.data.target)) {
1740
- if (!el.data.id.includes("-"))
1741
- this.service.log("E", "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}");
1742
- else {
1743
- var sourceTarget = el.data.id.split('-');
1744
- el.data.source = sourceTarget[0].trim();
1745
- el.data.target = sourceTarget[1].trim();
1746
- }
1747
- }
1748
- if (hasPreviousPositions && el.group == "nodes")
1749
- el.position = positionCache[el.data.id];
1750
- }
1751
- };
1752
- return EsDiagramComponent;
1753
- }());
1754
- EsDiagramComponent.decorators = [
1755
- { type: i0.Component, args: [{
1756
- selector: 'es-diagram',
1757
- template: "<div #graph class=\"graph-wrapper {{name}}\"></div>",
1758
- styles: [".graph-wrapper{height:100%;width:100%}.html-node-notransition{transition:none!important;transform:none!important}\n"]
1759
- },] }
1760
- ];
1761
- EsDiagramComponent.ctorParameters = function () { return [
1762
- { type: EsDiagramService, decorators: [{ type: i0.Optional }] },
1763
- { type: EsDiagramDispatcher, decorators: [{ type: i0.Optional }] },
1764
- { type: ReactiveExtensions }
1765
- ]; };
1766
- EsDiagramComponent.propDecorators = {
1767
- cyGraph: [{ type: i0.ViewChild, args: ['graph',] }],
1768
- name: [{ type: i0.Input }],
1769
- UseContextMenu: [{ type: i0.Input }],
1770
- ContextMenuOptions: [{ type: i0.Input }],
1771
- UseExpandCollapse: [{ type: i0.Input }],
1772
- ExpandCollapseOptions: [{ type: i0.Input }],
1773
- NativeOptions: [{ type: i0.Input }],
1774
- Elements: [{ type: i0.Input }],
1775
- NodeStyles: [{ type: i0.Input }],
1776
- EdgeStyles: [{ type: i0.Input }],
1777
- Readonly: [{ type: i0.Input }],
1778
- AutoupdateSize: [{ type: i0.Input }],
1779
- PreserveElementsPosition: [{ type: i0.Input }],
1780
- AnimateLayoutChanges: [{ type: i0.Input }],
1781
- SmartSelection: [{ type: i0.Input }],
1782
- SmartSelectionStyles: [{ type: i0.Input }],
1783
- ResizeThrottleTime: [{ type: i0.Input }],
1784
- Layout: [{ type: i0.Input }],
1785
- NodeHTMLTemplates: [{ type: i0.Input }],
1786
- ExtensionModulesImporter: [{ type: i0.Input }],
1787
- ExtensionModulesApplyer: [{ type: i0.Input }],
1788
- onNodeClick: [{ type: i0.Output }],
1789
- onNodeSelection: [{ type: i0.Output }],
1790
- onLayoutDone: [{ type: i0.Output }],
1791
- onLoaded: [{ type: i0.Output }]
1792
- };
1793
-
1794
- var EsDiagramModule = /** @class */ (function () {
1795
- function EsDiagramModule() {
1796
- }
1797
- EsDiagramModule.forRoot = function (config) {
1798
- return {
1799
- ngModule: EsDiagramModule,
1800
- providers: [
1801
- EsDiagramService,
1802
- EsDiagramDispatcher,
1803
- { provide: DIA_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
1804
- { provide: DIA_DEBUG_MODE, useValue: (config === null || config === void 0 ? void 0 : config.debugMode) || false },
1805
- ]
1806
- };
1807
- };
1808
- return EsDiagramModule;
1809
- }());
1810
- EsDiagramModule.decorators = [
1811
- { type: i0.NgModule, args: [{
1812
- declarations: [EsDiagramComponent],
1813
- imports: [common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule, common.CommonModule],
1814
- exports: [EsDiagramComponent]
1815
- },] }
1816
- ];
1817
-
1818
- /*
1819
- * Public API Surface of cytoscape-angular
1820
- */
1821
-
1822
- /**
1823
- * Generated bundle index. Do not edit.
1824
- */
1825
-
1826
- exports.BaseLayoutOptionsImpl = BaseLayoutOptionsImpl;
1827
- exports.BreadthFirstLayoutOptionsImpl = BreadthFirstLayoutOptionsImpl;
1828
- exports.CircleLayoutOptionsImpl = CircleLayoutOptionsImpl;
1829
- exports.ConcentricLayoutOptionsImpl = ConcentricLayoutOptionsImpl;
1830
- exports.ContextMenuCommand = ContextMenuCommand;
1831
- exports.ContextMenuOptions = ContextMenuOptions;
1832
- exports.CoseLayoutOptionsImpl = CoseLayoutOptionsImpl;
1833
- exports.DagreLayoutOptionsImpl = DagreLayoutOptionsImpl;
1834
- exports.EsDiagramComponent = EsDiagramComponent;
1835
- exports.EsDiagramModule = EsDiagramModule;
1836
- exports.EsDiagramModuleConfig = EsDiagramModuleConfig;
1837
- exports.ExpandCollapseOptions = ExpandCollapseOptions;
1838
- exports.GridLayoutOptionsImpl = GridLayoutOptionsImpl;
1839
- exports.NodeHTMLTemplate = NodeHTMLTemplate;
1840
- exports.NodeTemplate = NodeTemplate;
1841
- exports.NullLayoutOptionsImpl = NullLayoutOptionsImpl;
1842
- exports.PresetLayoutOptionsImpl = PresetLayoutOptionsImpl;
1843
- exports.RandomLayoutOptionsImpl = RandomLayoutOptionsImpl;
1844
- exports.ShapedLayoutOptionsImpl = ShapedLayoutOptionsImpl;
1845
- exports.ZoomLevelBasedTemplate = ZoomLevelBasedTemplate;
1846
- exports.ɵa = AnimateLayoutOptionsImpl;
1847
- exports.ɵb = EsDiagramService;
1848
- exports.ɵc = DIA_LOCALE;
1849
- exports.ɵd = DIA_DEBUG_MODE;
1850
- exports.ɵe = EsDiagramDispatcher;
1851
- exports.ɵf = ReactiveExtensions;
1852
-
1853
- Object.defineProperty(exports, '__esModule', { value: true });
1854
-
1855
- })));
1856
- //# sourceMappingURL=esfaenza-es-diagrams.umd.js.map