@neo4j-nvl/base 0.3.6-ade05d13 → 0.3.6-bc655308
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/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/modules/NvlController.d.ts +1 -0
- package/dist/types/modules/state.d.ts +27 -1
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +5 -5
- package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +0 -5
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +3 -2
- package/dist/types/renderers/canvasrenderer/util.d.ts +2 -2
- package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +1 -1
- package/dist/types/utils/ariaUtils.d.ts +3 -0
- package/dist/types/utils/ariaUtils.test.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +7 -2
- package/dist/types/utils/graphObjectUtils.d.ts +2 -1
- package/dist/types/utils/zoomFunctions.d.ts +32 -1
- package/package.json +2 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { CompatibilityError } from './utils/errors';
|
|
|
8
8
|
import type { Point } from './utils/geometry';
|
|
9
9
|
import type { HitTargetNode, HitTargetRelationship, HitTargets } from './utils/hittest';
|
|
10
10
|
import { nvlResultTransformer } from './utils/jsDriverResultTransformer';
|
|
11
|
+
import { getZoomTargetForNodePositions } from './utils/zoomFunctions';
|
|
11
12
|
/**
|
|
12
13
|
* Extends the MouseEvent interface with the {@link HitTargets} property.
|
|
13
14
|
* The result of a _.{@link NVL.getHits} call.
|
|
@@ -249,6 +250,8 @@ declare class NVL {
|
|
|
249
250
|
* @param {Node[]} data The positions that the nodes should be set to.
|
|
250
251
|
* @param {boolean} updateLayout whether or not the current layout algorithm
|
|
251
252
|
* should update the graph after setting the node positions.
|
|
253
|
+
* For node positions to be unaffected by layout algorithms, use the {@link FreeLayoutType}
|
|
254
|
+
* or use {@link pinNode} to pin the nodes that should remain still.
|
|
252
255
|
* False by default.
|
|
253
256
|
*/
|
|
254
257
|
setNodePositions(data: Node[], updateLayout?: boolean): void;
|
|
@@ -364,4 +367,4 @@ declare const colorMapperFunctions: {
|
|
|
364
367
|
};
|
|
365
368
|
export default NVL;
|
|
366
369
|
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
|
|
367
|
-
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand, nvlResultTransformer };
|
|
370
|
+
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
|
|
@@ -53,6 +53,7 @@ export default class NvlController {
|
|
|
53
53
|
private layoutDoneCallback;
|
|
54
54
|
private layoutComputingCallback;
|
|
55
55
|
private currentLayoutType;
|
|
56
|
+
private descriptionElement;
|
|
56
57
|
constructor(state: NvlState, options: NvlOptions);
|
|
57
58
|
private onWebGLContextLost;
|
|
58
59
|
private updateMinimapZoom;
|
|
@@ -23,6 +23,13 @@ export type BorderStyles = {
|
|
|
23
23
|
selected: BorderStyle;
|
|
24
24
|
default: BorderStyle;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export type DisabledItemStyles = {
|
|
30
|
+
color: string;
|
|
31
|
+
fontColor: string;
|
|
32
|
+
};
|
|
26
33
|
export declare const RelationshipBorderStyles: BorderStyles;
|
|
27
34
|
/** The default zoom level in a graph when not specified otherwise. */
|
|
28
35
|
export declare const DefaultZoomLevel = 0.75;
|
|
@@ -130,7 +137,12 @@ export interface NvlOptions {
|
|
|
130
137
|
* The DOM element in which to render the graph visualization
|
|
131
138
|
*/
|
|
132
139
|
frame?: HTMLElement;
|
|
133
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* The DOM container in which to render the minimap.
|
|
142
|
+
*
|
|
143
|
+
* @note When using a React ref, make sure the attached element is rendered before the NVL instance is created.
|
|
144
|
+
* Otherwise, the minimap will not be displayed.
|
|
145
|
+
*/
|
|
134
146
|
minimapContainer?: HTMLElement;
|
|
135
147
|
/** Configuration for the current layout */
|
|
136
148
|
layoutOptions?: LayoutOptions;
|
|
@@ -175,6 +187,10 @@ export interface NvlOptions {
|
|
|
175
187
|
nodeDefaultBorderColor?: string;
|
|
176
188
|
/** The color to use for the selected border of nodes */
|
|
177
189
|
selectedBorderColor?: string;
|
|
190
|
+
/** The color to use for the disabled nodes and relationships */
|
|
191
|
+
disabledItemColor?: string;
|
|
192
|
+
/** The color to use for the labels of the disabled nodes and relationships */
|
|
193
|
+
disabledItemFontColor?: string;
|
|
178
194
|
/**
|
|
179
195
|
* @internal
|
|
180
196
|
* Defines a time limit for how long layout iterations may run
|
|
@@ -185,6 +201,15 @@ export interface NvlOptions {
|
|
|
185
201
|
* @defaultValue false
|
|
186
202
|
*/
|
|
187
203
|
disableTelemetry?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Disables {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA | ARIA} attributes on the graph.
|
|
206
|
+
* By default, NVL adds ARIA attributes to the graph container to make it more accessible.
|
|
207
|
+
* Attributes include `role="image"`, `aria-label="Graph visualization"`
|
|
208
|
+
* and `aria-describedby="nvl-${instanceId}-description"`.
|
|
209
|
+
* The description element is a live region that will announce changes to the graph.
|
|
210
|
+
* @defaultValue false
|
|
211
|
+
*/
|
|
212
|
+
disableAria?: boolean;
|
|
188
213
|
}
|
|
189
214
|
/** Options that influence how fit-to-zoom should behave */
|
|
190
215
|
export type ZoomOptions = {
|
|
@@ -249,6 +274,7 @@ export interface NvlState {
|
|
|
249
274
|
reaction: Function;
|
|
250
275
|
nodeBorderStyles: BorderStyles;
|
|
251
276
|
relationshipBorderStyles: BorderStyles;
|
|
277
|
+
disabledItemStyles: DisabledItemStyles;
|
|
252
278
|
}
|
|
253
279
|
/**
|
|
254
280
|
* Create a new NVL state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BorderStyle } from '../../../modules/state';
|
|
1
|
+
import type { BorderStyle, DisabledItemStyles } from '../../../modules/state';
|
|
2
2
|
import type { Node, Relationship } from '../../../types/graph-element';
|
|
3
3
|
import type { Point } from '../../../utils/geometry';
|
|
4
4
|
import type ImageCache from '../ImageCache';
|
|
@@ -34,10 +34,10 @@ export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBund
|
|
|
34
34
|
* @param {Relationship} rel - the relationship
|
|
35
35
|
* @param {boolean} flip - whether to flip the label
|
|
36
36
|
*/
|
|
37
|
-
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, flip?: boolean) => void;
|
|
38
|
-
export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, drawCurves: boolean, selectedBorderStyle: BorderStyle) => void;
|
|
39
|
-
export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle) => void;
|
|
40
|
-
export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, drawCurves?: boolean) => void;
|
|
37
|
+
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, flip?: boolean) => void;
|
|
38
|
+
export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, drawCurves: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles) => void;
|
|
39
|
+
export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles) => void;
|
|
40
|
+
export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, drawCurves?: boolean) => void;
|
|
41
41
|
export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
|
|
42
42
|
/**
|
|
43
43
|
* Returns the bounding box of the arrow.
|
|
@@ -28,11 +28,6 @@ export declare const SelfRefHeight = 35;
|
|
|
28
28
|
export declare const SelfRefLabelMaxWidth = 40;
|
|
29
29
|
/** Width increase when a relationship is selected. */
|
|
30
30
|
export declare const SelectedWidthFactor = 1.5;
|
|
31
|
-
/** The style properties of a disabled relationship. */
|
|
32
|
-
export declare const Disabled: {
|
|
33
|
-
color: string;
|
|
34
|
-
fontColor: string;
|
|
35
|
-
};
|
|
36
31
|
/** The font styles for relationship captions. */
|
|
37
32
|
export declare const Font: {
|
|
38
33
|
size: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BorderStyles } from '../../../modules/state';
|
|
1
|
+
import type { BorderStyles, DisabledItemStyles } from '../../../modules/state';
|
|
2
2
|
import type { Node } from '../../../types/graph-element';
|
|
3
3
|
import type AnimationHandler from '../AnimationHandler';
|
|
4
4
|
type RingStyle = {
|
|
@@ -52,7 +52,8 @@ export declare const findMinLength: (lines: any[], ctx: CanvasRenderingContext2D
|
|
|
52
52
|
* @param imageCache {any} - The image cache to use.
|
|
53
53
|
* @param animationHandler {AnimationHandler} - The animation handler.
|
|
54
54
|
* @param nodeBorderStyles {BorderStyles} - The node border styles.
|
|
55
|
+
* @param disabledItemStyles {DisabledItemStyles} - The styles for the disabled items.
|
|
55
56
|
* @param zoomLevel {number} - The current zoom level.
|
|
56
57
|
*/
|
|
57
|
-
export declare const drawNode: (ctx: CanvasRenderingContext2D, node: Node, imageCache: any, animationHandler: AnimationHandler, nodeBorderStyles: BorderStyles, zoomLevel?: number) => void;
|
|
58
|
+
export declare const drawNode: (ctx: CanvasRenderingContext2D, node: Node, imageCache: any, animationHandler: AnimationHandler, nodeBorderStyles: BorderStyles, disabledItemStyles: DisabledItemStyles, ellipsisWidth?: number, zoomLevel?: number) => void;
|
|
58
59
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Point } from '../../utils/geometry';
|
|
2
2
|
import type { TextSegment } from './types';
|
|
3
|
-
export declare const fontThresholds: number
|
|
3
|
+
export declare const fontThresholds: [number, number][];
|
|
4
4
|
/**
|
|
5
5
|
* This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
|
|
6
6
|
* @param {string} color
|
|
@@ -65,5 +65,5 @@ export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
|
|
|
65
65
|
/**
|
|
66
66
|
* Prints the caption for a node
|
|
67
67
|
*/
|
|
68
|
-
export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number) => void;
|
|
68
|
+
export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number, ellipsisWidth: number) => void;
|
|
69
69
|
export {};
|
|
@@ -30,7 +30,7 @@ export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: st
|
|
|
30
30
|
*
|
|
31
31
|
* @return array of text lines
|
|
32
32
|
*/
|
|
33
|
-
export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean,
|
|
33
|
+
export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean, maxNoLines: number, align: string) => TextSegment[];
|
|
34
34
|
/**
|
|
35
35
|
* Returns the styles by char for a group of property values
|
|
36
36
|
* @param {array} captions = array of captions
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,9 +8,14 @@ export declare const VerletSimulationStopVelocity = 0.1;
|
|
|
8
8
|
export declare const MappingEnd = 999999;
|
|
9
9
|
export declare const ActiveAnimDuration = 1000;
|
|
10
10
|
export declare const DefaultNodeSize = 25;
|
|
11
|
-
export declare const DefaultNodeColor = "#
|
|
11
|
+
export declare const DefaultNodeColor = "#FFDF81";
|
|
12
|
+
export declare const DefaultRelColor = "#848484";
|
|
12
13
|
export declare const DefaultRelWidth = 1;
|
|
13
|
-
export declare const
|
|
14
|
+
export declare const DisabledItemColor = "#ededed";
|
|
15
|
+
export declare const DisabledItemFontColor = "#DDDDDD";
|
|
16
|
+
export declare const DefaultShadowColor = "#bbb";
|
|
17
|
+
export declare const DefaultSelectedInnerColor = "#fff";
|
|
18
|
+
export declare const DefaultSelectedOuterColor = "#8FE3E8";
|
|
14
19
|
export declare const absFillStyle: {
|
|
15
20
|
position: string;
|
|
16
21
|
top: number;
|
|
@@ -9,9 +9,10 @@ export type FlatRel = Omit<Relationship & {
|
|
|
9
9
|
* Falls back to default rel color when relationships between two nodes have varying colors.
|
|
10
10
|
* Sums widths of relationships when more than one relationship exists between two nodes.
|
|
11
11
|
* @param {Relationship[]} relItems List of all relationships and their connected ids.
|
|
12
|
+
* @param {string} [disabledItemColor] The color to use for the disabled relationships
|
|
12
13
|
* @return {FlatRel[]} A flattened list of relationships.
|
|
13
14
|
*/
|
|
14
|
-
export declare const relItemsToFlatList: (relItems: Relationship[]) => FlatRel[];
|
|
15
|
+
export declare const relItemsToFlatList: (relItems: Relationship[], disabledItemColor?: string) => FlatRel[];
|
|
15
16
|
export declare const getAdjNodesMapAndRelMap: (rels: Relationship[]) => {
|
|
16
17
|
adjNodesMap: Record<string, Set<string>>;
|
|
17
18
|
relMap: Record<string, Relationship[]>;
|
|
@@ -2,19 +2,50 @@ import type { Node } from '../index';
|
|
|
2
2
|
import type { Point } from './geometry';
|
|
3
3
|
declare const getExtremeLimits: (nodePositions: Point[]) => Point[];
|
|
4
4
|
declare const getMaxDistance: (extremeLimits?: Point[]) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Gets the center choordinates and the width and height for the given node positions
|
|
7
|
+
* @param {Point[] | Node[]} nodePositions - The node positions
|
|
8
|
+
* @param {number} maxNodeRadius - The maximum node radius
|
|
9
|
+
* @returns An object with the center x and y coordinates and the width and height
|
|
10
|
+
*/
|
|
5
11
|
declare const getPositionBoundaries: (nodePositions?: Point[] | Node[], maxNodeRadius?: number) => {
|
|
6
12
|
centerX: number;
|
|
7
13
|
centerY: number;
|
|
8
14
|
nodesWidth: number;
|
|
9
15
|
nodesHeight: number;
|
|
10
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Gets the required zoom level for the given view and scene dimensions to fit the scene into the view
|
|
19
|
+
* @param {number} viewWidth - The width of the required view
|
|
20
|
+
* @param {number} viewHeight - The height of the required view
|
|
21
|
+
* @param {number} sceneWidth - The width of the canvas scene
|
|
22
|
+
* @param {number} sceneHeight - The height of the canvas scene
|
|
23
|
+
* @returns An object with the zoom level for the x and y axis
|
|
24
|
+
*/
|
|
11
25
|
declare const getZoomLevel: (viewWidth: number, viewHeight: number, sceneWidth: number, sceneHeight: number) => {
|
|
12
26
|
zoomX: number;
|
|
13
27
|
zoomY: number;
|
|
14
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Creates a zoom target based on the given zoom levels and the min and max zoom level
|
|
31
|
+
* @param {number} zoomX - The zoom level for the x axis
|
|
32
|
+
* @param {number} zoomY - The zoom level for the y axis
|
|
33
|
+
* @param {number} minZoom - The minimum zoom level
|
|
34
|
+
* @param {number} maxZoom - The maximum zoom level
|
|
35
|
+
* @returns The zoom target
|
|
36
|
+
*/
|
|
15
37
|
declare const createZoomTarget: (zoomX: number, zoomY: number, minZoom?: number, maxZoom?: number) => number;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the zoom target to fit the given node positions into the scene
|
|
40
|
+
* @param {Point[]} nodePositions - The node positions
|
|
41
|
+
* @param {number} containerWidth - The width of the container NVL is displayed in
|
|
42
|
+
* @param {number} containerHeight - The height of the container NVL is displayed in
|
|
43
|
+
* @param {number} maxNodeRadius - The maximum node radius, which is added as margin to the scene (defaults to `50`)
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
declare const getZoomTargetForNodePositions: (nodePositions: Point[], containerWidth: number, containerHeight: number, maxNodeRadius?: number) => number;
|
|
16
47
|
declare const getFlexibleZoomLimit: (nodePositions: Point[], rect: HTMLCanvasElement, maxNodeRadius: number) => number;
|
|
17
48
|
declare const getNewZoomWithinLimits: (newZoom: number, oldZoom: number, minZoom: number, maxZoom: number) => number;
|
|
18
49
|
declare const isZoomOutAtLimit: (newZoom: number, oldZoom: number, zoomOutLimit: number) => boolean;
|
|
19
50
|
declare const getDynamicZoom: (nodePositions: Point[] & Node[], minZoom: number, maxZoom: number, rect: HTMLCanvasElement, newZoom: number, currentZoom: number) => number;
|
|
20
|
-
export { getFlexibleZoomLimit, isZoomOutAtLimit, getNewZoomWithinLimits, getExtremeLimits, getMaxDistance, getPositionBoundaries, getZoomLevel, createZoomTarget, getDynamicZoom };
|
|
51
|
+
export { getFlexibleZoomLimit, getZoomTargetForNodePositions, isZoomOutAtLimit, getNewZoomWithinLimits, getExtremeLimits, getMaxDistance, getPositionBoundaries, getZoomLevel, createZoomTarget, getDynamicZoom };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/base",
|
|
3
|
-
"version": "0.3.6-
|
|
3
|
+
"version": "0.3.6-bc655308",
|
|
4
4
|
"license": "SEE LICENSE IN 'LICENSE.txt'",
|
|
5
5
|
"homepage": "https://neo4j.com/docs/nvl/current/",
|
|
6
6
|
"description": "Base library for the Neo4j Visualization Library",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"postpack": "rm LICENSE.txt"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@neo4j-nvl/layout-workers": "0.3.6-
|
|
31
|
+
"@neo4j-nvl/layout-workers": "0.3.6-bc655308",
|
|
32
32
|
"@segment/analytics-next": "^1.70.0",
|
|
33
33
|
"color-string": "^1.9.1",
|
|
34
34
|
"d3-force": "^3.0.0",
|