@neo4j-nvl/base 0.3.6-e7f05fb1 → 0.3.6-eb8dc47c

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.
@@ -250,6 +250,8 @@ declare class NVL {
250
250
  * @param {Node[]} data The positions that the nodes should be set to.
251
251
  * @param {boolean} updateLayout whether or not the current layout algorithm
252
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.
253
255
  * False by default.
254
256
  */
255
257
  setNodePositions(data: Node[], updateLayout?: boolean): void;
@@ -16,12 +16,12 @@ export declare class CoseBilkentLayout extends AnimatedLayout {
16
16
  computing: boolean;
17
17
  pendingLayoutData: LayoutData;
18
18
  worker: SharedWorker;
19
+ private workersDisabled;
19
20
  constructor(config: {
20
21
  state: NvlState;
21
22
  cytoCompleteCallback?: () => void;
22
23
  animationCompleteCallback?: () => void;
23
24
  });
24
- setupWorker(): Promise<SharedWorker>;
25
25
  setOptions(): void;
26
26
  update(refreshPositions?: boolean, updateMobXNodes?: Node[], updateMobXRelationships?: Relationship[]): void;
27
27
  getShouldUpdate(): boolean;
@@ -14,8 +14,8 @@ export declare class HierarchicalLayout extends AnimatedLayout {
14
14
  private worker;
15
15
  private directionChanged;
16
16
  private packingChanged;
17
+ private workersDisabled;
17
18
  constructor(config: HierarchicalLayoutConfig);
18
- setupWorker(): Promise<SharedWorker>;
19
19
  setOptions(options: LayoutOptions): void;
20
20
  update(refreshPositions?: boolean): void;
21
21
  getShouldUpdate(): boolean;
@@ -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
- /** The DOM container in which to render the minimap */
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;
@@ -159,6 +171,10 @@ export interface NvlOptions {
159
171
  * Whether or not to disable WebGL completely.
160
172
  */
161
173
  disableWebGL?: boolean;
174
+ /**
175
+ * Disables the use of {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers | web workers} for the layout calculations.
176
+ */
177
+ disableWebWorkers?: boolean;
162
178
  /**
163
179
  * @internal
164
180
  * Specify the log level.
@@ -175,6 +191,10 @@ export interface NvlOptions {
175
191
  nodeDefaultBorderColor?: string;
176
192
  /** The color to use for the selected border of nodes */
177
193
  selectedBorderColor?: string;
194
+ /** The color to use for the disabled nodes and relationships */
195
+ disabledItemColor?: string;
196
+ /** The color to use for the labels of the disabled nodes and relationships */
197
+ disabledItemFontColor?: string;
178
198
  /**
179
199
  * @internal
180
200
  * Defines a time limit for how long layout iterations may run
@@ -185,6 +205,15 @@ export interface NvlOptions {
185
205
  * @defaultValue false
186
206
  */
187
207
  disableTelemetry?: boolean;
208
+ /**
209
+ * Disables {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA | ARIA} attributes on the graph.
210
+ * By default, NVL adds ARIA attributes to the graph container to make it more accessible.
211
+ * Attributes include `role="image"`, `aria-label="Graph visualization"`
212
+ * and `aria-describedby="nvl-${instanceId}-description"`.
213
+ * The description element is a live region that will announce changes to the graph.
214
+ * @defaultValue false
215
+ */
216
+ disableAria?: boolean;
188
217
  }
189
218
  /** Options that influence how fit-to-zoom should behave */
190
219
  export type ZoomOptions = {
@@ -214,6 +243,7 @@ export interface NvlState {
214
243
  webGLVisible: boolean;
215
244
  renderer: Renderer;
216
245
  disableWebGL: boolean;
246
+ disableWebWorkers: boolean;
217
247
  disableTelemetry: boolean;
218
248
  fitMovement: number;
219
249
  layout: Layout;
@@ -249,6 +279,7 @@ export interface NvlState {
249
279
  reaction: Function;
250
280
  nodeBorderStyles: BorderStyles;
251
281
  relationshipBorderStyles: BorderStyles;
282
+ disabledItemStyles: DisabledItemStyles;
252
283
  }
253
284
  /**
254
285
  * Create a new NVL state
@@ -17,6 +17,7 @@ export default class CanvasRenderer {
17
17
  private nodeVersion;
18
18
  private relVersion;
19
19
  private waypointVersion;
20
+ private ellipsisWidth;
20
21
  /**
21
22
  * Creates a new CanvasRenderer.
22
23
  * @param canvas {HTMLCanvasElement} - The canvas to render on.
@@ -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, fontInfoLevel: number, align: string) => TextSegment[];
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,3 @@
1
+ import type { NvlState } from '../modules/state';
2
+ export declare const enrichWithAria: (canvasParent: HTMLElement, instanceId: string) => HTMLDivElement;
3
+ export declare const updateAriaDescription: (state: NvlState, descriptionElement: HTMLDivElement) => void;
@@ -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 = "#478BFF";
11
+ export declare const DefaultNodeColor = "#FFDF81";
12
+ export declare const DefaultRelColor = "#848484";
12
13
  export declare const DefaultRelWidth = 1;
13
- export declare const DisabledRelColor = "#ededed";
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[]>;
@@ -0,0 +1,3 @@
1
+ type Layouts = 'CoseBilkentLayout' | 'HierarchicalLayout';
2
+ export declare const initializeWorker: (workerName: Layouts, workersDisabled?: boolean) => SharedWorker;
3
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/base",
3
- "version": "0.3.6-e7f05fb1",
3
+ "version": "0.3.6-eb8dc47c",
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-e7f05fb1",
31
+ "@neo4j-nvl/layout-workers": "0.3.6-eb8dc47c",
32
32
  "@segment/analytics-next": "^1.70.0",
33
33
  "color-string": "^1.9.1",
34
34
  "d3-force": "^3.0.0",