@neo4j-nvl/base 0.3.6 → 0.3.7-6326e57d

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +1 -0
  3. package/dist/base.mjs +1 -1
  4. package/dist/types/index.d.ts +6 -3
  5. package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +1 -1
  6. package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +2 -2
  7. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +1 -1
  8. package/dist/types/layouts/freeLayout/FreeLayout.d.ts +1 -1
  9. package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +2 -2
  10. package/dist/types/layouts/hierarchicallayout/constants.d.ts +1 -1
  11. package/dist/types/modules/NvlController.d.ts +2 -1
  12. package/dist/types/modules/ZoomTransitionHandler.d.ts +1 -1
  13. package/dist/types/modules/state/constants.d.ts +9 -0
  14. package/dist/types/modules/state/state.d.ts +8 -0
  15. package/dist/types/modules/{state.d.ts → state/types.d.ts} +70 -16
  16. package/dist/types/modules/state/utils.d.ts +44 -0
  17. package/dist/types/modules/state/utils.test.d.ts +1 -0
  18. package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +2 -1
  19. package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +8 -5
  20. package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +1 -6
  21. package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +3 -2
  22. package/dist/types/renderers/canvasrenderer/util.d.ts +2 -2
  23. package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +1 -1
  24. package/dist/types/renderers/webglrenderer/Controller.d.ts +1 -1
  25. package/dist/types/renderers/webglrenderer/Renderer.d.ts +1 -1
  26. package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
  27. package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
  28. package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
  29. package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
  30. package/dist/types/utils/ariaUtils.d.ts +3 -0
  31. package/dist/types/utils/ariaUtils.test.d.ts +1 -0
  32. package/dist/types/utils/colorUtils.d.ts +14 -0
  33. package/dist/types/utils/colorUtils.test.d.ts +1 -0
  34. package/dist/types/utils/constants.d.ts +9 -2
  35. package/dist/types/utils/graphObjectUtils.d.ts +2 -1
  36. package/dist/types/utils/hittest.d.ts +1 -1
  37. package/dist/types/utils/webWorkerUtils.d.ts +3 -0
  38. package/dist/types/utils/webWorkerUtils.test.d.ts +1 -0
  39. package/dist/types/utils/zoomFunctions.d.ts +32 -1
  40. package/package.json +6 -5
  41. package/dist/types/utils/colorMapperFunctions.d.ts +0 -6
  42. /package/dist/types/modules/{state.test.d.ts → state/state.test.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
2
- import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state';
3
- import { CanvasRendererType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state';
2
+ import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state/types';
3
+ import { CanvasRendererType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
4
4
  import type { StyledCaption } from './renderers/canvasrenderer/types';
5
5
  import { drawCircleBand } from './renderers/canvasrenderer/util';
6
6
  import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
@@ -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 };
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../modules/state';
1
+ import type { NvlState } from '../../modules/state/types';
2
2
  import type { Node } from '../../types/graph-element';
3
3
  export default class AnimatedLayout {
4
4
  positions: Record<string, Node>;
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../../modules/state';
1
+ import type { NvlState } from '../../../modules/state/types';
2
2
  import type { Node, Relationship } from '../../../types/graph-element';
3
3
  import AnimatedLayout from '../../animatedlayout/AnimatedLayout';
4
4
  type LayoutData = {
@@ -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;
@@ -1,4 +1,4 @@
1
- import type { ForceDirectedOptions, NvlState } from '../../../modules/state';
1
+ import type { ForceDirectedOptions, NvlState } from '../../../modules/state/types';
2
2
  import type { Node, Relationship } from '../../../types/graph-element';
3
3
  import type { Point } from '../../../utils/geometry';
4
4
  export declare class PhysLayout {
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../modules/state';
1
+ import type { NvlState } from '../../modules/state/types';
2
2
  import type { Node } from '../../types/graph-element';
3
3
  import type { Point } from '../../utils/geometry';
4
4
  export declare class FreeLayout {
@@ -1,4 +1,4 @@
1
- import { type HierarchicalOptions, type LayoutOptions, type NvlState } from '../../modules/state';
1
+ import { type HierarchicalOptions, type LayoutOptions, type NvlState } from '../../modules/state/types';
2
2
  import AnimatedLayout from '../animatedlayout/AnimatedLayout';
3
3
  type HierarchicalLayoutConfig = {
4
4
  state: NvlState;
@@ -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;
@@ -1,4 +1,4 @@
1
- import type { HierarchicalOptions } from '../../modules/state';
1
+ import type { HierarchicalOptions } from '../../modules/state/types';
2
2
  export declare const Ranker = "tight-tree";
3
3
  export declare const SubGraphSpacing = 100;
4
4
  export declare const DirectionUp = "up";
@@ -2,7 +2,7 @@ import type { Node, Relationship } from '../types/graph-element';
2
2
  import '../types/nvl-window-functions';
3
3
  import type { Point } from '../utils/geometry';
4
4
  import type { ExternalCallbacks } from './ExternalCallbackHandler';
5
- import type { Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './state';
5
+ import type { Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './state/types';
6
6
  type SaveToFileOptions = {
7
7
  filename?: string;
8
8
  backgroundColor?: string;
@@ -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;
@@ -1,6 +1,6 @@
1
1
  import PIDController from 'node-pid-controller';
2
2
  import type { Node } from '../types/graph-element';
3
- import type { NvlState } from './state';
3
+ import type { NvlState } from './state/types';
4
4
  export default class ZoomTransitionHandler {
5
5
  xCtrl: PIDController;
6
6
  yCtrl: PIDController;
@@ -0,0 +1,9 @@
1
+ import type { BorderStyles, NvlState } from './types';
2
+ export declare const NodeBorderStyles: BorderStyles;
3
+ export declare const RelationshipBorderStyles: BorderStyles;
4
+ export declare const DefaultZoomLevel = 0.75;
5
+ export declare const DefaultMaxZoom = 10;
6
+ export declare const DefaultMinZoom = 0.075;
7
+ export declare const DefaultMinimapMaxZoom = 0.2;
8
+ export declare const DefaultMinimapMinZoom = 0;
9
+ export declare const DefaultZoomOptions: NvlState['zoomOptions'];
@@ -0,0 +1,8 @@
1
+ import type { NvlOptions, NvlState } from './types';
2
+ /**
3
+ * Create a new NVL state
4
+ *
5
+ * @param {NvlOptions} options - The options for the new state
6
+ * @returns {NvlState} - The state object
7
+ */
8
+ export declare const createState: (options: NvlOptions) => NvlState;
@@ -1,7 +1,7 @@
1
1
  import type { LogLevelDesc } from 'loglevel';
2
- import type { WaypointPath } from '../renderers/canvasrenderer/types';
3
- import type { ExternalCallbacks } from './ExternalCallbackHandler';
4
- import type { NodeDataSet, RelationshipDataSet } from './dataset';
2
+ import type { WaypointPath } from '../../renderers/canvasrenderer/types';
3
+ import type { ExternalCallbacks } from '../ExternalCallbackHandler';
4
+ import type { NodeDataSet, RelationshipDataSet } from '../dataset';
5
5
  type RingStyle = {
6
6
  width?: number;
7
7
  widthFactor?: number;
@@ -23,9 +23,13 @@ export type BorderStyles = {
23
23
  selected: BorderStyle;
24
24
  default: BorderStyle;
25
25
  };
26
- export declare const RelationshipBorderStyles: BorderStyles;
27
- /** The default zoom level in a graph when not specified otherwise. */
28
- export declare const DefaultZoomLevel = 0.75;
26
+ /**
27
+ * @internal
28
+ */
29
+ export type DisabledItemStyles = {
30
+ color: string;
31
+ fontColor: string;
32
+ };
29
33
  /**
30
34
  * The options for the force directed layout
31
35
  */
@@ -130,7 +134,12 @@ export interface NvlOptions {
130
134
  * The DOM element in which to render the graph visualization
131
135
  */
132
136
  frame?: HTMLElement;
133
- /** The DOM container in which to render the minimap */
137
+ /**
138
+ * The DOM container in which to render the minimap.
139
+ *
140
+ * @note When using a React ref, make sure the attached element is rendered before the NVL instance is created.
141
+ * Otherwise, the minimap will not be displayed.
142
+ */
134
143
  minimapContainer?: HTMLElement;
135
144
  /** Configuration for the current layout */
136
145
  layoutOptions?: LayoutOptions;
@@ -171,10 +180,44 @@ export interface NvlOptions {
171
180
  */
172
181
  relationshipThreshold?: number;
173
182
  callbacks?: ExternalCallbacks;
174
- /** The color to use for the default border of nodes */
183
+ styling?: {
184
+ defaultNodeColor?: string;
185
+ defaultRelationshipColor?: string;
186
+ /** The color to use for the default border of nodes */
187
+ nodeDefaultBorderColor?: string;
188
+ /** The color to use for the selected border of nodes and relationships */
189
+ selectedBorderColor?: string;
190
+ /** The color to use for the selected inner border of nodes and relationships */
191
+ selectedInnerBorderColor?: string;
192
+ /** The color to use for the drop shadow of selected/hovered nodes and relationships */
193
+ dropShadowColor?: 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;
198
+ /** The color to use for the viewport box in the minimap */
199
+ minimapViewportBoxColor?: string;
200
+ };
201
+ /**
202
+ * The color to use for the default border of nodes
203
+ * @deprecated Use {@link styling.nodeDefaultBorderColor} instead
204
+ */
175
205
  nodeDefaultBorderColor?: string;
176
- /** The color to use for the selected border of nodes */
206
+ /**
207
+ * The color to use for the selected border of nodes
208
+ * @deprecated Use {@link styling.selectedBorderColor} instead
209
+ */
177
210
  selectedBorderColor?: string;
211
+ /**
212
+ * The color to use for the disabled nodes and relationships
213
+ * @deprecated Use {@link styling.disabledItemColor} instead
214
+ */
215
+ disabledItemColor?: string;
216
+ /**
217
+ * The color to use for the labels of the disabled nodes and relationships
218
+ * @deprecated Use {@link styling.disabledItemFontColor} instead
219
+ */
220
+ disabledItemFontColor?: string;
178
221
  /**
179
222
  * @internal
180
223
  * Defines a time limit for how long layout iterations may run
@@ -185,6 +228,19 @@ export interface NvlOptions {
185
228
  * @defaultValue false
186
229
  */
187
230
  disableTelemetry?: boolean;
231
+ /**
232
+ * 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.
233
+ */
234
+ disableWebWorkers?: boolean;
235
+ /**
236
+ * Disables {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA | ARIA} attributes on the graph.
237
+ * By default, NVL adds ARIA attributes to the graph container to make it more accessible.
238
+ * Attributes include `role="image"`, `aria-label="Graph visualization"`
239
+ * and `aria-describedby="nvl-${instanceId}-description"`.
240
+ * The description element is a live region that will announce changes to the graph.
241
+ * @defaultValue false
242
+ */
243
+ disableAria?: boolean;
188
244
  }
189
245
  /** Options that influence how fit-to-zoom should behave */
190
246
  export type ZoomOptions = {
@@ -214,6 +270,7 @@ export interface NvlState {
214
270
  webGLVisible: boolean;
215
271
  renderer: Renderer;
216
272
  disableWebGL: boolean;
273
+ disableWebWorkers: boolean;
217
274
  disableTelemetry: boolean;
218
275
  fitMovement: number;
219
276
  layout: Layout;
@@ -249,12 +306,9 @@ export interface NvlState {
249
306
  reaction: Function;
250
307
  nodeBorderStyles: BorderStyles;
251
308
  relationshipBorderStyles: BorderStyles;
309
+ disabledItemStyles: DisabledItemStyles;
310
+ defaultNodeColor: string;
311
+ defaultRelationshipColor: string;
312
+ minimapViewportBoxColor: string;
252
313
  }
253
- /**
254
- * Create a new NVL state
255
- *
256
- * @param {NvlOptions} options - The options for the new state
257
- * @returns {NvlState} - The state object
258
- */
259
- export declare const createState: (options: NvlOptions) => NvlState;
260
314
  export {};
@@ -0,0 +1,44 @@
1
+ import type { NvlOptions } from './types';
2
+ export declare const processColorStyles: (styling: NvlOptions['styling'], { legacyNodeDefaultBorderColor, legacySelectedBorderColor, legacyDisabledItemColor, legacyDisabledItemFontColor }: {
3
+ legacyNodeDefaultBorderColor?: string;
4
+ legacySelectedBorderColor?: string;
5
+ legacyDisabledItemColor?: string;
6
+ legacyDisabledItemFontColor?: string;
7
+ }) => {
8
+ nodeBorderStyles: {
9
+ default: {
10
+ rings?: {
11
+ width?: number;
12
+ widthFactor?: number;
13
+ color: string;
14
+ }[];
15
+ shadow?: import("./types").ShadowStyle;
16
+ };
17
+ selected: {
18
+ rings?: {
19
+ width?: number;
20
+ widthFactor?: number;
21
+ color: string;
22
+ }[];
23
+ shadow?: import("./types").ShadowStyle;
24
+ };
25
+ };
26
+ relationshipBorderStyles: {
27
+ default: import("./types").BorderStyle;
28
+ selected: {
29
+ rings?: {
30
+ width?: number;
31
+ widthFactor?: number;
32
+ color: string;
33
+ }[];
34
+ shadow?: import("./types").ShadowStyle;
35
+ };
36
+ };
37
+ disabledItemStyles: {
38
+ color: string;
39
+ fontColor: string;
40
+ };
41
+ defaultNodeColor: string;
42
+ defaultRelationshipColor: string;
43
+ minimapViewportBoxColor: string;
44
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../modules/state';
1
+ import type { NvlState } from '../../modules/state/types';
2
2
  import type { Node } from '../../types/graph-element';
3
3
  import type { Point } from '../../utils/geometry';
4
4
  import type { HitTargetNode, HitTargetRelationship } from '../../utils/hittest';
@@ -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/types';
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';
@@ -32,12 +32,15 @@ export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBund
32
32
  * @param {number} angle - the angle of the label
33
33
  * @param {number} maxWidth - the maximum width of the label
34
34
  * @param {Relationship} rel - the relationship
35
+ * @param {ArrowBundle} bundle - the arrow bundle
36
+ * @param {DisabledItemStyles} disabledItemStyles - the styles for disabled items
37
+ * @param {string} fontColor - the color of the font
35
38
  * @param {boolean} flip - whether to flip the label
36
39
  */
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;
40
+ export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, fontColor: string, flip?: boolean) => void;
41
+ export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, drawCurves: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor?: string) => void;
42
+ export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor?: string) => void;
43
+ export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor: string, drawCurves?: boolean) => void;
41
44
  export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
42
45
  /**
43
46
  * Returns the bounding box of the arrow.
@@ -9,7 +9,7 @@ export declare const HeadHeight = 9;
9
9
  /** The chin height of arrows. */
10
10
  export declare const HeadChinHeight = 2;
11
11
  /** The default color of relationships. */
12
- export declare const RelColor = "#848484";
12
+ export declare const RelColor = "#818790";
13
13
  /** The length of the curve of a curved relationship. */
14
14
  export declare const TaperRelLength = 30;
15
15
  /** The distance of the starting points of relationships in a bundle. */
@@ -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/types';
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, defaultNodeColor?: string, 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
@@ -1,6 +1,6 @@
1
1
  import type { Node, Relationship } from '../../index';
2
2
  import type { DataSet } from '../../modules/dataset';
3
- import type { NvlState } from '../../modules/state';
3
+ import type { NvlState } from '../../modules/state/types';
4
4
  import type Renderer from './Renderer';
5
5
  export interface ControllerInterface {
6
6
  mainSceneRenderer: Renderer;
@@ -1,6 +1,6 @@
1
1
  import { mat4 } from 'gl-matrix';
2
2
  import type { DataSet } from '../../modules/dataset';
3
- import type { NvlState } from '../../modules/state';
3
+ import type { NvlState } from '../../modules/state/types';
4
4
  import type { Node, Relationship } from '../../types/graph-element';
5
5
  export default class Renderer {
6
6
  private readonly nodeShader;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float drawDefaultBorder;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\n\nmediump float circleSize = 0.40;\nmediump float ringSize = 0.43;\nmediump float ringSize2 = 0.47;\nmediump float shadowSize = 0.51;\nlowp vec3 shadowColor = vec3(0.73);\nlowp vec3 lineColor = vec3(1.0);\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(ringSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(ringSize2, dist);\n lowp float ringAlpha2 = getCircleAlpha(ringSize2, nodeSize, dist);\n\n finalColor = mix(lineColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(ringSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = ringAlpha;\n }\n }\n gl_FragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
1
+ declare const _default: "uniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float drawDefaultBorder;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp vec3 selectedInnerBorderColor;\nvarying lowp vec3 shadowColor;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\n\nmediump float circleSize = 0.40;\nmediump float defaultBoderSize = 0.42;\nmediump float innerSelectedRingSize = 0.43;\nmediump float outerSelectedRingSize = 0.47;\nmediump float shadowSize = 0.51;\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float borderAlpha = getCircleAlpha(defaultBoderSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(innerSelectedRingSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(outerSelectedRingSize, dist);\n lowp float ringAlpha2 = getCircleAlpha(outerSelectedRingSize, nodeSize, dist);\n\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedInnerBorderColor, finalColor, borderAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(borderAlpha, ringAlpha2)));\n } else {\n finalColor = mix(selectedInnerBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n }\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(defaultBoderSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, borderAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = borderAlpha;\n }\n }\n gl_FragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp float u_drawDefaultBorder;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_selected;\nattribute lowp float a_hovered;\n\nvarying lowp float window;\nvarying lowp vec4 color;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
1
+ declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp vec3 u_selectedInnerBorderColor;\nuniform lowp vec3 u_shadowColor;\nuniform lowp float u_drawDefaultBorder;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_selected;\nattribute lowp float a_hovered;\n\nvarying lowp float window;\nvarying lowp vec4 color;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp vec3 selectedInnerBorderColor;\nvarying lowp vec3 shadowColor;\nvarying lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n selectedInnerBorderColor = u_selectedInnerBorderColor;\n shadowColor = u_shadowColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "void main(void) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n";
1
+ declare const _default: "\nvarying lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_FragColor = minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "attribute vec2 coordinates;\nuniform mat4 u_projection;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n}\n";
1
+ declare const _default: "\nattribute vec2 coordinates;\nuniform mat4 u_projection;\nuniform lowp vec4 u_minimapViewportBoxColor;\n\nvarying lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n minimapViewportBoxColor = u_minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -0,0 +1,3 @@
1
+ import type { NvlState } from '../modules/state/types';
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 {};
@@ -0,0 +1,14 @@
1
+ import colorString from 'color-string';
2
+ /**
3
+ * Determines whether a black or white font color is more readable for a given background color
4
+ * @param {string} color The background color
5
+ * @returns {string} The font color that should be used @defaultValue '#fff'
6
+ */
7
+ export declare const textColorForBackground: (color: string) => string;
8
+ export declare const colorToRGB: (color: string) => colorString.Color;
9
+ export declare const isValidColor: (color: unknown) => boolean;
10
+ export declare const rgbaToVec4: (rgba: number[]) => number[];
11
+ export declare const rgbToVec3: (rgb: number[]) => number[];
12
+ export declare const colorToUIntArray: (color: string) => number;
13
+ export declare const colorToVec3: (color: string) => number[];
14
+ export declare const colorToVec4: (color: string) => number[];
@@ -0,0 +1 @@
1
+ export {};
@@ -8,9 +8,16 @@ 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 = "#818790";
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 = "#CFD1D4";
17
+ export declare const DefaultSelectedInnerColor = "#F5F6F6";
18
+ export declare const DefaultSelectedOuterColor = "#8FE3E8";
19
+ export declare const TextColor = "#1A1B1D";
20
+ export declare const TextColorInverse = "#FFFFFF";
14
21
  export declare const absFillStyle: {
15
22
  position: string;
16
23
  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[]>;
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../modules/state';
1
+ import type { NvlState } from '../modules/state/types';
2
2
  import type { Node, Relationship } from '../types/graph-element';
3
3
  import type { Point } from './geometry';
4
4
  /**
@@ -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 {};
@@ -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 };