@neo4j-ndl/react-graph 0.0.2

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 (129) hide show
  1. package/LICENSE +674 -0
  2. package/lib/LICENSES.txt +229 -0
  3. package/lib/NOTICE.txt +26 -0
  4. package/lib/cjs/graph-visualization-buttons.js +175 -0
  5. package/lib/cjs/graph-visualization-buttons.js.map +1 -0
  6. package/lib/cjs/graph-visualization-context.js +62 -0
  7. package/lib/cjs/graph-visualization-context.js.map +1 -0
  8. package/lib/cjs/graph-visualization-sidepanel.js +56 -0
  9. package/lib/cjs/graph-visualization-sidepanel.js.map +1 -0
  10. package/lib/cjs/graph-visualization.js +328 -0
  11. package/lib/cjs/graph-visualization.js.map +1 -0
  12. package/lib/cjs/index.js +28 -0
  13. package/lib/cjs/index.js.map +1 -0
  14. package/lib/cjs/map-to-nvl-graph.js +167 -0
  15. package/lib/cjs/map-to-nvl-graph.js.map +1 -0
  16. package/lib/cjs/sidepanel-components/button-group.js +96 -0
  17. package/lib/cjs/sidepanel-components/button-group.js.map +1 -0
  18. package/lib/cjs/sidepanel-components/clickable-urls.js +46 -0
  19. package/lib/cjs/sidepanel-components/clickable-urls.js.map +1 -0
  20. package/lib/cjs/sidepanel-components/details-panel.js +86 -0
  21. package/lib/cjs/sidepanel-components/details-panel.js.map +1 -0
  22. package/lib/cjs/sidepanel-components/overview-panel.js +45 -0
  23. package/lib/cjs/sidepanel-components/overview-panel.js.map +1 -0
  24. package/lib/cjs/sidepanel-components/properties-table.js +49 -0
  25. package/lib/cjs/sidepanel-components/properties-table.js.map +1 -0
  26. package/lib/cjs/sidepanel-components/show-all.js +44 -0
  27. package/lib/cjs/sidepanel-components/show-all.js.map +1 -0
  28. package/lib/cjs/sidepanel-components/single-selection-sidepanel-contents.js +35 -0
  29. package/lib/cjs/sidepanel-components/single-selection-sidepanel-contents.js.map +1 -0
  30. package/lib/cjs/stories/graph-visualization-barebones.story.js +93 -0
  31. package/lib/cjs/stories/graph-visualization-barebones.story.js.map +1 -0
  32. package/lib/cjs/stories/graph-visualization-custom.story.js +74 -0
  33. package/lib/cjs/stories/graph-visualization-custom.story.js.map +1 -0
  34. package/lib/cjs/stories/graph-visualization-default.story.js +93 -0
  35. package/lib/cjs/stories/graph-visualization-default.story.js.map +1 -0
  36. package/lib/cjs/stories/graph-visualization-highlighting.story.js +30 -0
  37. package/lib/cjs/stories/graph-visualization-highlighting.story.js.map +1 -0
  38. package/lib/cjs/stories/graph-visualization-maximalist.story.js +105 -0
  39. package/lib/cjs/stories/graph-visualization-maximalist.story.js.map +1 -0
  40. package/lib/cjs/stories/graph-visualization-search.story.js +36 -0
  41. package/lib/cjs/stories/graph-visualization-search.story.js.map +1 -0
  42. package/lib/cjs/stories/graph-visualization.stories.js +112 -0
  43. package/lib/cjs/stories/graph-visualization.stories.js.map +1 -0
  44. package/lib/cjs/stories/index.js +51 -0
  45. package/lib/cjs/stories/index.js.map +1 -0
  46. package/lib/cjs/stories/story-data.js +89 -0
  47. package/lib/cjs/stories/story-data.js.map +1 -0
  48. package/lib/cjs/use-managed-node-state.js +262 -0
  49. package/lib/cjs/use-managed-node-state.js.map +1 -0
  50. package/lib/cjs/use-semi-controlled-state.js +43 -0
  51. package/lib/cjs/use-semi-controlled-state.js.map +1 -0
  52. package/lib/cjs/utils.js +68 -0
  53. package/lib/cjs/utils.js.map +1 -0
  54. package/lib/esm/graph-visualization-buttons.js +159 -0
  55. package/lib/esm/graph-visualization-buttons.js.map +1 -0
  56. package/lib/esm/graph-visualization-context.js +58 -0
  57. package/lib/esm/graph-visualization-context.js.map +1 -0
  58. package/lib/esm/graph-visualization-sidepanel.js +52 -0
  59. package/lib/esm/graph-visualization-sidepanel.js.map +1 -0
  60. package/lib/esm/graph-visualization.js +298 -0
  61. package/lib/esm/graph-visualization.js.map +1 -0
  62. package/lib/esm/index.js +23 -0
  63. package/lib/esm/index.js.map +1 -0
  64. package/lib/esm/map-to-nvl-graph.js +162 -0
  65. package/lib/esm/map-to-nvl-graph.js.map +1 -0
  66. package/lib/esm/sidepanel-components/button-group.js +69 -0
  67. package/lib/esm/sidepanel-components/button-group.js.map +1 -0
  68. package/lib/esm/sidepanel-components/clickable-urls.js +40 -0
  69. package/lib/esm/sidepanel-components/clickable-urls.js.map +1 -0
  70. package/lib/esm/sidepanel-components/details-panel.js +82 -0
  71. package/lib/esm/sidepanel-components/details-panel.js.map +1 -0
  72. package/lib/esm/sidepanel-components/overview-panel.js +41 -0
  73. package/lib/esm/sidepanel-components/overview-panel.js.map +1 -0
  74. package/lib/esm/sidepanel-components/properties-table.js +45 -0
  75. package/lib/esm/sidepanel-components/properties-table.js.map +1 -0
  76. package/lib/esm/sidepanel-components/show-all.js +41 -0
  77. package/lib/esm/sidepanel-components/show-all.js.map +1 -0
  78. package/lib/esm/sidepanel-components/single-selection-sidepanel-contents.js +31 -0
  79. package/lib/esm/sidepanel-components/single-selection-sidepanel-contents.js.map +1 -0
  80. package/lib/esm/stories/graph-visualization-barebones.story.js +90 -0
  81. package/lib/esm/stories/graph-visualization-barebones.story.js.map +1 -0
  82. package/lib/esm/stories/graph-visualization-custom.story.js +71 -0
  83. package/lib/esm/stories/graph-visualization-custom.story.js.map +1 -0
  84. package/lib/esm/stories/graph-visualization-default.story.js +90 -0
  85. package/lib/esm/stories/graph-visualization-default.story.js.map +1 -0
  86. package/lib/esm/stories/graph-visualization-highlighting.story.js +28 -0
  87. package/lib/esm/stories/graph-visualization-highlighting.story.js.map +1 -0
  88. package/lib/esm/stories/graph-visualization-maximalist.story.js +102 -0
  89. package/lib/esm/stories/graph-visualization-maximalist.story.js.map +1 -0
  90. package/lib/esm/stories/graph-visualization-search.story.js +34 -0
  91. package/lib/esm/stories/graph-visualization-search.story.js.map +1 -0
  92. package/lib/esm/stories/graph-visualization.stories.js +109 -0
  93. package/lib/esm/stories/graph-visualization.stories.js.map +1 -0
  94. package/lib/esm/stories/index.js +39 -0
  95. package/lib/esm/stories/index.js.map +1 -0
  96. package/lib/esm/stories/story-data.js +86 -0
  97. package/lib/esm/stories/story-data.js.map +1 -0
  98. package/lib/esm/use-managed-node-state.js +259 -0
  99. package/lib/esm/use-managed-node-state.js.map +1 -0
  100. package/lib/esm/use-semi-controlled-state.js +40 -0
  101. package/lib/esm/use-semi-controlled-state.js.map +1 -0
  102. package/lib/esm/utils.js +60 -0
  103. package/lib/esm/utils.js.map +1 -0
  104. package/lib/types/graph-visualization-buttons.d.ts +56 -0
  105. package/lib/types/graph-visualization-context.d.ts +122 -0
  106. package/lib/types/graph-visualization-sidepanel.d.ts +32 -0
  107. package/lib/types/graph-visualization.d.ts +178 -0
  108. package/lib/types/index.d.ts +22 -0
  109. package/lib/types/map-to-nvl-graph.d.ts +37 -0
  110. package/lib/types/sidepanel-components/button-group.d.ts +24 -0
  111. package/lib/types/sidepanel-components/clickable-urls.d.ts +26 -0
  112. package/lib/types/sidepanel-components/details-panel.d.ts +25 -0
  113. package/lib/types/sidepanel-components/overview-panel.d.ts +21 -0
  114. package/lib/types/sidepanel-components/properties-table.d.ts +31 -0
  115. package/lib/types/sidepanel-components/show-all.d.ts +29 -0
  116. package/lib/types/sidepanel-components/single-selection-sidepanel-contents.d.ts +21 -0
  117. package/lib/types/stories/graph-visualization-barebones.story.d.ts +23 -0
  118. package/lib/types/stories/graph-visualization-custom.story.d.ts +23 -0
  119. package/lib/types/stories/graph-visualization-default.story.d.ts +23 -0
  120. package/lib/types/stories/graph-visualization-highlighting.story.d.ts +22 -0
  121. package/lib/types/stories/graph-visualization-maximalist.story.d.ts +23 -0
  122. package/lib/types/stories/graph-visualization-search.story.d.ts +22 -0
  123. package/lib/types/stories/graph-visualization.stories.d.ts +39 -0
  124. package/lib/types/stories/index.d.ts +32 -0
  125. package/lib/types/stories/story-data.d.ts +26 -0
  126. package/lib/types/use-managed-node-state.d.ts +116 -0
  127. package/lib/types/use-semi-controlled-state.d.ts +23 -0
  128. package/lib/types/utils.d.ts +29 -0
  129. package/package.json +79 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ import { type NeoNode, type NeoRel } from '../graph-visualization-context';
22
+ export declare const StoryGraph: {
23
+ nodes: NeoNode[];
24
+ rels: NeoRel[];
25
+ };
26
+ export declare const containerClasses = "n-w-full n-border-palette-neutral-border-weak n-mx-2 n-rounded-lg n-border";
@@ -0,0 +1,116 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ import { type HitTargets, type Node, type Relationship } from '@neo4j-nvl/base';
22
+ import { type MouseEventCallbacks } from '@neo4j-nvl/react';
23
+ import { type Gesture, type GraphSelection, type InteractionMode } from './graph-visualization-context';
24
+ export type ManagedNodeStateArgs = {
25
+ selected: GraphSelection;
26
+ setSelected: (newSelection: GraphSelection) => void;
27
+ gesture: Gesture;
28
+ interactionMode: InteractionMode;
29
+ setInteractionMode: (newInteractionMode: InteractionMode) => void;
30
+ mouseEventCallbacks: MouseEventCallbacks;
31
+ nvlGraph: {
32
+ nodes: Node[];
33
+ rels: Relationship[];
34
+ };
35
+ highlightedNodeIds?: string[];
36
+ highlightedRelationshipIds?: string[];
37
+ };
38
+ export declare function useManagedNodeState({ selected, setSelected, gesture, interactionMode, setInteractionMode, mouseEventCallbacks, nvlGraph, highlightedNodeIds, highlightedRelationshipIds, }: ManagedNodeStateArgs): {
39
+ nodesWithState: {
40
+ disabled: boolean;
41
+ selected: boolean;
42
+ size?: number;
43
+ pinned?: boolean;
44
+ x?: number;
45
+ y?: number;
46
+ activated?: boolean;
47
+ icon?: string;
48
+ html?: HTMLElement;
49
+ id: string;
50
+ color?: string;
51
+ caption?: string;
52
+ hovered?: boolean;
53
+ captionSize?: number;
54
+ captionAlign?: "top" | "bottom" | "center";
55
+ captions?: import("@neo4j-nvl/base").StyledCaption[];
56
+ overlayIcon?: {
57
+ url: string;
58
+ position?: number[];
59
+ size?: number;
60
+ };
61
+ }[];
62
+ relsWithState: {
63
+ disabled: boolean;
64
+ selected: boolean;
65
+ from: string;
66
+ to: string;
67
+ type?: string;
68
+ width?: number;
69
+ captionHtml?: HTMLElement;
70
+ id: string;
71
+ color?: string;
72
+ caption?: string;
73
+ hovered?: boolean;
74
+ captionSize?: number;
75
+ captionAlign?: "top" | "bottom" | "center";
76
+ captions?: import("@neo4j-nvl/base").StyledCaption[];
77
+ overlayIcon?: {
78
+ url: string;
79
+ position?: number[];
80
+ size?: number;
81
+ };
82
+ }[];
83
+ wrappedMouseEventCallbacks: {
84
+ onBoxSelect: boolean | (({ nodes, rels }: {
85
+ nodes: Node[];
86
+ rels: Relationship[];
87
+ }, evt: MouseEvent) => void);
88
+ onBoxStarted: boolean | ((event: MouseEvent) => void) | undefined;
89
+ onCanvasClick: boolean | ((evt: MouseEvent) => void);
90
+ onDragEnd: boolean | ((draggedNodes: Node[], evt: MouseEvent) => void);
91
+ onDragStart: boolean | ((draggedNodes: Node[], evt: MouseEvent) => void);
92
+ onDrawEnded: boolean | ((newRelationshipToAdd: Relationship | null, newTargetNodeToAdd: Node | null, event: MouseEvent) => void);
93
+ onDrawStarted: boolean | ((evt: MouseEvent) => void);
94
+ onHover: boolean | ((element: Node | Relationship, hitElements: HitTargets, event: MouseEvent) => void) | undefined;
95
+ onHoverNodeMargin: boolean | ((hoveredNode: Node | null, evt: MouseEvent) => void) | undefined;
96
+ onLassoSelect: boolean | (({ nodes, rels }: {
97
+ nodes: Node[];
98
+ rels: Relationship[];
99
+ }, evt: MouseEvent) => void);
100
+ onLassoStarted: boolean | ((event: MouseEvent) => void) | undefined;
101
+ onNodeClick: boolean | ((node: Node, hitElements: HitTargets, evt: MouseEvent) => void);
102
+ onNodeDoubleClick: boolean | ((node: Node, hitElements: HitTargets, evt: MouseEvent) => void);
103
+ onPan: boolean | ((panning: {
104
+ x: number;
105
+ y: number;
106
+ }, event: MouseEvent) => void);
107
+ onRelationshipClick: boolean | ((relationship: Relationship, hitElements: HitTargets, evt: MouseEvent) => void);
108
+ onRelationshipDoubleClick: boolean | ((relationship: Relationship, hitElements: HitTargets, evt: MouseEvent) => void);
109
+ onZoom: boolean | ((zoomLevel: number, event: WheelEvent) => void);
110
+ onCanvasDoubleClick?: ((event: MouseEvent) => void) | boolean;
111
+ onCanvasRightClick?: ((event: MouseEvent) => void) | boolean;
112
+ onNodeRightClick?: ((node: Node, hitElements: HitTargets, event: MouseEvent) => void) | boolean;
113
+ onRelationshipRightClick?: ((relationship: Relationship, hitElements: HitTargets, event: MouseEvent) => void) | boolean;
114
+ onDrag?: ((nodes: Node[], evt: MouseEvent) => void) | boolean;
115
+ };
116
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ type SetStateAction<T> = T | ((prev: T) => T);
22
+ export declare function useSemicontrolledState<T>(externalState: T, externalSetState?: (newState: T) => void): [T, (setState: SetStateAction<T>) => void];
23
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ import { type NodeData, type RelData } from './graph-visualization-context';
22
+ export declare const isMac: boolean;
23
+ export declare const xor: (a: string[], b: string[]) => string[];
24
+ export declare const mapValues: <T, R>(obj: Record<string, T>, fn: (value: T) => R) => Record<string, R>;
25
+ export declare const searchProperties: (properties: Record<string, {
26
+ stringified: string;
27
+ }>, text: string) => boolean;
28
+ export declare const searchNodes: (nodes: NodeData[], text: string) => string[];
29
+ export declare const searchRels: (rels: RelData[], text: string) => string[];
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@neo4j-ndl/react-graph",
3
+ "version": "0.0.2",
4
+ "sideEffects": false,
5
+ "description": "React implementation of the graph visualization from Neo4j Design System",
6
+ "keywords": [
7
+ "neo4j",
8
+ "react",
9
+ "design system",
10
+ "needle",
11
+ "ndl",
12
+ "graph"
13
+ ],
14
+ "author": "Neo4j Inc.",
15
+ "homepage": "https://www.neo4j.design",
16
+ "license": "GPL-3.0",
17
+ "main": "./lib/cjs/index.js",
18
+ "module": "./lib/esm/index.js",
19
+ "types": "./lib/types/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./lib/esm/index.js",
23
+ "require": "./lib/cjs/index.js",
24
+ "types": "./lib/types/index.d.ts"
25
+ }
26
+ },
27
+ "directories": {
28
+ "lib": "lib"
29
+ },
30
+ "files": [
31
+ "lib",
32
+ "icons"
33
+ ],
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "devDependencies": {
38
+ "@axe-core/playwright": "4.9.0",
39
+ "@playwright/experimental-ct-react": "1.55.1",
40
+ "@playwright/test": "1.55.1",
41
+ "@testing-library/jest-dom": "6.6.3",
42
+ "@testing-library/react": "14.3.1",
43
+ "@types/react": "18.2.18",
44
+ "@types/react-dom": "18.2.7",
45
+ "@storybook/react-vite": "9.0.11",
46
+ "@neo4j-devtools/word-color": "0.0.8",
47
+ "@vitejs/plugin-react": "4.5.2",
48
+ "react": "18.2.0",
49
+ "typescript": "5.5.4",
50
+ "vitest": "2.1.9"
51
+ },
52
+ "peerDependencies": {
53
+ "react": ">=16.8.0",
54
+ "react-dom": ">=16.8.0",
55
+ "@neo4j-nvl/base": "^1.0.0",
56
+ "@neo4j-nvl/interaction-handlers": "^1.0.0",
57
+ "@neo4j-nvl/react": "^1.0.0",
58
+ "@neo4j-ndl/base": "^3.7.33",
59
+ "@neo4j-ndl/react": "^3.9.21"
60
+ },
61
+ "dependencies": {
62
+ "classnames": "2.5.1",
63
+ "re-resizable": "6.11.2"
64
+ },
65
+ "scripts": {
66
+ "test": "pnpm run test:unit && pnpm run test:playwright",
67
+ "test:unit": "pnpm exec vitest --run --typecheck --exclude node_modules",
68
+ "test:playwright": "pnpm exec playwright test",
69
+ "build": "pnpm run build:esm && pnpm run build:cjs && pnpm run build:types",
70
+ "build:esm": "pnpm exec tsc -p tsconfig.esm.json",
71
+ "build:cjs": "pnpm exec tsc -p tsconfig.cjs.json",
72
+ "watch:esm": "pnpm exec tsc -p tsconfig.esm.json --watch",
73
+ "watch:cjs": "pnpm exec tsc -p tsconfig.cjs.json --watch",
74
+ "build:types": "pnpm exec tsc -p tsconfig.types.json",
75
+ "format": "pnpm exec prettier --write 'src/**/*.{js,jsx,ts,tsx}'",
76
+ "lint": "pnpm exec eslint src",
77
+ "nuke:local": "../../scripts/cc.sh '{yellow ☢️} Nuking react-graph! {yellow ☢️}' && pnpm dlx rimraf@5.0.5 .tsbuildinfo node_modules lib playwright-report test-results playwright/.cache"
78
+ }
79
+ }