@tic-nova/ngx-interactive-org-chart 1.4.0
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.
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { AfterViewInit, OnDestroy, TemplateRef, ElementRef } from '@angular/core';
|
|
3
|
+
import { PanZoom } from 'panzoom';
|
|
4
|
+
|
|
5
|
+
interface OrgChartNode<T = unknown> {
|
|
6
|
+
readonly id?: string;
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
readonly data?: T;
|
|
9
|
+
readonly children?: OrgChartNode[];
|
|
10
|
+
readonly collapsed?: boolean;
|
|
11
|
+
readonly hidden?: boolean;
|
|
12
|
+
readonly nodeClass?: string;
|
|
13
|
+
readonly style?: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
readonly descendantsCount?: number;
|
|
17
|
+
}
|
|
18
|
+
interface OrgChartConfigTheme {
|
|
19
|
+
readonly node: {
|
|
20
|
+
readonly background: string;
|
|
21
|
+
readonly color: string;
|
|
22
|
+
readonly shadow: string;
|
|
23
|
+
readonly outlineColor: string;
|
|
24
|
+
readonly outlineWidth?: string;
|
|
25
|
+
readonly activeOutlineColor: string;
|
|
26
|
+
readonly highlightShadowColor: string;
|
|
27
|
+
readonly padding: string;
|
|
28
|
+
readonly borderRadius: string;
|
|
29
|
+
readonly activeColor: string;
|
|
30
|
+
readonly containerSpacing?: string;
|
|
31
|
+
readonly maxWidth: string;
|
|
32
|
+
readonly minWidth: string;
|
|
33
|
+
readonly maxHeight: string;
|
|
34
|
+
readonly minHeight: string;
|
|
35
|
+
readonly dragOverOutlineColor: string;
|
|
36
|
+
};
|
|
37
|
+
readonly connector: {
|
|
38
|
+
readonly color: string;
|
|
39
|
+
readonly activeColor: string;
|
|
40
|
+
readonly borderRadius: string;
|
|
41
|
+
readonly width: string;
|
|
42
|
+
};
|
|
43
|
+
readonly collapseButton: {
|
|
44
|
+
readonly size: string;
|
|
45
|
+
readonly borderColor: string;
|
|
46
|
+
readonly borderRadius: string;
|
|
47
|
+
readonly color: string;
|
|
48
|
+
readonly background: string;
|
|
49
|
+
readonly hoverColor: string;
|
|
50
|
+
readonly hoverBackground: string;
|
|
51
|
+
readonly hoverShadow: string;
|
|
52
|
+
readonly hoverTransformScale: string;
|
|
53
|
+
readonly focusOutline: string;
|
|
54
|
+
readonly countFontSize: string;
|
|
55
|
+
};
|
|
56
|
+
readonly container: {
|
|
57
|
+
readonly background: string;
|
|
58
|
+
readonly border: string;
|
|
59
|
+
};
|
|
60
|
+
readonly miniMap: {
|
|
61
|
+
readonly background: string;
|
|
62
|
+
readonly borderColor: string;
|
|
63
|
+
readonly borderRadius: string;
|
|
64
|
+
readonly shadow: string;
|
|
65
|
+
readonly nodeColor: string;
|
|
66
|
+
readonly viewportBackground: string;
|
|
67
|
+
readonly viewportBorderColor: string;
|
|
68
|
+
readonly viewportBorderWidth: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
type NgxInteractiveOrgChartTheme = DeepPartial<OrgChartConfigTheme>;
|
|
72
|
+
type NgxInteractiveOrgChartLayout = 'vertical' | 'horizontal';
|
|
73
|
+
interface OrgChartToggleNodeArgs<T> {
|
|
74
|
+
readonly node: OrgChartNode<T>;
|
|
75
|
+
readonly targetNode: string;
|
|
76
|
+
readonly collapse?: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface OrgChartDropNodeEventArgs<T> {
|
|
79
|
+
readonly draggedNode: OrgChartNode<T>;
|
|
80
|
+
readonly targetNode: OrgChartNode<T>;
|
|
81
|
+
}
|
|
82
|
+
type DeepPartial<T> = {
|
|
83
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
declare class NgxInteractiveOrgChart<T> implements AfterViewInit, OnDestroy {
|
|
87
|
+
#private;
|
|
88
|
+
/**
|
|
89
|
+
* Optional template for a custom node.
|
|
90
|
+
* When provided, this template will be used to render each node in the org chart.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* The template context includes:
|
|
94
|
+
* - `$implicit`: The node data
|
|
95
|
+
* - `node`: The node data (alternative accessor)
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```html
|
|
99
|
+
* <ngx-interactive-org-chart>
|
|
100
|
+
* <ng-template #nodeTemplate let-node="node">
|
|
101
|
+
* <div class="custom-node">
|
|
102
|
+
* <h3>{{ node.data?.name }}</h3>
|
|
103
|
+
* <p>{{ node.data?.age }}</p>
|
|
104
|
+
* </div>
|
|
105
|
+
* </ng-template>
|
|
106
|
+
* </ngx-interactive-org-chart>
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
protected readonly customNodeTemplate?: TemplateRef<unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* Optional template for a custom drag handle.
|
|
112
|
+
* When provided, only this element will be draggable instead of the entire node.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* The template context includes:
|
|
116
|
+
* - `$implicit`: The node data
|
|
117
|
+
* - `node`: The node data (alternative accessor)
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```html
|
|
121
|
+
* <ngx-interactive-org-chart [draggable]="true">
|
|
122
|
+
* <ng-template #dragHandleTemplate let-node="node">
|
|
123
|
+
* <button class="drag-handle" title="Drag to move">
|
|
124
|
+
* <svg><!-- Drag icon --></svg>
|
|
125
|
+
* </button>
|
|
126
|
+
* </ng-template>
|
|
127
|
+
* </ngx-interactive-org-chart>
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
protected readonly customDragHandleTemplate?: TemplateRef<unknown>;
|
|
131
|
+
protected readonly panZoomContainer: _angular_core.Signal<ElementRef<HTMLElement>>;
|
|
132
|
+
private readonly orgChartContainer;
|
|
133
|
+
private readonly container;
|
|
134
|
+
/**
|
|
135
|
+
* The data for the org chart.
|
|
136
|
+
*/
|
|
137
|
+
readonly data: _angular_core.InputSignal<OrgChartNode<T>>;
|
|
138
|
+
/**
|
|
139
|
+
* The initial zoom level for the chart.
|
|
140
|
+
*/
|
|
141
|
+
readonly initialZoom: _angular_core.InputSignal<number | undefined>;
|
|
142
|
+
/**
|
|
143
|
+
* The minimum zoom level for the chart
|
|
144
|
+
*/
|
|
145
|
+
readonly minZoom: _angular_core.InputSignal<number>;
|
|
146
|
+
/**
|
|
147
|
+
* The maximum zoom level for the chart.
|
|
148
|
+
*/
|
|
149
|
+
readonly maxZoom: _angular_core.InputSignal<number>;
|
|
150
|
+
/**
|
|
151
|
+
* The speed at which the chart zooms in/out on wheel or pinch.
|
|
152
|
+
*/
|
|
153
|
+
readonly zoomSpeed: _angular_core.InputSignal<number>;
|
|
154
|
+
/**
|
|
155
|
+
* The speed at which the chart zooms in/out on double-click.
|
|
156
|
+
*/
|
|
157
|
+
readonly zoomDoubleClickSpeed: _angular_core.InputSignal<number>;
|
|
158
|
+
/**
|
|
159
|
+
* Whether the nodes can be collapsed/expanded.
|
|
160
|
+
*/
|
|
161
|
+
readonly collapsible: _angular_core.InputSignal<boolean>;
|
|
162
|
+
/**
|
|
163
|
+
* The CSS class to apply to each node element.
|
|
164
|
+
*/
|
|
165
|
+
readonly nodeClass: _angular_core.InputSignal<string | undefined>;
|
|
166
|
+
/**
|
|
167
|
+
* If set to `true`, all the nodes will be initially collapsed.
|
|
168
|
+
*/
|
|
169
|
+
readonly initialCollapsed: _angular_core.InputSignal<boolean | undefined>;
|
|
170
|
+
/**
|
|
171
|
+
* Whether to enable RTL (right-to-left) layout.
|
|
172
|
+
*/
|
|
173
|
+
readonly isRtl: _angular_core.InputSignal<boolean | undefined>;
|
|
174
|
+
/**
|
|
175
|
+
* The layout direction of the org chart tree.
|
|
176
|
+
* - 'vertical': Traditional top-to-bottom tree layout
|
|
177
|
+
* - 'horizontal': Left-to-right tree layout
|
|
178
|
+
*/
|
|
179
|
+
readonly layout: _angular_core.InputSignal<NgxInteractiveOrgChartLayout>;
|
|
180
|
+
/**
|
|
181
|
+
* Whether to focus on the node when it is collapsed and focus on its children when it is expanded.
|
|
182
|
+
*/
|
|
183
|
+
readonly focusOnCollapseOrExpand: _angular_core.InputSignal<boolean>;
|
|
184
|
+
/**
|
|
185
|
+
* Whether to display the count of children for each node on expand/collapse button.
|
|
186
|
+
*/
|
|
187
|
+
readonly displayChildrenCount: _angular_core.InputSignal<boolean>;
|
|
188
|
+
/**
|
|
189
|
+
* The ratio of the node's width to the viewport's width when highlighting.
|
|
190
|
+
*/
|
|
191
|
+
readonly highlightZoomNodeWidthRatio: _angular_core.InputSignal<number>;
|
|
192
|
+
/**
|
|
193
|
+
* The ratio of the node's height to the viewport's height when highlighting.
|
|
194
|
+
*/
|
|
195
|
+
readonly highlightZoomNodeHeightRatio: _angular_core.InputSignal<number>;
|
|
196
|
+
/**
|
|
197
|
+
* Whether to enable drag and drop functionality for nodes.
|
|
198
|
+
* When enabled, nodes can be dragged and dropped onto other nodes.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* By default, the entire node is draggable. To use a custom drag handle instead,
|
|
202
|
+
* provide a `dragHandleTemplate` template with the selector `#dragHandleTemplate`.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```html
|
|
206
|
+
* <ngx-interactive-org-chart [draggable]="true">
|
|
207
|
+
* <!-- Custom drag handle template -->
|
|
208
|
+
* <ng-template #dragHandleTemplate let-node="node">
|
|
209
|
+
* <span class="drag-handle">⋮⋮</span>
|
|
210
|
+
* </ng-template>
|
|
211
|
+
* </ngx-interactive-org-chart>
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
readonly draggable: _angular_core.InputSignal<boolean>;
|
|
215
|
+
/**
|
|
216
|
+
* Predicate function to determine if a specific node can be dragged.
|
|
217
|
+
*
|
|
218
|
+
* @param node - The node to check
|
|
219
|
+
* @returns true if the node can be dragged, false otherwise
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* // Prevent CEO node from being dragged
|
|
224
|
+
* canDragNode = (node: OrgChartNode) => node.data?.role !== 'CEO';
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
readonly canDragNode: _angular_core.InputSignal<((node: OrgChartNode<T>) => boolean) | undefined>;
|
|
228
|
+
/**
|
|
229
|
+
* Predicate function to determine if a node can accept drops.
|
|
230
|
+
*
|
|
231
|
+
* @param draggedNode - The node being dragged
|
|
232
|
+
* @param targetNode - The potential drop target
|
|
233
|
+
* @returns true if the drop is allowed, false otherwise
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* // Don't allow employees to have subordinates
|
|
238
|
+
* canDropNode = (dragged: OrgChartNode, target: OrgChartNode) => {
|
|
239
|
+
* return target.data?.type !== 'Employee';
|
|
240
|
+
* };
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
readonly canDropNode: _angular_core.InputSignal<((draggedNode: OrgChartNode<T>, targetNode: OrgChartNode<T>) => boolean) | undefined>;
|
|
244
|
+
/**
|
|
245
|
+
* The distance in pixels from the viewport edge to trigger auto-panning during drag.
|
|
246
|
+
* The threshold is calculated automatically as 10% of the container dimensions for better responsiveness across different screen sizes.
|
|
247
|
+
* @default 0.1
|
|
248
|
+
*/
|
|
249
|
+
readonly dragEdgeThreshold: _angular_core.InputSignal<number>;
|
|
250
|
+
/**
|
|
251
|
+
* The speed of auto-panning in pixels per frame during drag.
|
|
252
|
+
* @default 15
|
|
253
|
+
*/
|
|
254
|
+
readonly dragAutoPanSpeed: _angular_core.InputSignal<number>;
|
|
255
|
+
/**
|
|
256
|
+
* The minimum zoom level for the chart when highlighting a node.
|
|
257
|
+
*/
|
|
258
|
+
readonly highlightZoomMinimum: _angular_core.InputSignal<number>;
|
|
259
|
+
/**
|
|
260
|
+
* The theme options for the org chart.
|
|
261
|
+
* This allows customization of the chart's appearance, including node styles, connector styles, and
|
|
262
|
+
* other visual elements.
|
|
263
|
+
*/
|
|
264
|
+
readonly themeOptions: _angular_core.InputSignal<{
|
|
265
|
+
readonly node?: {
|
|
266
|
+
readonly background?: string | undefined;
|
|
267
|
+
readonly color?: string | undefined;
|
|
268
|
+
readonly shadow?: string | undefined;
|
|
269
|
+
readonly outlineColor?: string | undefined;
|
|
270
|
+
readonly outlineWidth?: string | undefined;
|
|
271
|
+
readonly activeOutlineColor?: string | undefined;
|
|
272
|
+
readonly highlightShadowColor?: string | undefined;
|
|
273
|
+
readonly padding?: string | undefined;
|
|
274
|
+
readonly borderRadius?: string | undefined;
|
|
275
|
+
readonly activeColor?: string | undefined;
|
|
276
|
+
readonly containerSpacing?: string | undefined;
|
|
277
|
+
readonly maxWidth?: string | undefined;
|
|
278
|
+
readonly minWidth?: string | undefined;
|
|
279
|
+
readonly maxHeight?: string | undefined;
|
|
280
|
+
readonly minHeight?: string | undefined;
|
|
281
|
+
readonly dragOverOutlineColor?: string | undefined;
|
|
282
|
+
} | undefined;
|
|
283
|
+
readonly connector?: {
|
|
284
|
+
readonly color?: string | undefined;
|
|
285
|
+
readonly activeColor?: string | undefined;
|
|
286
|
+
readonly borderRadius?: string | undefined;
|
|
287
|
+
readonly width?: string | undefined;
|
|
288
|
+
} | undefined;
|
|
289
|
+
readonly collapseButton?: {
|
|
290
|
+
readonly size?: string | undefined;
|
|
291
|
+
readonly borderColor?: string | undefined;
|
|
292
|
+
readonly borderRadius?: string | undefined;
|
|
293
|
+
readonly color?: string | undefined;
|
|
294
|
+
readonly background?: string | undefined;
|
|
295
|
+
readonly hoverColor?: string | undefined;
|
|
296
|
+
readonly hoverBackground?: string | undefined;
|
|
297
|
+
readonly hoverShadow?: string | undefined;
|
|
298
|
+
readonly hoverTransformScale?: string | undefined;
|
|
299
|
+
readonly focusOutline?: string | undefined;
|
|
300
|
+
readonly countFontSize?: string | undefined;
|
|
301
|
+
} | undefined;
|
|
302
|
+
readonly container?: {
|
|
303
|
+
readonly background?: string | undefined;
|
|
304
|
+
readonly border?: string | undefined;
|
|
305
|
+
} | undefined;
|
|
306
|
+
readonly miniMap?: {
|
|
307
|
+
readonly background?: string | undefined;
|
|
308
|
+
readonly borderColor?: string | undefined;
|
|
309
|
+
readonly borderRadius?: string | undefined;
|
|
310
|
+
readonly shadow?: string | undefined;
|
|
311
|
+
readonly nodeColor?: string | undefined;
|
|
312
|
+
readonly viewportBackground?: string | undefined;
|
|
313
|
+
readonly viewportBorderColor?: string | undefined;
|
|
314
|
+
readonly viewportBorderWidth?: string | undefined;
|
|
315
|
+
} | undefined;
|
|
316
|
+
} | undefined>;
|
|
317
|
+
/**
|
|
318
|
+
* Whether to show the mini map navigation tool.
|
|
319
|
+
* @default false
|
|
320
|
+
*/
|
|
321
|
+
readonly showMiniMap: _angular_core.InputSignal<boolean>;
|
|
322
|
+
/**
|
|
323
|
+
* Position of the mini map on the screen.
|
|
324
|
+
* @default 'bottom-right'
|
|
325
|
+
*/
|
|
326
|
+
readonly miniMapPosition: _angular_core.InputSignal<"top-left" | "top-right" | "bottom-left" | "bottom-right">;
|
|
327
|
+
/**
|
|
328
|
+
* Width of the mini map in pixels.
|
|
329
|
+
* @default 200
|
|
330
|
+
*/
|
|
331
|
+
readonly miniMapWidth: _angular_core.InputSignal<number>;
|
|
332
|
+
/**
|
|
333
|
+
* Height of the mini map in pixels.
|
|
334
|
+
* @default 150
|
|
335
|
+
*/
|
|
336
|
+
readonly miniMapHeight: _angular_core.InputSignal<number>;
|
|
337
|
+
/**
|
|
338
|
+
* Event emitted when a node is dropped onto another node.
|
|
339
|
+
* Provides the dragged node and the target node.
|
|
340
|
+
*/
|
|
341
|
+
readonly nodeDrop: _angular_core.OutputEmitterRef<OrgChartDropNodeEventArgs<T>>;
|
|
342
|
+
/**
|
|
343
|
+
* Event emitted when a node drag operation starts.
|
|
344
|
+
*/
|
|
345
|
+
readonly nodeDragStart: _angular_core.OutputEmitterRef<OrgChartNode<T>>;
|
|
346
|
+
/**
|
|
347
|
+
* Event emitted when a node drag operation ends.
|
|
348
|
+
*/
|
|
349
|
+
readonly nodeDragEnd: _angular_core.OutputEmitterRef<OrgChartNode<T>>;
|
|
350
|
+
private readonly defaultThemeOptions;
|
|
351
|
+
protected readonly finalThemeOptions: _angular_core.Signal<{
|
|
352
|
+
readonly node?: {
|
|
353
|
+
readonly background?: string | undefined;
|
|
354
|
+
readonly color?: string | undefined;
|
|
355
|
+
readonly shadow?: string | undefined;
|
|
356
|
+
readonly outlineColor?: string | undefined;
|
|
357
|
+
readonly outlineWidth?: string | undefined;
|
|
358
|
+
readonly activeOutlineColor?: string | undefined;
|
|
359
|
+
readonly highlightShadowColor?: string | undefined;
|
|
360
|
+
readonly padding?: string | undefined;
|
|
361
|
+
readonly borderRadius?: string | undefined;
|
|
362
|
+
readonly activeColor?: string | undefined;
|
|
363
|
+
readonly containerSpacing?: string | undefined;
|
|
364
|
+
readonly maxWidth?: string | undefined;
|
|
365
|
+
readonly minWidth?: string | undefined;
|
|
366
|
+
readonly maxHeight?: string | undefined;
|
|
367
|
+
readonly minHeight?: string | undefined;
|
|
368
|
+
readonly dragOverOutlineColor?: string | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
readonly connector?: {
|
|
371
|
+
readonly color?: string | undefined;
|
|
372
|
+
readonly activeColor?: string | undefined;
|
|
373
|
+
readonly borderRadius?: string | undefined;
|
|
374
|
+
readonly width?: string | undefined;
|
|
375
|
+
} | undefined;
|
|
376
|
+
readonly collapseButton?: {
|
|
377
|
+
readonly size?: string | undefined;
|
|
378
|
+
readonly borderColor?: string | undefined;
|
|
379
|
+
readonly borderRadius?: string | undefined;
|
|
380
|
+
readonly color?: string | undefined;
|
|
381
|
+
readonly background?: string | undefined;
|
|
382
|
+
readonly hoverColor?: string | undefined;
|
|
383
|
+
readonly hoverBackground?: string | undefined;
|
|
384
|
+
readonly hoverShadow?: string | undefined;
|
|
385
|
+
readonly hoverTransformScale?: string | undefined;
|
|
386
|
+
readonly focusOutline?: string | undefined;
|
|
387
|
+
readonly countFontSize?: string | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
readonly container?: {
|
|
390
|
+
readonly background?: string | undefined;
|
|
391
|
+
readonly border?: string | undefined;
|
|
392
|
+
} | undefined;
|
|
393
|
+
readonly miniMap?: {
|
|
394
|
+
readonly background?: string | undefined;
|
|
395
|
+
readonly borderColor?: string | undefined;
|
|
396
|
+
readonly borderRadius?: string | undefined;
|
|
397
|
+
readonly shadow?: string | undefined;
|
|
398
|
+
readonly nodeColor?: string | undefined;
|
|
399
|
+
readonly viewportBackground?: string | undefined;
|
|
400
|
+
readonly viewportBorderColor?: string | undefined;
|
|
401
|
+
readonly viewportBorderWidth?: string | undefined;
|
|
402
|
+
} | undefined;
|
|
403
|
+
}>;
|
|
404
|
+
protected readonly nodes: _angular_core.WritableSignal<OrgChartNode<T> | null>;
|
|
405
|
+
protected readonly scale: _angular_core.WritableSignal<number>;
|
|
406
|
+
protected readonly draggedNode: _angular_core.WritableSignal<OrgChartNode<T> | null>;
|
|
407
|
+
protected readonly dragOverNode: _angular_core.WritableSignal<OrgChartNode<T> | null>;
|
|
408
|
+
private readonly currentDragOverElement;
|
|
409
|
+
private autoPanInterval;
|
|
410
|
+
private keyboardListener;
|
|
411
|
+
private touchDragState;
|
|
412
|
+
protected panZoomInstance: PanZoom | null;
|
|
413
|
+
protected readonly containerElement: _angular_core.Signal<HTMLElement | null>;
|
|
414
|
+
/**
|
|
415
|
+
* A computed property that returns the current scale of the org chart.
|
|
416
|
+
* @returns {number} The current scale of the org chart.
|
|
417
|
+
*/
|
|
418
|
+
readonly getScale: _angular_core.Signal<number>;
|
|
419
|
+
/**
|
|
420
|
+
* A computed property that flattens the org chart nodes into a single array.
|
|
421
|
+
* It recursively traverses the nodes and their children, returning a flat array of OrgChartNode<T>.
|
|
422
|
+
* This is useful for operations that require a single list of all nodes, such as searching or displaying all nodes in a list.
|
|
423
|
+
* @returns {OrgChartNode<T>[]} An array of all nodes in the org chart, flattened from the hierarchical structure.
|
|
424
|
+
*/
|
|
425
|
+
readonly flattenedNodes: _angular_core.Signal<OrgChartNode<T>[]>;
|
|
426
|
+
private readonly setNodes;
|
|
427
|
+
ngAfterViewInit(): void;
|
|
428
|
+
/**
|
|
429
|
+
* Initializes the pan-zoom functionality for the org chart.
|
|
430
|
+
* This method creates a new panZoom instance and sets it up with the container element.
|
|
431
|
+
* It also ensures that any existing panZoom instance is disposed of before creating a new one.
|
|
432
|
+
*/
|
|
433
|
+
initiatePanZoom(): void;
|
|
434
|
+
/**
|
|
435
|
+
* Zooms in of the org chart.
|
|
436
|
+
* @param {Object} options - Options for zooming.
|
|
437
|
+
* @param {number} [options.by=10] - The percentage to zoom in or out by.
|
|
438
|
+
* @param {boolean} [options.relative=true] - Whether to zoom relative to the current zoom level.
|
|
439
|
+
* If true, zooms in by a percentage of the current zoom level.
|
|
440
|
+
* If false, zooms to an absolute scale.
|
|
441
|
+
*/
|
|
442
|
+
zoomIn({ by, relative }?: {
|
|
443
|
+
by?: number;
|
|
444
|
+
relative?: boolean;
|
|
445
|
+
}): void;
|
|
446
|
+
/**
|
|
447
|
+
* Zooms out of the org chart.
|
|
448
|
+
* @param {Object} options - Options for zooming.
|
|
449
|
+
* @param {number} [options.by=10] - The percentage to zoom in or out by.
|
|
450
|
+
* @param {boolean} [options.relative=true] - Whether to zoom relative to the current zoom level.
|
|
451
|
+
* If true, zooms out by a percentage of the current zoom level.
|
|
452
|
+
* If false, zooms to an absolute scale.
|
|
453
|
+
*/
|
|
454
|
+
zoomOut({ by, relative }?: {
|
|
455
|
+
by?: number;
|
|
456
|
+
relative?: boolean;
|
|
457
|
+
}): void;
|
|
458
|
+
/**
|
|
459
|
+
* Highlights a specific node in the org chart and pans to it.
|
|
460
|
+
* @param {string} nodeId - The ID of the node to highlight.
|
|
461
|
+
*/
|
|
462
|
+
highlightNode(nodeId: string | number): void;
|
|
463
|
+
/**
|
|
464
|
+
* Pans the view of the org chart.
|
|
465
|
+
* @param x The horizontal offset to pan to.
|
|
466
|
+
* @param y The vertical offset to pan to.
|
|
467
|
+
* @param smooth Whether to animate the panning.
|
|
468
|
+
* @returns void
|
|
469
|
+
*/
|
|
470
|
+
pan(x: number, y: number, smooth: boolean): void;
|
|
471
|
+
/**
|
|
472
|
+
* Resets the pan position of the org chart to center it horizontally and vertically.
|
|
473
|
+
* This method calculates the center position based on the container's dimensions
|
|
474
|
+
* and the hosting element's dimensions, then moves the panZoom instance to that position.
|
|
475
|
+
*/
|
|
476
|
+
resetPan(): void;
|
|
477
|
+
/**
|
|
478
|
+
* Resets the zoom level of the org chart to fit the content within the container.
|
|
479
|
+
* This method calculates the optimal scale to fit the content and applies it.
|
|
480
|
+
* @param {number} [padding=20] - Optional padding around the content when calculating the fit scale.
|
|
481
|
+
*/
|
|
482
|
+
resetZoom(padding?: number): void;
|
|
483
|
+
/**
|
|
484
|
+
* Resets both the pan position and zoom level of the org chart.
|
|
485
|
+
* This method first resets the pan position, then resets the zoom level after a short delay.
|
|
486
|
+
* @param {number} [padding=20] - Optional padding around the content when calculating the fit scale.
|
|
487
|
+
*/
|
|
488
|
+
resetPanAndZoom(padding?: number): void;
|
|
489
|
+
/**
|
|
490
|
+
* Toggles the collapse state of all nodes in the org chart.
|
|
491
|
+
* If `collapse` is provided, it will collapse or expand all nodes accordingly.
|
|
492
|
+
* If not provided, it will toggle the current state of the root node.
|
|
493
|
+
*/
|
|
494
|
+
toggleCollapseAll(collapse?: boolean): void;
|
|
495
|
+
/**
|
|
496
|
+
* Toggles the collapse state of a specific node in the org chart.
|
|
497
|
+
* If `collapse` is provided, it will collapse or expand the node accordingly.
|
|
498
|
+
* If not provided, it will toggle the current state of the node.
|
|
499
|
+
* @param {Object} options - Options for toggling collapse.
|
|
500
|
+
* @param {OrgChartNode<T>} options.node - The node to toggle.
|
|
501
|
+
* @param {boolean} [options.collapse] - Whether to collapse or expand the node.
|
|
502
|
+
* @param {boolean} [options.highlightNode=false] - Whether to highlight the node after toggling.
|
|
503
|
+
* @param {boolean} [options.playAnimation=false] - Whether to play animation when highlighting.
|
|
504
|
+
*/
|
|
505
|
+
onToggleCollapse({ node, collapse, highlightNode, playAnimation, }: {
|
|
506
|
+
node: OrgChartNode<T>;
|
|
507
|
+
collapse?: boolean;
|
|
508
|
+
highlightNode?: boolean;
|
|
509
|
+
playAnimation?: boolean;
|
|
510
|
+
}): void;
|
|
511
|
+
protected zoom({ type, by, relative, }: {
|
|
512
|
+
type: 'in' | 'out';
|
|
513
|
+
by?: number;
|
|
514
|
+
relative?: boolean;
|
|
515
|
+
}): void;
|
|
516
|
+
protected panZoomToNode({ nodeElement, skipZoom, playAnimation, }: {
|
|
517
|
+
nodeElement: HTMLElement;
|
|
518
|
+
skipZoom?: boolean;
|
|
519
|
+
playAnimation?: boolean;
|
|
520
|
+
}): void;
|
|
521
|
+
protected getNodeId(nodeId: string | number): string;
|
|
522
|
+
protected getNodeChildrenId(nodeId: string | number): string;
|
|
523
|
+
/**
|
|
524
|
+
* Handles the drag start event for a node.
|
|
525
|
+
* @param event - The drag event
|
|
526
|
+
* @param node - The node being dragged
|
|
527
|
+
*/
|
|
528
|
+
protected onDragStart(event: DragEvent, node: OrgChartNode<T>): void;
|
|
529
|
+
/**
|
|
530
|
+
* Sets up keyboard event listener for drag cancellation.
|
|
531
|
+
*/
|
|
532
|
+
private setupKeyboardListener;
|
|
533
|
+
/**
|
|
534
|
+
* Removes the keyboard event listener.
|
|
535
|
+
*/
|
|
536
|
+
private removeKeyboardListener;
|
|
537
|
+
private cancelDrag;
|
|
538
|
+
/**
|
|
539
|
+
* Handles the drag end event for a node.
|
|
540
|
+
* @param event - The drag event
|
|
541
|
+
* @param node - The node that was being dragged
|
|
542
|
+
*/
|
|
543
|
+
protected onDragEnd(event: DragEvent, node: OrgChartNode<T>): void;
|
|
544
|
+
/**
|
|
545
|
+
* Handles the drag over event for a node.
|
|
546
|
+
* @param event - The drag event
|
|
547
|
+
* @param node - The node being dragged over
|
|
548
|
+
*/
|
|
549
|
+
protected onDragOver(event: DragEvent, node: OrgChartNode<T>): void;
|
|
550
|
+
/**
|
|
551
|
+
* Handles the drag over event on the container for auto-panning.
|
|
552
|
+
* @param event - The drag event
|
|
553
|
+
*/
|
|
554
|
+
protected onContainerDragOver(event: DragEvent): void;
|
|
555
|
+
/**
|
|
556
|
+
* Handles the drag enter event for a node.
|
|
557
|
+
* @param event - The drag event
|
|
558
|
+
* @param node - The node being entered
|
|
559
|
+
*/
|
|
560
|
+
protected onDragEnter(event: DragEvent, node: OrgChartNode<T>): void;
|
|
561
|
+
/**
|
|
562
|
+
* Handles the drag leave event for a node.
|
|
563
|
+
* @param event - The drag event
|
|
564
|
+
*/
|
|
565
|
+
protected onDragLeave(event: DragEvent): void;
|
|
566
|
+
/**
|
|
567
|
+
* Handles the drop event for a node.
|
|
568
|
+
* @param event - The drag event
|
|
569
|
+
* @param targetNode - The node where the drop occurred
|
|
570
|
+
*/
|
|
571
|
+
protected onDrop(event: DragEvent, targetNode: OrgChartNode<T>): void;
|
|
572
|
+
/**
|
|
573
|
+
* Checks if a node is a descendant of another node.
|
|
574
|
+
* @param node - The node to check
|
|
575
|
+
* @param potentialAncestor - The potential ancestor node
|
|
576
|
+
* @returns true if node is a descendant of potentialAncestor
|
|
577
|
+
*/
|
|
578
|
+
private isNodeDescendant;
|
|
579
|
+
/**
|
|
580
|
+
* Handles the touch start event for drag on mobile devices.
|
|
581
|
+
* @param event - The touch event
|
|
582
|
+
* @param node - The node being touched
|
|
583
|
+
*/
|
|
584
|
+
protected onTouchStart(event: TouchEvent, node: OrgChartNode<T>): void;
|
|
585
|
+
/**
|
|
586
|
+
* Handles touch move event during drag on mobile devices.
|
|
587
|
+
*/
|
|
588
|
+
private onTouchMoveDocument;
|
|
589
|
+
/**
|
|
590
|
+
* Handles touch end event during drag on mobile devices.
|
|
591
|
+
*/
|
|
592
|
+
private onTouchEndDocument;
|
|
593
|
+
/**
|
|
594
|
+
* Resets the touch drag state to its initial values.
|
|
595
|
+
*/
|
|
596
|
+
private resetTouchDragState;
|
|
597
|
+
/**
|
|
598
|
+
* Removes touch event listeners from the document.
|
|
599
|
+
*/
|
|
600
|
+
private removeTouchListeners;
|
|
601
|
+
/**
|
|
602
|
+
* Creates a ghost element to follow the touch during drag.
|
|
603
|
+
*/
|
|
604
|
+
private createTouchGhostElement;
|
|
605
|
+
/**
|
|
606
|
+
* Updates the position of the touch ghost element.
|
|
607
|
+
*/
|
|
608
|
+
private updateTouchGhostPosition;
|
|
609
|
+
/**
|
|
610
|
+
* Removes the touch ghost element.
|
|
611
|
+
*/
|
|
612
|
+
private removeTouchGhostElement;
|
|
613
|
+
/**
|
|
614
|
+
* Gets the element under a touch point.
|
|
615
|
+
*/
|
|
616
|
+
private getElementUnderTouch;
|
|
617
|
+
/**
|
|
618
|
+
* Handles touch drag over a node.
|
|
619
|
+
*/
|
|
620
|
+
private handleTouchDragOver;
|
|
621
|
+
/**
|
|
622
|
+
* Clears all drag-over visual states.
|
|
623
|
+
*/
|
|
624
|
+
private clearDragOverState;
|
|
625
|
+
/**
|
|
626
|
+
* Gets a node element by node data.
|
|
627
|
+
*/
|
|
628
|
+
private getNodeElement;
|
|
629
|
+
/**
|
|
630
|
+
* Gets node ID from a DOM element.
|
|
631
|
+
*/
|
|
632
|
+
private getNodeIdFromElement;
|
|
633
|
+
/**
|
|
634
|
+
* Finds a node by ID in the tree.
|
|
635
|
+
*/
|
|
636
|
+
private findNodeById;
|
|
637
|
+
/**
|
|
638
|
+
* Handles auto-panning during touch drag.
|
|
639
|
+
*/
|
|
640
|
+
private handleTouchAutoPan;
|
|
641
|
+
private handleAutoPan;
|
|
642
|
+
private startAutoPan;
|
|
643
|
+
private stopAutoPan;
|
|
644
|
+
private calculateScale;
|
|
645
|
+
private getFitScale;
|
|
646
|
+
/**
|
|
647
|
+
* Calculates the optimal zoom level for highlighting a specific node.
|
|
648
|
+
* The zoom is calculated to ensure the node is appropriately sized relative to the container,
|
|
649
|
+
* while respecting the minimum and maximum zoom constraints.
|
|
650
|
+
* @param {HTMLElement} nodeElement - The node element to calculate zoom for.
|
|
651
|
+
* @returns {number} The optimal zoom level for the node.
|
|
652
|
+
*/
|
|
653
|
+
private calculateOptimalZoom;
|
|
654
|
+
ngOnDestroy(): void;
|
|
655
|
+
/**
|
|
656
|
+
* Disables native dragging on child elements (images, SVGs, anchors) within nodes.
|
|
657
|
+
* This prevents child elements from interfering with the node's drag functionality.
|
|
658
|
+
* Called automatically via effect when nodes change.
|
|
659
|
+
*/
|
|
660
|
+
private disableChildDragging;
|
|
661
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxInteractiveOrgChart<any>, never>;
|
|
662
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgxInteractiveOrgChart<any>, "ngx-interactive-org-chart", never, { "data": { "alias": "data"; "required": true; "isSignal": true; }; "initialZoom": { "alias": "initialZoom"; "required": false; "isSignal": true; }; "minZoom": { "alias": "minZoom"; "required": false; "isSignal": true; }; "maxZoom": { "alias": "maxZoom"; "required": false; "isSignal": true; }; "zoomSpeed": { "alias": "zoomSpeed"; "required": false; "isSignal": true; }; "zoomDoubleClickSpeed": { "alias": "zoomDoubleClickSpeed"; "required": false; "isSignal": true; }; "collapsible": { "alias": "collapsible"; "required": false; "isSignal": true; }; "nodeClass": { "alias": "nodeClass"; "required": false; "isSignal": true; }; "initialCollapsed": { "alias": "initialCollapsed"; "required": false; "isSignal": true; }; "isRtl": { "alias": "isRtl"; "required": false; "isSignal": true; }; "layout": { "alias": "layout"; "required": false; "isSignal": true; }; "focusOnCollapseOrExpand": { "alias": "focusOnCollapseOrExpand"; "required": false; "isSignal": true; }; "displayChildrenCount": { "alias": "displayChildrenCount"; "required": false; "isSignal": true; }; "highlightZoomNodeWidthRatio": { "alias": "highlightZoomNodeWidthRatio"; "required": false; "isSignal": true; }; "highlightZoomNodeHeightRatio": { "alias": "highlightZoomNodeHeightRatio"; "required": false; "isSignal": true; }; "draggable": { "alias": "draggable"; "required": false; "isSignal": true; }; "canDragNode": { "alias": "canDragNode"; "required": false; "isSignal": true; }; "canDropNode": { "alias": "canDropNode"; "required": false; "isSignal": true; }; "dragEdgeThreshold": { "alias": "dragEdgeThreshold"; "required": false; "isSignal": true; }; "dragAutoPanSpeed": { "alias": "dragAutoPanSpeed"; "required": false; "isSignal": true; }; "highlightZoomMinimum": { "alias": "highlightZoomMinimum"; "required": false; "isSignal": true; }; "themeOptions": { "alias": "themeOptions"; "required": false; "isSignal": true; }; "showMiniMap": { "alias": "showMiniMap"; "required": false; "isSignal": true; }; "miniMapPosition": { "alias": "miniMapPosition"; "required": false; "isSignal": true; }; "miniMapWidth": { "alias": "miniMapWidth"; "required": false; "isSignal": true; }; "miniMapHeight": { "alias": "miniMapHeight"; "required": false; "isSignal": true; }; }, { "nodeDrop": "nodeDrop"; "nodeDragStart": "nodeDragStart"; "nodeDragEnd": "nodeDragEnd"; }, ["customNodeTemplate", "customDragHandleTemplate"], never, true, never>;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
type MiniMapPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
666
|
+
interface MiniMapTheme {
|
|
667
|
+
readonly background?: string;
|
|
668
|
+
readonly borderColor?: string;
|
|
669
|
+
readonly borderRadius?: string;
|
|
670
|
+
readonly shadow?: string;
|
|
671
|
+
readonly nodeColor?: string;
|
|
672
|
+
readonly viewportBackground?: string;
|
|
673
|
+
readonly viewportBorderColor?: string;
|
|
674
|
+
readonly viewportBorderWidth?: string;
|
|
675
|
+
}
|
|
676
|
+
declare class MiniMapComponent implements OnDestroy {
|
|
677
|
+
#private;
|
|
678
|
+
readonly panZoomInstance: _angular_core.InputSignal<PanZoom | null>;
|
|
679
|
+
readonly chartContainer: _angular_core.InputSignal<HTMLElement | null>;
|
|
680
|
+
readonly position: _angular_core.InputSignal<MiniMapPosition>;
|
|
681
|
+
readonly width: _angular_core.InputSignal<number>;
|
|
682
|
+
readonly height: _angular_core.InputSignal<number>;
|
|
683
|
+
readonly visible: _angular_core.InputSignal<boolean>;
|
|
684
|
+
readonly themeOptions: _angular_core.InputSignal<MiniMapTheme | undefined>;
|
|
685
|
+
readonly navigate: _angular_core.OutputEmitterRef<{
|
|
686
|
+
x: number;
|
|
687
|
+
y: number;
|
|
688
|
+
}>;
|
|
689
|
+
protected readonly canvasRef: _angular_core.Signal<ElementRef<HTMLCanvasElement> | undefined>;
|
|
690
|
+
protected readonly viewportRef: _angular_core.Signal<ElementRef<HTMLDivElement> | undefined>;
|
|
691
|
+
protected readonly viewportStyle: _angular_core.WritableSignal<Record<string, string>>;
|
|
692
|
+
protected readonly miniMapStyle: _angular_core.Signal<{
|
|
693
|
+
width: string;
|
|
694
|
+
height: string;
|
|
695
|
+
backgroundColor: string;
|
|
696
|
+
borderColor: string;
|
|
697
|
+
borderRadius: string;
|
|
698
|
+
boxShadow: string;
|
|
699
|
+
}>;
|
|
700
|
+
protected readonly viewportIndicatorStyle: _angular_core.Signal<{
|
|
701
|
+
backgroundColor: string;
|
|
702
|
+
borderColor: string;
|
|
703
|
+
borderWidth: string;
|
|
704
|
+
}>;
|
|
705
|
+
protected readonly nodeColor: _angular_core.Signal<string>;
|
|
706
|
+
constructor();
|
|
707
|
+
ngOnDestroy(): void;
|
|
708
|
+
protected onMouseDown(event: MouseEvent): void;
|
|
709
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MiniMapComponent, never>;
|
|
710
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MiniMapComponent, "ngx-org-chart-mini-map", never, { "panZoomInstance": { "alias": "panZoomInstance"; "required": true; "isSignal": true; }; "chartContainer": { "alias": "chartContainer"; "required": true; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "visible": { "alias": "visible"; "required": false; "isSignal": true; }; "themeOptions": { "alias": "themeOptions"; "required": false; "isSignal": true; }; }, { "navigate": "navigate"; }, never, never, true, never>;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Moves a node from its current position to become a child of a target node.
|
|
715
|
+
* This is a pure function that returns a new tree structure without modifying the original.
|
|
716
|
+
*
|
|
717
|
+
* @param rootNode - The root node of the tree
|
|
718
|
+
* @param draggedNodeId - The ID of the node to move
|
|
719
|
+
* @param targetNodeId - The ID of the node that will become the parent
|
|
720
|
+
* @returns A new tree structure with the node moved, or null if the operation fails
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const updatedTree = moveNode(currentTree, '5', '3');
|
|
725
|
+
* if (updatedTree) {
|
|
726
|
+
* this.data.set(updatedTree);
|
|
727
|
+
* }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
declare function moveNode<T>(rootNode: OrgChartNode<T>, draggedNodeId: string | number, targetNodeId: string | number): OrgChartNode<T> | null;
|
|
731
|
+
/**
|
|
732
|
+
* Finds a node in the tree by its ID.
|
|
733
|
+
*
|
|
734
|
+
* @param node - The node to search in
|
|
735
|
+
* @param nodeId - The ID of the node to find
|
|
736
|
+
* @returns The found node or null
|
|
737
|
+
*/
|
|
738
|
+
declare function findNode<T>(node: OrgChartNode<T>, nodeId: string | number): OrgChartNode<T> | null;
|
|
739
|
+
/**
|
|
740
|
+
* Checks if a node is a descendant of another node.
|
|
741
|
+
*
|
|
742
|
+
* @param node - The potential ancestor node
|
|
743
|
+
* @param descendantId - The ID of the potential descendant
|
|
744
|
+
* @returns true if the node with descendantId is a descendant of node
|
|
745
|
+
*/
|
|
746
|
+
declare function isNodeDescendant<T>(node: OrgChartNode<T>, descendantId: string | number): boolean;
|
|
747
|
+
/**
|
|
748
|
+
* Removes a node from the tree structure.
|
|
749
|
+
* Returns a new tree without the specified node.
|
|
750
|
+
*
|
|
751
|
+
* @param node - The root node to search in
|
|
752
|
+
* @param nodeIdToRemove - The ID of the node to remove
|
|
753
|
+
* @returns A new tree structure without the removed node
|
|
754
|
+
*/
|
|
755
|
+
declare function removeNode<T>(node: OrgChartNode<T>, nodeIdToRemove: string | number): OrgChartNode<T> | null;
|
|
756
|
+
/**
|
|
757
|
+
* Adds a node as a child of the target parent node.
|
|
758
|
+
* Returns a new tree structure with the node added.
|
|
759
|
+
*
|
|
760
|
+
* @param node - The root node to search in
|
|
761
|
+
* @param targetParentId - The ID of the node that will become the parent
|
|
762
|
+
* @param nodeToAdd - The node to add as a child
|
|
763
|
+
* @returns A new tree structure with the node added
|
|
764
|
+
*/
|
|
765
|
+
declare function addNodeToParent<T>(node: OrgChartNode<T>, targetParentId: string | number, nodeToAdd: OrgChartNode<T>): OrgChartNode<T> | null;
|
|
766
|
+
|
|
767
|
+
export { MiniMapComponent, NgxInteractiveOrgChart, addNodeToParent, findNode, isNodeDescendant, moveNode, removeNode };
|
|
768
|
+
export type { MiniMapPosition, MiniMapTheme, NgxInteractiveOrgChartLayout, NgxInteractiveOrgChartTheme, OrgChartDropNodeEventArgs, OrgChartNode, OrgChartToggleNodeArgs };
|