@macrostrat/feedback-components 1.0.1 → 1.1.1
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.3b3a5357.js +137 -0
- package/dist/esm/feedback-components.3b3a5357.js.map +1 -0
- package/dist/esm/feedback-components.46a7a347.js +269 -0
- package/dist/esm/feedback-components.46a7a347.js.map +1 -0
- package/dist/esm/{node.28634e40.js → feedback-components.5509fab3.js} +11 -6
- package/dist/esm/feedback-components.5509fab3.js.map +1 -0
- package/dist/esm/feedback-components.586103e8.js +578 -0
- package/dist/esm/feedback-components.586103e8.js.map +1 -0
- package/dist/esm/{extractions.65bb73cc.js → feedback-components.5df2a926.js} +46 -18
- package/dist/esm/feedback-components.5df2a926.js.map +1 -0
- package/dist/esm/{main.module.cd706d67.js → feedback-components.6d32ee91.js} +1 -1
- package/dist/esm/{main.module.cd706d67.js.map → feedback-components.6d32ee91.js.map} +1 -1
- package/dist/esm/feedback-components.95dbe7d7.js +82 -0
- package/dist/esm/feedback-components.95dbe7d7.js.map +1 -0
- package/dist/esm/{type-selector.6e8952d6.js → feedback-components.ad9f284e.js} +6 -5
- package/dist/esm/feedback-components.ad9f284e.js.map +1 -0
- package/dist/esm/{main.module.8d366b6e.css → feedback-components.bf93773c.css} +1 -1
- package/dist/esm/{main.module.8d366b6e.css.map → feedback-components.bf93773c.css.map} +1 -1
- package/dist/esm/{main.module.2f2972c8.css → feedback-components.e273ed5b.css} +1 -1
- package/dist/esm/{main.module.2f2972c8.css.map → feedback-components.e273ed5b.css.map} +1 -1
- package/dist/esm/{main.module.d2fbdf09.js → feedback-components.f9850d85.js} +1 -1
- package/dist/esm/{main.module.d2fbdf09.js.map → feedback-components.f9850d85.js.map} +1 -1
- package/dist/esm/{edit-state.c39d8466.js → feedback-components.fa1d3641.js} +125 -7
- package/dist/esm/feedback-components.fa1d3641.js.map +1 -0
- package/dist/esm/feedback-components.fb60c70d.css +180 -0
- package/dist/esm/feedback-components.fb60c70d.css.map +1 -0
- package/dist/esm/index.d.ts +10 -64
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/node/feedback-components.2f391fa4.js +2 -0
- package/dist/node/feedback-components.2f391fa4.js.map +1 -0
- package/dist/node/feedback-components.561466ac.js +2 -0
- package/dist/node/feedback-components.561466ac.js.map +1 -0
- package/dist/node/feedback-components.571ee23c.js +2 -0
- package/dist/node/feedback-components.571ee23c.js.map +1 -0
- package/dist/node/{main.module.ebdf985b.js → feedback-components.794f429b.js} +2 -2
- package/dist/node/feedback-components.794f429b.js.map +1 -0
- package/dist/node/{main.module.1fdfe813.css → feedback-components.83c21466.css} +1 -1
- package/dist/node/feedback-components.83c21466.css.map +1 -0
- package/dist/node/feedback-components.8b03e8be.js +2 -0
- package/dist/node/feedback-components.8b03e8be.js.map +1 -0
- package/dist/node/{main.module.6bc7d51b.css → feedback-components.9eb1d41a.css} +1 -1
- package/dist/node/feedback-components.9eb1d41a.css.map +1 -0
- package/dist/node/feedback-components.a39f7653.js +2 -0
- package/dist/node/feedback-components.a39f7653.js.map +1 -0
- package/dist/node/feedback-components.acac789b.js +2 -0
- package/dist/node/feedback-components.acac789b.js.map +1 -0
- package/dist/node/feedback-components.b7946db4.js +2 -0
- package/dist/node/feedback-components.b7946db4.js.map +1 -0
- package/dist/node/feedback-components.c459cc27.js +2 -0
- package/dist/node/feedback-components.c459cc27.js.map +1 -0
- package/dist/node/feedback-components.c88cb37f.css +2 -0
- package/dist/node/feedback-components.c88cb37f.css.map +1 -0
- package/dist/node/feedback-components.ec54a1e7.js +2 -0
- package/dist/node/feedback-components.ec54a1e7.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +7 -6
- package/src/extractions/index.ts +76 -21
- package/src/extractions/types.ts +6 -1
- package/src/feedback/edit-state.ts +184 -16
- package/src/feedback/feedback.module.sass +121 -9
- package/src/feedback/graph.ts +90 -32
- package/src/feedback/index.ts +553 -146
- package/src/feedback/node.ts +7 -1
- package/src/feedback/text-visualizer.ts +286 -49
- package/src/feedback/type-selector/index.ts +4 -2
- package/dist/esm/edit-state.c39d8466.js.map +0 -1
- package/dist/esm/extractions.65bb73cc.js.map +0 -1
- package/dist/esm/feedback.5c86878e.js +0 -252
- package/dist/esm/feedback.5c86878e.js.map +0 -1
- package/dist/esm/feedback.module.55921afe.css +0 -44
- package/dist/esm/feedback.module.55921afe.css.map +0 -1
- package/dist/esm/feedback.module.765b1e58.js +0 -28
- package/dist/esm/feedback.module.765b1e58.js.map +0 -1
- package/dist/esm/graph.f4f65d79.js +0 -83
- package/dist/esm/graph.f4f65d79.js.map +0 -1
- package/dist/esm/node.28634e40.js.map +0 -1
- package/dist/esm/text-visualizer.198e27ff.js +0 -101
- package/dist/esm/text-visualizer.198e27ff.js.map +0 -1
- package/dist/esm/type-selector.6e8952d6.js.map +0 -1
- package/dist/node/edit-state.f50ca728.js +0 -2
- package/dist/node/edit-state.f50ca728.js.map +0 -1
- package/dist/node/extractions.e6ea2eb9.js +0 -2
- package/dist/node/extractions.e6ea2eb9.js.map +0 -1
- package/dist/node/feedback.8d3d1219.js +0 -2
- package/dist/node/feedback.8d3d1219.js.map +0 -1
- package/dist/node/feedback.module.a8744203.js +0 -2
- package/dist/node/feedback.module.a8744203.js.map +0 -1
- package/dist/node/feedback.module.c4eab97d.css +0 -2
- package/dist/node/feedback.module.c4eab97d.css.map +0 -1
- package/dist/node/graph.ca5b649f.js +0 -2
- package/dist/node/graph.ca5b649f.js.map +0 -1
- package/dist/node/main.module.1857be22.js +0 -2
- package/dist/node/main.module.1857be22.js.map +0 -1
- package/dist/node/main.module.1fdfe813.css.map +0 -1
- package/dist/node/main.module.6bc7d51b.css.map +0 -1
- package/dist/node/main.module.ebdf985b.js.map +0 -1
- package/dist/node/node.33108ccc.js +0 -2
- package/dist/node/node.33108ccc.js.map +0 -1
- package/dist/node/text-visualizer.1e770afa.js +0 -2
- package/dist/node/text-visualizer.1e770afa.js.map +0 -1
- package/dist/node/type-selector.0035ef7d.js +0 -2
- package/dist/node/type-selector.0035ef7d.js.map +0 -1
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import "./feedback.module.55921afe.css";
|
|
2
|
-
import $bvJLP$feedbackmodule765b1e58js from "./feedback.module.765b1e58.js";
|
|
3
|
-
import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./node.28634e40.js";
|
|
4
|
-
import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./text-visualizer.198e27ff.js";
|
|
5
|
-
import {ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./extractions.65bb73cc.js";
|
|
6
|
-
import {useUpdatableTree as $b79bf29960412ca7$export$911bb4b9c8065d3d, TreeDispatchContext as $b79bf29960412ca7$export$e5ce04c5b3f58533, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./edit-state.c39d8466.js";
|
|
7
|
-
import {OmniboxSelector as $fda9ef5406c1cfb4$export$d8660660a589068c} from "./type-selector.6e8952d6.js";
|
|
8
|
-
import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./graph.f4f65d79.js";
|
|
9
|
-
import $bvJLP$macrostrathyper from "@macrostrat/hyper";
|
|
10
|
-
import {Tree as $bvJLP$Tree} from "react-arborist";
|
|
11
|
-
import {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} from "@blueprintjs/core";
|
|
13
|
-
import {FlexRow as $bvJLP$FlexRow, CancelButton as $bvJLP$CancelButton, SaveButton as $bvJLP$SaveButton, DataField as $bvJLP$DataField} from "@macrostrat/ui-components";
|
|
14
|
-
import $bvJLP$useelementdimensions from "use-element-dimensions";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function $parcel$interopDefault(a) {
|
|
18
|
-
return a && a.__esModule ? a.default : a;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const $71d20dff35996763$var$h = (0, $bvJLP$macrostrathyper).styled((0, ($parcel$interopDefault($bvJLP$feedbackmodule765b1e58js))));
|
|
34
|
-
function $71d20dff35996763$var$setsAreTheSame(a, b) {
|
|
35
|
-
if (a.size !== b.size) return false;
|
|
36
|
-
for (const item of a){
|
|
37
|
-
if (!b.has(item)) return false;
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave }) {
|
|
42
|
-
// Get the input arguments
|
|
43
|
-
const [state, dispatch] = (0, $b79bf29960412ca7$export$911bb4b9c8065d3d)(entities.map($71d20dff35996763$var$processEntity), entityTypes);
|
|
44
|
-
const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType } = state;
|
|
45
|
-
const [{ width: width, height: height }, ref] = (0, $bvJLP$useelementdimensions)();
|
|
46
|
-
return $71d20dff35996763$var$h((0, $b79bf29960412ca7$export$e5ce04c5b3f58533).Provider, {
|
|
47
|
-
value: dispatch
|
|
48
|
-
}, [
|
|
49
|
-
$71d20dff35996763$var$h((0, $156a3efbc315814c$export$6e107db9091b8219), {
|
|
50
|
-
text: text,
|
|
51
|
-
dispatch: dispatch,
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
nodes: tree,
|
|
54
|
-
selectedNodes: selectedNodes
|
|
55
|
-
}),
|
|
56
|
-
$71d20dff35996763$var$h((0, $bvJLP$FlexRow), {
|
|
57
|
-
alignItems: "baseline",
|
|
58
|
-
justifyContent: "space-between"
|
|
59
|
-
}, [
|
|
60
|
-
$71d20dff35996763$var$h((0, $03d8811e9c9b360d$export$4eb2a0ce903ce967), {
|
|
61
|
-
data: model
|
|
62
|
-
}),
|
|
63
|
-
$71d20dff35996763$var$h((0, $bvJLP$SegmentedControl), {
|
|
64
|
-
options: [
|
|
65
|
-
{
|
|
66
|
-
label: "Tree",
|
|
67
|
-
value: "tree"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: "Graph",
|
|
71
|
-
value: "graph"
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
value: state.viewMode,
|
|
75
|
-
small: true,
|
|
76
|
-
onValueChange (value) {
|
|
77
|
-
console.log("Setting view mode", value);
|
|
78
|
-
dispatch({
|
|
79
|
-
type: "set-view-mode",
|
|
80
|
-
payload: value
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
]),
|
|
85
|
-
$71d20dff35996763$var$h("div.entity-panel", {
|
|
86
|
-
ref: ref
|
|
87
|
-
}, [
|
|
88
|
-
$71d20dff35996763$var$h((0, $bvJLP$Card), {
|
|
89
|
-
className: "control-panel"
|
|
90
|
-
}, [
|
|
91
|
-
$71d20dff35996763$var$h((0, $bvJLP$ButtonGroup), {
|
|
92
|
-
vertical: true,
|
|
93
|
-
fill: true,
|
|
94
|
-
minimal: true,
|
|
95
|
-
alignText: "left"
|
|
96
|
-
}, [
|
|
97
|
-
$71d20dff35996763$var$h((0, $bvJLP$CancelButton), {
|
|
98
|
-
icon: "trash",
|
|
99
|
-
disabled: state.initialTree == state.tree,
|
|
100
|
-
onClick () {
|
|
101
|
-
dispatch({
|
|
102
|
-
type: "reset"
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}, "Reset"),
|
|
106
|
-
$71d20dff35996763$var$h((0, $bvJLP$SaveButton), {
|
|
107
|
-
onClick () {
|
|
108
|
-
onSave(state.tree);
|
|
109
|
-
},
|
|
110
|
-
disabled: state.initialTree == state.tree
|
|
111
|
-
}, "Save")
|
|
112
|
-
]),
|
|
113
|
-
$71d20dff35996763$var$h($71d20dff35996763$var$EntityTypeSelector, {
|
|
114
|
-
entityTypes: entityTypes,
|
|
115
|
-
selected: selectedEntityType,
|
|
116
|
-
onChange (payload) {
|
|
117
|
-
dispatch({
|
|
118
|
-
type: "select-entity-type",
|
|
119
|
-
payload: payload
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
isOpen: isSelectingEntityType,
|
|
123
|
-
setOpen: (isOpen)=>dispatch({
|
|
124
|
-
type: "toggle-entity-type-selector",
|
|
125
|
-
payload: isOpen
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
]),
|
|
129
|
-
$71d20dff35996763$var$h.if(state.viewMode == "tree")($71d20dff35996763$var$ManagedSelectionTree, {
|
|
130
|
-
selectedNodes: selectedNodes,
|
|
131
|
-
dispatch: dispatch,
|
|
132
|
-
tree: tree,
|
|
133
|
-
width: width,
|
|
134
|
-
height: height,
|
|
135
|
-
matchComponent: matchComponent
|
|
136
|
-
}),
|
|
137
|
-
$71d20dff35996763$var$h.if(state.viewMode == "graph")((0, $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566), {
|
|
138
|
-
tree: tree,
|
|
139
|
-
width: width,
|
|
140
|
-
height: height
|
|
141
|
-
})
|
|
142
|
-
])
|
|
143
|
-
]);
|
|
144
|
-
}
|
|
145
|
-
function $71d20dff35996763$var$processEntity(entity) {
|
|
146
|
-
// @ts-ignore
|
|
147
|
-
return {
|
|
148
|
-
...entity,
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
term_type: entity.type.name,
|
|
151
|
-
txt_range: [
|
|
152
|
-
entity.indices
|
|
153
|
-
],
|
|
154
|
-
children: entity.children?.map($71d20dff35996763$var$processEntity) ?? []
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function $71d20dff35996763$var$EntityTypeSelector({ entityTypes: entityTypes, selected: selected, isOpen: isOpen, setOpen: setOpen, onChange: onChange }) {
|
|
158
|
-
// Show all entity types when selected is null
|
|
159
|
-
const _selected = selected != null ? selected : undefined;
|
|
160
|
-
return $71d20dff35996763$var$h((0, $bvJLP$DataField), {
|
|
161
|
-
label: "Entity type",
|
|
162
|
-
inline: true
|
|
163
|
-
}, [
|
|
164
|
-
$71d20dff35996763$var$h("code.bp5-code", {
|
|
165
|
-
onClick () {
|
|
166
|
-
setOpen((d)=>!d);
|
|
167
|
-
}
|
|
168
|
-
}, selected.name),
|
|
169
|
-
$71d20dff35996763$var$h((0, $fda9ef5406c1cfb4$export$d8660660a589068c), {
|
|
170
|
-
isOpen: isOpen,
|
|
171
|
-
items: Array.from(entityTypes.values()),
|
|
172
|
-
selectedItem: _selected,
|
|
173
|
-
onSelectItem (item) {
|
|
174
|
-
setOpen(false);
|
|
175
|
-
onChange(item);
|
|
176
|
-
},
|
|
177
|
-
onClose () {
|
|
178
|
-
setOpen(false);
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
]);
|
|
182
|
-
}
|
|
183
|
-
function $71d20dff35996763$var$ManagedSelectionTree(props) {
|
|
184
|
-
const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent, ...rest } = props;
|
|
185
|
-
const ref = (0, $bvJLP$useRef)();
|
|
186
|
-
const _Node = (0, $bvJLP$useCallback)((props)=>$71d20dff35996763$var$h((0, $b6b9741bf83336eb$export$2e2bcd8739ae039), {
|
|
187
|
-
...props,
|
|
188
|
-
matchComponent: matchComponent
|
|
189
|
-
}), [
|
|
190
|
-
matchComponent
|
|
191
|
-
]);
|
|
192
|
-
(0, $bvJLP$useEffect)(()=>{
|
|
193
|
-
if (ref.current == null) return;
|
|
194
|
-
// Check if selection matches current
|
|
195
|
-
const selection = new Set(selectedNodes.map((d)=>d.toString()));
|
|
196
|
-
const currentSelection = ref.current.selectedIds;
|
|
197
|
-
if ($71d20dff35996763$var$setsAreTheSame(selection, currentSelection)) return;
|
|
198
|
-
// If the selection is the same, do nothing
|
|
199
|
-
// Set selection
|
|
200
|
-
ref.current.setSelection({
|
|
201
|
-
ids: selectedNodes.map((d)=>d.toString()),
|
|
202
|
-
anchor: null,
|
|
203
|
-
mostRecent: null
|
|
204
|
-
});
|
|
205
|
-
}, [
|
|
206
|
-
selectedNodes
|
|
207
|
-
]);
|
|
208
|
-
return $71d20dff35996763$var$h((0, $bvJLP$Tree), {
|
|
209
|
-
className: "selection-tree",
|
|
210
|
-
height: height,
|
|
211
|
-
width: width,
|
|
212
|
-
ref: ref,
|
|
213
|
-
data: tree,
|
|
214
|
-
onMove ({ dragIds: dragIds, parentId: parentId, index: index }) {
|
|
215
|
-
dispatch({
|
|
216
|
-
type: "move-node",
|
|
217
|
-
payload: {
|
|
218
|
-
dragIds: dragIds.map((d)=>parseInt(d)),
|
|
219
|
-
parentId: parentId ? parseInt(parentId) : null,
|
|
220
|
-
index: index
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
onDelete ({ ids: ids }) {
|
|
225
|
-
dispatch({
|
|
226
|
-
type: "delete-node",
|
|
227
|
-
payload: {
|
|
228
|
-
ids: ids.map((d)=>parseInt(d))
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
},
|
|
232
|
-
onSelect (nodes) {
|
|
233
|
-
let ids = nodes.map((d)=>parseInt(d.id));
|
|
234
|
-
if (ids.length == 1 && ids[0] == selectedNodes[0]) // Deselect
|
|
235
|
-
ids = [];
|
|
236
|
-
dispatch({
|
|
237
|
-
type: "select-node",
|
|
238
|
-
payload: {
|
|
239
|
-
ids: ids
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
},
|
|
243
|
-
children: _Node,
|
|
244
|
-
idAccessor (d) {
|
|
245
|
-
return d.id.toString();
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
export {$71d20dff35996763$export$a90600c9da52b40c as Feedb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AAY;QACd;IACF,GAAG;QAAC;KAAc;IAElB,OAAO,wBAAE,CAAA,GAAA,WAAG,GAAG;QACb,WAAW;gBACX;eACA;aACA;QACA,MAAM;QACN,QAAO,WAAE,OAAO,YAAE,QAAQ,SAAE,KAAK,EAAE;YACjC,SAAS;gBACP,MAAM;gBACN,SAAS;oBACP,SAAS,QAAQ,GAAG,CAAC,CAAC,IAAM,SAAS;oBACrC,UAAU,WAAW,SAAS,YAAY;2BAC1C;gBACF;YACF;QACF;QACA,UAAS,OAAE,GAAG,EAAE;YACd,SAAS;gBACP,MAAM;gBACN,SAAS;oBAAE,KAAK,IAAI,GAAG,CAAC,CAAC,IAAM,SAAS;gBAAI;YAC9C;QACF;QACA,UAAS,KAAK;YACZ,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC,IAAM,SAAS,EAAE,EAAE;YACxC,IAAI,IAAI,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE,IAAI,aAAa,CAAC,EAAE,EAC/C,WAAW;YACX,MAAM,EAAE;YAEV,SAAS;gBAAE,MAAM;gBAAe,SAAS;yBAAE;gBAAI;YAAE;QACnD;QACA,UAAU;QACV,YAAW,CAAW;YACpB,OAAO,EAAE,EAAE,CAAC,QAAQ;QACtB;IACF;AACF","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 { ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { ButtonGroup, Card, SegmentedControl } from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\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}) {\n // Get the input arguments\n\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes\n );\n\n const { selectedNodes, tree, selectedEntityType, isSelectingEntityType } =\n state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n }),\n h(FlexRow, { alignItems: \"baseline\", justifyContent: \"space-between\" }, [\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 h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h(Card, { className: \"control-panel\" }, [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\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(EntityTypeSelector, {\n entityTypes,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\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 }),\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}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n return h(DataField, { label: \"Entity type\", inline: true }, [\n h(\n \"code.bp5-code\",\n {\n onClick() {\n setOpen((d) => !d);\n },\n },\n selected.name\n ),\n h(OmniboxSelector, {\n isOpen,\n items: Array.from(entityTypes.values()),\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction ManagedSelectionTree(props) {\n const {\n selectedNodes,\n dispatch,\n tree,\n height,\n width,\n matchComponent,\n ...rest\n } = props;\n\n const ref = useRef<TreeApi<TreeData>>();\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent]\n );\n\n useEffect(() => {\n if (ref.current == null) return;\n // Check if selection matches current\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n // If the selection is the same, do nothing\n\n // Set selection\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n return 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(nodes) {\n let ids = nodes.map((d) => parseInt(d.id));\n if (ids.length == 1 && ids[0] == selectedNodes[0]) {\n // Deselect\n ids = [];\n }\n dispatch({ type: \"select-node\", payload: { ids } });\n },\n children: _Node,\n idAccessor(d: TreeData) {\n return d.id.toString();\n },\n });\n}\n"],"names":[],"version":3,"file":"feedback.5c86878e.js.map"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
.QoX8-W_feedback-component {
|
|
2
|
-
width: 800px;
|
|
3
|
-
position: relative;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.QoX8-W_feedback-component > svg {
|
|
7
|
-
width: 800px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.QoX8-W_node {
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.QoX8-W_feedback-text {
|
|
15
|
-
margin-bottom: 2em;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.QoX8-W_entity-panel {
|
|
19
|
-
max-height: 600px;
|
|
20
|
-
position: relative;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.QoX8-W_control-panel {
|
|
24
|
-
max-width: 15em;
|
|
25
|
-
padding: .2em .5em;
|
|
26
|
-
position: absolute;
|
|
27
|
-
top: 1em;
|
|
28
|
-
right: 1em;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.QoX8-W_entity-panel {
|
|
32
|
-
background: var(--panel-secondary-background-color);
|
|
33
|
-
min-height: 100px;
|
|
34
|
-
box-shadow: 0 0 0 1px var(--panel-border-color) inset;
|
|
35
|
-
border-radius: 4px;
|
|
36
|
-
flex: 1;
|
|
37
|
-
padding: 1em;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.QoX8-W_selection-tree {
|
|
41
|
-
margin: -1em 0;
|
|
42
|
-
padding: 1em 0;
|
|
43
|
-
}
|
|
44
|
-
/*# sourceMappingURL=feedback.module.55921afe.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;AAIE;;;;AAGF;;;;AAIA;;;;AAGA;;;;;AAIA;;;;;;;;AAOA;;;;;;;;;AASA","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n"],"names":[],"version":3,"file":"feedback.module.55921afe.css.map"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function $parcel$export(e, n, v, s) {
|
|
3
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
-
}
|
|
5
|
-
var $49c87ee97f392268$exports = {};
|
|
6
|
-
|
|
7
|
-
$parcel$export($49c87ee97f392268$exports, "control-panel", () => $49c87ee97f392268$export$a0a23f31d5562853, (v) => $49c87ee97f392268$export$a0a23f31d5562853 = v);
|
|
8
|
-
$parcel$export($49c87ee97f392268$exports, "entity-panel", () => $49c87ee97f392268$export$38f2cd12e45697e, (v) => $49c87ee97f392268$export$38f2cd12e45697e = v);
|
|
9
|
-
$parcel$export($49c87ee97f392268$exports, "feedback-component", () => $49c87ee97f392268$export$579bd45c78bf5510, (v) => $49c87ee97f392268$export$579bd45c78bf5510 = v);
|
|
10
|
-
$parcel$export($49c87ee97f392268$exports, "feedback-text", () => $49c87ee97f392268$export$890489be1870bed5, (v) => $49c87ee97f392268$export$890489be1870bed5 = v);
|
|
11
|
-
$parcel$export($49c87ee97f392268$exports, "node", () => $49c87ee97f392268$export$35059013cd4a06db, (v) => $49c87ee97f392268$export$35059013cd4a06db = v);
|
|
12
|
-
$parcel$export($49c87ee97f392268$exports, "selection-tree", () => $49c87ee97f392268$export$3ae1b51693c80a9c, (v) => $49c87ee97f392268$export$3ae1b51693c80a9c = v);
|
|
13
|
-
var $49c87ee97f392268$export$a0a23f31d5562853;
|
|
14
|
-
var $49c87ee97f392268$export$38f2cd12e45697e;
|
|
15
|
-
var $49c87ee97f392268$export$579bd45c78bf5510;
|
|
16
|
-
var $49c87ee97f392268$export$890489be1870bed5;
|
|
17
|
-
var $49c87ee97f392268$export$35059013cd4a06db;
|
|
18
|
-
var $49c87ee97f392268$export$3ae1b51693c80a9c;
|
|
19
|
-
$49c87ee97f392268$export$a0a23f31d5562853 = `QoX8-W_control-panel`;
|
|
20
|
-
$49c87ee97f392268$export$38f2cd12e45697e = `QoX8-W_entity-panel`;
|
|
21
|
-
$49c87ee97f392268$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;
|
|
22
|
-
$49c87ee97f392268$export$890489be1870bed5 = `QoX8-W_feedback-text`;
|
|
23
|
-
$49c87ee97f392268$export$35059013cd4a06db = `QoX8-W_node`;
|
|
24
|
-
$49c87ee97f392268$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export {$49c87ee97f392268$exports as default};
|
|
28
|
-
//# sourceMappingURL=feedback.module.765b1e58.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,2CAAiC,CAAC,mBAAmB,CAAC;AACtD,4CAAuC,CAAC,yBAAyB,CAAC;AAClE,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,4CAAyB,CAAC,WAAW,CAAC;AACtC,4CAAmC,CAAC,qBAAqB,CAAC","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n"],"names":[],"version":3,"file":"feedback.module.765b1e58.js.map"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./edit-state.c39d8466.js";
|
|
2
|
-
import $phGch$macrostrathyper from "@macrostrat/hyper";
|
|
3
|
-
import {forceSimulation as $phGch$forceSimulation, forceLink as $phGch$forceLink, forceManyBody as $phGch$forceManyBody, forceCenter as $phGch$forceCenter, forceCollide as $phGch$forceCollide} from "d3-force";
|
|
4
|
-
import {useState as $phGch$useState, useEffect as $phGch$useEffect} from "react";
|
|
5
|
-
import {Spinner as $phGch$Spinner} from "@blueprintjs/core";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566(props) {
|
|
13
|
-
// A graph view with react-flow
|
|
14
|
-
// Get positions of nodes using force simulation
|
|
15
|
-
const { tree: tree, width: width, height: height } = props;
|
|
16
|
-
const [nodes, setNodes] = (0, $phGch$useState)(null);
|
|
17
|
-
const [links, setLinks] = (0, $phGch$useState)(null);
|
|
18
|
-
(0, $phGch$useEffect)(()=>{
|
|
19
|
-
const { nodes: nodes, edges: edges } = (0, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e)(tree);
|
|
20
|
-
const nodesMap = new Map(nodes.map((d)=>[
|
|
21
|
-
d.id,
|
|
22
|
-
d
|
|
23
|
-
]));
|
|
24
|
-
const links = edges.map((d)=>{
|
|
25
|
-
return {
|
|
26
|
-
source: nodesMap.get(d.source),
|
|
27
|
-
target: nodesMap.get(d.dest),
|
|
28
|
-
strength: 1
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
const simulation = (0, $phGch$forceSimulation)(nodes).force("link", (0, $phGch$forceLink)(links)).force("charge", (0, $phGch$forceManyBody)().strength(-50)).force("center", (0, $phGch$forceCenter)(width / 2, height / 2)).force("collide", (0, $phGch$forceCollide)().radius(20)).on("tick", ()=>{
|
|
32
|
-
// Update the positions of the nodes
|
|
33
|
-
// setNodes(nodes);
|
|
34
|
-
console.log("Simulation tick");
|
|
35
|
-
}).on("end", ()=>{
|
|
36
|
-
// Update the positions of the nodes
|
|
37
|
-
setNodes(nodes);
|
|
38
|
-
setLinks(links);
|
|
39
|
-
});
|
|
40
|
-
return ()=>{
|
|
41
|
-
simulation.stop();
|
|
42
|
-
};
|
|
43
|
-
}, [
|
|
44
|
-
tree,
|
|
45
|
-
width,
|
|
46
|
-
height
|
|
47
|
-
]);
|
|
48
|
-
if (nodes == null || links == null) return (0, $phGch$macrostrathyper)((0, $phGch$Spinner));
|
|
49
|
-
console.log("Graph", nodes, links);
|
|
50
|
-
return (0, $phGch$macrostrathyper)("div.graph-view", {
|
|
51
|
-
style: {
|
|
52
|
-
width: width,
|
|
53
|
-
height: height
|
|
54
|
-
}
|
|
55
|
-
}, [
|
|
56
|
-
(0, $phGch$macrostrathyper)("svg", {
|
|
57
|
-
width: width,
|
|
58
|
-
height: height
|
|
59
|
-
}, [
|
|
60
|
-
(0, $phGch$macrostrathyper)("g.nodes", nodes.map((d)=>{
|
|
61
|
-
return (0, $phGch$macrostrathyper)("circle", {
|
|
62
|
-
cx: d.x,
|
|
63
|
-
cy: d.y,
|
|
64
|
-
r: 5,
|
|
65
|
-
fill: "blue"
|
|
66
|
-
});
|
|
67
|
-
})),
|
|
68
|
-
(0, $phGch$macrostrathyper)("g.links", links.map((d)=>{
|
|
69
|
-
return (0, $phGch$macrostrathyper)("line", {
|
|
70
|
-
x1: d.source.x,
|
|
71
|
-
y1: d.source.y,
|
|
72
|
-
x2: d.target.x,
|
|
73
|
-
y2: d.target.y,
|
|
74
|
-
stroke: "black"
|
|
75
|
-
});
|
|
76
|
-
}))
|
|
77
|
-
])
|
|
78
|
-
]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export {$ff8c3e7f2bc22925$export$6a7fe3ef90e8d566 as GraphView};
|
|
83
|
-
//# sourceMappingURL=graph.f4f65d79.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAgBO,SAAS,0CAAU,KAIzB;IACC,+BAA+B;IAC/B,gDAAgD;IAChD,MAAM,QAAE,IAAI,SAAE,KAAK,UAAE,MAAM,EAAE,GAAG;IAEhC,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAyB;IAC1D,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAyB;IAE1D,CAAA,GAAA,gBAAQ,EAAE;QACR,MAAM,SAAE,KAAK,SAAE,KAAK,EAAE,GAAG,CAAA,GAAA,yCAAU,EAAE;QAErC,MAAM,WAAW,IAAI,IACnB,MAAM,GAAG,CAAC,CAAC,IAAM;gBAAC,EAAE,EAAE;gBAAE;aAAE;QAG5B,MAAM,QAAQ,MAAM,GAAG,CAAC,CAAC;YACvB,OAAO;gBACL,QAAQ,SAAS,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CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,QAAQ;gBACV;YACF;SAEH;KACF;AACH","sources":["packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport h from \"@macrostrat/hyper\";\n\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 } from \"@blueprintjs/core\";\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\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);\n\n return h(\"div.graph-view\", { style: { width, height } }, [\n h(\"svg\", { width, height }, [\n h(\n \"g.nodes\",\n nodes.map((d) => {\n return h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: \"blue\",\n });\n })\n ),\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 ]),\n ]);\n}\n"],"names":[],"version":3,"file":"graph.f4f65d79.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAOA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,0EAAK;AAE5B,SAAS,iCAAW,UAAoB,EAAE,QAAkB;IAC1D,OAAO,WAAW,EAAE,IAAI,SAAS,EAAE;AACnC,wEAAwE;AAC1E;AAEA,SAAS,wCAAkB,IAAuB,EAAE,IAAuB;IACzE,gFAAgF;IAChF,IAAI,KAAK,aAAa,CAAC,MAAM,IAAI,GAC/B,OAAO;IAGT,KAAK,MAAM,gBAAgB,KAAK,aAAa,CAAE;QAC7C,IAAI,iCAAW,KAAK,IAAI,EAAE,aAAa,IAAI,GACzC,OAAO;IAEX;IAEA,0CAA0C;IAC1C,IAAI,KAAK,MAAM,IAAI,QAAQ,wCAAkB,KAAK,MAAM,EAAE,OACxD,OAAO;IAGT,OAAO;AACT;AAEA,SAAS,mCAAa,IAAuB,EAAE,IAAuB;IACpE,KAAK,MAAM,gBAAgB,KAAK,aAAa,CAAE;QAC7C,IAAI,iCAAW,KAAK,IAAI,EAAE,aAAa,IAAI,GACzC,OAAO;IAEX;IACA,OAAO;AACT;AAEA,SAAS,2BAAK,QAAE,IAAI,SAAE,KAAK,cAAE,UAAU,QAAE,IAAI,kBAAE,cAAc,EAAO;IAClE,IAAI,cAAuB,wCAAkB,MAAM;IACnD,IAAI,SAAkB,mCAAa,MAAM;IAEzC,MAAM,WAAW,CAAA,GAAA,yCAAc;IAE/B,OAAO,wBACL,YACA;eAAE;QAAO,KAAK;IAAW,GACzB,wBAAE,CAAA,GAAA,yCAAQ,GAAG;QACX,MAAM,KAAK,IAAI;gBACf;qBACA;wBACA;QACA;YACE,SAAS;gBAAE,MAAM;YAA8B;QACjD;IACF;AAEJ;IAEA,2CAAe","sources":["packages/feedback-components/src/feedback/node.ts"],"sourcesContent":["import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n })\n );\n}\n\nexport default Node;\n"],"names":[],"version":3,"file":"node.28634e40.js.map"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import "./feedback.module.55921afe.css";
|
|
2
|
-
import $aogpP$feedbackmodule765b1e58js from "./feedback.module.765b1e58.js";
|
|
3
|
-
import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200} from "./extractions.65bb73cc.js";
|
|
4
|
-
import {TextAnnotateBlend as $aogpP$TextAnnotateBlend} from "react-text-annotate-blend";
|
|
5
|
-
import $aogpP$macrostrathyper from "@macrostrat/hyper";
|
|
6
|
-
import {useCallback as $aogpP$useCallback} from "react";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function $parcel$interopDefault(a) {
|
|
10
|
-
return a && a.__esModule ? a.default : a;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const $156a3efbc315814c$var$h = (0, $aogpP$macrostrathyper).styled((0, ($parcel$interopDefault($aogpP$feedbackmodule765b1e58js))));
|
|
18
|
-
function $156a3efbc315814c$var$buildTags(highlights, selectedNodes) {
|
|
19
|
-
let tags = [];
|
|
20
|
-
// If entity ID has already been seen, don't add it again
|
|
21
|
-
const entities = new Set();
|
|
22
|
-
for (const highlight of highlights){
|
|
23
|
-
// Don't add multiply-linked entities multiple times
|
|
24
|
-
if (entities.has(highlight.id)) continue;
|
|
25
|
-
const highlighted = $156a3efbc315814c$var$isHighlighted(highlight, selectedNodes);
|
|
26
|
-
const active = $156a3efbc315814c$var$isActive(highlight, selectedNodes);
|
|
27
|
-
tags.push({
|
|
28
|
-
markStyle: {
|
|
29
|
-
...(0, $03d8811e9c9b360d$export$35baa338324d8550)(highlight.backgroundColor, {
|
|
30
|
-
highlighted: highlighted,
|
|
31
|
-
active: active
|
|
32
|
-
}),
|
|
33
|
-
borderRadius: "0.2em",
|
|
34
|
-
padding: "0.1em",
|
|
35
|
-
borderWidth: "1.5px",
|
|
36
|
-
cursor: "pointer"
|
|
37
|
-
},
|
|
38
|
-
tagStyle: {
|
|
39
|
-
display: "none"
|
|
40
|
-
},
|
|
41
|
-
...highlight
|
|
42
|
-
});
|
|
43
|
-
entities.add(highlight.id);
|
|
44
|
-
}
|
|
45
|
-
return tags;
|
|
46
|
-
}
|
|
47
|
-
function $156a3efbc315814c$var$isActive(tag, selectedNodes) {
|
|
48
|
-
return selectedNodes.includes(tag.id);
|
|
49
|
-
}
|
|
50
|
-
function $156a3efbc315814c$var$isHighlighted(tag, selectedNodes) {
|
|
51
|
-
if (selectedNodes.length === 0) return true;
|
|
52
|
-
return (selectedNodes.includes(tag.id) || tag.parents?.some((d)=>selectedNodes.includes(d))) ?? false;
|
|
53
|
-
}
|
|
54
|
-
function $156a3efbc315814c$export$6e107db9091b8219(props) {
|
|
55
|
-
// Convert input to tags
|
|
56
|
-
const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch } = props;
|
|
57
|
-
let allTags = $156a3efbc315814c$var$buildTags((0, $03d8811e9c9b360d$export$c4b91360064ad200)(nodes, null), selectedNodes);
|
|
58
|
-
const onChange = (0, $aogpP$useCallback)((tags)=>{
|
|
59
|
-
// New tags
|
|
60
|
-
console.log(tags);
|
|
61
|
-
const newTags = tags.filter((d)=>!("id" in d));
|
|
62
|
-
if (newTags.length > 0) {
|
|
63
|
-
const { start: start, end: end } = newTags[0];
|
|
64
|
-
const payload = {
|
|
65
|
-
start: start,
|
|
66
|
-
end: end,
|
|
67
|
-
text: text.slice(start, end)
|
|
68
|
-
};
|
|
69
|
-
dispatch({
|
|
70
|
-
type: "create-node",
|
|
71
|
-
payload: payload
|
|
72
|
-
});
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const tagIDs = new Set(tags.map((d)=>d.id));
|
|
76
|
-
const removedIds = allTags.map((d)=>d.id).filter((d)=>!tagIDs.has(d));
|
|
77
|
-
/* Find the id that was removed: that is the one that will be selected
|
|
78
|
-
(we are hijacking the 'click to delete' functionality to select instead) */ if (removedIds.length > 0) dispatch({
|
|
79
|
-
type: "toggle-node-selected",
|
|
80
|
-
payload: {
|
|
81
|
-
ids: removedIds
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}, [
|
|
85
|
-
allTags,
|
|
86
|
-
text
|
|
87
|
-
]);
|
|
88
|
-
return $156a3efbc315814c$var$h((0, $aogpP$TextAnnotateBlend), {
|
|
89
|
-
style: {
|
|
90
|
-
fontSize: "1.2em"
|
|
91
|
-
},
|
|
92
|
-
className: "feedback-text",
|
|
93
|
-
content: text,
|
|
94
|
-
onChange: onChange,
|
|
95
|
-
value: allTags
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export {$156a3efbc315814c$export$6e107db9091b8219 as FeedbackText};
|
|
101
|
-
//# sourceMappingURL=text-visualizer.198e27ff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AASA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,0EAAK;AAU5B,SAAS,gCACP,UAAuB,EACvB,aAAuB;IAEvB,IAAI,OAA2B,EAAE;IAEjC,yDAAyD;IACzD,MAAM,WAAW,IAAI;IAErB,KAAK,MAAM,aAAa,WAAY;QAClC,oDAAoD;QACpD,IAAI,SAAS,GAAG,CAAC,UAAU,EAAE,GAAG;QAEhC,MAAM,cAAc,oCAAc,WAAW;QAC7C,MAAM,SAAS,+BAAS,WAAW;QAEnC,KAAK,IAAI,CAAC;YACR,WAAW;gBACT,GAAG,CAAA,GAAA,yCAAU,EAAE,UAAU,eAAe,EAAE;iCACxC;4BACA;gBACF,EAAE;gBACF,cAAc;gBACd,SAAS;gBACT,aAAa;gBACb,QAAQ;YACV;YACA,UAAU;gBACR,SAAS;YACX;YACA,GAAG,SAAS;QACd;QAEA,SAAS,GAAG,CAAC,UAAU,EAAE;IAC3B;IAEA,OAAO;AACT;AAEA,SAAS,+BAAS,GAAc,EAAE,aAAuB;IACvD,OAAO,cAAc,QAAQ,CAAC,IAAI,EAAE;AACtC;AAEA,SAAS,oCAAc,GAAc,EAAE,aAAuB;IAC5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sourcesContent":["import { AnnotateBlendTag, TextAnnotateBlend } from \"react-text-annotate-blend\";\nimport { InternalEntity } from \"./types\";\nimport { TreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { buildHighlights, getTagStyle } from \"../extractions\";\nimport { Highlight } from \"../extractions/types\";\nimport { useCallback } from \"react\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n}\n\nfunction buildTags(\n highlights: Highlight[],\n selectedNodes: number[]\n): AnnotateBlendTag[] {\n let tags: AnnotateBlendTag[] = [];\n\n // If entity ID has already been seen, don't add it again\n const entities = new Set<number>();\n\n for (const highlight of highlights) {\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n\n const highlighted = isHighlighted(highlight, selectedNodes);\n const active = isActive(highlight, selectedNodes);\n\n tags.push({\n markStyle: {\n ...getTagStyle(highlight.backgroundColor, {\n highlighted,\n active,\n }),\n borderRadius: \"0.2em\",\n padding: \"0.1em\",\n borderWidth: \"1.5px\",\n cursor: \"pointer\",\n },\n tagStyle: {\n display: \"none\",\n },\n ...highlight,\n });\n\n entities.add(highlight.id);\n }\n\n return tags;\n}\n\nfunction isActive(tag: Highlight, selectedNodes: number[]) {\n return selectedNodes.includes(tag.id);\n}\n\nfunction isHighlighted(tag: Highlight, selectedNodes: number[]) {\n if (selectedNodes.length === 0) return true;\n return (\n (selectedNodes.includes(tag.id) ||\n tag.parents?.some((d) => selectedNodes.includes(d))) ??\n false\n );\n}\n\nexport function FeedbackText(props: FeedbackTextProps) {\n // Convert input to tags\n const { text, selectedNodes, nodes, dispatch } = props;\n let allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes\n );\n\n const onChange = useCallback(\n (tags) => {\n // New tags\n console.log(tags);\n const newTags = tags.filter((d) => !(\"id\" in d));\n if (newTags.length > 0) {\n const { start, end } = newTags[0];\n const payload = { start, end, text: text.slice(start, end) };\n dispatch({ type: \"create-node\", payload });\n return;\n }\n\n const tagIDs = new Set(tags.map((d) => d.id));\n const removedIds = allTags.map((d) => d.id).filter((d) => !tagIDs.has(d));\n\n /* Find the id that was removed: that is the one that will be selected\n (we are hijacking the 'click to delete' functionality to select instead) */\n if (removedIds.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: removedIds },\n });\n }\n },\n [allTags, text]\n );\n\n return h(TextAnnotateBlend, {\n style: {\n fontSize: \"1.2em\",\n },\n className: \"feedback-text\",\n content: text,\n onChange,\n value: allTags,\n });\n}\n"],"names":[],"version":3,"file":"text-visualizer.198e27ff.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;CAEC;;;;;AAUD,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,sEAAK;AAa5B,MAAM,oCAAoD,CAAC;IACzD,sCAAsC,GACtC,IAAI,UAAE,MAAM,YAAE,QAAQ,aAAE,SAAS,YAAE,QAAQ,QAAE,IAAI,YAAE,QAAQ,EAAE,GAAG;IAChE,YAAY,CAAA,GAAA,iBAAS,EAAE;gBAAE;kBAAQ;IAAS,GAAG;IAC7C,MAAM,UAAU,IAAM,SAAS;IAE/B,OAAO,wBACL,sBACA;QACE,KAAK,KAAK,EAAE;mBACZ;iBACA;IACF,GACA;QACE,wBAAE,cAAc;YAAE,OAAO;gBAAE,iBAAiB,KAAK,KAAK;YAAC;QAAE;QACzD,wBAAE,YAAY,CAAC,GAAG,KAAK,IAAI;KAC5B;AAEL;AAWO,SAAS,0CAAmB,KAAsB;IACvD,2CAA2C,GAC3C,MAAM,gBAAE,YAAY,SAAE,KAAK,UAAE,MAAM,WAAE,OAAO,EAAE,GAAG;IAEjD,OAAO,wBAAE,CAAA,GAAA,cAAM,GAAG;QAChB,cAAc;eACd;QACA,eAAe;gBACf;iBACA;QACA,cAAa,IAAO,EAAE,eAAE,WAAW,aAAE,SAAS,EAAE;YAC9C,OAAO,wBAAE,mCAAa;gBACpB,KAAK,KAAK,EAAE;sBACZ;gBACA,UAAU;gBACV,QAAQ,UAAU,MAAM;gBACxB,UAAU,UAAU,MAAM;YAC5B;QACF;IACF;AACF","sources":["packages/feedback-components/src/feedback/type-selector/index.ts"],"sourcesContent":["/**\n * Entity type selector\n */\n\nimport styles from \"./main.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport classNames from \"classnames\";\nimport React from \"react\";\nimport { Omnibar, OmnibarProps } from \"@blueprintjs/select\";\nimport \"@blueprintjs/select/lib/css/blueprint-select.css\";\n\nconst h = hyper.styled(styles);\n\ninterface TagItemProps<T> {\n selected: boolean;\n active: boolean;\n className?: string;\n item: T;\n\n onSelect(t: T): void;\n\n children?: React.ReactElement;\n}\n\nconst TagListItem: React.ComponentType<TagItemProps<T>> = (props) => {\n /** Render a tag for the omnibox list */\n let { active, selected, className, onSelect, item, children } = props;\n className = classNames({ active, selected }, className);\n const onClick = () => onSelect(item);\n\n return h(\n \"div.item-container\",\n {\n key: item.id,\n className,\n onClick,\n },\n [\n h(\"div.swatch\", { style: { backgroundColor: item.color } }),\n h(\"div.item\", {}, item.name),\n ]\n );\n};\n\ntype BoxLifecycleProps<T> = Pick<OmnibarProps<T>, \"onClose\" | \"isOpen\">;\n\ninterface OmniboxProps<T> extends BoxLifecycleProps<T> {\n items: T[];\n selectedItem: T;\n onSelectItem: (t: T) => void;\n listItemComponent?: React.ComponentType<TagItemProps<T>>;\n}\n\nexport function OmniboxSelector<T>(props: OmniboxProps<T>) {\n /** A general omnibox for annotation types */\n const { onSelectItem, items, isOpen, onClose } = props;\n\n return h(Omnibar, {\n onItemSelect: onSelectItem,\n items,\n resetOnSelect: false,\n isOpen,\n onClose,\n itemRenderer(item: T, { handleClick, modifiers }) {\n return h(TagListItem, {\n key: item.id,\n item,\n onSelect: handleClick,\n active: modifiers.active,\n selected: modifiers.active,\n });\n },\n });\n}\n"],"names":[],"version":3,"file":"type-selector.6e8952d6.js.map"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,O,iB,C,K,O,A,O,qB,CC+DmC,AAAA,EAAmC","sources":["<anon>","packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import {useReducer as $eGztG$useReducer, createContext as $eGztG$createContext, useContext as $eGztG$useContext} from \"react\";\nimport $eGztG$immutabilityhelper from \"immutability-helper\";\n\n\n\nvar $330ae695507d96f5$export$53ec42062883b2d4 = /*#__PURE__*/ function(ViewMode) {\n ViewMode[\"Tree\"] = \"tree\";\n ViewMode[\"Graph\"] = \"graph\";\n return ViewMode;\n}({});\nfunction $330ae695507d96f5$export$911bb4b9c8065d3d(initialTree, entityTypes) {\n // Get the first entity type\n const type = entityTypes.values().next().value;\n return (0, $eGztG$useReducer)($330ae695507d96f5$var$treeReducer, {\n initialTree: initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: \"tree\"\n });\n}\nconst $330ae695507d96f5$export$e5ce04c5b3f58533 = (0, $eGztG$createContext)(null);\nfunction $330ae695507d96f5$export$e1068f2d1c68f87e() {\n const dispatch = (0, $eGztG$useContext)($330ae695507d96f5$export$e5ce04c5b3f58533);\n if (dispatch == null) throw new Error(\"No dispatch context available\");\n return dispatch;\n}\nfunction $330ae695507d96f5$var$treeReducer(state, action) {\n console.log(action);\n switch(action.type){\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.dragIds);\n let keyPath = [];\n if (action.payload.parentId) {\n keyPath = $330ae695507d96f5$var$findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n // Add removed nodes to the new tree at the correct location\n let updateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n $splice: [\n [\n action.payload.index,\n 0,\n ...removedNodes\n ]\n ]\n });\n return {\n ...state,\n tree: (0, $eGztG$immutabilityhelper)(newTree, updateSpec)\n };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.ids);\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n const children = _removedNodes.flatMap((node)=>node.children ?? []).filter((child)=>!$330ae695507d96f5$var$nodeIsInTree(newTree2, child.id));\n // Reset the selection\n return {\n ...state,\n tree: [\n ...newTree2,\n ...children\n ],\n selectedNodes: state.selectedNodes.filter((id)=>!action.payload.ids.includes(id))\n };\n case \"select-node\":\n const { ids: ids } = action.payload;\n return {\n ...state,\n selectedNodes: ids\n };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter((id)=>!state.selectedNodes.includes(id));\n const nodesToKeep = state.selectedNodes.filter((id)=>!action.payload.ids.includes(id));\n return {\n ...state,\n selectedNodes: [\n ...nodesToKeep,\n ...nodesToAdd\n ]\n };\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text: text, start: start, end: end } = action.payload;\n const node = {\n id: newId,\n name: text,\n children: [],\n indices: [\n start,\n end\n ],\n type: state.selectedEntityType\n };\n return {\n ...state,\n tree: [\n ...state.tree,\n node\n ],\n selectedNodes: [\n newId\n ],\n lastInternalId: newId\n };\n /** Entity type selection */ case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType\n };\n case \"select-entity-type\":\n {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes){\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n const nestedSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n type: {\n $set: action.payload\n }\n });\n newTree2 = (0, $eGztG$immutabilityhelper)(newTree2, nestedSpec);\n }\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload\n };\n }\n case \"deselect\":\n return {\n ...state,\n selectedNodes: []\n };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: []\n };\n case \"set-view-mode\":\n return {\n ...state,\n viewMode: action.payload\n };\n }\n}\nfunction $330ae695507d96f5$var$nodeIsInTree(tree, id) {\n for (let node of tree){\n if (node.id == id) return true;\n else if (node.children) {\n if ($330ae695507d96f5$var$nodeIsInTree(node.children, id)) return true;\n }\n }\n return false;\n}\nfunction $330ae695507d96f5$var$buildNestedSpec(keyPath, innerSpec) {\n // Build a nested object from a key path\n let spec = innerSpec;\n for(let i = keyPath.length - 1; i >= 0; i--)spec = {\n [keyPath[i]]: spec\n };\n return spec;\n// Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\nfunction $330ae695507d96f5$var$findNode(tree, id) {\n // Find the index of the node with the given id in the tree, returning the key path\n for(let i = 0; i < tree.length; i++){\n if (tree[i].id == id) return [\n i\n ];\n else if (tree[i].children) {\n let path = $330ae695507d96f5$var$findNode(tree[i].children, id);\n if (path != null) return [\n i,\n \"children\",\n ...path\n ];\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$removeNodes(tree, ids) {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */ let newTree = [];\n let removedNodes = [];\n for (let node of tree)if (ids.includes(node.id)) removedNodes.push(node);\n else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = $330ae695507d96f5$var$removeNodes(node.children, ids);\n node = {\n ...node,\n children: newChildren\n };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n return [\n newTree,\n removedNodes\n ];\n}\nfunction $330ae695507d96f5$export$8d9dbb7a64bf2a5e(tree) {\n // Convert the tree to a graph\n let nodes = [];\n let edges = [];\n const nodeMap = new Map();\n for (let node of tree){\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) continue;\n const { indices: indices, id: id, name: name } = node;\n const nodeData = {\n id: id,\n type: node.type.id,\n name: name,\n txt_range: [\n indices\n ],\n reasoning: null,\n match: node.match\n };\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n if (node.children) {\n for (let child of node.children)edges.push({\n source: node.id,\n dest: child.id\n });\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = $330ae695507d96f5$export$8d9dbb7a64bf2a5e(node.children);\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n return {\n nodes: nodes,\n edges: edges\n };\n}\n\n\n//# sourceMappingURL=edit-state.f50ca728.js.map\n","import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n console.log(action);\n switch (action.type) {\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id)\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n return { ...state, selectedNodes: ids };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id)\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id)\n );\n return { ...state, selectedNodes: [...nodesToKeep, ...nodesToAdd] };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[]\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: node.type.id,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n"],"names":["createContext","$eGztG$createContext"],"version":3,"file":"edit-state.f50ca728.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"classnames";import"@blueprintjs/core";import"@macrostrat/color-utils";import r from"@macrostrat/hyper";var e,t=globalThis,o={},a={},i=t.parcelRequire94c2;null==i&&((i=function(r){if(r in o)return o[r].exports;if(r in a){var e=a[r];delete a[r];var t={id:r,exports:{}};return o[r]=t,e.call(t.exports,t,t.exports),t.exports}var i=Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(r,e){a[r]=e},t.parcelRequire94c2=i),i.register;var l={};l=i("daZiC").getBundleURL("78C1X")+"main.module.1fdfe813.css",r.styled((e=l)&&e.__esModule?e.default:e);
|
|
2
|
-
//# sourceMappingURL=extractions.e6ea2eb9.js.map
|