458 lines
17 KiB
TypeScript
458 lines
17 KiB
TypeScript
import { HierarchyGraphDef, HierarchyGraphNodeDef, HierarchyGraphEdgeDef, HierarchyGraphOption, HierarchyGraphNodeInfo, HierarchyBaseNodeInfo, HierarchyBaseEdgeInfo, LayoutConfig } from 'dagre-compound';
|
|
import { NzSafeAny } from 'ng-zorro-antd/core/types';
|
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
import { Observable, ReplaySubject } from 'rxjs';
|
|
import * as i0 from '@angular/core';
|
|
import { EventEmitter, OnInit, TemplateRef, AfterViewInit, OnChanges, AfterContentChecked, QueryList, ElementRef, SimpleChanges, NgZone } from '@angular/core';
|
|
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
|
|
import { Selection } from 'd3-selection';
|
|
import { ZoomBehavior, ZoomTransform } from 'd3-zoom';
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
declare enum NzGraphEdgeType {
|
|
LINE = "line",
|
|
CURVE = "curve"
|
|
}
|
|
interface NzGraphDataDef extends HierarchyGraphDef {
|
|
nodes: NzGraphNodeDef[];
|
|
edges: NzGraphEdgeDef[];
|
|
}
|
|
interface NzGraphNodeDef extends HierarchyGraphNodeDef {
|
|
label?: string;
|
|
}
|
|
interface NzGraphEdgeDef extends HierarchyGraphEdgeDef {
|
|
label?: string;
|
|
}
|
|
interface NzGraphOption extends HierarchyGraphOption {
|
|
}
|
|
declare type NzRankDirection = 'TB' | 'BT' | 'LR' | 'RL';
|
|
interface NzGraphGroupNode extends HierarchyGraphNodeInfo {
|
|
nodes: Array<NzGraphNode | NzGraphGroupNode>;
|
|
edges: NzGraphEdge[];
|
|
[key: string]: NzSafeAny;
|
|
}
|
|
interface NzGraphNode extends HierarchyBaseNodeInfo {
|
|
id: NzSafeAny;
|
|
name: NzSafeAny;
|
|
label?: string;
|
|
[key: string]: NzSafeAny;
|
|
}
|
|
interface NzGraphEdge extends HierarchyBaseEdgeInfo {
|
|
id: NzSafeAny;
|
|
v: NzSafeAny;
|
|
w: NzSafeAny;
|
|
label?: string;
|
|
}
|
|
interface NzLayoutSetting extends LayoutConfig {
|
|
}
|
|
interface NzGraphBaseLayout {
|
|
layout: {
|
|
nodeSep: number;
|
|
rankSep: number;
|
|
edgeSep: number;
|
|
};
|
|
subScene: {
|
|
paddingTop: number;
|
|
paddingBottom: number;
|
|
paddingLeft: number;
|
|
paddingRight: number;
|
|
labelHeight: number;
|
|
};
|
|
defaultCompoundNode: {
|
|
width: number;
|
|
height: number;
|
|
maxLabelWidth: number;
|
|
};
|
|
defaultNode: {
|
|
width: number;
|
|
height: number;
|
|
labelOffset: number;
|
|
maxLabelWidth: number;
|
|
};
|
|
defaultEdge: {
|
|
type: NzGraphEdgeType | string;
|
|
};
|
|
}
|
|
declare function nzTypeDefinition<T>(): (item: unknown) => T;
|
|
type NzDeepPartial<T> = {
|
|
[P in keyof T]?: T[P] extends Array<infer U> ? Array<NzDeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<NzDeepPartial<U>> : NzDeepPartial<T[P]>;
|
|
};
|
|
type NzGraphLayoutConfig = NzDeepPartial<NzGraphBaseLayout>;
|
|
declare const NZ_GRAPH_LAYOUT_SETTING: NzLayoutSetting;
|
|
interface NzZoomTransform {
|
|
x: number;
|
|
y: number;
|
|
k: number;
|
|
}
|
|
interface RelativePositionInfo {
|
|
topLeft: {
|
|
x: number;
|
|
y: number;
|
|
};
|
|
bottomRight: {
|
|
x: number;
|
|
y: number;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
interface NzGraphBaseSource<T, K> {
|
|
/** The saved graph nodes data for `expandAll` action. */
|
|
dataSource: T;
|
|
/** The expansion model */
|
|
expansionModel: SelectionModel<K>;
|
|
/** Whether the data node is expanded or collapsed. Return true if it's expanded. */
|
|
isExpanded(dataNode: K): boolean;
|
|
/** Expand or collapse data node */
|
|
toggle(dataNode: K): void;
|
|
/** Expand one data node */
|
|
expand(dataNode: K): void;
|
|
/** Collapse one data node */
|
|
collapse(dataNode: K): void;
|
|
/** Expand all the dataNodes in the tree */
|
|
expandAll(): void;
|
|
/** Collapse all the dataNodes in the tree */
|
|
collapseAll(): void;
|
|
}
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
declare class NzGraphData implements NzGraphBaseSource<NzGraphDataDef, string> {
|
|
private _data;
|
|
dataSource: NzGraphDataDef;
|
|
/** A selection model with multi-selection to track expansion status. */
|
|
expansionModel: SelectionModel<string>;
|
|
/** Toggles one single data node's expanded/collapsed state. */
|
|
toggle(nodeName: string): void;
|
|
/** Expands one single data node. */
|
|
expand(nodeName: string): void;
|
|
/** Collapses one single data node. */
|
|
collapse(nodeName: string): void;
|
|
/** Whether a given data node is expanded or not. Returns true if the data node is expanded. */
|
|
isExpanded(nodeName: string): boolean;
|
|
/** Collapse all dataNodes in the tree. */
|
|
collapseAll(): void;
|
|
expandAll(): void;
|
|
setData(data: NzGraphDataDef): void;
|
|
constructor(source?: NzGraphDataDef);
|
|
connect(): Observable<NzGraphDataDef>;
|
|
disconnect(): void;
|
|
private findParents;
|
|
private findChildren;
|
|
}
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
/**
|
|
* https://angular.io/errors/NG3003
|
|
* An intermediate interface for {@link NzGraphComponent} & {@link NzGraphNodeComponent}
|
|
*/
|
|
declare abstract class NzGraph {
|
|
abstract nzNodeClick: EventEmitter<NzGraphNode | NzGraphGroupNode>;
|
|
}
|
|
|
|
interface Info {
|
|
x: number;
|
|
y: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
declare class NzGraphNodeComponent implements OnInit {
|
|
private readonly ngZone;
|
|
private readonly el;
|
|
private readonly builder;
|
|
private readonly renderer2;
|
|
private readonly graphComponent;
|
|
private readonly destroyRef;
|
|
node: NzGraphNode | NzGraphGroupNode;
|
|
noAnimation?: boolean;
|
|
customTemplate?: TemplateRef<{
|
|
$implicit: NzGraphNode | NzGraphGroupNode;
|
|
}>;
|
|
animationInfo: Info | null;
|
|
initialState: boolean;
|
|
private animationPlayer;
|
|
ngOnInit(): void;
|
|
makeAnimation(): Observable<void>;
|
|
makeNoAnimation(): void;
|
|
getAnimationInfo(): Info;
|
|
nodeTransform(): {
|
|
x: number;
|
|
y: number;
|
|
};
|
|
computeCXPositionOfNodeShape(): number;
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphNodeComponent, never>;
|
|
static ɵcmp: i0.ɵɵComponentDeclaration<NzGraphNodeComponent, "[nz-graph-node]", never, { "node": { "alias": "node"; "required": false; }; "noAnimation": { "alias": "noAnimation"; "required": false; }; "customTemplate": { "alias": "customTemplate"; "required": false; }; }, {}, never, never, true, never>;
|
|
static ngAcceptInputType_noAnimation: unknown;
|
|
}
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
declare class NzGraphZoomDirective implements AfterViewInit {
|
|
private destroyRef;
|
|
private cdr;
|
|
private element;
|
|
nzZoom?: number;
|
|
nzMinZoom: number;
|
|
nzMaxZoom: number;
|
|
readonly nzTransformEvent: EventEmitter<NzZoomTransform>;
|
|
readonly nzZoomChange: EventEmitter<number>;
|
|
svgSelection: Selection<NzSafeAny, NzSafeAny, NzSafeAny, NzSafeAny>;
|
|
zoomBehavior: ZoomBehavior<NzSafeAny, NzSafeAny>;
|
|
svgElement: SVGSVGElement;
|
|
gZoomElement: SVGGElement;
|
|
constructor();
|
|
ngAfterViewInit(): void;
|
|
bind(): void;
|
|
unbind(): void;
|
|
fitCenter(duration?: number): void;
|
|
focus(id: NzSafeAny, duration?: number): void;
|
|
/**
|
|
* Handle zoom event
|
|
*
|
|
* @param transform
|
|
*/
|
|
private zoomed;
|
|
/**
|
|
* Scale with zoom and duration
|
|
*
|
|
* @param duration
|
|
* @param scale
|
|
* @private
|
|
*/
|
|
private reScale;
|
|
private getRelativePositionInfo;
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphZoomDirective, never>;
|
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NzGraphZoomDirective, "[nz-graph-zoom]", ["nzGraphZoom"], { "nzZoom": { "alias": "nzZoom"; "required": false; }; "nzMinZoom": { "alias": "nzMinZoom"; "required": false; }; "nzMaxZoom": { "alias": "nzMaxZoom"; "required": false; }; }, { "nzTransformEvent": "nzTransformEvent"; "nzZoomChange": "nzZoomChange"; }, never, never, true, never>;
|
|
static ngAcceptInputType_nzZoom: unknown;
|
|
}
|
|
|
|
/** Checks whether an object is a data source. */
|
|
declare function isDataSource(value: NzSafeAny): value is NzGraphData;
|
|
declare class NzGraphComponent implements OnInit, OnChanges, AfterContentChecked, NzGraph {
|
|
private cdr;
|
|
private elementRef;
|
|
private destroyRef;
|
|
listOfNodeElement: QueryList<ElementRef>;
|
|
listOfNodeComponent: QueryList<NzGraphNodeComponent>;
|
|
nodeTemplate?: TemplateRef<{
|
|
$implicit: NzGraphNode;
|
|
}>;
|
|
groupNodeTemplate?: TemplateRef<{
|
|
$implicit: NzGraphGroupNode;
|
|
}>;
|
|
customGraphEdgeTemplate?: TemplateRef<{
|
|
$implicit: NzGraphEdge;
|
|
}>;
|
|
/**
|
|
* Provides a stream containing the latest data array to render.
|
|
* Data source can be an observable of NzGraphData, or a NzGraphData to render.
|
|
*/
|
|
nzGraphData: NzGraphData;
|
|
nzRankDirection: NzRankDirection;
|
|
nzGraphLayoutConfig?: NzGraphLayoutConfig;
|
|
nzAutoSize: boolean;
|
|
readonly nzGraphInitialized: EventEmitter<NzGraphComponent>;
|
|
readonly nzGraphRendered: EventEmitter<NzGraphComponent>;
|
|
readonly nzNodeClick: EventEmitter<NzGraphGroupNode | NzGraphNode>;
|
|
requestId: number;
|
|
transformStyle: string;
|
|
graphRenderedSubject$: ReplaySubject<void>;
|
|
renderInfo: NzGraphGroupNode;
|
|
mapOfNodeAttr: Record<string, NzGraphNodeDef>;
|
|
mapOfEdgeAttr: Record<string, NzGraphEdgeDef>;
|
|
zoom: number;
|
|
readonly typedNodes: (item: unknown) => (NzGraphGroupNode | NzGraphNode)[];
|
|
private dataSource?;
|
|
private layoutSetting;
|
|
/** Data subscription */
|
|
private _dataSubscription?;
|
|
edgeTrackByFun: (edge: NzGraphEdge) => string;
|
|
subGraphTransform: (node: NzGraphGroupNode) => string;
|
|
$asNzGraphEdges: (data: unknown) => NzGraphEdge[];
|
|
coreTransform: (node: NzGraphGroupNode) => string;
|
|
noAnimation: NzNoAnimationDirective | null;
|
|
nzGraphZoom: NzGraphZoomDirective | null;
|
|
constructor();
|
|
ngOnInit(): void;
|
|
ngOnChanges(changes: SimpleChanges): void;
|
|
ngAfterContentChecked(): void;
|
|
/**
|
|
* Move graph to center and scale automatically
|
|
*/
|
|
fitCenter(): void;
|
|
/**
|
|
* re-Draw graph
|
|
*
|
|
* @param data
|
|
* @param options
|
|
* @param needResize
|
|
*/
|
|
drawGraph(data: NzGraphDataDef, options: NzGraphOption, needResize?: boolean): Promise<void>;
|
|
/**
|
|
* Redraw all nodes
|
|
*
|
|
* @param animate
|
|
*/
|
|
drawNodes(animate?: boolean): Promise<void>;
|
|
private resizeNodeSize;
|
|
/**
|
|
* Switch to the provided data source by resetting the data and unsubscribing from the current
|
|
* render change subscription if one exists. If the data source is null, interpret this by
|
|
* clearing the node outlet. Otherwise start listening for new data.
|
|
*/
|
|
private _switchDataSource;
|
|
/** Set up a subscription for the data provided by the data source. */
|
|
private observeRenderChanges;
|
|
/**
|
|
* Get renderInfo and prepare some data
|
|
*
|
|
* @param data
|
|
* @param options
|
|
* @private
|
|
*/
|
|
private buildGraphInfo;
|
|
/**
|
|
* Play with animation
|
|
*
|
|
* @private
|
|
*/
|
|
private makeNodesAnimation;
|
|
private parseInfo;
|
|
/**
|
|
* Merge config with user inputs
|
|
*
|
|
* @param config
|
|
* @private
|
|
*/
|
|
private mergeConfig;
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphComponent, never>;
|
|
static ɵcmp: i0.ɵɵComponentDeclaration<NzGraphComponent, "nz-graph", ["nzGraph"], { "nzGraphData": { "alias": "nzGraphData"; "required": false; }; "nzRankDirection": { "alias": "nzRankDirection"; "required": false; }; "nzGraphLayoutConfig": { "alias": "nzGraphLayoutConfig"; "required": false; }; "nzAutoSize": { "alias": "nzAutoSize"; "required": false; }; }, { "nzGraphInitialized": "nzGraphInitialized"; "nzGraphRendered": "nzGraphRendered"; "nzNodeClick": "nzNodeClick"; }, ["nodeTemplate", "groupNodeTemplate", "customGraphEdgeTemplate"], ["*"], true, never>;
|
|
static ngAcceptInputType_nzAutoSize: unknown;
|
|
}
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
declare class Minimap {
|
|
private ngZone;
|
|
private svg;
|
|
private zoomG;
|
|
private mainZoom;
|
|
private minimap;
|
|
private maxWidth;
|
|
private labelPadding;
|
|
private canvas;
|
|
private canvasRect;
|
|
private canvasBuffer;
|
|
private minimapSvg;
|
|
private viewpoint;
|
|
private scaleMinimap;
|
|
private scaleMain;
|
|
private translate;
|
|
private viewpointCoord;
|
|
private minimapSize;
|
|
private unlisteners;
|
|
constructor(ngZone: NgZone, svg: SVGSVGElement, zoomG: SVGGElement, mainZoom: ZoomBehavior<NzSafeAny, NzSafeAny>, minimap: HTMLElement, maxWidth: number, labelPadding: number);
|
|
destroy(): void;
|
|
private minimapOffset;
|
|
private updateViewpoint;
|
|
update(): void;
|
|
/**
|
|
* Handles changes in zooming/panning. Should be called from the main svg
|
|
* to notify that a zoom/pan was performed, and this minimap will update its
|
|
* viewpoint rectangle.
|
|
*
|
|
* @param transform
|
|
*/
|
|
zoom(transform?: ZoomTransform | NzZoomTransform): void;
|
|
}
|
|
|
|
/**
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
|
|
*/
|
|
|
|
declare class NzGraphMinimapComponent {
|
|
private elementRef;
|
|
private ngZone;
|
|
private destroyRef;
|
|
minimap?: Minimap;
|
|
constructor();
|
|
init(containerEle: ElementRef, zoomBehavior: ZoomBehavior<NzSafeAny, NzSafeAny>): void;
|
|
zoom(transform: NzZoomTransform): void;
|
|
update(): void;
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphMinimapComponent, never>;
|
|
static ɵcmp: i0.ɵɵComponentDeclaration<NzGraphMinimapComponent, "nz-graph-minimap", never, {}, {}, never, never, true, never>;
|
|
}
|
|
|
|
declare class NzGraphDefsComponent {
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphDefsComponent, never>;
|
|
static ɵcmp: i0.ɵɵComponentDeclaration<NzGraphDefsComponent, "svg:defs[nz-graph-defs]", never, {}, {}, never, never, true, never>;
|
|
}
|
|
|
|
declare class NzGraphNodeDirective {
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphNodeDirective, never>;
|
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NzGraphNodeDirective, "[nzGraphNode]", ["nzGraphNode"], {}, {}, never, never, true, never>;
|
|
}
|
|
|
|
declare class NzGraphGroupNodeDirective {
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphGroupNodeDirective, never>;
|
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NzGraphGroupNodeDirective, "[nzGraphGroupNode]", ["nzGraphGroupNode"], {}, {}, never, never, true, never>;
|
|
}
|
|
|
|
declare class NzGraphEdgeComponent implements OnInit, OnChanges {
|
|
private injector;
|
|
private cdr;
|
|
edge: NzGraphEdge;
|
|
edgeType?: NzGraphEdgeType | string;
|
|
customTemplate?: TemplateRef<{
|
|
$implicit: NzGraphEdge;
|
|
}>;
|
|
get id(): string;
|
|
private el;
|
|
private path;
|
|
private line;
|
|
ngOnInit(): void;
|
|
ngOnChanges(changes: SimpleChanges): void;
|
|
initElementStyle(): void;
|
|
setLine(): void;
|
|
setPath(d: string): void;
|
|
setElementData(): void;
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphEdgeComponent, never>;
|
|
static ɵcmp: i0.ɵɵComponentDeclaration<NzGraphEdgeComponent, "[nz-graph-edge]", never, { "edge": { "alias": "edge"; "required": false; }; "edgeType": { "alias": "edgeType"; "required": false; }; "customTemplate": { "alias": "customTemplate"; "required": false; }; }, {}, never, never, true, never>;
|
|
}
|
|
|
|
declare class NzGraphEdgeDirective {
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphEdgeDirective, never>;
|
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NzGraphEdgeDirective, "[nzGraphEdge]", ["nzGraphEdge"], {}, {}, never, never, true, never>;
|
|
}
|
|
|
|
declare class NzGraphModule {
|
|
static ɵfac: i0.ɵɵFactoryDeclaration<NzGraphModule, never>;
|
|
static ɵmod: i0.ɵɵNgModuleDeclaration<NzGraphModule, never, [typeof NzGraphComponent, typeof NzGraphMinimapComponent, typeof NzGraphDefsComponent, typeof NzGraphNodeDirective, typeof NzGraphGroupNodeDirective, typeof NzGraphZoomDirective, typeof NzGraphNodeComponent, typeof NzGraphEdgeComponent, typeof NzGraphEdgeDirective], [typeof NzGraphComponent, typeof NzGraphMinimapComponent, typeof NzGraphDefsComponent, typeof NzGraphNodeDirective, typeof NzGraphGroupNodeDirective, typeof NzGraphZoomDirective, typeof NzGraphNodeComponent, typeof NzGraphEdgeComponent, typeof NzGraphEdgeDirective]>;
|
|
static ɵinj: i0.ɵɵInjectorDeclaration<NzGraphModule>;
|
|
}
|
|
|
|
export { NZ_GRAPH_LAYOUT_SETTING, NzGraphComponent, NzGraphData, NzGraphDefsComponent, NzGraphEdgeComponent, NzGraphEdgeDirective, NzGraphEdgeType, NzGraphGroupNodeDirective, NzGraphMinimapComponent, NzGraphModule, NzGraphNodeComponent, NzGraphNodeDirective, NzGraphZoomDirective, isDataSource, nzTypeDefinition };
|
|
export type { NzDeepPartial, NzGraphBaseLayout, NzGraphBaseSource, NzGraphDataDef, NzGraphEdge, NzGraphEdgeDef, NzGraphGroupNode, NzGraphLayoutConfig, NzGraphNode, NzGraphNodeDef, NzGraphOption, NzLayoutSetting, NzRankDirection, NzZoomTransform, RelativePositionInfo };
|