@progress/kendo-angular-diagrams 21.0.0-develop.9 → 21.0.1-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/connection-tooltip-template.directive.d.ts +38 -0
- package/diagram.component.d.ts +126 -36
- package/diagram.module.d.ts +3 -1
- package/directives.d.ts +3 -1
- package/esm2022/connection-tooltip-template.directive.mjs +47 -0
- package/esm2022/diagram.component.mjs +337 -67
- package/esm2022/diagram.module.mjs +4 -2
- package/esm2022/directives.mjs +5 -1
- package/esm2022/index.mjs +4 -1
- package/esm2022/models.mjs +7 -0
- package/esm2022/package-metadata.mjs +2 -2
- package/esm2022/shape-tooltip-template.directive.mjs +47 -0
- package/fesm2022/progress-kendo-angular-diagrams.mjs +431 -74
- package/index.d.ts +4 -1
- package/models.d.ts +211 -0
- package/package.json +11 -11
- package/shape-tooltip-template.directive.d.ts +38 -0
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Component, ElementRef, EventEmitter, HostBinding, Input, NgZone, Output, Renderer2, } from '@angular/core';
|
|
6
|
-
import { Diagram } from '@progress/kendo-diagram-common';
|
|
5
|
+
import { Component, ContentChild, ElementRef, EventEmitter, HostBinding, Input, NgZone, Output, Renderer2, TemplateRef, ViewChild, ViewContainerRef, } from '@angular/core';
|
|
6
|
+
import { Shape, Connection, Diagram, convertToDiagramModel, placeTooltip } from '@progress/kendo-diagram-common';
|
|
7
7
|
import { validatePackage } from '@progress/kendo-licensing';
|
|
8
8
|
import { packageMetadata } from './package-metadata';
|
|
9
9
|
import { hasObservers, shouldShowValidationUI, getLicenseMessage, WatermarkOverlayComponent, isDocumentAvailable } from '@progress/kendo-angular-common';
|
|
10
|
-
import {
|
|
10
|
+
import { PopupService } from '@progress/kendo-angular-popup';
|
|
11
|
+
import { NgIf, NgTemplateOutlet } from '@angular/common';
|
|
11
12
|
import { events, loadTheme } from '@progress/kendo-diagram-common';
|
|
12
13
|
import { CONNECTION_DEFAULTS, SHAPE_DEFAULTS } from './utils';
|
|
14
|
+
import { ShapeTooltipTemplateDirective } from './shape-tooltip-template.directive';
|
|
15
|
+
import { ConnectionTooltipTemplateDirective } from './connection-tooltip-template.directive';
|
|
13
16
|
import * as i0 from "@angular/core";
|
|
17
|
+
import * as i1 from "@progress/kendo-angular-popup";
|
|
14
18
|
/**
|
|
15
19
|
* Represents the [Kendo UI Diagram component for Angular](slug:overview_diagram).
|
|
16
20
|
*
|
|
@@ -25,41 +29,57 @@ export class DiagramComponent {
|
|
|
25
29
|
wrapperElement;
|
|
26
30
|
renderer;
|
|
27
31
|
zone;
|
|
32
|
+
popupService;
|
|
33
|
+
viewContainer;
|
|
28
34
|
diagramClass = true;
|
|
29
35
|
/**
|
|
30
36
|
* Defines the default configuration options applicable to all connections.
|
|
31
|
-
* Changing the property value dynamically triggers a reinitialization of the Diagram
|
|
37
|
+
* Changing the property value dynamically triggers a reinitialization of the `Diagram`.
|
|
38
|
+
*
|
|
32
39
|
*/
|
|
33
40
|
connectionDefaults = CONNECTION_DEFAULTS;
|
|
34
41
|
/**
|
|
35
|
-
* Defines the connections that render between the shapes in the Diagram.
|
|
36
|
-
*
|
|
42
|
+
* Defines the connections that render between the shapes in the `Diagram` (see [Connections article](slug:diagram_connections)).
|
|
43
|
+
* Accepts either an array of `ConnectionOptions` or an array of any objects
|
|
44
|
+
* that will be mapped using the `connectionModelFields` configuration.
|
|
45
|
+
* Changing this property dynamically reinitializes the `Diagram`.
|
|
46
|
+
*
|
|
37
47
|
*/
|
|
38
48
|
connections = [];
|
|
39
49
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
50
|
+
* Defines the field mapping configuration for connections data binding ([see example](slug:diagram_data_binding#field-mapping)).
|
|
51
|
+
* Maps source object properties to `Diagram` connection properties.
|
|
52
|
+
* Only used when `connections` is an array of custom objects instead of `ConnectionOptions`.
|
|
53
|
+
*/
|
|
54
|
+
connectionModelFields;
|
|
55
|
+
/**
|
|
56
|
+
* A set of settings to configure the `Diagram` behavior when the user attempts to drag, resize, or remove shapes.
|
|
57
|
+
* Changing the property value dynamically triggers a reinitialization of the `Diagram`.
|
|
58
|
+
*
|
|
42
59
|
* @default true
|
|
43
60
|
*/
|
|
44
61
|
editable = { drag: true, resize: true, remove: true };
|
|
45
62
|
/**
|
|
46
|
-
*
|
|
47
|
-
* Changing the property value dynamically triggers a reinitialization of the Diagram
|
|
63
|
+
* Defines the layout configuration for arranging shapes and connections in the `Diagram` (see [Layout article](slug:diagram_layouts)).
|
|
64
|
+
* Changing the property value dynamically triggers a reinitialization of the `Diagram`.
|
|
65
|
+
*
|
|
48
66
|
*/
|
|
49
67
|
layout;
|
|
50
68
|
/**
|
|
51
|
-
* Defines the pannable options. Use this setting to disable Diagram pan or change the key that activates the pan behavior.
|
|
69
|
+
* Defines the pannable options. Use this setting to disable `Diagram` pan or change the key that activates the pan behavior.
|
|
70
|
+
*
|
|
52
71
|
* @default true
|
|
53
72
|
*/
|
|
54
73
|
pannable = true;
|
|
55
74
|
/**
|
|
56
|
-
* Defines the Diagram selection options.
|
|
75
|
+
* Defines the `Diagram` selection options.
|
|
57
76
|
*
|
|
58
|
-
* By default, you can select shapes in the Diagram in one of two ways:
|
|
77
|
+
* By default, you can select shapes in the `Diagram` in one of two ways:
|
|
59
78
|
* - Clicking a single shape to select it and deselect any previously selected shapes.
|
|
60
79
|
* - Holding the `Ctrl/Cmd on MacOS` key while clicking multiple shapes to select them and any other shapes between them.
|
|
61
80
|
*
|
|
62
81
|
* Use the `selectable` configuration to allow single selection only, enable selection by drawing a rectangular area with the mouse around shapes in the canvas, or disable selection altogether.
|
|
82
|
+
*
|
|
63
83
|
* @default true
|
|
64
84
|
*/
|
|
65
85
|
selectable = true;
|
|
@@ -69,30 +89,39 @@ export class DiagramComponent {
|
|
|
69
89
|
*/
|
|
70
90
|
shapeDefaults = SHAPE_DEFAULTS;
|
|
71
91
|
/**
|
|
72
|
-
* Defines the shapes that render in the Diagram.
|
|
73
|
-
*
|
|
92
|
+
* Defines the shapes that render in the `Diagram` (see [Shapes article](slug:diagram_shapes)).
|
|
93
|
+
* Accepts either an array of `ShapeOptions` or an array of any objects
|
|
94
|
+
* that will be mapped using the `shapeModelFields` configuration.
|
|
95
|
+
* Changing the property value dynamically triggers a reinitialization of the `Diagram`.
|
|
96
|
+
*
|
|
74
97
|
*/
|
|
75
98
|
shapes = [];
|
|
76
99
|
/**
|
|
77
|
-
* Defines the
|
|
100
|
+
* Defines the field mapping configuration for shapes data binding ([see example](slug:diagram_data_binding#field-mapping)).
|
|
101
|
+
* Maps source object properties to `Diagram` shape properties.
|
|
102
|
+
* Only used when `shapes` is an array of custom objects instead of `ShapeOptions`.
|
|
103
|
+
*/
|
|
104
|
+
shapeModelFields;
|
|
105
|
+
/**
|
|
106
|
+
* Defines the zoom level of the `Diagram`.
|
|
78
107
|
*
|
|
79
108
|
* @default 1
|
|
80
109
|
*/
|
|
81
110
|
zoom = 1;
|
|
82
111
|
/**
|
|
83
|
-
* Defines the maximum zoom level of the Diagram
|
|
112
|
+
* Defines the maximum zoom level of the `Diagram`.
|
|
84
113
|
*
|
|
85
114
|
* @default 2
|
|
86
115
|
*/
|
|
87
116
|
zoomMax = 2;
|
|
88
117
|
/**
|
|
89
|
-
* Defines the minimum zoom level of the Diagram
|
|
118
|
+
* Defines the minimum zoom level of the `Diagram`.
|
|
90
119
|
*
|
|
91
120
|
* @default 0.1
|
|
92
121
|
*/
|
|
93
122
|
zoomMin = 0.1;
|
|
94
123
|
/**
|
|
95
|
-
* Defines the zoom rate of the Diagram
|
|
124
|
+
* Defines the zoom rate of the `Diagram`.
|
|
96
125
|
*
|
|
97
126
|
* @default 0.1
|
|
98
127
|
*/
|
|
@@ -130,7 +159,7 @@ export class DiagramComponent {
|
|
|
130
159
|
*/
|
|
131
160
|
mouseLeave = new EventEmitter();
|
|
132
161
|
/**
|
|
133
|
-
* Fires when the user pans the Diagram
|
|
162
|
+
* Fires when the user pans the `Diagram`.
|
|
134
163
|
*/
|
|
135
164
|
onPan = new EventEmitter();
|
|
136
165
|
/**
|
|
@@ -138,32 +167,40 @@ export class DiagramComponent {
|
|
|
138
167
|
*/
|
|
139
168
|
onSelect = new EventEmitter();
|
|
140
169
|
/**
|
|
141
|
-
* Fires when the
|
|
170
|
+
* Fires when the `Diagram` has finished zooming out.
|
|
142
171
|
*/
|
|
143
172
|
zoomEnd = new EventEmitter();
|
|
144
173
|
/**
|
|
145
|
-
* Fires when the
|
|
174
|
+
* Fires when the `Diagram` starts zooming in or out.
|
|
146
175
|
*/
|
|
147
176
|
zoomStart = new EventEmitter();
|
|
177
|
+
/**
|
|
178
|
+
* Fires when a tooltip should shown for a shape or connection.
|
|
179
|
+
*/
|
|
180
|
+
tooltipShow = new EventEmitter();
|
|
181
|
+
/**
|
|
182
|
+
* Fires when a tooltip should be hidden.
|
|
183
|
+
*/
|
|
184
|
+
tooltipHide = new EventEmitter();
|
|
148
185
|
/**
|
|
149
186
|
* @hidden
|
|
150
187
|
* Represents the Diagram instance, holding the core functionality of the Diagram.
|
|
151
188
|
*/
|
|
152
189
|
diagramWidget;
|
|
153
190
|
/**
|
|
154
|
-
* The currently selected items in the Diagram
|
|
191
|
+
* The currently selected items in the `Diagram`.
|
|
155
192
|
*/
|
|
156
193
|
get selection() {
|
|
157
194
|
return this.diagramWidget?.select();
|
|
158
195
|
}
|
|
159
196
|
/**
|
|
160
|
-
* The actual shapes created by the Diagram
|
|
197
|
+
* The actual shapes created by the `Diagram`.
|
|
161
198
|
*/
|
|
162
199
|
get diagramShapes() {
|
|
163
200
|
return this.diagramWidget?.shapes;
|
|
164
201
|
}
|
|
165
202
|
/**
|
|
166
|
-
* The actual connections created by the Diagram
|
|
203
|
+
* The actual connections created by the `Diagram`.
|
|
167
204
|
*/
|
|
168
205
|
get diagramConnections() {
|
|
169
206
|
return this.diagramWidget?.connections;
|
|
@@ -176,6 +213,10 @@ export class DiagramComponent {
|
|
|
176
213
|
* @hidden
|
|
177
214
|
*/
|
|
178
215
|
licenseMessage;
|
|
216
|
+
/**
|
|
217
|
+
* @hidden
|
|
218
|
+
*/
|
|
219
|
+
customTemplate;
|
|
179
220
|
options = {
|
|
180
221
|
shapes: this.shapes,
|
|
181
222
|
connections: this.connections,
|
|
@@ -188,22 +229,43 @@ export class DiagramComponent {
|
|
|
188
229
|
shapeDefaults: this.shapeDefaults,
|
|
189
230
|
connectionDefaults: this.connectionDefaults
|
|
190
231
|
};
|
|
191
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Stores the converted shapes from user data.
|
|
234
|
+
*/
|
|
235
|
+
convertedShapes = [];
|
|
236
|
+
/**
|
|
237
|
+
* Stores the converted connections from user data.
|
|
238
|
+
*/
|
|
239
|
+
convertedConnections = [];
|
|
240
|
+
/**
|
|
241
|
+
* Current popup instance for tooltip.
|
|
242
|
+
*/
|
|
243
|
+
tooltipPopup;
|
|
244
|
+
defaultTooltipTemplate;
|
|
245
|
+
customTooltipTemplate;
|
|
246
|
+
shapeTooltipTemplate;
|
|
247
|
+
connectionTooltipTemplate;
|
|
248
|
+
/**
|
|
249
|
+
* @hidden
|
|
250
|
+
* The original data item provided by the user. Passed in the tooltip template context.
|
|
251
|
+
*/
|
|
252
|
+
dataItem;
|
|
253
|
+
constructor(wrapperElement, renderer, zone, popupService, viewContainer) {
|
|
192
254
|
this.wrapperElement = wrapperElement;
|
|
193
255
|
this.renderer = renderer;
|
|
194
256
|
this.zone = zone;
|
|
257
|
+
this.popupService = popupService;
|
|
258
|
+
this.viewContainer = viewContainer;
|
|
195
259
|
const isValid = validatePackage(packageMetadata);
|
|
196
260
|
this.licenseMessage = getLicenseMessage(packageMetadata);
|
|
197
261
|
this.showLicenseWatermark = shouldShowValidationUI(isValid);
|
|
198
262
|
}
|
|
199
263
|
ngOnChanges(changes) {
|
|
200
264
|
let recreate = false;
|
|
201
|
-
if (changes['shapes']) {
|
|
202
|
-
this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (changes['connections']) {
|
|
206
|
-
this.options.connections = this.connections;
|
|
265
|
+
if (changes['shapes'] || changes['connections'] || changes['shapeModelFields'] || changes['connectionModelFields']) {
|
|
266
|
+
this.convertUserData();
|
|
267
|
+
this.options.shapes = this.convertedShapes;
|
|
268
|
+
this.options.connections = this.convertedConnections;
|
|
207
269
|
recreate = true;
|
|
208
270
|
}
|
|
209
271
|
if (changes['connectionDefaults']) {
|
|
@@ -260,53 +322,37 @@ export class DiagramComponent {
|
|
|
260
322
|
}
|
|
261
323
|
if (recreate) {
|
|
262
324
|
this.init();
|
|
325
|
+
this.bindDiagramEvents();
|
|
263
326
|
}
|
|
264
327
|
}
|
|
265
328
|
ngAfterViewInit() {
|
|
329
|
+
this.convertUserData();
|
|
330
|
+
this.options.shapes = this.convertedShapes;
|
|
331
|
+
this.options.connections = this.convertedConnections;
|
|
266
332
|
this.renderer.setStyle(this.wrapperElement.nativeElement, 'display', 'block');
|
|
267
333
|
this.init();
|
|
268
|
-
|
|
269
|
-
this.diagramWidget.bind(eventName, (e) => {
|
|
270
|
-
if (eventName === 'click') {
|
|
271
|
-
eventName = 'diagramClick';
|
|
272
|
-
}
|
|
273
|
-
if (eventName === 'select') {
|
|
274
|
-
eventName = 'onSelect';
|
|
275
|
-
}
|
|
276
|
-
if (eventName === 'pan') {
|
|
277
|
-
eventName = 'onPan';
|
|
278
|
-
}
|
|
279
|
-
if (eventName === 'itemBoundsChange') {
|
|
280
|
-
eventName = 'shapeBoundsChange';
|
|
281
|
-
}
|
|
282
|
-
const emitter = this.activeEmitter(eventName);
|
|
283
|
-
if (emitter) {
|
|
284
|
-
this.zone.run(() => {
|
|
285
|
-
emitter.emit(e);
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
});
|
|
334
|
+
this.bindDiagramEvents();
|
|
290
335
|
}
|
|
291
336
|
ngOnDestroy() {
|
|
337
|
+
this.hideTooltip();
|
|
292
338
|
this.diagramWidget?.destroy();
|
|
293
339
|
}
|
|
294
340
|
/**
|
|
295
|
-
* Provides the current Diagram's shapes and connections that can be used to create a new Diagram when needed.
|
|
341
|
+
* Provides the current `Diagram`'s shapes and connections that can be used to create a new `Diagram` when needed.
|
|
296
342
|
* @returns {DiagramState} Object containing shapes and connections arrays.
|
|
297
343
|
*/
|
|
298
344
|
getState() {
|
|
299
345
|
return this.diagramWidget?.save();
|
|
300
346
|
}
|
|
301
347
|
/**
|
|
302
|
-
* Focuses the Diagram
|
|
348
|
+
* Focuses the `Diagram`.
|
|
303
349
|
* @returns {boolean} true if focus was set successfully.
|
|
304
350
|
*/
|
|
305
351
|
focus() {
|
|
306
352
|
return this.diagramWidget?.focus();
|
|
307
353
|
}
|
|
308
354
|
/**
|
|
309
|
-
* Clears the Diagram
|
|
355
|
+
* Clears the `Diagram`.
|
|
310
356
|
*/
|
|
311
357
|
clear() {
|
|
312
358
|
this.diagramWidget?.clear();
|
|
@@ -321,7 +367,7 @@ export class DiagramComponent {
|
|
|
321
367
|
return this.diagramWidget?.connected(source, target);
|
|
322
368
|
}
|
|
323
369
|
/**
|
|
324
|
-
* Adds connection to the Diagram
|
|
370
|
+
* Adds connection to the `Diagram`.
|
|
325
371
|
* @param {Connection} Connection.
|
|
326
372
|
* @param {boolean} Boolean.
|
|
327
373
|
* @returns {Connection} The newly created connection.
|
|
@@ -331,7 +377,7 @@ export class DiagramComponent {
|
|
|
331
377
|
return newConnection;
|
|
332
378
|
}
|
|
333
379
|
/**
|
|
334
|
-
* Adds shape to the Diagram
|
|
380
|
+
* Adds shape to the `Diagram`.
|
|
335
381
|
* @param {ShapeOptions | Shape | Point} If you pass a `Point`, a new Shape with default options will be created and positioned at that point.
|
|
336
382
|
* @param {boolean} Boolean indicating if the action should be undoable.
|
|
337
383
|
* @returns {Shape} The newly created shape.
|
|
@@ -341,7 +387,7 @@ export class DiagramComponent {
|
|
|
341
387
|
return newShape;
|
|
342
388
|
}
|
|
343
389
|
/**
|
|
344
|
-
* Removes shape(s) and/or connection(s) from the Diagram
|
|
390
|
+
* Removes shape(s) and/or connection(s) from the `Diagram`.
|
|
345
391
|
* @param {Shape | Connection | (Shape | Connection)[]} Shape, Connection or an Array of Shapes and/or Connections.
|
|
346
392
|
* @param {Boolean} Boolean indicating if the action should be undoable.
|
|
347
393
|
*/
|
|
@@ -349,7 +395,7 @@ export class DiagramComponent {
|
|
|
349
395
|
this.diagramWidget?.remove(items, undoable);
|
|
350
396
|
}
|
|
351
397
|
/**
|
|
352
|
-
* Connects two items in the Diagram
|
|
398
|
+
* Connects two items in the `Diagram`.
|
|
353
399
|
* @param {Shape | Connector | Point} Shape, Shape's Connector or Point.
|
|
354
400
|
* @param {Shape | Connector | Point} Shape, Shape's Connector or Point.
|
|
355
401
|
* @param {ConnectionOptions} Connection options.
|
|
@@ -380,7 +426,7 @@ export class DiagramComponent {
|
|
|
380
426
|
return this.diagramWidget?.select(items, options);
|
|
381
427
|
}
|
|
382
428
|
/**
|
|
383
|
-
* Selects all items in the Diagram
|
|
429
|
+
* Selects all items in the `Diagram`.
|
|
384
430
|
*/
|
|
385
431
|
selectAll() {
|
|
386
432
|
this.diagramWidget?.selectAll();
|
|
@@ -564,12 +610,199 @@ export class DiagramComponent {
|
|
|
564
610
|
exportVisual() {
|
|
565
611
|
return this.diagramWidget?.exportVisual();
|
|
566
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Handles the tooltipShow event from the diagram widget.
|
|
615
|
+
*/
|
|
616
|
+
handleTooltipShow(event) {
|
|
617
|
+
this.hideTooltip();
|
|
618
|
+
const dataItem = event.item.dataItem;
|
|
619
|
+
const isShape = event.item instanceof Shape;
|
|
620
|
+
const isConnection = event.item instanceof Connection;
|
|
621
|
+
this.setCustomTemplate(isShape, isConnection);
|
|
622
|
+
const defaultsEnabled = isShape
|
|
623
|
+
? this.options.shapeDefaults.tooltip?.visible
|
|
624
|
+
: this.options.connectionDefaults.tooltip?.visible;
|
|
625
|
+
const itemTooltipEnabled = dataItem.tooltip?.visible;
|
|
626
|
+
const optionsArray = isShape ? this.options.shapes : this.options.connections;
|
|
627
|
+
const optionsItem = optionsArray?.find((item) => item.id === event.item.id);
|
|
628
|
+
const hasTooltipText = !!dataItem.tooltipText || !!optionsItem?.tooltipText;
|
|
629
|
+
if (!dataItem.tooltipText && optionsItem?.tooltipText) {
|
|
630
|
+
dataItem.tooltipText = optionsItem.tooltipText;
|
|
631
|
+
}
|
|
632
|
+
const shouldShowTooltip = itemTooltipEnabled !== false && hasTooltipText && (defaultsEnabled || itemTooltipEnabled);
|
|
633
|
+
if (shouldShowTooltip) {
|
|
634
|
+
this.dataItem = dataItem;
|
|
635
|
+
let popupContent = this.defaultTooltipTemplate;
|
|
636
|
+
const showCustomTemplate = Boolean((isShape && this.shapeTooltipTemplate) || (isConnection && this.connectionTooltipTemplate));
|
|
637
|
+
if (showCustomTemplate) {
|
|
638
|
+
popupContent = this.customTooltipTemplate;
|
|
639
|
+
}
|
|
640
|
+
const popupClass = this.popupClass(isShape, dataItem);
|
|
641
|
+
this.showTooltip(event, popupContent, popupClass);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
showTooltip(event, content, popupClass) {
|
|
645
|
+
this.tooltipPopup = this.popupService.open({
|
|
646
|
+
content: content,
|
|
647
|
+
appendTo: this.viewContainer,
|
|
648
|
+
popupClass,
|
|
649
|
+
animate: false
|
|
650
|
+
});
|
|
651
|
+
const contentElement = this.tooltipPopup.popupElement.querySelector('.k-popup');
|
|
652
|
+
if (content === this.defaultTooltipTemplate) {
|
|
653
|
+
this.renderer.addClass(contentElement, 'k-tooltip');
|
|
654
|
+
}
|
|
655
|
+
const popupElementRect = contentElement.getBoundingClientRect();
|
|
656
|
+
const zoom = event.item.diagram.zoom();
|
|
657
|
+
const pan = event.item.diagram.pan();
|
|
658
|
+
const diagramRect = this.diagramWidget.element.getBoundingClientRect();
|
|
659
|
+
const win = this.diagramWidget.element.ownerDocument.defaultView;
|
|
660
|
+
const lines = this.diagramWidget.connections.map(con => con.allPoints());
|
|
661
|
+
const shapes = this.diagramWidget.shapes.map(shp => shp.bounds());
|
|
662
|
+
const pos = placeTooltip({
|
|
663
|
+
hovered: event.item,
|
|
664
|
+
mouse: event.point,
|
|
665
|
+
shapes: shapes,
|
|
666
|
+
connections: lines,
|
|
667
|
+
diagramRect: diagramRect,
|
|
668
|
+
zoom: zoom,
|
|
669
|
+
pan: pan,
|
|
670
|
+
tooltipSize: { width: popupElementRect.width, height: popupElementRect.height },
|
|
671
|
+
viewportBounds: new DOMRect(0, 0, win.innerWidth, win.innerHeight)
|
|
672
|
+
});
|
|
673
|
+
this.tooltipPopup.popup.instance.offset = { left: pos.left + win.scrollX, top: pos.top + win.scrollY };
|
|
674
|
+
this.tooltipShow.emit({ ...this.dataItem });
|
|
675
|
+
}
|
|
676
|
+
popupClass(isShape, dataItem) {
|
|
677
|
+
const defaultCssClass = isShape
|
|
678
|
+
? this.options.shapeDefaults?.tooltip?.cssClass
|
|
679
|
+
: this.options.connectionDefaults?.tooltip?.cssClass;
|
|
680
|
+
const itemCssClass = dataItem.tooltip?.cssClass;
|
|
681
|
+
const popupClass = defaultCssClass || itemCssClass;
|
|
682
|
+
return popupClass;
|
|
683
|
+
}
|
|
684
|
+
setCustomTemplate(isShape, isConnection) {
|
|
685
|
+
this.customTemplate = null;
|
|
686
|
+
if (isShape && this.shapeTooltipTemplate) {
|
|
687
|
+
this.customTemplate = this.shapeTooltipTemplate.templateRef;
|
|
688
|
+
}
|
|
689
|
+
if (isConnection && this.connectionTooltipTemplate) {
|
|
690
|
+
this.customTemplate = this.connectionTooltipTemplate.templateRef;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Handles the tooltipHide event from the diagram widget.
|
|
695
|
+
*/
|
|
696
|
+
handleTooltipHide() {
|
|
697
|
+
this.hideTooltip();
|
|
698
|
+
this.tooltipHide.emit({ ...this.dataItem });
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Hides the current tooltip and cleans up resources.
|
|
702
|
+
*/
|
|
703
|
+
hideTooltip() {
|
|
704
|
+
if (this.tooltipPopup) {
|
|
705
|
+
this.tooltipPopup.close();
|
|
706
|
+
this.tooltipPopup = undefined;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
567
709
|
activeEmitter(name) {
|
|
568
710
|
const emitter = this[name];
|
|
569
711
|
if (emitter?.emit && hasObservers(emitter)) {
|
|
570
712
|
return emitter;
|
|
571
713
|
}
|
|
572
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* Binds event handlers to the diagram widget.
|
|
717
|
+
*/
|
|
718
|
+
bindDiagramEvents() {
|
|
719
|
+
events.forEach((eventName) => {
|
|
720
|
+
this.diagramWidget.bind(eventName, (e) => {
|
|
721
|
+
if (eventName === 'click') {
|
|
722
|
+
eventName = 'diagramClick';
|
|
723
|
+
}
|
|
724
|
+
if (eventName === 'select') {
|
|
725
|
+
eventName = 'onSelect';
|
|
726
|
+
}
|
|
727
|
+
if (eventName === 'pan') {
|
|
728
|
+
eventName = 'onPan';
|
|
729
|
+
}
|
|
730
|
+
if (eventName === 'itemBoundsChange') {
|
|
731
|
+
eventName = 'shapeBoundsChange';
|
|
732
|
+
}
|
|
733
|
+
if (eventName === 'tooltipShow') {
|
|
734
|
+
this.zone.run(() => {
|
|
735
|
+
this.handleTooltipShow(e);
|
|
736
|
+
});
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
if (eventName === 'tooltipHide') {
|
|
740
|
+
this.zone.run(() => {
|
|
741
|
+
this.handleTooltipHide();
|
|
742
|
+
});
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
const emitter = this.activeEmitter(eventName);
|
|
746
|
+
if (emitter) {
|
|
747
|
+
this.zone.run(() => {
|
|
748
|
+
emitter.emit(e);
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Converts user data to Diagram model format using field mappings.
|
|
756
|
+
*/
|
|
757
|
+
convertUserData() {
|
|
758
|
+
if (this.shapeModelFields || this.connectionModelFields) {
|
|
759
|
+
const mapping = {
|
|
760
|
+
shapes: {
|
|
761
|
+
source: () => this.shapes || [],
|
|
762
|
+
map: this.createFieldMapping(this.shapeModelFields)
|
|
763
|
+
},
|
|
764
|
+
connections: {
|
|
765
|
+
source: () => this.connections || [],
|
|
766
|
+
map: this.createFieldMapping(this.connectionModelFields)
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
const result = convertToDiagramModel({ shapes: this.shapes, connections: this.options.connections }, mapping);
|
|
770
|
+
this.convertedShapes = this.addDataItemProperty(result.shapes, this.shapes);
|
|
771
|
+
this.convertedConnections = this.addDataItemProperty(result.connections, this.connections);
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
this.convertedShapes = this.addDataItemProperty(this.shapes, this.shapes);
|
|
775
|
+
this.convertedConnections = this.addDataItemProperty(this.connections, this.connections);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
addDataItemProperty(array, sourceArray) {
|
|
779
|
+
if (!array || !Array.isArray(array) || array.length === 0) {
|
|
780
|
+
return [];
|
|
781
|
+
}
|
|
782
|
+
if (!sourceArray || !Array.isArray(sourceArray)) {
|
|
783
|
+
return array;
|
|
784
|
+
}
|
|
785
|
+
return array.map((item, index) => ({
|
|
786
|
+
...item,
|
|
787
|
+
dataItem: sourceArray[index]
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Creates field mapping configuration from model fields.
|
|
792
|
+
*/
|
|
793
|
+
createFieldMapping(modelFields) {
|
|
794
|
+
if (!modelFields) {
|
|
795
|
+
return {};
|
|
796
|
+
}
|
|
797
|
+
const mapping = {};
|
|
798
|
+
Object.keys(modelFields).forEach(key => {
|
|
799
|
+
const fieldName = modelFields[key];
|
|
800
|
+
if (fieldName) {
|
|
801
|
+
mapping[key] = fieldName;
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
return mapping;
|
|
805
|
+
}
|
|
573
806
|
init() {
|
|
574
807
|
if (!isDocumentAvailable()) {
|
|
575
808
|
return;
|
|
@@ -589,10 +822,18 @@ export class DiagramComponent {
|
|
|
589
822
|
this.options[prop] = this[prop];
|
|
590
823
|
this.diagramWidget?.setOptions(this.options);
|
|
591
824
|
}
|
|
592
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
593
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: DiagramComponent, isStandalone: true, selector: "kendo-diagram", inputs: { connectionDefaults: "connectionDefaults", connections: "connections", editable: "editable", layout: "layout", pannable: "pannable", selectable: "selectable", shapeDefaults: "shapeDefaults", shapes: "shapes", zoom: "zoom", zoomMax: "zoomMax", zoomMin: "zoomMin", zoomRate: "zoomRate" }, outputs: { change: "change", diagramClick: "diagramClick", drag: "drag", dragEnd: "dragEnd", dragStart: "dragStart", shapeBoundsChange: "shapeBoundsChange", mouseEnter: "mouseEnter", mouseLeave: "mouseLeave", onPan: "pan", onSelect: "select", zoomEnd: "zoomEnd", zoomStart: "zoomStart" }, host: { properties: { "class.k-diagram": "this.diagramClass" } }, exportAs: ["kendoDiagram"], usesOnChanges: true, ngImport: i0, template: `
|
|
825
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i1.PopupService }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
826
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: DiagramComponent, isStandalone: true, selector: "kendo-diagram", inputs: { connectionDefaults: "connectionDefaults", connections: "connections", connectionModelFields: "connectionModelFields", editable: "editable", layout: "layout", pannable: "pannable", selectable: "selectable", shapeDefaults: "shapeDefaults", shapes: "shapes", shapeModelFields: "shapeModelFields", zoom: "zoom", zoomMax: "zoomMax", zoomMin: "zoomMin", zoomRate: "zoomRate" }, outputs: { change: "change", diagramClick: "diagramClick", drag: "drag", dragEnd: "dragEnd", dragStart: "dragStart", shapeBoundsChange: "shapeBoundsChange", mouseEnter: "mouseEnter", mouseLeave: "mouseLeave", onPan: "pan", onSelect: "select", zoomEnd: "zoomEnd", zoomStart: "zoomStart", tooltipShow: "tooltipShow", tooltipHide: "tooltipHide" }, host: { properties: { "class.k-diagram": "this.diagramClass" } }, providers: [PopupService], queries: [{ propertyName: "shapeTooltipTemplate", first: true, predicate: ShapeTooltipTemplateDirective, descendants: true }, { propertyName: "connectionTooltipTemplate", first: true, predicate: ConnectionTooltipTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "defaultTooltipTemplate", first: true, predicate: ["defaultTemplate"], descendants: true }, { propertyName: "customTooltipTemplate", first: true, predicate: ["customTooltipTemplate"], descendants: true }], exportAs: ["kendoDiagram"], usesOnChanges: true, ngImport: i0, template: `
|
|
594
827
|
<div kendoWatermarkOverlay *ngIf="showLicenseWatermark" [licenseMessage]="licenseMessage"></div>
|
|
595
|
-
|
|
828
|
+
|
|
829
|
+
<ng-template #customTooltipTemplate>
|
|
830
|
+
<ng-container [ngTemplateOutlet]="customTemplate" [ngTemplateOutletContext]="{ $implicit: dataItem }"></ng-container>
|
|
831
|
+
</ng-template>
|
|
832
|
+
|
|
833
|
+
<ng-template #defaultTemplate>
|
|
834
|
+
{{dataItem?.tooltipText}}
|
|
835
|
+
</ng-template>
|
|
836
|
+
`, isInline: true, dependencies: [{ kind: "component", type: WatermarkOverlayComponent, selector: "div[kendoWatermarkOverlay]", inputs: ["licenseMessage"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
596
837
|
}
|
|
597
838
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramComponent, decorators: [{
|
|
598
839
|
type: Component,
|
|
@@ -602,16 +843,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
602
843
|
selector: 'kendo-diagram',
|
|
603
844
|
template: `
|
|
604
845
|
<div kendoWatermarkOverlay *ngIf="showLicenseWatermark" [licenseMessage]="licenseMessage"></div>
|
|
846
|
+
|
|
847
|
+
<ng-template #customTooltipTemplate>
|
|
848
|
+
<ng-container [ngTemplateOutlet]="customTemplate" [ngTemplateOutletContext]="{ $implicit: dataItem }"></ng-container>
|
|
849
|
+
</ng-template>
|
|
850
|
+
|
|
851
|
+
<ng-template #defaultTemplate>
|
|
852
|
+
{{dataItem?.tooltipText}}
|
|
853
|
+
</ng-template>
|
|
605
854
|
`,
|
|
606
|
-
imports: [WatermarkOverlayComponent, NgIf]
|
|
855
|
+
imports: [WatermarkOverlayComponent, NgIf, NgTemplateOutlet, ShapeTooltipTemplateDirective, ConnectionTooltipTemplateDirective],
|
|
856
|
+
providers: [PopupService]
|
|
607
857
|
}]
|
|
608
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }], propDecorators: { diagramClass: [{
|
|
858
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i1.PopupService }, { type: i0.ViewContainerRef }], propDecorators: { diagramClass: [{
|
|
609
859
|
type: HostBinding,
|
|
610
860
|
args: ['class.k-diagram']
|
|
611
861
|
}], connectionDefaults: [{
|
|
612
862
|
type: Input
|
|
613
863
|
}], connections: [{
|
|
614
864
|
type: Input
|
|
865
|
+
}], connectionModelFields: [{
|
|
866
|
+
type: Input
|
|
615
867
|
}], editable: [{
|
|
616
868
|
type: Input
|
|
617
869
|
}], layout: [{
|
|
@@ -624,6 +876,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
624
876
|
type: Input
|
|
625
877
|
}], shapes: [{
|
|
626
878
|
type: Input
|
|
879
|
+
}], shapeModelFields: [{
|
|
880
|
+
type: Input
|
|
627
881
|
}], zoom: [{
|
|
628
882
|
type: Input
|
|
629
883
|
}], zoomMax: [{
|
|
@@ -658,4 +912,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
658
912
|
type: Output
|
|
659
913
|
}], zoomStart: [{
|
|
660
914
|
type: Output
|
|
915
|
+
}], tooltipShow: [{
|
|
916
|
+
type: Output
|
|
917
|
+
}], tooltipHide: [{
|
|
918
|
+
type: Output
|
|
919
|
+
}], defaultTooltipTemplate: [{
|
|
920
|
+
type: ViewChild,
|
|
921
|
+
args: ['defaultTemplate']
|
|
922
|
+
}], customTooltipTemplate: [{
|
|
923
|
+
type: ViewChild,
|
|
924
|
+
args: ['customTooltipTemplate']
|
|
925
|
+
}], shapeTooltipTemplate: [{
|
|
926
|
+
type: ContentChild,
|
|
927
|
+
args: [ShapeTooltipTemplateDirective]
|
|
928
|
+
}], connectionTooltipTemplate: [{
|
|
929
|
+
type: ContentChild,
|
|
930
|
+
args: [ConnectionTooltipTemplateDirective]
|
|
661
931
|
}] } });
|
|
@@ -6,6 +6,8 @@ import { NgModule } from '@angular/core';
|
|
|
6
6
|
import { KENDO_DIAGRAM } from './directives';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
import * as i1 from "./diagram.component";
|
|
9
|
+
import * as i2 from "./shape-tooltip-template.directive";
|
|
10
|
+
import * as i3 from "./connection-tooltip-template.directive";
|
|
9
11
|
/**
|
|
10
12
|
* Represents the [NgModule](link:site.data.urls.angular['ngmoduleapi'])
|
|
11
13
|
* definition for the Diagram component.
|
|
@@ -39,8 +41,8 @@ import * as i1 from "./diagram.component";
|
|
|
39
41
|
*/
|
|
40
42
|
export class DiagramModule {
|
|
41
43
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
42
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: DiagramModule, imports: [i1.DiagramComponent], exports: [i1.DiagramComponent] });
|
|
43
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramModule, imports: [
|
|
44
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: DiagramModule, imports: [i1.DiagramComponent, i2.ShapeTooltipTemplateDirective, i3.ConnectionTooltipTemplateDirective], exports: [i1.DiagramComponent, i2.ShapeTooltipTemplateDirective, i3.ConnectionTooltipTemplateDirective] });
|
|
45
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramModule, imports: [i1.DiagramComponent] });
|
|
44
46
|
}
|
|
45
47
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DiagramModule, decorators: [{
|
|
46
48
|
type: NgModule,
|