@plait/graph-viz 0.62.0-next.7 → 0.62.0-next.9

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.
@@ -1,15 +1,21 @@
1
1
  import { Options } from 'roughjs/bin/core';
2
2
  export declare const DEFAULT_EDGE_STYLES: Options;
3
- export declare const DEFAULT_NODE_SIZE = 60;
3
+ export declare const DEFAULT_NODE_SIZE = 30;
4
4
  export declare const DEFAULT_ACTIVE_NODE_SIZE_MULTIPLIER = 1.2;
5
- export declare const DEFAULT_ACTIVE_WAVE_NODE_SIZE_MULTIPLIER = 1.6;
5
+ export declare const DEFAULT_ACTIVE_WAVE_NODE_SIZE_MULTIPLIER = 1.5;
6
6
  export declare const DEFAULT_NODE_LABEL_MARGIN_TOP = 4;
7
7
  export declare const DEFAULT_NODE_LABEL_FONT_SIZE = 12;
8
8
  export declare const SECOND_DEPTH_NODE_ALPHA = 0.5;
9
9
  export declare const SECOND_DEPTH_LINE_ALPHA = 0.5;
10
10
  export declare const ACTIVE_BACKGROUND_NODE_ALPHA = 0.1;
11
+ export declare const NODE_ICON_CLASS_NAME = "force-atlas-node-icon";
12
+ export declare const ACTIVE_NODE_ICON_CLASS_NAME = "force-atlas-node-icon-active";
13
+ export declare const NODE_ICON_FONT_SIZE = 16;
14
+ export declare const ACTIVE_NODE_ICON_FONT_SIZE = 18;
15
+ export declare const DEFAULT_NODE_BACKGROUND_COLOR = "#9c9cfb";
16
+ export declare const DEFAULT_NODE_ICON_COLOR = "#fff";
11
17
  export declare const DEFAULT_NODE_STYLES: Options;
12
- export declare const DEFAULT_NODE_SCALING_RATIO = 600;
18
+ export declare const DEFAULT_NODE_SCALING_RATIO = 20;
13
19
  export declare const DEFAULT_LINE_STYLES: {
14
20
  color: {
15
21
  0: string;
@@ -0,0 +1,10 @@
1
+ import { PlaitBoard } from '@plait/core';
2
+ import { ForceAtlasNodeElement } from '../../interfaces/element';
3
+ import { NodeIconItem } from '../types';
4
+ export declare abstract class ForceAtlasNodeIconBaseComponent {
5
+ iconItem: NodeIconItem;
6
+ board: PlaitBoard;
7
+ element: ForceAtlasNodeElement;
8
+ abstract nativeElement(): HTMLElement;
9
+ initialize(): void;
10
+ }
@@ -1,10 +1,15 @@
1
1
  import { PlaitBoard } from '@plait/core';
2
- import { Generator } from '@plait/common';
2
+ import { Generator, RenderComponentRef } from '@plait/common';
3
3
  import { ForceAtlasNodeElement } from '../../interfaces';
4
4
  import { NodeGeneratorData } from '../types';
5
+ import { NodeIconProps } from '../with-node-icon';
5
6
  export declare class ForceAtlasNodeGenerator extends Generator<ForceAtlasNodeElement, NodeGeneratorData> {
6
7
  static key: string;
7
8
  constructor(board: PlaitBoard);
8
9
  canDraw(element: ForceAtlasNodeElement): boolean;
9
10
  draw(element: ForceAtlasNodeElement, data: NodeGeneratorData): SVGGElement;
11
+ drawIcon(element: ForceAtlasNodeElement, data: NodeGeneratorData): {
12
+ ref: RenderComponentRef<NodeIconProps>;
13
+ iconG: SVGGElement;
14
+ };
10
15
  }
@@ -26,3 +26,8 @@ export interface NodeGeneratorData extends GeneratorExtraData {
26
26
  isActive: boolean;
27
27
  isFirstDepth: boolean;
28
28
  }
29
+ export interface NodeIconItem {
30
+ name: string;
31
+ fontSize?: number;
32
+ color?: string;
33
+ }
@@ -2,6 +2,7 @@ import { EdgeDirection } from '../types';
2
2
  import { PlaitBoard, Point } from '@plait/core';
3
3
  import { ForceAtlasNodeElement } from '../../interfaces';
4
4
  export declare function drawNode(board: PlaitBoard, node: ForceAtlasNodeElement, point: Point, options: {
5
+ iconG?: SVGGElement;
5
6
  isActive: boolean;
6
7
  isFirstDepth: boolean;
7
8
  }): SVGGElement;
@@ -8,3 +8,8 @@ export declare function isHitNode(node: ForceAtlasNodeElement, point: [Point, Po
8
8
  export declare function getAssociatedNodesById(id: string, forceAtlasElement: ForceAtlasElement): ForceAtlasNodeElement[];
9
9
  export declare function getNodeGenerator(node: ForceAtlasNodeElement): ForceAtlasNodeGenerator;
10
10
  export declare function isFirstDepthNode(currentNodeId: string, activeNodeId: string, forceAtlasElement: ForceAtlasElement): boolean;
11
+ export declare function getNodeIcon(node: ForceAtlasNodeElement): {
12
+ name: string;
13
+ fontSize: number;
14
+ color: string;
15
+ };
@@ -1,2 +1,2 @@
1
1
  import { PlaitBoard } from '@plait/core';
2
- export declare const withForceAtlas: (board: PlaitBoard) => PlaitBoard;
2
+ export declare const withForceAtlas: (board: PlaitBoard) => PlaitBoard & import("./with-node-icon").ForceAtlasNodeIconBoard;
@@ -0,0 +1,13 @@
1
+ import { PlaitBoard } from '@plait/core';
2
+ import { ForceAtlasNodeElement } from '../interfaces/element';
3
+ import { RenderComponentRef } from '@plait/common';
4
+ import { NodeIconItem } from './types';
5
+ export interface ForceAtlasNodeIconBoard {
6
+ renderNodeIcon: (container: Element | DocumentFragment, props: NodeIconProps) => RenderComponentRef<NodeIconProps>;
7
+ }
8
+ export declare const withNodeIcon: <T extends PlaitBoard = PlaitBoard>(board: T) => T & ForceAtlasNodeIconBoard;
9
+ export interface NodeIconProps {
10
+ board: PlaitBoard;
11
+ iconItem: NodeIconItem;
12
+ element: ForceAtlasNodeElement;
13
+ }
@@ -1,7 +1,8 @@
1
1
  import { PlaitElement } from '@plait/core';
2
+ import { NodeIconItem } from '../force-atlas/types';
2
3
  export interface ForceAtlasNodeElement extends PlaitElement {
3
4
  label: string;
4
- icon: string;
5
+ icon: string | NodeIconItem;
5
6
  size?: number;
6
7
  isActive?: boolean;
7
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plait/graph-viz",
3
- "version": "0.62.0-next.7",
3
+ "version": "0.62.0-next.9",
4
4
  "peerDependencies": {
5
5
  "graphology": "^0.25.4",
6
6
  "graphology-layout": "^0.6.1",
@@ -14,7 +14,9 @@
14
14
  "repository": "https://github.com/worktile/plait",
15
15
  "keywords": [
16
16
  "graph",
17
- "force-atlas"
17
+ "force-atlas",
18
+ "knowledge-graph",
19
+ "network-graph"
18
20
  ],
19
21
  "module": "fesm2022/plait-graph-viz.mjs",
20
22
  "typings": "index.d.ts",
package/public-api.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './force-atlas/constants';
2
2
  export * from './force-atlas/types';
3
3
  export * from './force-atlas/with-force-atlas';
4
+ export * from './force-atlas/with-node-icon';
4
5
  export * from './interfaces/index';
6
+ export * from './force-atlas/core/node-icon-base.component';