@neo4j-ndl/react 3.8.7 → 3.8.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.
- package/lib/cjs/graph-visualization/graph-viz-buttons.js +142 -0
- package/lib/cjs/graph-visualization/graph-viz-buttons.js.map +1 -0
- package/lib/cjs/graph-visualization/graph-viz-context.js +62 -0
- package/lib/cjs/graph-visualization/graph-viz-context.js.map +1 -0
- package/lib/cjs/graph-visualization/graph-viz-sidepanel.js +56 -0
- package/lib/cjs/graph-visualization/graph-viz-sidepanel.js.map +1 -0
- package/lib/cjs/graph-visualization/graph-viz.js +289 -0
- package/lib/cjs/graph-visualization/graph-viz.js.map +1 -0
- package/lib/cjs/graph-visualization/index.js +44 -0
- package/lib/cjs/graph-visualization/index.js.map +1 -0
- package/lib/cjs/graph-visualization/map-to-nvl-graph.js +167 -0
- package/lib/cjs/graph-visualization/map-to-nvl-graph.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/button-group.js +96 -0
- package/lib/cjs/graph-visualization/sidepanel-components/button-group.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/clickable-urls-test.js +214 -0
- package/lib/cjs/graph-visualization/sidepanel-components/clickable-urls-test.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/clickable-urls.js +46 -0
- package/lib/cjs/graph-visualization/sidepanel-components/clickable-urls.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/details-panel.js +87 -0
- package/lib/cjs/graph-visualization/sidepanel-components/details-panel.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/overview-panel.js +45 -0
- package/lib/cjs/graph-visualization/sidepanel-components/overview-panel.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/properties-table.js +49 -0
- package/lib/cjs/graph-visualization/sidepanel-components/properties-table.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/show-all.js +44 -0
- package/lib/cjs/graph-visualization/sidepanel-components/show-all.js.map +1 -0
- package/lib/cjs/graph-visualization/sidepanel-components/single-selection-sidepanel-contents.js +35 -0
- package/lib/cjs/graph-visualization/sidepanel-components/single-selection-sidepanel-contents.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-barebones.story.js +93 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-barebones.story.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-custom.story.js +74 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-custom.story.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-default.story.js +93 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-default.story.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-maximalist.story.js +106 -0
- package/lib/cjs/graph-visualization/stories/graph-viz-maximalist.story.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/graph-viz.stories.js +85 -0
- package/lib/cjs/graph-visualization/stories/graph-viz.stories.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/index.js +44 -0
- package/lib/cjs/graph-visualization/stories/index.js.map +1 -0
- package/lib/cjs/graph-visualization/stories/story-data.js +89 -0
- package/lib/cjs/graph-visualization/stories/story-data.js.map +1 -0
- package/lib/cjs/graph-visualization/use-managed-selection-state.js +258 -0
- package/lib/cjs/graph-visualization/use-managed-selection-state.js.map +1 -0
- package/lib/cjs/graph-visualization/use-semi-controlled-state.js +38 -0
- package/lib/cjs/graph-visualization/use-semi-controlled-state.js.map +1 -0
- package/lib/cjs/graph-visualization/utils.js +30 -0
- package/lib/cjs/graph-visualization/utils.js.map +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/graph-visualization/graph-viz-buttons.js +127 -0
- package/lib/esm/graph-visualization/graph-viz-buttons.js.map +1 -0
- package/lib/esm/graph-visualization/graph-viz-context.js +58 -0
- package/lib/esm/graph-visualization/graph-viz-context.js.map +1 -0
- package/lib/esm/graph-visualization/graph-viz-sidepanel.js +52 -0
- package/lib/esm/graph-visualization/graph-viz-sidepanel.js.map +1 -0
- package/lib/esm/graph-visualization/graph-viz.js +259 -0
- package/lib/esm/graph-visualization/graph-viz.js.map +1 -0
- package/lib/esm/graph-visualization/index.js +25 -0
- package/lib/esm/graph-visualization/index.js.map +1 -0
- package/lib/esm/graph-visualization/map-to-nvl-graph.js +162 -0
- package/lib/esm/graph-visualization/map-to-nvl-graph.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/button-group.js +69 -0
- package/lib/esm/graph-visualization/sidepanel-components/button-group.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/clickable-urls-test.js +212 -0
- package/lib/esm/graph-visualization/sidepanel-components/clickable-urls-test.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/clickable-urls.js +40 -0
- package/lib/esm/graph-visualization/sidepanel-components/clickable-urls.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/details-panel.js +83 -0
- package/lib/esm/graph-visualization/sidepanel-components/details-panel.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/overview-panel.js +41 -0
- package/lib/esm/graph-visualization/sidepanel-components/overview-panel.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/properties-table.js +45 -0
- package/lib/esm/graph-visualization/sidepanel-components/properties-table.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/show-all.js +41 -0
- package/lib/esm/graph-visualization/sidepanel-components/show-all.js.map +1 -0
- package/lib/esm/graph-visualization/sidepanel-components/single-selection-sidepanel-contents.js +31 -0
- package/lib/esm/graph-visualization/sidepanel-components/single-selection-sidepanel-contents.js.map +1 -0
- package/lib/esm/graph-visualization/stories/graph-viz-barebones.story.js +90 -0
- package/lib/esm/graph-visualization/stories/graph-viz-barebones.story.js.map +1 -0
- package/lib/esm/graph-visualization/stories/graph-viz-custom.story.js +71 -0
- package/lib/esm/graph-visualization/stories/graph-viz-custom.story.js.map +1 -0
- package/lib/esm/graph-visualization/stories/graph-viz-default.story.js +90 -0
- package/lib/esm/graph-visualization/stories/graph-viz-default.story.js.map +1 -0
- package/lib/esm/graph-visualization/stories/graph-viz-maximalist.story.js +103 -0
- package/lib/esm/graph-visualization/stories/graph-viz-maximalist.story.js.map +1 -0
- package/lib/esm/graph-visualization/stories/graph-viz.stories.js +82 -0
- package/lib/esm/graph-visualization/stories/graph-viz.stories.js.map +1 -0
- package/lib/esm/graph-visualization/stories/index.js +34 -0
- package/lib/esm/graph-visualization/stories/index.js.map +1 -0
- package/lib/esm/graph-visualization/stories/story-data.js +86 -0
- package/lib/esm/graph-visualization/stories/story-data.js.map +1 -0
- package/lib/esm/graph-visualization/use-managed-selection-state.js +255 -0
- package/lib/esm/graph-visualization/use-managed-selection-state.js.map +1 -0
- package/lib/esm/graph-visualization/use-semi-controlled-state.js +35 -0
- package/lib/esm/graph-visualization/use-semi-controlled-state.js.map +1 -0
- package/lib/esm/graph-visualization/utils.js +25 -0
- package/lib/esm/graph-visualization/utils.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/types/graph-visualization/graph-viz-buttons.d.ts +49 -0
- package/lib/types/graph-visualization/graph-viz-context.d.ts +122 -0
- package/lib/types/graph-visualization/graph-viz-sidepanel.d.ts +32 -0
- package/lib/types/graph-visualization/graph-viz.d.ts +149 -0
- package/lib/types/graph-visualization/index.d.ts +24 -0
- package/lib/types/graph-visualization/map-to-nvl-graph.d.ts +37 -0
- package/lib/types/graph-visualization/sidepanel-components/button-group.d.ts +24 -0
- package/lib/types/graph-visualization/sidepanel-components/clickable-urls-test.d.ts +21 -0
- package/lib/types/graph-visualization/sidepanel-components/clickable-urls.d.ts +26 -0
- package/lib/types/graph-visualization/sidepanel-components/details-panel.d.ts +25 -0
- package/lib/types/graph-visualization/sidepanel-components/overview-panel.d.ts +21 -0
- package/lib/types/graph-visualization/sidepanel-components/properties-table.d.ts +31 -0
- package/lib/types/graph-visualization/sidepanel-components/show-all.d.ts +29 -0
- package/lib/types/graph-visualization/sidepanel-components/single-selection-sidepanel-contents.d.ts +21 -0
- package/lib/types/graph-visualization/stories/graph-viz-barebones.story.d.ts +23 -0
- package/lib/types/graph-visualization/stories/graph-viz-custom.story.d.ts +23 -0
- package/lib/types/graph-visualization/stories/graph-viz-default.story.d.ts +23 -0
- package/lib/types/graph-visualization/stories/graph-viz-maximalist.story.d.ts +23 -0
- package/lib/types/graph-visualization/stories/graph-viz.stories.d.ts +36 -0
- package/lib/types/graph-visualization/stories/index.d.ts +28 -0
- package/lib/types/graph-visualization/stories/story-data.d.ts +26 -0
- package/lib/types/graph-visualization/use-managed-selection-state.d.ts +114 -0
- package/lib/types/graph-visualization/use-semi-controlled-state.d.ts +21 -0
- package/lib/types/graph-visualization/utils.d.ts +23 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,162 @@
|
|
|
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 { calculateDefaultNodeColors } from '@neo4j-devtools/word-color';
|
|
22
|
+
import { tokens } from '@neo4j-ndl/base';
|
|
23
|
+
export const DEFAULT_REL_COLOR = tokens.colors.neutral['40'];
|
|
24
|
+
export const NO_LABEL_FALLBACK_COLOR = tokens.colors.neutral['40'];
|
|
25
|
+
const sortAlphabetically = (a = '', b = '') => a.toLowerCase().localeCompare(b.toLowerCase());
|
|
26
|
+
function getMostCommonColor(colors) {
|
|
27
|
+
var _a;
|
|
28
|
+
const [firstColor] = colors;
|
|
29
|
+
if (firstColor === undefined) {
|
|
30
|
+
return NO_LABEL_FALLBACK_COLOR;
|
|
31
|
+
}
|
|
32
|
+
const colorCounts = {};
|
|
33
|
+
for (const color of colors) {
|
|
34
|
+
colorCounts[color] = ((_a = colorCounts[color]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
35
|
+
}
|
|
36
|
+
let maxCount = 0;
|
|
37
|
+
let mostCommonColor = firstColor;
|
|
38
|
+
for (const [color, colorCount] of Object.entries(colorCounts)) {
|
|
39
|
+
if (colorCount > maxCount) {
|
|
40
|
+
maxCount = colorCount;
|
|
41
|
+
mostCommonColor = color;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return mostCommonColor;
|
|
45
|
+
}
|
|
46
|
+
function transformToItemMetada(arg) {
|
|
47
|
+
return Object.entries(arg).reduce((acc, [label, colors]) => {
|
|
48
|
+
acc[label] = {
|
|
49
|
+
mostCommonColor: getMostCommonColor(colors),
|
|
50
|
+
totalCount: colors.length,
|
|
51
|
+
};
|
|
52
|
+
return acc;
|
|
53
|
+
}, {});
|
|
54
|
+
}
|
|
55
|
+
export const captionPriorityOrder = [
|
|
56
|
+
/^name$/i,
|
|
57
|
+
/^title$/i,
|
|
58
|
+
/^label$/i,
|
|
59
|
+
/name$/i,
|
|
60
|
+
/description$/i,
|
|
61
|
+
/^.+/,
|
|
62
|
+
];
|
|
63
|
+
export function getDefaultCaptionKey(options) {
|
|
64
|
+
const captionKeys = options
|
|
65
|
+
.filter((option) => option.type === 'property')
|
|
66
|
+
.map((option) => option.captionKey);
|
|
67
|
+
for (const regex of captionPriorityOrder) {
|
|
68
|
+
const matchingKey = captionKeys.find((key) => regex.test(key));
|
|
69
|
+
if (matchingKey !== undefined) {
|
|
70
|
+
return {
|
|
71
|
+
captionKey: matchingKey,
|
|
72
|
+
type: 'property',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const typeOption = options.find((option) => option.type === 'type');
|
|
77
|
+
if (typeOption) {
|
|
78
|
+
return typeOption;
|
|
79
|
+
}
|
|
80
|
+
return options.find((option) => option.type === 'id');
|
|
81
|
+
}
|
|
82
|
+
const getDefaultNodeCaption = (item) => {
|
|
83
|
+
const options = Object.keys(item.properties).map((property) => ({
|
|
84
|
+
captionKey: property,
|
|
85
|
+
type: 'property',
|
|
86
|
+
}));
|
|
87
|
+
options.push({ type: 'id' }, { type: 'type' });
|
|
88
|
+
const defaultCaptionKey = getDefaultCaptionKey(options);
|
|
89
|
+
if ((defaultCaptionKey === null || defaultCaptionKey === void 0 ? void 0 : defaultCaptionKey.type) === 'property') {
|
|
90
|
+
const caption = item.properties[defaultCaptionKey.captionKey];
|
|
91
|
+
if (caption !== undefined) {
|
|
92
|
+
// remove quotes from string
|
|
93
|
+
if (caption.type === 'string') {
|
|
94
|
+
return [{ value: caption.stringified.slice(1, -1) }];
|
|
95
|
+
}
|
|
96
|
+
return [{ value: caption.stringified }];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const [firstLabel] = item.labels;
|
|
100
|
+
if ((defaultCaptionKey === null || defaultCaptionKey === void 0 ? void 0 : defaultCaptionKey.type) === 'type' && firstLabel !== undefined) {
|
|
101
|
+
return [{ value: firstLabel }];
|
|
102
|
+
}
|
|
103
|
+
return [{ value: item.id }];
|
|
104
|
+
};
|
|
105
|
+
// Properties can be huge, so we split them out into a separate lookup table
|
|
106
|
+
// to prevent them from making the physics slow
|
|
107
|
+
// here we also apply default colors & captions to nodes and relationships
|
|
108
|
+
// and sample colors for the sidepanel
|
|
109
|
+
// in the future we'll apply styling here as well
|
|
110
|
+
export function mapToNvlGraph(rawNodes, rawRels) {
|
|
111
|
+
const labelColorPairs = {};
|
|
112
|
+
const typeColorPairs = {};
|
|
113
|
+
const nodeData = {};
|
|
114
|
+
const relData = {};
|
|
115
|
+
const nodes = rawNodes.map((node) => {
|
|
116
|
+
var _a;
|
|
117
|
+
const [firstLabel] = node.labels;
|
|
118
|
+
const newNode = Object.assign(Object.assign({ captions: getDefaultNodeCaption(node), color: (_a = node.color) !== null && _a !== void 0 ? _a : (firstLabel === undefined
|
|
119
|
+
? NO_LABEL_FALLBACK_COLOR
|
|
120
|
+
: calculateDefaultNodeColors(firstLabel).backgroundColor) }, node), { labels: undefined, properties: undefined });
|
|
121
|
+
nodeData[node.id] = {
|
|
122
|
+
color: newNode.color,
|
|
123
|
+
id: node.id,
|
|
124
|
+
labelsSorted: [...node.labels].sort(sortAlphabetically),
|
|
125
|
+
properties: node.properties,
|
|
126
|
+
};
|
|
127
|
+
node.labels.forEach((label) => {
|
|
128
|
+
var _a;
|
|
129
|
+
labelColorPairs[label] = [
|
|
130
|
+
...((_a = labelColorPairs[label]) !== null && _a !== void 0 ? _a : []),
|
|
131
|
+
newNode.color,
|
|
132
|
+
];
|
|
133
|
+
});
|
|
134
|
+
return newNode;
|
|
135
|
+
});
|
|
136
|
+
const rels = rawRels.map((rel) => {
|
|
137
|
+
var _a, _b, _c;
|
|
138
|
+
relData[rel.id] = {
|
|
139
|
+
color: (_a = rel.color) !== null && _a !== void 0 ? _a : DEFAULT_REL_COLOR,
|
|
140
|
+
id: rel.id,
|
|
141
|
+
properties: rel.properties,
|
|
142
|
+
type: rel.type,
|
|
143
|
+
};
|
|
144
|
+
typeColorPairs[rel.type] = [
|
|
145
|
+
...((_b = typeColorPairs[rel.type]) !== null && _b !== void 0 ? _b : []),
|
|
146
|
+
(_c = rel.color) !== null && _c !== void 0 ? _c : DEFAULT_REL_COLOR,
|
|
147
|
+
];
|
|
148
|
+
return Object.assign(Object.assign({ captions: [{ value: rel.type }], color: DEFAULT_REL_COLOR }, rel), { properties: undefined, type: undefined });
|
|
149
|
+
});
|
|
150
|
+
const labelMetaData = transformToItemMetada(labelColorPairs);
|
|
151
|
+
const typeMetaData = transformToItemMetada(typeColorPairs);
|
|
152
|
+
const dataLookupTable = {
|
|
153
|
+
labelMetaData,
|
|
154
|
+
labels: Object.keys(labelMetaData).sort((a, b) => sortAlphabetically(a, b)),
|
|
155
|
+
nodes: nodeData,
|
|
156
|
+
relationships: relData,
|
|
157
|
+
typeMetaData,
|
|
158
|
+
types: Object.keys(typeMetaData).sort((a, b) => sortAlphabetically(a, b)),
|
|
159
|
+
};
|
|
160
|
+
return { dataLookupTable, nodes, rels };
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=map-to-nvl-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-to-nvl-graph.js","sourceRoot":"","sources":["../../../src/graph-visualization/map-to-nvl-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAsBzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnE,MAAM,kBAAkB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAC5C,CAAC,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAEjD,SAAS,kBAAkB,CAAC,MAAgB;;IAC1C,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;IAE5B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO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;QAEF,qCACE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAC/B,KAAK,EAAE,iBAAiB,IACrB,GAAG,KACN,UAAU,EAAE,SAAS,EACrB,IAAI,EAAE,SAAS,IACf;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAE3D,MAAM,eAAe,GAAoB;QACvC,aAAa;QACb,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,KAAK,EAAE,QAAQ;QACf,aAAa,EAAE,OAAO;QACtB,YAAY;QACZ,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC1E,CAAC;IAEF,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import React, { cloneElement, useCallback, useMemo, useRef, useState, } from 'react';
|
|
23
|
+
export const ButtonGroup = ({ children }) => {
|
|
24
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
25
|
+
const parentRef = useRef(null);
|
|
26
|
+
const focusElement = (index) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const child = (_b = (_a = parentRef.current) === null || _a === void 0 ? void 0 : _a.children[index]) === null || _b === void 0 ? void 0 : _b.children[0];
|
|
29
|
+
if (child instanceof HTMLElement) {
|
|
30
|
+
child.focus();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const childrenCount = useMemo(() => React.Children.count(children), [children]);
|
|
34
|
+
const safeSetSelectedIndex = useCallback((index) => {
|
|
35
|
+
if (index >= childrenCount) {
|
|
36
|
+
setSelectedIndex(childrenCount - 1);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
setSelectedIndex(Math.max(0, index));
|
|
40
|
+
}
|
|
41
|
+
}, [childrenCount, setSelectedIndex]);
|
|
42
|
+
const handleKeyDown = (event) => {
|
|
43
|
+
let newIndx = selectedIndex;
|
|
44
|
+
if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {
|
|
45
|
+
newIndx = (selectedIndex + 1) % React.Children.count(children);
|
|
46
|
+
safeSetSelectedIndex(newIndx);
|
|
47
|
+
}
|
|
48
|
+
else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
|
|
49
|
+
newIndx =
|
|
50
|
+
(selectedIndex - 1 + React.Children.count(children)) %
|
|
51
|
+
React.Children.count(children);
|
|
52
|
+
safeSetSelectedIndex(newIndx);
|
|
53
|
+
}
|
|
54
|
+
// set focus to new button
|
|
55
|
+
focusElement(newIndx);
|
|
56
|
+
};
|
|
57
|
+
return (
|
|
58
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
59
|
+
_jsx("ul", { onKeyDown: (e) => handleKeyDown(e), ref: parentRef, style: { all: 'inherit', listStyleType: 'none' }, children: React.Children.map(children, (child, index) => {
|
|
60
|
+
if (!React.isValidElement(child)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const clonedElement = cloneElement(child, {
|
|
64
|
+
tabIndex: selectedIndex === index ? 0 : -1,
|
|
65
|
+
});
|
|
66
|
+
return _jsx("li", { children: clonedElement }, index);
|
|
67
|
+
}) }));
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=button-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.js","sourceRoot":"","sources":["../../../../src/graph-visualization/sidepanel-components/button-group.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE;IACzE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEjD,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;;QACrC,MAAM,KAAK,GAAG,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,QAAQ,CAAC,KAAK,CAAC,0CAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE9D,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,KAAK,CAAC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,CAAC;IAEF,OAAO;IACL,2EAA2E;IAC3E,aACE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAClC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,YAE/C,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC7C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,EAAE;gBACxC,QAAQ,EAAE,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aACN,CAAC,CAAC;YAExC,OAAO,uBAAiB,aAAa,IAArB,KAAK,CAAsB,CAAC;QAC9C,CAAC,CAAC,GACC,CACN,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
/* eslint-disable no-irregular-whitespace */
|
|
23
|
+
import { render } from '@testing-library/react';
|
|
24
|
+
import { describe, expect, it, test } from 'vitest';
|
|
25
|
+
import { ClickableUrls } from './clickable-urls';
|
|
26
|
+
describe('clickable-urls', () => {
|
|
27
|
+
describe('convertUrlsToHrefTags', () => {
|
|
28
|
+
test('handles most common URL formats', () => {
|
|
29
|
+
const urls = [
|
|
30
|
+
'bolt://127.0.0.1:7687',
|
|
31
|
+
'http://foo.com',
|
|
32
|
+
'http://goo.gl',
|
|
33
|
+
'https://foo.com',
|
|
34
|
+
'https://www.foo.com',
|
|
35
|
+
'https://www.foo.com/',
|
|
36
|
+
'https://www.foo.com/bar',
|
|
37
|
+
'http://goo.gl/1',
|
|
38
|
+
'http://goo.gl/2',
|
|
39
|
+
'http://firstround.com/review/thoughts-on-gender-and-radical-candor/?ct=t(How_Does_Your_Leadership_Team_Rate_12_3_2015)',
|
|
40
|
+
'https://google.com',
|
|
41
|
+
'http://www.cool.com.au',
|
|
42
|
+
'http://www.cool.com.au/ersdfs',
|
|
43
|
+
'http://www.cool.com.au/ersdfs?dfd=dfgd@s=1',
|
|
44
|
+
'http://www.cool.com:81/index.html',
|
|
45
|
+
];
|
|
46
|
+
const expected = urls.map((url) => `
|
|
47
|
+
<div>
|
|
48
|
+
<span>
|
|
49
|
+
|
|
50
|
+
<a
|
|
51
|
+
href="${url}"
|
|
52
|
+
rel="noreferrer"
|
|
53
|
+
target="_blank"
|
|
54
|
+
>
|
|
55
|
+
${url}
|
|
56
|
+
</a>
|
|
57
|
+
|
|
58
|
+
</span>
|
|
59
|
+
</div>
|
|
60
|
+
`);
|
|
61
|
+
urls.forEach((url, index) => expect(render(_jsx(ClickableUrls, { text: url })).container).toMatchInlineSnapshot(expected[index]));
|
|
62
|
+
});
|
|
63
|
+
test('does not catch invalid or missing protocol urls', () => {
|
|
64
|
+
expect(render(_jsx(ClickableUrls, { text: "google.com" })).container)
|
|
65
|
+
.toMatchInlineSnapshot(`
|
|
66
|
+
<div>
|
|
67
|
+
<span>
|
|
68
|
+
google.com
|
|
69
|
+
</span>
|
|
70
|
+
</div>
|
|
71
|
+
`);
|
|
72
|
+
expect(render(_jsx(ClickableUrls, { text: "https:google.com" })).container)
|
|
73
|
+
.toMatchInlineSnapshot(`
|
|
74
|
+
<div>
|
|
75
|
+
<span>
|
|
76
|
+
https:google.com
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
`);
|
|
80
|
+
});
|
|
81
|
+
test('handles urls inside parentheses', () => {
|
|
82
|
+
expect(render(_jsx(ClickableUrls, { text: "(http://goo.gl/1)" })).container)
|
|
83
|
+
.toMatchInlineSnapshot(`
|
|
84
|
+
<div>
|
|
85
|
+
<span>
|
|
86
|
+
(
|
|
87
|
+
<a
|
|
88
|
+
href="http://goo.gl/1"
|
|
89
|
+
rel="noreferrer"
|
|
90
|
+
target="_blank"
|
|
91
|
+
>
|
|
92
|
+
http://goo.gl/1
|
|
93
|
+
</a>
|
|
94
|
+
)
|
|
95
|
+
</span>
|
|
96
|
+
</div>
|
|
97
|
+
`);
|
|
98
|
+
});
|
|
99
|
+
test('does not include punctuation, comma, exclamation', () => {
|
|
100
|
+
expect(render(_jsx(ClickableUrls, { text: "http://foo.com/." })).container)
|
|
101
|
+
.toMatchInlineSnapshot(`
|
|
102
|
+
<div>
|
|
103
|
+
<span>
|
|
104
|
+
|
|
105
|
+
<a
|
|
106
|
+
href="http://foo.com/"
|
|
107
|
+
rel="noreferrer"
|
|
108
|
+
target="_blank"
|
|
109
|
+
>
|
|
110
|
+
http://foo.com/
|
|
111
|
+
</a>
|
|
112
|
+
.
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
`);
|
|
116
|
+
expect(render(_jsx(ClickableUrls, { text: "http://foo.com/!" })).container)
|
|
117
|
+
.toMatchInlineSnapshot(`
|
|
118
|
+
<div>
|
|
119
|
+
<span>
|
|
120
|
+
|
|
121
|
+
<a
|
|
122
|
+
href="http://foo.com/"
|
|
123
|
+
rel="noreferrer"
|
|
124
|
+
target="_blank"
|
|
125
|
+
>
|
|
126
|
+
http://foo.com/
|
|
127
|
+
</a>
|
|
128
|
+
!
|
|
129
|
+
</span>
|
|
130
|
+
</div>
|
|
131
|
+
`);
|
|
132
|
+
expect(render(_jsx(ClickableUrls, { text: "http://foo.com/," })).container)
|
|
133
|
+
.toMatchInlineSnapshot(`
|
|
134
|
+
<div>
|
|
135
|
+
<span>
|
|
136
|
+
|
|
137
|
+
<a
|
|
138
|
+
href="http://foo.com/"
|
|
139
|
+
rel="noreferrer"
|
|
140
|
+
target="_blank"
|
|
141
|
+
>
|
|
142
|
+
http://foo.com/
|
|
143
|
+
</a>
|
|
144
|
+
,
|
|
145
|
+
</span>
|
|
146
|
+
</div>
|
|
147
|
+
`);
|
|
148
|
+
});
|
|
149
|
+
test('Handles multiple URLs, even if in a text block', () => {
|
|
150
|
+
const URLs = 'sftp://foo.se is better than ftp://bar.dk';
|
|
151
|
+
const textBlock = `
|
|
152
|
+
Long black tulips, born in your blue tints
|
|
153
|
+
Lemongrass eyelids, smoke in your slick lips
|
|
154
|
+
(${URLs})
|
|
155
|
+
Chocolate chapstick, backbeat strat flips
|
|
156
|
+
Swimming pool spaceships, light through the wave tips
|
|
157
|
+
`;
|
|
158
|
+
const { container } = render(_jsx(ClickableUrls, { text: textBlock }));
|
|
159
|
+
expect(container).toMatchInlineSnapshot(`
|
|
160
|
+
<div>
|
|
161
|
+
<span>
|
|
162
|
+
|
|
163
|
+
Long black tulips, born in your blue tints
|
|
164
|
+
Lemongrass eyelids, smoke in your slick lips
|
|
165
|
+
(
|
|
166
|
+
<a
|
|
167
|
+
href="sftp://foo.se"
|
|
168
|
+
rel="noreferrer"
|
|
169
|
+
target="_blank"
|
|
170
|
+
>
|
|
171
|
+
sftp://foo.se
|
|
172
|
+
</a>
|
|
173
|
+
is better than
|
|
174
|
+
<a
|
|
175
|
+
href="ftp://bar.dk"
|
|
176
|
+
rel="noreferrer"
|
|
177
|
+
target="_blank"
|
|
178
|
+
>
|
|
179
|
+
ftp://bar.dk
|
|
180
|
+
</a>
|
|
181
|
+
)
|
|
182
|
+
Chocolate chapstick, backbeat strat flips
|
|
183
|
+
Swimming pool spaceships, light through the wave tips
|
|
184
|
+
|
|
185
|
+
</span>
|
|
186
|
+
</div>
|
|
187
|
+
`);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
describe('ClickableUrls', () => {
|
|
191
|
+
it('renders escaped HTML except for generated tags', () => {
|
|
192
|
+
const text = `Hello, my <strong>name</strong> is <a href="http://twitter.com/neo4j" onClick="alert(1)">Neo4j</a>.`;
|
|
193
|
+
const { container } = render(_jsx(ClickableUrls, { text: text }));
|
|
194
|
+
expect(container).toMatchInlineSnapshot(`
|
|
195
|
+
<div>
|
|
196
|
+
<span>
|
|
197
|
+
Hello, my <strong>name</strong> is <a href="
|
|
198
|
+
<a
|
|
199
|
+
href="http://twitter.com/neo4j"
|
|
200
|
+
rel="noreferrer"
|
|
201
|
+
target="_blank"
|
|
202
|
+
>
|
|
203
|
+
http://twitter.com/neo4j
|
|
204
|
+
</a>
|
|
205
|
+
" onClick="alert(1)">Neo4j</a>.
|
|
206
|
+
</span>
|
|
207
|
+
</div>
|
|
208
|
+
`);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
//# sourceMappingURL=clickable-urls-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clickable-urls-test.js","sourceRoot":"","sources":["../../../../src/graph-visualization/sidepanel-components/clickable-urls-test.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4CAA4C;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,M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AC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,IAAI,GAAG,qGAAqG,CAAC;YAEnH,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC;YAC5D,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;OAcvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import React from 'react';
|
|
23
|
+
// credits to https://www.regextester.com/96504, modified though
|
|
24
|
+
const URL_REGEX =
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
/(?:https?|s?ftp|bolt):\/\/(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))?/gi;
|
|
27
|
+
const ClickableUrlsComponent = ({ text }) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const definedText = text !== null && text !== void 0 ? text : '';
|
|
30
|
+
const urls = (_a = definedText.match(URL_REGEX)) !== null && _a !== void 0 ? _a : [];
|
|
31
|
+
return (_jsx(_Fragment, { children: definedText.split(URL_REGEX).map((t, index) => {
|
|
32
|
+
/* since we never move these components this key should be fine */
|
|
33
|
+
return (_jsxs(React.Fragment, { children: [t, urls[index] && (
|
|
34
|
+
// Should be safe from XSS.
|
|
35
|
+
// Ref: https://mathiasbynens.github.io/rel-noopener/
|
|
36
|
+
_jsx("a", { href: urls[index], target: "_blank", rel: "noopener noreferrer", className: "hover:underline", children: urls[index] }))] }, `clickable-url-${index}`));
|
|
37
|
+
}) }));
|
|
38
|
+
};
|
|
39
|
+
export const ClickableUrls = React.memo(ClickableUrlsComponent);
|
|
40
|
+
//# sourceMappingURL=clickable-urls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clickable-urls.js","sourceRoot":"","sources":["../../../../src/graph-visualization/sidepanel-components/clickable-urls.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,gEAAgE;AAChE,MAAM,SAAS;AACb,2BAA2B;AAC3B,oKAAoK,CAAC;AAMvK,MAAM,sBAAsB,GAAG,CAAC,EAAE,IAAI,EAAsB,EAAE,EAAE;;IAC9D,MAAM,WAAW,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,MAAA,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,mCAAI,EAAE,CAAC;IAEhD,OAAO,CACL,4BACG,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAC7C,kEAAkE;YAClE,OAAO,CACL,MAAC,KAAK,CAAC,QAAQ,eACZ,CAAC,EACD,IAAI,CAAC,KAAK,CAAC,IAAI;oBACd,2BAA2B;oBAC3B,qDAAqD;oBACrD,YACE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EACjB,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,SAAS,EAAC,iBAAiB,YAE1B,IAAI,CAAC,KAAK,CAAC,GACV,CACL,KAbkB,iBAAiB,KAAK,EAAE,CAc5B,CAClB,CAAC;QACJ,CAAC,CAAC,GACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import { ClipboardButton } from '@neo4j-ndl/react/clipboard-copier';
|
|
23
|
+
import { GraphLabel } from '@neo4j-ndl/react/graph-label';
|
|
24
|
+
import { useMemo } from 'react';
|
|
25
|
+
import { useGraphVizContext, } from '../graph-viz-context';
|
|
26
|
+
import { GraphVizSidepanel } from '../graph-viz-sidepanel';
|
|
27
|
+
import { PropertiesTable } from './properties-table';
|
|
28
|
+
export const DetailsPanel = ({ paneWidth = 400 }) => {
|
|
29
|
+
const { selected, nvlGraph } = useGraphVizContext();
|
|
30
|
+
const nodeData = useMemo(() => {
|
|
31
|
+
const [nodeId] = selected.nodeIds;
|
|
32
|
+
if (nodeId !== undefined) {
|
|
33
|
+
return nvlGraph.dataLookupTable.nodes[nodeId];
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}, [selected, nvlGraph]);
|
|
37
|
+
const relData = useMemo(() => {
|
|
38
|
+
const [relId] = selected.relationshipIds;
|
|
39
|
+
if (relId !== undefined) {
|
|
40
|
+
return nvlGraph.dataLookupTable.relationships[relId];
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}, [selected, nvlGraph]);
|
|
44
|
+
const selectedItem = useMemo(() => {
|
|
45
|
+
if (nodeData) {
|
|
46
|
+
return { data: nodeData, dataType: 'node' };
|
|
47
|
+
}
|
|
48
|
+
if (relData) {
|
|
49
|
+
return { data: relData, dataType: 'relationship' };
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}, [nodeData, relData]);
|
|
53
|
+
if (selectedItem === undefined) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const properties = [
|
|
57
|
+
{
|
|
58
|
+
key: '<id>',
|
|
59
|
+
type: 'String',
|
|
60
|
+
value: `${selectedItem.data.id}`,
|
|
61
|
+
},
|
|
62
|
+
...Object.keys(selectedItem.data.properties).map((key) => {
|
|
63
|
+
return {
|
|
64
|
+
key: key,
|
|
65
|
+
type: selectedItem.data.properties[key].type,
|
|
66
|
+
value: selectedItem.data.properties[key].stringified,
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsxs(GraphVizSidepanel.Title, { children: [_jsx("h6", { className: "ndl-details-title", children: selectedItem.dataType === 'node'
|
|
71
|
+
? 'Node details'
|
|
72
|
+
: 'Relationship details' }), _jsx(ClipboardButton, { textToCopy: properties
|
|
73
|
+
.map((prop) => `${prop.key}: ${prop.value}`)
|
|
74
|
+
.join('\n'), size: "small" })] }), _jsxs(GraphVizSidepanel.Content, { children: [_jsx("div", { className: "ndl-details-tags", children: selectedItem.dataType === 'node' ? (selectedItem.data.labelsSorted.map((label) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return (_jsx(GraphLabel, { type: "node", color: (_b = (_a = nvlGraph.dataLookupTable.labelMetaData[label]) === null || _a === void 0 ? void 0 : _a.mostCommonColor) !== null && _b !== void 0 ? _b : '', as: "span", htmlAttributes: {
|
|
77
|
+
tabIndex: 0,
|
|
78
|
+
}, children: label }, label));
|
|
79
|
+
})) : (_jsx(GraphLabel, { type: "relationship", color: selectedItem.data.color, as: "span", htmlAttributes: {
|
|
80
|
+
tabIndex: 0,
|
|
81
|
+
}, children: selectedItem.data.type }, selectedItem.data.type)) }), _jsx("div", { className: "ndl-details-divider" }), _jsx(PropertiesTable, { properties: selectedItem.data.properties, paneWidth: paneWidth })] })] }));
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=details-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details-panel.js","sourceRoot":"","sources":["../../../../src/graph-visualization/sidepanel-components/details-panel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAGL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,EAAE;;4BAAC,OAAA,CAC5C,KAAC,UAAU,IACT,IAAI,EAAC,MAAM,EACX,KAAK,EACH,MAAA,MAAA,QAAQ,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,CAAC,0CACzC,eAAe,mCAAI,EAAE,EAG3B,EAAE,EAAC,MAAM,EACT,cAAc,EAAE;oCACd,QAAQ,EAAE,CAAC;iCACZ,YAEA,KAAK,IAND,KAAK,CAOC,CACd,CAAA;yBAAA,CAAC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,UAAU,IACT,IAAI,EAAC,cAAc,EACnB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,EAE9B,EAAE,EAAC,MAAM,EACT,cAAc,EAAE;gCACd,QAAQ,EAAE,CAAC;6BACZ,YAEA,YAAY,CAAC,IAAI,CAAC,IAAI,IANlB,YAAY,CAAC,IAAI,CAAC,IAAI,CAOhB,CACd,GACG,EAEN,cAAK,SAAS,EAAC,qBAAqB,GAAG,EACvC,KAAC,eAAe,IACd,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,UAAU,EACxC,SAAS,EAAE,SAAS,GACpB,IACwB,IAC3B,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import { GraphLabel, Typography } from '@neo4j-ndl/react';
|
|
23
|
+
import { useGraphVizContext } from '../graph-viz-context';
|
|
24
|
+
import { GraphVizSidepanel } from '../graph-viz-sidepanel';
|
|
25
|
+
import { ShowAll } from './show-all';
|
|
26
|
+
const OVERVIEW_STEP_SIZE = 25;
|
|
27
|
+
export const OverviewPanel = () => {
|
|
28
|
+
const { nvlGraph } = useGraphVizContext();
|
|
29
|
+
return (_jsxs(_Fragment, { children: [_jsx(GraphVizSidepanel.Title, { children: _jsx(Typography, { variant: "h6", children: "Results overview" }) }), _jsx(GraphVizSidepanel.Content, { children: _jsxs("div", { className: "ndl-graph-viz-overview-panel", children: [nvlGraph.dataLookupTable.labels.length > 0 && (_jsxs("div", { className: "ndl-overview-section", children: [_jsx("div", { className: "ndl-overview-header", children: _jsxs("span", { children: ["Nodes", ` (${nvlGraph.nodes.length.toLocaleString()})`] }) }), _jsx("div", { className: "ndl-overview-items", tabIndex: 0, children: _jsx(ShowAll, { initiallyShown: OVERVIEW_STEP_SIZE, isButtonGroup: true, children: nvlGraph.dataLookupTable.labels.map((label) => function GraphLabelWrapper() {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
return (_jsxs(GraphLabel, { type: "node", htmlAttributes: {
|
|
32
|
+
tabIndex: -1,
|
|
33
|
+
}, color: (_b = (_a = nvlGraph.dataLookupTable.labelMetaData[label]) === null || _a === void 0 ? void 0 : _a.mostCommonColor) !== null && _b !== void 0 ? _b : '', as: "span", children: [label, " (", (_d = (_c = nvlGraph.dataLookupTable.labelMetaData[label]) === null || _c === void 0 ? void 0 : _c.totalCount) !== null && _d !== void 0 ? _d : 0, ")"] }, label));
|
|
34
|
+
}) }) })] })), nvlGraph.dataLookupTable.types.length > 0 && (_jsxs("div", { className: "ndl-overview-relationships-section", children: [_jsxs("span", { className: "ndl-overview-relationships-title", children: ["Relationships", ` (${nvlGraph.rels.length.toLocaleString()})`] }), _jsx("div", { className: "ndl-overview-items", children: _jsx(ShowAll, { initiallyShown: OVERVIEW_STEP_SIZE, isButtonGroup: true, children: nvlGraph.dataLookupTable.types.map((type) => {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
return (_jsxs(GraphLabel, { type: "relationship", htmlAttributes: {
|
|
37
|
+
tabIndex: -1,
|
|
38
|
+
}, color: (_b = (_a = nvlGraph.dataLookupTable.typeMetaData[type]) === null || _a === void 0 ? void 0 : _a.mostCommonColor) !== null && _b !== void 0 ? _b : '', as: "span", children: [type, " (", (_d = (_c = nvlGraph.dataLookupTable.typeMetaData[type]) === null || _c === void 0 ? void 0 : _c.totalCount) !== null && _d !== void 0 ? _d : 0, ")"] }, type));
|
|
39
|
+
}) }) })] }))] }) })] }));
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=overview-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overview-panel.js","sourceRoot":"","sources":["../../../../src/graph-visualization/sidepanel-components/overview-panel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAE1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