@macrostrat/feedback-components 1.1.3 → 1.1.5
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/CHANGELOG.md +10 -0
- package/dist/esm/feedback-components.03f08dc7.js +287 -0
- package/dist/esm/feedback-components.03f08dc7.js.map +1 -0
- package/dist/esm/feedback-components.06a79c6a.js +354 -0
- package/dist/esm/feedback-components.06a79c6a.js.map +1 -0
- package/dist/esm/{feedback-components.f577ebea.js → feedback-components.3f59f2a5.js} +14 -89
- package/dist/esm/feedback-components.3f59f2a5.js.map +1 -0
- package/dist/esm/{feedback-components.45d25912.js → feedback-components.4cbd249a.js} +5 -5
- package/dist/esm/{feedback-components.45d25912.js.map → feedback-components.4cbd249a.js.map} +1 -1
- package/dist/esm/{feedback-components.fb60c70d.css → feedback-components.5a8f0185.css} +29 -4
- package/dist/esm/feedback-components.5a8f0185.css.map +1 -0
- package/dist/esm/{feedback-components.fa1d3641.js → feedback-components.6cec1102.js} +84 -9
- package/dist/esm/feedback-components.6cec1102.js.map +1 -0
- package/dist/esm/{feedback-components.95dbe7d7.js → feedback-components.7c2fe400.js} +16 -1
- package/dist/esm/feedback-components.7c2fe400.js.map +1 -0
- package/dist/esm/{feedback-components.832b2eae.js → feedback-components.939a3a9f.js} +7 -7
- package/dist/esm/feedback-components.939a3a9f.js.map +1 -0
- package/dist/esm/feedback-components.e53837d9.js +248 -0
- package/dist/esm/feedback-components.e53837d9.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/node/{feedback-components.f9abf0d6.js → feedback-components.3888aa2a.js} +2 -2
- package/dist/node/{feedback-components.f9abf0d6.js.map → feedback-components.3888aa2a.js.map} +1 -1
- package/dist/node/feedback-components.388de4ac.js +2 -0
- package/dist/node/feedback-components.388de4ac.js.map +1 -0
- package/dist/node/feedback-components.827f8d80.js +2 -0
- package/dist/node/feedback-components.827f8d80.js.map +1 -0
- package/dist/node/feedback-components.9e1d4e4c.js +2 -0
- package/dist/node/feedback-components.9e1d4e4c.js.map +1 -0
- package/dist/node/feedback-components.b8da3bce.js +2 -0
- package/dist/node/feedback-components.b8da3bce.js.map +1 -0
- package/dist/node/feedback-components.c31cf831.js +2 -0
- package/dist/node/feedback-components.c31cf831.js.map +1 -0
- package/dist/node/feedback-components.db4d0a14.css +2 -0
- package/dist/node/feedback-components.db4d0a14.css.map +1 -0
- package/dist/node/feedback-components.f91331e9.js +2 -0
- package/dist/node/feedback-components.f91331e9.js.map +1 -0
- package/dist/node/feedback-components.fc0395df.js +2 -0
- package/dist/node/feedback-components.fc0395df.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +2 -2
- package/src/feedback/edit-state.ts +99 -3
- package/src/feedback/feedback.module.sass +24 -4
- package/src/feedback/graph.ts +5 -2
- package/src/feedback/index.ts +39 -320
- package/src/feedback/matches.ts +279 -0
- package/src/feedback/text-visualizer.ts +34 -88
- package/src/feedback/typelist.ts +321 -0
- package/dist/esm/feedback-components.1e7da538.js +0 -587
- package/dist/esm/feedback-components.1e7da538.js.map +0 -1
- package/dist/esm/feedback-components.832b2eae.js.map +0 -1
- package/dist/esm/feedback-components.95dbe7d7.js.map +0 -1
- package/dist/esm/feedback-components.f577ebea.js.map +0 -1
- package/dist/esm/feedback-components.fa1d3641.js.map +0 -1
- package/dist/esm/feedback-components.fb60c70d.css.map +0 -1
- package/dist/node/feedback-components.25f1909a.js +0 -2
- package/dist/node/feedback-components.25f1909a.js.map +0 -1
- package/dist/node/feedback-components.4cd6b208.js +0 -2
- package/dist/node/feedback-components.4cd6b208.js.map +0 -1
- package/dist/node/feedback-components.9328e8ba.js +0 -2
- package/dist/node/feedback-components.9328e8ba.js.map +0 -1
- package/dist/node/feedback-components.b7946db4.js +0 -2
- package/dist/node/feedback-components.b7946db4.js.map +0 -1
- package/dist/node/feedback-components.c459cc27.js +0 -2
- package/dist/node/feedback-components.c459cc27.js.map +0 -1
- package/dist/node/feedback-components.c88cb37f.css +0 -2
- package/dist/node/feedback-components.c88cb37f.css.map +0 -1
|
@@ -1,587 +0,0 @@
|
|
|
1
|
-
import "./feedback-components.fb60c70d.css";
|
|
2
|
-
import $bvJLP$feedbackcomponents95dbe7d7js from "./feedback-components.95dbe7d7.js";
|
|
3
|
-
import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./feedback-components.45d25912.js";
|
|
4
|
-
import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./feedback-components.f577ebea.js";
|
|
5
|
-
import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./feedback-components.707e3490.js";
|
|
6
|
-
import {TreeDispatchContext as $b79bf29960412ca7$export$e5ce04c5b3f58533, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e, useUpdatableTree as $b79bf29960412ca7$export$911bb4b9c8065d3d} from "./feedback-components.fa1d3641.js";
|
|
7
|
-
import {OmniboxSelector as $fda9ef5406c1cfb4$export$d8660660a589068c} from "./feedback-components.ad9f284e.js";
|
|
8
|
-
import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./feedback-components.832b2eae.js";
|
|
9
|
-
import $bvJLP$macrostrathyper from "@macrostrat/hyper";
|
|
10
|
-
import {Tree as $bvJLP$Tree} from "react-arborist";
|
|
11
|
-
import {useState as $bvJLP$useState, useRef as $bvJLP$useRef, useCallback as $bvJLP$useCallback, useEffect as $bvJLP$useEffect} from "react";
|
|
12
|
-
import {SegmentedControl as $bvJLP$SegmentedControl, Card as $bvJLP$Card, ButtonGroup as $bvJLP$ButtonGroup, Switch as $bvJLP$Switch, Divider as $bvJLP$Divider, Icon as $bvJLP$Icon, Overlay2 as $bvJLP$Overlay2, Popover as $bvJLP$Popover} from "@blueprintjs/core";
|
|
13
|
-
import {ErrorBoundary as $bvJLP$ErrorBoundary, FlexRow as $bvJLP$FlexRow, CancelButton as $bvJLP$CancelButton, SaveButton as $bvJLP$SaveButton, useInDarkMode as $bvJLP$useInDarkMode} from "@macrostrat/ui-components";
|
|
14
|
-
import $bvJLP$useelementdimensions from "use-element-dimensions";
|
|
15
|
-
import {ColorPicker as $bvJLP$ColorPicker} from "@macrostrat/data-sheet";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function $parcel$interopDefault(a) {
|
|
19
|
-
return a && a.__esModule ? a.default : a;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const $71d20dff35996763$var$h = (0, $bvJLP$macrostrathyper).styled((0, ($parcel$interopDefault($bvJLP$feedbackcomponents95dbe7d7js))));
|
|
36
|
-
function $71d20dff35996763$var$setsAreTheSame(a, b) {
|
|
37
|
-
if (a.size !== b.size) return false;
|
|
38
|
-
for (const item of a){
|
|
39
|
-
if (!b.has(item)) return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap, matchLinks: matchLinks }) {
|
|
44
|
-
// Get the input arguments
|
|
45
|
-
const [state, dispatch] = (0, $b79bf29960412ca7$export$911bb4b9c8065d3d)(entities.map($71d20dff35996763$var$processEntity), entityTypes);
|
|
46
|
-
const [match, setMatchLinks] = (0, $bvJLP$useState)(matchLinks || {});
|
|
47
|
-
const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType, entityTypesMap: entityTypesMap } = state;
|
|
48
|
-
const [{ width: width, height: height }, ref] = (0, $bvJLP$useelementdimensions)();
|
|
49
|
-
return $71d20dff35996763$var$h("div.page-wrapper", [
|
|
50
|
-
$71d20dff35996763$var$h("div.feedback-container", $71d20dff35996763$var$h((0, $b79bf29960412ca7$export$e5ce04c5b3f58533).Provider, {
|
|
51
|
-
value: dispatch
|
|
52
|
-
}, [
|
|
53
|
-
$71d20dff35996763$var$h((0, $bvJLP$ErrorBoundary), {
|
|
54
|
-
description: "An error occurred while rendering the feedback text component."
|
|
55
|
-
}, $71d20dff35996763$var$h((0, $156a3efbc315814c$export$6e107db9091b8219), {
|
|
56
|
-
text: text,
|
|
57
|
-
dispatch: dispatch,
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
nodes: tree,
|
|
60
|
-
selectedNodes: selectedNodes,
|
|
61
|
-
allowOverlap: allowOverlap,
|
|
62
|
-
matchLinks: match
|
|
63
|
-
})),
|
|
64
|
-
$71d20dff35996763$var$h((0, $bvJLP$FlexRow), {
|
|
65
|
-
alignItems: "baseline",
|
|
66
|
-
justifyContent: "space-between"
|
|
67
|
-
}, [
|
|
68
|
-
$71d20dff35996763$var$h((0, $03d8811e9c9b360d$export$4eb2a0ce903ce967), {
|
|
69
|
-
data: model
|
|
70
|
-
}),
|
|
71
|
-
$71d20dff35996763$var$h((0, $bvJLP$SegmentedControl), {
|
|
72
|
-
options: [
|
|
73
|
-
{
|
|
74
|
-
label: "Tree",
|
|
75
|
-
value: "tree"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
label: "Graph",
|
|
79
|
-
value: "graph"
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
value: state.viewMode,
|
|
83
|
-
small: true,
|
|
84
|
-
onValueChange (value) {
|
|
85
|
-
console.log("Setting view mode", value);
|
|
86
|
-
dispatch({
|
|
87
|
-
type: "set-view-mode",
|
|
88
|
-
payload: value
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
]),
|
|
93
|
-
$71d20dff35996763$var$h("div.entity-panel", {
|
|
94
|
-
ref: ref
|
|
95
|
-
}, [
|
|
96
|
-
$71d20dff35996763$var$h.if(state.viewMode == "tree")($71d20dff35996763$var$ManagedSelectionTree, {
|
|
97
|
-
selectedNodes: selectedNodes,
|
|
98
|
-
dispatch: dispatch,
|
|
99
|
-
tree: tree,
|
|
100
|
-
width: width,
|
|
101
|
-
height: height,
|
|
102
|
-
matchComponent: matchComponent
|
|
103
|
-
}),
|
|
104
|
-
$71d20dff35996763$var$h.if(state.viewMode == "graph")((0, $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566), {
|
|
105
|
-
tree: tree,
|
|
106
|
-
width: width,
|
|
107
|
-
height: height,
|
|
108
|
-
dispatch: dispatch,
|
|
109
|
-
selectedNodes: selectedNodes
|
|
110
|
-
})
|
|
111
|
-
])
|
|
112
|
-
])),
|
|
113
|
-
$71d20dff35996763$var$h((0, $bvJLP$Card), {
|
|
114
|
-
className: "control-panel"
|
|
115
|
-
}, [
|
|
116
|
-
$71d20dff35996763$var$h("div.control-content", [
|
|
117
|
-
$71d20dff35996763$var$h((0, $bvJLP$ButtonGroup), {
|
|
118
|
-
vertical: true,
|
|
119
|
-
fill: true,
|
|
120
|
-
minimal: true,
|
|
121
|
-
alignText: "left"
|
|
122
|
-
}, [
|
|
123
|
-
$71d20dff35996763$var$h.if(matchLinks)((0, $bvJLP$Switch), {
|
|
124
|
-
label: "Show matches",
|
|
125
|
-
checked: match !== null,
|
|
126
|
-
onChange: (e)=>{
|
|
127
|
-
setMatchLinks(match === null ? matchLinks || {} : null);
|
|
128
|
-
}
|
|
129
|
-
}),
|
|
130
|
-
$71d20dff35996763$var$h((0, $bvJLP$CancelButton), {
|
|
131
|
-
icon: "trash",
|
|
132
|
-
disabled: state.initialTree == state.tree,
|
|
133
|
-
onClick () {
|
|
134
|
-
dispatch({
|
|
135
|
-
type: "reset"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, "Reset"),
|
|
139
|
-
$71d20dff35996763$var$h((0, $bvJLP$SaveButton), {
|
|
140
|
-
onClick () {
|
|
141
|
-
onSave(state.tree);
|
|
142
|
-
},
|
|
143
|
-
disabled: state.initialTree == state.tree
|
|
144
|
-
}, "Save")
|
|
145
|
-
]),
|
|
146
|
-
$71d20dff35996763$var$h((0, $bvJLP$Divider)),
|
|
147
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$EntityTypeSelector, {
|
|
148
|
-
entityTypes: entityTypesMap,
|
|
149
|
-
selected: selectedEntityType,
|
|
150
|
-
onChange (payload) {
|
|
151
|
-
dispatch({
|
|
152
|
-
type: "select-entity-type",
|
|
153
|
-
payload: payload
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
dispatch: dispatch,
|
|
157
|
-
tree: tree,
|
|
158
|
-
selectedNodes: selectedNodes,
|
|
159
|
-
isOpen: isSelectingEntityType,
|
|
160
|
-
setOpen: (isOpen)=>dispatch({
|
|
161
|
-
type: "toggle-entity-type-selector",
|
|
162
|
-
payload: isOpen
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
])
|
|
166
|
-
])
|
|
167
|
-
]);
|
|
168
|
-
}
|
|
169
|
-
function $71d20dff35996763$var$processEntity(entity) {
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
return {
|
|
172
|
-
...entity,
|
|
173
|
-
// @ts-ignore
|
|
174
|
-
term_type: entity.type.name,
|
|
175
|
-
txt_range: [
|
|
176
|
-
entity.indices
|
|
177
|
-
],
|
|
178
|
-
children: entity.children?.map($71d20dff35996763$var$processEntity) ?? []
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function $71d20dff35996763$var$EntityTypeSelector({ entityTypes: entityTypes, selected: selected, isOpen: isOpen, setOpen: setOpen, onChange: onChange, tree: tree, dispatch: dispatch, selectedNodes: selectedNodes = [] }) {
|
|
182
|
-
// Show all entity types when selected is null
|
|
183
|
-
const _selected = selected != null ? selected : undefined;
|
|
184
|
-
const [inputValue, setInputValue] = (0, $bvJLP$useState)("");
|
|
185
|
-
const types = Array.from(entityTypes.values());
|
|
186
|
-
const items = inputValue !== "" ? types.filter((d)=>d.name.toLowerCase().includes(inputValue.toLowerCase())) : types;
|
|
187
|
-
return $71d20dff35996763$var$h("div.entity-type-selector", [
|
|
188
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$TypeList, {
|
|
189
|
-
types: entityTypes,
|
|
190
|
-
selected: _selected,
|
|
191
|
-
dispatch: dispatch,
|
|
192
|
-
selectedNodes: selectedNodes,
|
|
193
|
-
tree: tree
|
|
194
|
-
}),
|
|
195
|
-
$71d20dff35996763$var$h((0, $fda9ef5406c1cfb4$export$d8660660a589068c), {
|
|
196
|
-
isOpen: isOpen,
|
|
197
|
-
items: items,
|
|
198
|
-
selectedItem: _selected,
|
|
199
|
-
onSelectItem (item) {
|
|
200
|
-
setOpen(false);
|
|
201
|
-
onChange(item);
|
|
202
|
-
},
|
|
203
|
-
onQueryChange (query) {
|
|
204
|
-
setInputValue(query);
|
|
205
|
-
},
|
|
206
|
-
onClose () {
|
|
207
|
-
setOpen(false);
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
]);
|
|
211
|
-
}
|
|
212
|
-
function $71d20dff35996763$var$countNodes(tree) {
|
|
213
|
-
if (!tree) return 0;
|
|
214
|
-
let count = 0;
|
|
215
|
-
function recurse(nodes) {
|
|
216
|
-
for (const node of nodes){
|
|
217
|
-
count++;
|
|
218
|
-
if (node.children && Array.isArray(node.children)) recurse(node.children);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
recurse(tree);
|
|
222
|
-
return count;
|
|
223
|
-
}
|
|
224
|
-
function $71d20dff35996763$var$ManagedSelectionTree(props) {
|
|
225
|
-
const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent } = props;
|
|
226
|
-
const ref = (0, $bvJLP$useRef)();
|
|
227
|
-
// Use a ref to track clicks (won't cause rerender)
|
|
228
|
-
const clickedRef = (0, $bvJLP$useRef)(false);
|
|
229
|
-
const _Node = (0, $bvJLP$useCallback)((props)=>$71d20dff35996763$var$h((0, $b6b9741bf83336eb$export$2e2bcd8739ae039), {
|
|
230
|
-
...props,
|
|
231
|
-
matchComponent: matchComponent
|
|
232
|
-
}), [
|
|
233
|
-
matchComponent
|
|
234
|
-
]);
|
|
235
|
-
// Update Tree selection when selectedNodes change
|
|
236
|
-
(0, $bvJLP$useEffect)(()=>{
|
|
237
|
-
if (ref.current == null) return;
|
|
238
|
-
const selection = new Set(selectedNodes.map((d)=>d.toString()));
|
|
239
|
-
const currentSelection = ref.current.selectedIds;
|
|
240
|
-
if ($71d20dff35996763$var$setsAreTheSame(selection, currentSelection)) return;
|
|
241
|
-
ref.current.setSelection({
|
|
242
|
-
ids: selectedNodes.map((d)=>d.toString()),
|
|
243
|
-
anchor: null,
|
|
244
|
-
mostRecent: null
|
|
245
|
-
});
|
|
246
|
-
}, [
|
|
247
|
-
selectedNodes
|
|
248
|
-
]);
|
|
249
|
-
// Mark clicked when user clicks inside the tree container
|
|
250
|
-
function handleClick() {
|
|
251
|
-
clickedRef.current = true;
|
|
252
|
-
}
|
|
253
|
-
const ctrlPressedRef = (0, $bvJLP$useRef)(false);
|
|
254
|
-
(0, $bvJLP$useEffect)(()=>{
|
|
255
|
-
const down = (e)=>{
|
|
256
|
-
if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;
|
|
257
|
-
};
|
|
258
|
-
const up = ()=>ctrlPressedRef.current = false;
|
|
259
|
-
window.addEventListener("keydown", down);
|
|
260
|
-
window.addEventListener("keyup", up);
|
|
261
|
-
return ()=>{
|
|
262
|
-
window.removeEventListener("keydown", down);
|
|
263
|
-
window.removeEventListener("keyup", up);
|
|
264
|
-
};
|
|
265
|
-
}, []);
|
|
266
|
-
const handleSelect = (0, $bvJLP$useCallback)((nodes)=>{
|
|
267
|
-
if (!clickedRef.current) return;
|
|
268
|
-
clickedRef.current = false;
|
|
269
|
-
const isMultiSelect = ctrlPressedRef.current;
|
|
270
|
-
let ids = nodes.map((d)=>parseInt(d.id));
|
|
271
|
-
if (isMultiSelect) dispatch({
|
|
272
|
-
type: "toggle-node-selected",
|
|
273
|
-
payload: {
|
|
274
|
-
ids: ids
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
else {
|
|
278
|
-
if (ids.length === 1 && ids[0] === selectedNodes[0]) ids = [];
|
|
279
|
-
dispatch({
|
|
280
|
-
type: "select-node",
|
|
281
|
-
payload: {
|
|
282
|
-
ids: ids
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
}, [
|
|
287
|
-
selectedNodes,
|
|
288
|
-
dispatch
|
|
289
|
-
]);
|
|
290
|
-
return $71d20dff35996763$var$h("div.selection-tree-wrapper", {
|
|
291
|
-
onPointerDown: handleClick
|
|
292
|
-
}, $71d20dff35996763$var$h((0, $bvJLP$Tree), {
|
|
293
|
-
className: "selection-tree",
|
|
294
|
-
height: height,
|
|
295
|
-
width: width,
|
|
296
|
-
ref: ref,
|
|
297
|
-
data: tree,
|
|
298
|
-
onMove ({ dragIds: dragIds, parentId: parentId, index: index }) {
|
|
299
|
-
dispatch({
|
|
300
|
-
type: "move-node",
|
|
301
|
-
payload: {
|
|
302
|
-
dragIds: dragIds.map((d)=>parseInt(d)),
|
|
303
|
-
parentId: parentId ? parseInt(parentId) : null,
|
|
304
|
-
index: index
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
},
|
|
308
|
-
onDelete ({ ids: ids }) {
|
|
309
|
-
dispatch({
|
|
310
|
-
type: "delete-node",
|
|
311
|
-
payload: {
|
|
312
|
-
ids: ids.map((d)=>parseInt(d))
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
},
|
|
316
|
-
onSelect: handleSelect,
|
|
317
|
-
children: _Node,
|
|
318
|
-
idAccessor (d) {
|
|
319
|
-
return d.id.toString();
|
|
320
|
-
}
|
|
321
|
-
}));
|
|
322
|
-
}
|
|
323
|
-
function $71d20dff35996763$var$TypeList({ types: types, selected: selected, dispatch: dispatch, selectedNodes: selectedNodes, tree: tree }) {
|
|
324
|
-
const [selectedType, setSelectedType] = (0, $bvJLP$useState)(null);
|
|
325
|
-
const isSelectedNodes = selectedNodes.length > 0;
|
|
326
|
-
const darkMode = (0, $bvJLP$useInDarkMode)();
|
|
327
|
-
const luminance = darkMode ? 0.9 : 0.4;
|
|
328
|
-
return $71d20dff35996763$var$h("div.type-list-container", [
|
|
329
|
-
$71d20dff35996763$var$h("div.type-list-header", isSelectedNodes && !selectedType ? "Change selected nodes to:" : "Entity Types"),
|
|
330
|
-
$71d20dff35996763$var$h("div.type-list", Array.from(types.values()).map((type)=>$71d20dff35996763$var$h($71d20dff35996763$var$TypeTag, {
|
|
331
|
-
type: type,
|
|
332
|
-
luminance: luminance,
|
|
333
|
-
selectedType: selectedType,
|
|
334
|
-
setSelectedType: setSelectedType,
|
|
335
|
-
dispatch: dispatch,
|
|
336
|
-
tree: tree,
|
|
337
|
-
selectedNodes: selectedNodes,
|
|
338
|
-
selected: selected,
|
|
339
|
-
isSelectedNodes: isSelectedNodes
|
|
340
|
-
}))),
|
|
341
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$AddType, {
|
|
342
|
-
dispatch: dispatch
|
|
343
|
-
})
|
|
344
|
-
]);
|
|
345
|
-
}
|
|
346
|
-
function $71d20dff35996763$var$collectMatchingIds(tree, id) {
|
|
347
|
-
const ids = [];
|
|
348
|
-
function traverse(node) {
|
|
349
|
-
if (node.type.id === id) ids.push(node.id);
|
|
350
|
-
if (Array.isArray(node.children)) node.children.forEach(traverse);
|
|
351
|
-
}
|
|
352
|
-
tree.forEach(traverse);
|
|
353
|
-
return ids;
|
|
354
|
-
}
|
|
355
|
-
function $71d20dff35996763$var$AddType({ dispatch: dispatch }) {
|
|
356
|
-
const [overlayOpen, setOverlayOpen] = (0, $bvJLP$useState)(false);
|
|
357
|
-
const saveHandler = (payload)=>{
|
|
358
|
-
dispatch({
|
|
359
|
-
type: "add-entity-type",
|
|
360
|
-
payload: payload
|
|
361
|
-
});
|
|
362
|
-
setOverlayOpen(false);
|
|
363
|
-
};
|
|
364
|
-
return $71d20dff35996763$var$h("div.add-type-container", [
|
|
365
|
-
$71d20dff35996763$var$h("div.add-type", {
|
|
366
|
-
onClick: ()=>setOverlayOpen(true)
|
|
367
|
-
}, [
|
|
368
|
-
$71d20dff35996763$var$h("p.add-type-text", "Add new type"),
|
|
369
|
-
$71d20dff35996763$var$h((0, $bvJLP$Icon), {
|
|
370
|
-
icon: "plus"
|
|
371
|
-
})
|
|
372
|
-
]),
|
|
373
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$TypeOverlay, {
|
|
374
|
-
setOverlayOpen: setOverlayOpen,
|
|
375
|
-
overlayOpen: overlayOpen,
|
|
376
|
-
title: "Add New Type",
|
|
377
|
-
saveHandler: saveHandler
|
|
378
|
-
})
|
|
379
|
-
]);
|
|
380
|
-
}
|
|
381
|
-
function $71d20dff35996763$var$EditType({ dispatch: dispatch, type: type }) {
|
|
382
|
-
const [editorOpen, setEditorOpen] = (0, $bvJLP$useState)(false);
|
|
383
|
-
const saveHandler = (payload)=>{
|
|
384
|
-
dispatch({
|
|
385
|
-
type: "update-entity-type",
|
|
386
|
-
payload: payload
|
|
387
|
-
});
|
|
388
|
-
setEditorOpen(false);
|
|
389
|
-
};
|
|
390
|
-
return $71d20dff35996763$var$h("div.edit-type", [
|
|
391
|
-
$71d20dff35996763$var$h((0, $bvJLP$Icon), {
|
|
392
|
-
icon: "edit",
|
|
393
|
-
className: "edit-icon",
|
|
394
|
-
onClick: (e)=>{
|
|
395
|
-
e.stopPropagation();
|
|
396
|
-
setEditorOpen(true);
|
|
397
|
-
}
|
|
398
|
-
}),
|
|
399
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$TypeOverlay, {
|
|
400
|
-
setOverlayOpen: setEditorOpen,
|
|
401
|
-
overlayOpen: editorOpen,
|
|
402
|
-
originalType: type,
|
|
403
|
-
title: "Edit Type",
|
|
404
|
-
saveHandler: saveHandler
|
|
405
|
-
})
|
|
406
|
-
]);
|
|
407
|
-
}
|
|
408
|
-
function $71d20dff35996763$var$TypeOverlay({ setOverlayOpen: setOverlayOpen, overlayOpen: overlayOpen, originalType: originalType, title: title, saveHandler: saveHandler }) {
|
|
409
|
-
const { name: name, description: description, color: color, id: id } = originalType || {};
|
|
410
|
-
const [nameInput, setNameInput] = (0, $bvJLP$useState)(name || "");
|
|
411
|
-
const [descriptionInput, setDescriptionInput] = (0, $bvJLP$useState)(description || "");
|
|
412
|
-
const [colorInput, setColorInput] = (0, $bvJLP$useState)(color || "#fff");
|
|
413
|
-
return $71d20dff35996763$var$h((0, $bvJLP$Overlay2), {
|
|
414
|
-
isOpen: overlayOpen
|
|
415
|
-
}, $71d20dff35996763$var$h("div.overlay-container", $71d20dff35996763$var$h("div.add-type-overlay", [
|
|
416
|
-
$71d20dff35996763$var$h("h2.title", [
|
|
417
|
-
title,
|
|
418
|
-
$71d20dff35996763$var$h((0, $bvJLP$Icon), {
|
|
419
|
-
icon: "cross",
|
|
420
|
-
className: "close-icon",
|
|
421
|
-
onClick: ()=>{
|
|
422
|
-
setOverlayOpen(false);
|
|
423
|
-
},
|
|
424
|
-
style: {
|
|
425
|
-
cursor: "pointer",
|
|
426
|
-
color: "red"
|
|
427
|
-
}
|
|
428
|
-
})
|
|
429
|
-
]),
|
|
430
|
-
$71d20dff35996763$var$h("div.form-group", [
|
|
431
|
-
$71d20dff35996763$var$h("div.text-inputs", [
|
|
432
|
-
$71d20dff35996763$var$h("div.form-field.name", [
|
|
433
|
-
$71d20dff35996763$var$h("p.label", "Name"),
|
|
434
|
-
$71d20dff35996763$var$h("input", {
|
|
435
|
-
type: "text",
|
|
436
|
-
placeholder: "Enter type name",
|
|
437
|
-
onChange: (e)=>setNameInput(e.target.value),
|
|
438
|
-
value: nameInput
|
|
439
|
-
})
|
|
440
|
-
]),
|
|
441
|
-
$71d20dff35996763$var$h("div.form-field.form-description", [
|
|
442
|
-
$71d20dff35996763$var$h("p.label", "Description"),
|
|
443
|
-
$71d20dff35996763$var$h("input", {
|
|
444
|
-
type: "text",
|
|
445
|
-
placeholder: "Enter type description",
|
|
446
|
-
onChange: (e)=>setDescriptionInput(e.target.value),
|
|
447
|
-
value: descriptionInput
|
|
448
|
-
})
|
|
449
|
-
])
|
|
450
|
-
]),
|
|
451
|
-
$71d20dff35996763$var$h("div.form-field.color", [
|
|
452
|
-
$71d20dff35996763$var$h("p.label", "Color"),
|
|
453
|
-
$71d20dff35996763$var$h((0, $bvJLP$ColorPicker), {
|
|
454
|
-
value: colorInput,
|
|
455
|
-
onChange: (color)=>setColorInput(color),
|
|
456
|
-
style: {
|
|
457
|
-
width: "100%"
|
|
458
|
-
}
|
|
459
|
-
})
|
|
460
|
-
])
|
|
461
|
-
]),
|
|
462
|
-
$71d20dff35996763$var$h((0, $bvJLP$SaveButton), {
|
|
463
|
-
className: "save-btn",
|
|
464
|
-
small: true,
|
|
465
|
-
onClick: ()=>saveHandler({
|
|
466
|
-
name: nameInput,
|
|
467
|
-
description: descriptionInput,
|
|
468
|
-
color: colorInput,
|
|
469
|
-
id: id
|
|
470
|
-
})
|
|
471
|
-
}, "Save changes")
|
|
472
|
-
])));
|
|
473
|
-
}
|
|
474
|
-
function $71d20dff35996763$var$TypeTag({ type: type, luminance: luminance, selectedType: selectedType, setSelectedType: setSelectedType, dispatch: dispatch, tree: tree, selectedNodes: selectedNodes, selected: selected, isSelectedNodes: isSelectedNodes }) {
|
|
475
|
-
const { color: color, name: name, id: id, description: description } = type;
|
|
476
|
-
const darkMode = (0, $bvJLP$useInDarkMode)();
|
|
477
|
-
const isSelected = id === selected?.id && selectedNodes.length > 0;
|
|
478
|
-
const style = (0, $03d8811e9c9b360d$export$35baa338324d8550)(color, {
|
|
479
|
-
active: isSelected,
|
|
480
|
-
highlighted: selectedNodes.length === 0
|
|
481
|
-
});
|
|
482
|
-
const payload = {
|
|
483
|
-
id: id,
|
|
484
|
-
name: name,
|
|
485
|
-
color: color,
|
|
486
|
-
description: description
|
|
487
|
-
};
|
|
488
|
-
const ids = $71d20dff35996763$var$collectMatchingIds(tree, id);
|
|
489
|
-
const handleTagClick = ()=>{
|
|
490
|
-
if (!isSelectedNodes && selectedType === null) {
|
|
491
|
-
if (ids.length > 0) {
|
|
492
|
-
setSelectedType(type);
|
|
493
|
-
dispatch({
|
|
494
|
-
type: "toggle-node-selected",
|
|
495
|
-
payload: {
|
|
496
|
-
ids: ids
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
} else if (isSelectedNodes && selectedType === null) {
|
|
501
|
-
if (id === selected?.id && selectedNodes.length > 0) dispatch({
|
|
502
|
-
type: "toggle-node-selected",
|
|
503
|
-
payload: {
|
|
504
|
-
ids: selectedNodes
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
else dispatch({
|
|
508
|
-
type: "select-entity-type",
|
|
509
|
-
payload: payload
|
|
510
|
-
});
|
|
511
|
-
} else if (isSelectedNodes && selectedType.id === id) {
|
|
512
|
-
setSelectedType(null);
|
|
513
|
-
dispatch({
|
|
514
|
-
type: "toggle-node-selected",
|
|
515
|
-
payload: {
|
|
516
|
-
ids: ids
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
} else if (isSelectedNodes && selectedType.id !== id) {
|
|
520
|
-
if (ids.length > 0) {
|
|
521
|
-
setSelectedType(type);
|
|
522
|
-
const oldIds = $71d20dff35996763$var$collectMatchingIds(tree, selectedType.id);
|
|
523
|
-
dispatch({
|
|
524
|
-
type: "toggle-node-selected",
|
|
525
|
-
payload: {
|
|
526
|
-
ids: oldIds
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
dispatch({
|
|
530
|
-
type: "toggle-node-selected",
|
|
531
|
-
payload: {
|
|
532
|
-
ids: ids
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
} else console.warn("Unexpected state in TypeTag click handler", {
|
|
537
|
-
isSelectedNodes: isSelectedNodes,
|
|
538
|
-
selectedType: selectedType,
|
|
539
|
-
selectedNodes: selectedNodes,
|
|
540
|
-
ids: ids,
|
|
541
|
-
id: id,
|
|
542
|
-
selected: selected
|
|
543
|
-
});
|
|
544
|
-
};
|
|
545
|
-
return $71d20dff35996763$var$h((0, $bvJLP$Popover), {
|
|
546
|
-
autoFocus: false,
|
|
547
|
-
content: $71d20dff35996763$var$h("div.description", description || "No description available"),
|
|
548
|
-
interactionKind: "hover"
|
|
549
|
-
}, $71d20dff35996763$var$h("div.type-tag", {
|
|
550
|
-
onClick: handleTagClick,
|
|
551
|
-
style: {
|
|
552
|
-
cursor: ids.length > 0 || isSelectedNodes && !selectedType ? "pointer" : "",
|
|
553
|
-
color: "black",
|
|
554
|
-
backgroundColor: style.backgroundColor,
|
|
555
|
-
border: isSelected ? `1px solid var(--text-emphasized-color)` : `1px solid var(--background-color)`
|
|
556
|
-
}
|
|
557
|
-
}, $71d20dff35996763$var$h("div.type-container", [
|
|
558
|
-
$71d20dff35996763$var$h("div.type-name", name),
|
|
559
|
-
$71d20dff35996763$var$h("div.icons", [
|
|
560
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$EditType, {
|
|
561
|
-
dispatch: dispatch,
|
|
562
|
-
type: type
|
|
563
|
-
}),
|
|
564
|
-
$71d20dff35996763$var$h((0, $bvJLP$Icon), {
|
|
565
|
-
icon: "cross",
|
|
566
|
-
className: "delete-type-icon",
|
|
567
|
-
style: {
|
|
568
|
-
color: "red",
|
|
569
|
-
cursor: "pointer"
|
|
570
|
-
},
|
|
571
|
-
onClick: (e)=>{
|
|
572
|
-
e.stopPropagation();
|
|
573
|
-
dispatch({
|
|
574
|
-
type: "delete-entity-type",
|
|
575
|
-
payload: {
|
|
576
|
-
id: id
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
})
|
|
581
|
-
])
|
|
582
|
-
])));
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
export {$71d20dff35996763$export$a90600c9da52b40c as FeedbackComponent, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e as treeToGraph};
|
|
587
|
-
//# sourceMappingURL=feedback-components.1e7da538.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,8EAAK;AAE5B,SAAS,qCAAkB,CAAS,EAAE,CAAS;IAC7C,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EAAE,OAAO;IAC9B,KAAK,MAAM,QAAQ,EAAG;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,OAAO;IAC3B;IACA,OAAO;AACT;AAEO,SAAS,0CAAkB,YAChC,WAAW,EAAE,QACb,IAAI,SACJ,KAAK,eACL,WAAW,kBACX,cAAc,UACd,MAAM,gBACN,YAAY,cACZ,UAAU,EACX;IACC,0BAA0B;IAC1B,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,yCAAe,EACvC,SAAS,GAAG,CAAC,sCACb;IAEF,MAAM,CAAC,OAAO,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE,cAAc,CAAC;IAEvD,MAAM,iBACJ,aAAa,QACb,IAAI,sBACJ,kBAAkB,yBAClB,qBAAqB,kBACrB,cAAc,EACf,GAAG;IAEJ,MAAM,CAAC,SAAE,KAAK,UAAE,MAAM,EAAE,EAAE,IAAI,GAAG,CAAA,GAAA,2BAAmB;IAEpD,OAAO,wBAAE,oBAAoB;QAC3B,wBACE,0BACA,wBAAE,CAAA,GAAA,yCAAkB,EAAE,QAAQ,EAAE;YAAE,OAAO;QAAS,GAAG;YACnD,wBACE,CAAA,GAAA,oBAAY,GACZ;gBACE,aACE;YACJ,GACA,wBAAE,CAAA,GAAA,yCAAW,GAAG;sBACd;0BACA;gBACA,aAAa;gBACb,OAAO;+BACP;8BACA;gBACA,YAAY;YAC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oBACjB,SAAS;wBACP,MAAM;wBACN,SAAS;gCAAE;wBAAG;oBAChB;gBACF;YACF;SACD;KACF;AAGP","sources":["packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { Tree, TreeApi } from \"react-arborist\";\nimport Node from \"./node\";\nimport { FeedbackText } from \"./text-visualizer\";\nimport type { InternalEntity, TreeData } from \"./types\";\nimport type { Entity } from \"../extractions\";\nimport { getTagStyle, ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n ButtonGroup,\n Card,\n SegmentedControl,\n Icon,\n Popover,\n Divider,\n Overlay2,\n} from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n ErrorBoundary,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport { ColorPicker } from \"@macrostrat/data-sheet\";\nimport { Switch } from \"@blueprintjs/core\";\n\nexport type { GraphData } from \"./edit-state\";\nexport { treeToGraph } from \"./edit-state\";\nexport type { TreeData } from \"./types\";\n\nconst h = hyper.styled(styles);\n\nfunction setsAreTheSame<T>(a: Set<T>, b: Set<T>) {\n if (a.size !== b.size) return false;\n for (const item of a) {\n if (!b.has(item)) return false;\n }\n return true;\n}\n\nexport function FeedbackComponent({\n entities = [],\n text,\n model,\n entityTypes,\n matchComponent,\n onSave,\n allowOverlap,\n matchLinks,\n}) {\n // Get the input arguments\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes,\n );\n const [match, setMatchLinks] = useState(matchLinks || {});\n\n const {\n selectedNodes,\n tree,\n selectedEntityType,\n isSelectingEntityType,\n entityTypesMap,\n } = state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(\"div.page-wrapper\", [\n h(\n \"div.feedback-container\",\n h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(\n ErrorBoundary,\n {\n description:\n \"An error occurred while rendering the feedback text component.\",\n },\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n allowOverlap,\n matchLinks: match,\n }),\n ),\n h(\n FlexRow,\n { alignItems: \"baseline\", justifyContent: \"space-between\" },\n [\n h(ModelInfo, { data: model }),\n h(SegmentedControl, {\n options: [\n { label: \"Tree\", value: \"tree\" },\n { label: \"Graph\", value: \"graph\" },\n ],\n value: state.viewMode,\n small: true,\n onValueChange(value: ViewMode) {\n console.log(\"Setting view mode\", value);\n dispatch({ type: \"set-view-mode\", payload: value });\n },\n }),\n ],\n ),\n h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h.if(state.viewMode == \"tree\")(ManagedSelectionTree, {\n selectedNodes,\n dispatch,\n tree,\n width,\n height,\n matchComponent,\n }),\n h.if(state.viewMode == \"graph\")(GraphView, {\n tree,\n width,\n height,\n dispatch,\n selectedNodes,\n }),\n ],\n ),\n ]),\n ),\n h(Card, { className: \"control-panel\" }, [\n h(\"div.control-content\", [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\n },\n [\n h.if(matchLinks)(Switch, {\n label: \"Show matches\",\n checked: match !== null,\n onChange: (e) => {\n setMatchLinks(match === null ? matchLinks || {} : null);\n },\n }),\n h(\n CancelButton,\n {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick() {\n dispatch({ type: \"reset\" });\n },\n },\n \"Reset\",\n ),\n h(\n SaveButton,\n {\n onClick() {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree,\n },\n \"Save\",\n ),\n ],\n ),\n h(Divider),\n h(EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n dispatch,\n tree,\n selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\n }),\n ]),\n ]),\n ]);\n}\n\nfunction processEntity(entity: Entity): InternalEntity {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [entity.indices],\n children: entity.children?.map(processEntity) ?? [],\n };\n}\n\nfunction EntityTypeSelector({\n entityTypes,\n selected,\n isOpen,\n setOpen,\n onChange,\n tree,\n dispatch,\n selectedNodes = [],\n}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = useState(\"\");\n const types = Array.from(entityTypes.values());\n\n const items =\n inputValue !== \"\"\n ? types.filter((d) =>\n d.name.toLowerCase().includes(inputValue.toLowerCase()),\n )\n : types;\n\n return h(\"div.entity-type-selector\", [\n h(TypeList, {\n types: entityTypes,\n selected: _selected,\n dispatch,\n selectedNodes,\n tree,\n }),\n h(OmniboxSelector, {\n isOpen,\n items,\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onQueryChange(query) {\n setInputValue(query);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n\n function recurse(nodes) {\n for (const node of nodes) {\n count++;\n if (node.children && Array.isArray(node.children)) {\n recurse(node.children);\n }\n }\n }\n\n recurse(tree);\n return count;\n}\n\nfunction ManagedSelectionTree(props) {\n const { selectedNodes, dispatch, tree, height, width, matchComponent } =\n props;\n\n const ref = useRef<TreeApi<TreeData>>();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = useRef(false);\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent],\n );\n\n // Update Tree selection when selectedNodes change\n useEffect(() => {\n if (ref.current == null) return;\n\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n\n const ctrlPressedRef = useRef(false);\n\n useEffect(() => {\n const down = (e) => {\n if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;\n };\n const up = () => (ctrlPressedRef.current = false);\n\n window.addEventListener(\"keydown\", down);\n window.addEventListener(\"keyup\", up);\n return () => {\n window.removeEventListener(\"keydown\", down);\n window.removeEventListener(\"keyup\", up);\n };\n }, []);\n\n const handleSelect = useCallback(\n (nodes) => {\n if (!clickedRef.current) return;\n clickedRef.current = false;\n const isMultiSelect = ctrlPressedRef.current;\n\n let ids = nodes.map((d) => parseInt(d.id));\n\n if (isMultiSelect) {\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else {\n if (ids.length === 1 && ids[0] === selectedNodes[0]) {\n ids = [];\n }\n\n dispatch({ type: \"select-node\", payload: { ids } });\n }\n },\n [selectedNodes, dispatch],\n );\n\n return h(\n \"div.selection-tree-wrapper\",\n { onPointerDown: handleClick },\n h(Tree, {\n className: \"selection-tree\",\n height,\n width,\n ref,\n data: tree,\n onMove({ dragIds, parentId, index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d) => parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index,\n },\n });\n },\n onDelete({ ids }) {\n dispatch({\n type: \"delete-node\",\n payload: { ids: ids.map((d) => parseInt(d)) },\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor(d) {\n return d.id.toString();\n },\n }),\n );\n}\n\nfunction TypeList({ types, selected, dispatch, selectedNodes, tree }) {\n const [selectedType, setSelectedType] = useState(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = useInDarkMode();\n const luminance = darkMode ? 0.9 : 0.4;\n\n return h(\"div.type-list-container\", [\n h(\n \"div.type-list-header\",\n isSelectedNodes && !selectedType\n ? \"Change selected nodes to:\"\n : \"Entity Types\",\n ),\n h(\n \"div.type-list\",\n Array.from(types.values()).map((type) =>\n h(TypeTag, {\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n }),\n ),\n ),\n h(AddType, { dispatch }),\n ]);\n}\n\nfunction collectMatchingIds(tree, id) {\n const ids = [];\n\n function traverse(node) {\n if (node.type.id === id) {\n ids.push(node.id);\n }\n if (Array.isArray(node.children)) {\n node.children.forEach(traverse);\n }\n }\n\n tree.forEach(traverse);\n return ids;\n}\n\nfunction AddType({ dispatch }) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"add-entity-type\",\n payload,\n });\n setOverlayOpen(false);\n };\n\n return h(\"div.add-type-container\", [\n h(\"div.add-type\", { onClick: () => setOverlayOpen(true) }, [\n h(\"p.add-type-text\", \"Add new type\"),\n h(Icon, { icon: \"plus\" }),\n ]),\n h(TypeOverlay, {\n setOverlayOpen,\n overlayOpen,\n title: \"Add New Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction EditType({ dispatch, type }) {\n const [editorOpen, setEditorOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"update-entity-type\",\n payload,\n });\n setEditorOpen(false);\n };\n\n return h(\"div.edit-type\", [\n h(Icon, {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e) => {\n e.stopPropagation();\n setEditorOpen(true);\n },\n }),\n h(TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction TypeOverlay({\n setOverlayOpen,\n overlayOpen,\n originalType,\n title,\n saveHandler,\n}) {\n const { name, description, color, id } = originalType || {};\n\n const [nameInput, setNameInput] = useState(name || \"\");\n const [descriptionInput, setDescriptionInput] = useState(description || \"\");\n const [colorInput, setColorInput] = useState(color || \"#fff\");\n\n return h(\n Overlay2,\n {\n isOpen: overlayOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n title,\n h(Icon, {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: () => {\n setOverlayOpen(false);\n },\n style: { cursor: \"pointer\", color: \"red\" },\n }),\n ]),\n h(\"div.form-group\", [\n h(\"div.text-inputs\", [\n h(\"div.form-field.name\", [\n h(\"p.label\", \"Name\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e) => setNameInput(e.target.value),\n value: nameInput,\n }),\n ]),\n h(\"div.form-field.form-description\", [\n h(\"p.label\", \"Description\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e) => setDescriptionInput(e.target.value),\n value: descriptionInput,\n }),\n ]),\n ]),\n h(\"div.form-field.color\", [\n h(\"p.label\", \"Color\"),\n h(ColorPicker, {\n value: colorInput,\n onChange: (color) => setColorInput(color),\n style: { width: \"100%\" },\n }),\n ]),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () =>\n saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id,\n }),\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n\nfunction TypeTag({\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n}) {\n const { color, name, id, description } = type;\n const darkMode = useInDarkMode();\n const isSelected = id === selected?.id && selectedNodes.length > 0;\n\n const style = getTagStyle(color, {\n active: isSelected,\n highlighted: selectedNodes.length === 0,\n });\n\n const payload = {\n id,\n name,\n color,\n description,\n };\n\n const ids = collectMatchingIds(tree, id);\n\n const handleTagClick = () => {\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: selectedNodes },\n });\n } else {\n dispatch({ type: \"select-entity-type\", payload });\n }\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = collectMatchingIds(tree, selectedType.id);\n\n dispatch({ type: \"toggle-node-selected\", payload: { ids: oldIds } });\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else {\n console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes,\n selectedType,\n selectedNodes,\n ids,\n id,\n selected,\n });\n }\n };\n\n return h(\n Popover,\n {\n autoFocus: false,\n content: h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\",\n },\n h(\n \"div.type-tag\",\n {\n onClick: handleTagClick,\n style: {\n cursor:\n ids.length > 0 || (isSelectedNodes && !selectedType)\n ? \"pointer\"\n : \"\",\n color: \"black\",\n backgroundColor: style.backgroundColor,\n border: isSelected\n ? `1px solid var(--text-emphasized-color)`\n : `1px solid var(--background-color)`,\n },\n },\n h(\"div.type-container\", [\n h(\"div.type-name\", name),\n h(\"div.icons\", [\n h(EditType, {\n dispatch,\n type,\n }),\n h(Icon, {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: { color: \"red\", cursor: \"pointer\" },\n onClick: (e) => {\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: { id },\n });\n },\n }),\n ]),\n ]),\n ),\n );\n}\n"],"names":[],"version":3,"file":"feedback-components.1e7da538.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;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cAAc,MAAM,KAAK,GACvD;gCACA,wEAAwE;gCACxE,EAAE,eAAe;gCACjB,SAAS;oCACP,MAAM;oCACN,SAAS;wCAAE,KAAK;4CAAC,EAAE,EAAE;yCAAC;oCAAC;gCACzB;4BACF,OACE,SAAS;gCACP,MAAM;gCACN,SAAS;oCAAE,KAAK;wCAAC,EAAE,EAAE;qCAAC;gCAAC;4BACzB;wBAEJ;wBACA,WAAW,SAAS,aAAa;gCACjC;wBACA,aAAa;oBACf;oBACA,wBAAE,EAAE,CAAC,YACH,QACA;wBACE,GAAG,EAAE,CAAC,GAAG;wBACT,GAAG,EAAE,CAAC,GAAG;wBACT,WAAW;oBACb,GACA,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;oBAE1B,wBAAE,EAAE,CAAC,CAAC,YAAY,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;iBACpD;YACH;SAEH;KACF;AAEL;AAEA,SAAS,oCAAc,EAAU,EAAE,aAAuB,EAAE,KAAiB;IAC3E,IAAI,cAAc,MAAM,KAAK,GAAG,OAAO;IACvC,OACE,cAAc,QAAQ,CAAC,OACvB,MAAM,IAAI,CACR,CAAC,OACC,cAAc,QAAQ,CAAC,KAAK,EAAE,KAC9B,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAU,MAAM,EAAE,KAAK;AAGnD","sources":["packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport {\n forceSimulation,\n SimulationNodeDatum,\n SimulationLinkDatum,\n forceCenter,\n forceLink,\n forceManyBody,\n forceCollide,\n} from \"d3-force\";\nimport { useEffect, useState } from \"react\";\nimport { Spinner, Switch } from \"@blueprintjs/core\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { getTagStyle } from \"../extractions\";\n\nconst h = hyper.styled(styles);\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n dispatch: (action: any) => void;\n selectedNodes: number[];\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height, dispatch, selectedNodes } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\n const [showLabels, setShowLabels] = useState(false);\n\n useEffect(() => {\n const { nodes, edges } = treeToGraph(tree);\n\n const nodesMap = new Map<number, SimulationNodeDatum>(\n nodes.map((d) => [d.id, d]),\n );\n\n const links = edges.map((d) => {\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1,\n };\n });\n\n const simulation = forceSimulation(nodes)\n .force(\"link\", forceLink(links))\n .force(\"charge\", forceManyBody().strength(-50))\n .force(\"center\", forceCenter(width / 2, height / 2))\n .force(\"collide\", forceCollide().radius(20))\n .on(\"tick\", () => {\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n })\n .on(\"end\", () => {\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n\n return () => {\n simulation.stop();\n };\n }, [tree, width, height]);\n\n if (nodes == null || links == null) {\n return h(Spinner);\n }\n\n console.log(\"Graph\", nodes, links, selectedNodes);\n\n return h(\n ErrorBoundary,\n {\n description: \"An error occurred while rendering the graph view.\",\n },\n h(\"div.graph-view\", { style: { width, height } }, [\n h(Switch, {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e) => setShowLabels(e.target.checked),\n }),\n h(\"svg\", { width, height }, [\n h(\n \"g.links\",\n links.map((d) => {\n return h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\",\n });\n }),\n ),\n h(\n \"g.nodes\",\n nodes.map((d) => {\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = isHighlighted(d.id, selectedNodes, nodes);\n const style = getTagStyle(d.color, { highlighted, active });\n\n return h(\"g\", [\n h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 8,\n fill: style.backgroundColor || \"blue\",\n onClick: (e) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === d.id && selectedNodes.length === 1)\n ) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [d.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [d.id] },\n });\n }\n },\n className: active ? \"selected\" : \"\",\n stroke,\n strokeWidth: 2,\n }),\n h.if(showLabels)(\n \"text\",\n {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\",\n },\n d.name || `Node ${d.id}`,\n ),\n h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`),\n ]);\n }),\n ),\n ]),\n ]),\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: TreeData[]) {\n if (selectedNodes.length === 0) return true;\n return (\n selectedNodes.includes(id) ||\n nodes.some(\n (node) =>\n selectedNodes.includes(node.id) &&\n node.children.some((child) => child.id === id),\n )\n );\n}\n"],"names":[],"version":3,"file":"feedback-components.832b2eae.js.map"}
|