@macrostrat/feedback-components 1.1.3 → 1.1.4
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 +5 -0
- package/dist/esm/{feedback-components.95dbe7d7.js → feedback-components.00434ff7.js} +10 -1
- package/dist/esm/feedback-components.00434ff7.js.map +1 -0
- package/dist/esm/{feedback-components.f577ebea.js → feedback-components.1c15f37f.js} +32 -24
- package/dist/esm/feedback-components.1c15f37f.js.map +1 -0
- package/dist/esm/{feedback-components.1e7da538.js → feedback-components.204f7d2b.js} +23 -281
- package/dist/esm/feedback-components.204f7d2b.js.map +1 -0
- package/dist/esm/{feedback-components.832b2eae.js → feedback-components.28ba71be.js} +5 -5
- package/dist/esm/{feedback-components.832b2eae.js.map → feedback-components.28ba71be.js.map} +1 -1
- package/dist/esm/feedback-components.7e879290.js +286 -0
- package/dist/esm/feedback-components.7e879290.js.map +1 -0
- package/dist/esm/{feedback-components.45d25912.js → feedback-components.d55a1d18.js} +5 -5
- package/dist/esm/{feedback-components.45d25912.js.map → feedback-components.d55a1d18.js.map} +1 -1
- package/dist/esm/{feedback-components.fb60c70d.css → feedback-components.d591ffec.css} +20 -1
- package/dist/esm/feedback-components.d591ffec.css.map +1 -0
- package/dist/esm/{feedback-components.fa1d3641.js → feedback-components.f6605b83.js} +49 -7
- package/dist/esm/feedback-components.f6605b83.js.map +1 -0
- package/dist/esm/feedback-components.fd8ac9ca.js +230 -0
- package/dist/esm/feedback-components.fd8ac9ca.js.map +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/node/feedback-components.0eef8d0c.js +2 -0
- package/dist/node/feedback-components.0eef8d0c.js.map +1 -0
- package/dist/node/{feedback-components.f9abf0d6.js → feedback-components.2f740fc7.js} +2 -2
- package/dist/node/{feedback-components.f9abf0d6.js.map → feedback-components.2f740fc7.js.map} +1 -1
- package/dist/node/{feedback-components.4cd6b208.js → feedback-components.41db283a.js} +2 -2
- package/dist/node/{feedback-components.4cd6b208.js.map → feedback-components.41db283a.js.map} +1 -1
- package/dist/node/feedback-components.69d0ccd0.js +2 -0
- package/dist/node/feedback-components.69d0ccd0.js.map +1 -0
- package/dist/node/feedback-components.a7b43cfa.js +2 -0
- package/dist/node/feedback-components.a7b43cfa.js.map +1 -0
- package/dist/node/feedback-components.b9317f9c.js +2 -0
- package/dist/node/feedback-components.b9317f9c.js.map +1 -0
- package/dist/node/{feedback-components.c88cb37f.css → feedback-components.e096504e.css} +2 -2
- package/dist/node/feedback-components.e096504e.css.map +1 -0
- package/dist/node/feedback-components.e140ac86.js +2 -0
- package/dist/node/feedback-components.e140ac86.js.map +1 -0
- package/dist/node/feedback-components.f8373b58.js +2 -0
- package/dist/node/feedback-components.f8373b58.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/src/feedback/edit-state.ts +52 -3
- package/src/feedback/feedback.module.sass +17 -1
- package/src/feedback/index.ts +11 -317
- package/src/feedback/matches.ts +241 -0
- package/src/feedback/text-visualizer.ts +21 -21
- package/src/feedback/typelist.ts +312 -0
- package/dist/esm/feedback-components.1e7da538.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.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.map +0 -1
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,O,oD,C,S,E,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,O,S,C,c,C,I,C,E,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,S,E,E,S,E,E,G,E,E,U,6C,e,C,4C,W,C,6C,W,C,6C,iB,C,6C,S,C,6C,S,C,6C,iB,C,6C,W","sources":["<anon>","packages/feedback-components/src/index.ts"],"sourcesContent":["import \"./feedback-components.b22d37d1.js\";\nimport \"./feedback-components.
|
|
1
|
+
{"mappings":"A,M,oD,A,O,oD,C,S,E,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,O,S,C,c,C,I,C,E,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,S,E,E,S,E,E,G,E,E,U,6C,e,C,4C,W,C,6C,W,C,6C,iB,C,6C,S,C,6C,S,C,6C,iB,C,6C,W","sources":["<anon>","packages/feedback-components/src/index.ts"],"sourcesContent":["import \"./feedback-components.b22d37d1.js\";\nimport \"./feedback-components.0eef8d0c.js\";\n\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $c688386f08592f9c$exports = {};\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nvar $aZPCw = parcelRequire(\"aZPCw\");\n$parcel$exportWildcard($c688386f08592f9c$exports, $edvRb);\n$parcel$exportWildcard($c688386f08592f9c$exports, $aZPCw);\n\n\nexport {$8c534c0378e15a46$export$c4b91360064ad200 as buildHighlights, $8c534c0378e15a46$export$d60b563f571177d as enhanceData, $8c534c0378e15a46$export$35baa338324d8550 as getTagStyle, $8c534c0378e15a46$export$2b07158757c249e0 as ExtractionContext, $8c534c0378e15a46$export$4eb2a0ce903ce967 as ModelInfo, $8c534c0378e15a46$export$117e56c71b172cde as EntityTag, $2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=index.js.map\n","export * from \"./extractions\";\nexport * from \"./feedback\";\n"],"names":["$parcel$exportWildcard","dest","source","Object","keys","forEach","key","prototype","hasOwnProperty","call","defineProperty","enumerable","get","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","err","Error","code","register","$c688386f08592f9c$exports","$edvRb","$aZPCw","$8c534c0378e15a46$export$c4b91360064ad200","buildHighlights","$8c534c0378e15a46$export$d60b563f571177d","enhanceData","$8c534c0378e15a46$export$35baa338324d8550","getTagStyle","$8c534c0378e15a46$export$2b07158757c249e0","ExtractionContext","$8c534c0378e15a46$export$4eb2a0ce903ce967","ModelInfo","$8c534c0378e15a46$export$117e56c71b172cde","EntityTag","$2c86488f2f3c1edd$export$a90600c9da52b40c","FeedbackComponent","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","treeToGraph"],"version":3,"file":"index.js.map","sourceRoot":"../../../../"}
|
package/package.json
CHANGED
|
@@ -48,7 +48,9 @@ type TreeAction =
|
|
|
48
48
|
type: "update-entity-type";
|
|
49
49
|
payload: { id: number; name: string; description: string; color: string };
|
|
50
50
|
}
|
|
51
|
-
| { type: "select-range"; payload: { ids: number[] } }
|
|
51
|
+
| { type: "select-range"; payload: { ids: number[] } }
|
|
52
|
+
| { type: "add-match"; payload: { id: number; payload: any } }
|
|
53
|
+
| { type: "remove-match"; payload: { id: number } };
|
|
52
54
|
|
|
53
55
|
export type TreeDispatch = Dispatch<TreeAction>;
|
|
54
56
|
|
|
@@ -246,7 +248,6 @@ function treeReducer(state: TreeState, action: TreeAction) {
|
|
|
246
248
|
|
|
247
249
|
case "delete-entity-type": {
|
|
248
250
|
// Remove the entity type from the map
|
|
249
|
-
console.log("Deleting entity type:", action.payload.id);
|
|
250
251
|
const { id } = action.payload;
|
|
251
252
|
const newEntityTypesMap = new Map(state.entityTypesMap);
|
|
252
253
|
const oldType = newEntityTypesMap.get(id);
|
|
@@ -263,6 +264,54 @@ function treeReducer(state: TreeState, action: TreeAction) {
|
|
|
263
264
|
};
|
|
264
265
|
}
|
|
265
266
|
|
|
267
|
+
case "add-match": {
|
|
268
|
+
const { id } = action.payload;
|
|
269
|
+
|
|
270
|
+
// Find the node path
|
|
271
|
+
const keyPath = findNode(state.tree, id);
|
|
272
|
+
if (!keyPath) {
|
|
273
|
+
console.warn(`Node with id ${id} not found`);
|
|
274
|
+
return state;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Build update spec to set the `match` property
|
|
278
|
+
const matchUpdateSpec = buildNestedSpec(keyPath, {
|
|
279
|
+
match: { $set: action.payload.payload },
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const updatedTree = update(state.tree, matchUpdateSpec);
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
...state,
|
|
286
|
+
tree: updatedTree,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
case "remove-match": {
|
|
291
|
+
const { id } = action.payload;
|
|
292
|
+
|
|
293
|
+
console.log("Removing match for node with id:", id);
|
|
294
|
+
|
|
295
|
+
// Find the node path
|
|
296
|
+
const keyPath = findNode(state.tree, id);
|
|
297
|
+
if (!keyPath) {
|
|
298
|
+
console.warn(`Node with id ${id} not found`);
|
|
299
|
+
return state;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Build update spec to unset the `match` property
|
|
303
|
+
const matchUpdateSpec = buildNestedSpec(keyPath, {
|
|
304
|
+
match: { $set: null },
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const updatedTree = update(state.tree, matchUpdateSpec);
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
...state,
|
|
311
|
+
tree: updatedTree,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
266
315
|
/** Entity type selection */
|
|
267
316
|
case "toggle-entity-type-selector":
|
|
268
317
|
return {
|
|
@@ -431,7 +480,7 @@ export function treeToGraph(tree: TreeData[]): GraphData {
|
|
|
431
480
|
return { nodes, edges };
|
|
432
481
|
}
|
|
433
482
|
|
|
434
|
-
function findNodeById(tree, id) {
|
|
483
|
+
export function findNodeById(tree, id) {
|
|
435
484
|
for (const node of tree) {
|
|
436
485
|
if (node.id === id) {
|
|
437
486
|
return node;
|
|
@@ -146,4 +146,20 @@ mark
|
|
|
146
146
|
.node-label
|
|
147
147
|
fill: var(--text-emphasized-color)
|
|
148
148
|
fontSize: 10px
|
|
149
|
-
pointerEvents: none
|
|
149
|
+
pointerEvents: none
|
|
150
|
+
|
|
151
|
+
.match-item
|
|
152
|
+
background-color: var(--background-color)
|
|
153
|
+
color: var(--text-emphasized-color)
|
|
154
|
+
padding: .1em .2em
|
|
155
|
+
border-radius: .2em
|
|
156
|
+
margin-bottom: 4px
|
|
157
|
+
cursor: pointer
|
|
158
|
+
|
|
159
|
+
.match-container
|
|
160
|
+
display: flex
|
|
161
|
+
justify-content: space-between
|
|
162
|
+
align-items: center
|
|
163
|
+
|
|
164
|
+
.close-btn
|
|
165
|
+
cursor: pointer
|
package/src/feedback/index.ts
CHANGED
|
@@ -18,26 +18,20 @@ import {
|
|
|
18
18
|
ButtonGroup,
|
|
19
19
|
Card,
|
|
20
20
|
SegmentedControl,
|
|
21
|
-
Icon,
|
|
22
|
-
Popover,
|
|
23
21
|
Divider,
|
|
24
|
-
Overlay2,
|
|
25
22
|
} from "@blueprintjs/core";
|
|
26
23
|
import { OmniboxSelector } from "./type-selector";
|
|
27
24
|
import {
|
|
28
25
|
CancelButton,
|
|
29
|
-
DataField,
|
|
30
26
|
ErrorBoundary,
|
|
31
|
-
FlexBox,
|
|
32
27
|
FlexRow,
|
|
33
28
|
SaveButton,
|
|
34
29
|
} from "@macrostrat/ui-components";
|
|
35
30
|
import useElementDimensions from "use-element-dimensions";
|
|
36
31
|
import { GraphView } from "./graph";
|
|
37
|
-
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import { Switch } from "@blueprintjs/core";
|
|
32
|
+
|
|
33
|
+
import { Matches } from "./matches";
|
|
34
|
+
import { TypeList } from "./typelist";
|
|
41
35
|
|
|
42
36
|
export type { GraphData } from "./edit-state";
|
|
43
37
|
export { treeToGraph } from "./edit-state";
|
|
@@ -155,13 +149,6 @@ export function FeedbackComponent({
|
|
|
155
149
|
alignText: "left",
|
|
156
150
|
},
|
|
157
151
|
[
|
|
158
|
-
h.if(matchLinks)(Switch, {
|
|
159
|
-
label: "Show matches",
|
|
160
|
-
checked: match !== null,
|
|
161
|
-
onChange: (e) => {
|
|
162
|
-
setMatchLinks(match === null ? matchLinks || {} : null);
|
|
163
|
-
},
|
|
164
|
-
}),
|
|
165
152
|
h(
|
|
166
153
|
CancelButton,
|
|
167
154
|
{
|
|
@@ -185,6 +172,14 @@ export function FeedbackComponent({
|
|
|
185
172
|
),
|
|
186
173
|
],
|
|
187
174
|
),
|
|
175
|
+
h(Matches, {
|
|
176
|
+
match,
|
|
177
|
+
setMatchLinks,
|
|
178
|
+
matchLinks,
|
|
179
|
+
selectedNodes,
|
|
180
|
+
tree,
|
|
181
|
+
dispatch,
|
|
182
|
+
}),
|
|
188
183
|
h(Divider),
|
|
189
184
|
h(EntityTypeSelector, {
|
|
190
185
|
entityTypes: entityTypesMap,
|
|
@@ -386,304 +381,3 @@ function ManagedSelectionTree(props) {
|
|
|
386
381
|
}),
|
|
387
382
|
);
|
|
388
383
|
}
|
|
389
|
-
|
|
390
|
-
function TypeList({ types, selected, dispatch, selectedNodes, tree }) {
|
|
391
|
-
const [selectedType, setSelectedType] = useState(null);
|
|
392
|
-
const isSelectedNodes = selectedNodes.length > 0;
|
|
393
|
-
const darkMode = useInDarkMode();
|
|
394
|
-
const luminance = darkMode ? 0.9 : 0.4;
|
|
395
|
-
|
|
396
|
-
return h("div.type-list-container", [
|
|
397
|
-
h(
|
|
398
|
-
"div.type-list-header",
|
|
399
|
-
isSelectedNodes && !selectedType
|
|
400
|
-
? "Change selected nodes to:"
|
|
401
|
-
: "Entity Types",
|
|
402
|
-
),
|
|
403
|
-
h(
|
|
404
|
-
"div.type-list",
|
|
405
|
-
Array.from(types.values()).map((type) =>
|
|
406
|
-
h(TypeTag, {
|
|
407
|
-
type,
|
|
408
|
-
luminance,
|
|
409
|
-
selectedType,
|
|
410
|
-
setSelectedType,
|
|
411
|
-
dispatch,
|
|
412
|
-
tree,
|
|
413
|
-
selectedNodes,
|
|
414
|
-
selected,
|
|
415
|
-
isSelectedNodes,
|
|
416
|
-
}),
|
|
417
|
-
),
|
|
418
|
-
),
|
|
419
|
-
h(AddType, { dispatch }),
|
|
420
|
-
]);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function collectMatchingIds(tree, id) {
|
|
424
|
-
const ids = [];
|
|
425
|
-
|
|
426
|
-
function traverse(node) {
|
|
427
|
-
if (node.type.id === id) {
|
|
428
|
-
ids.push(node.id);
|
|
429
|
-
}
|
|
430
|
-
if (Array.isArray(node.children)) {
|
|
431
|
-
node.children.forEach(traverse);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
tree.forEach(traverse);
|
|
436
|
-
return ids;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
function AddType({ dispatch }) {
|
|
440
|
-
const [overlayOpen, setOverlayOpen] = useState(false);
|
|
441
|
-
|
|
442
|
-
const saveHandler = (payload) => {
|
|
443
|
-
dispatch({
|
|
444
|
-
type: "add-entity-type",
|
|
445
|
-
payload,
|
|
446
|
-
});
|
|
447
|
-
setOverlayOpen(false);
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
return h("div.add-type-container", [
|
|
451
|
-
h("div.add-type", { onClick: () => setOverlayOpen(true) }, [
|
|
452
|
-
h("p.add-type-text", "Add new type"),
|
|
453
|
-
h(Icon, { icon: "plus" }),
|
|
454
|
-
]),
|
|
455
|
-
h(TypeOverlay, {
|
|
456
|
-
setOverlayOpen,
|
|
457
|
-
overlayOpen,
|
|
458
|
-
title: "Add New Type",
|
|
459
|
-
saveHandler,
|
|
460
|
-
}),
|
|
461
|
-
]);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
function EditType({ dispatch, type }) {
|
|
465
|
-
const [editorOpen, setEditorOpen] = useState(false);
|
|
466
|
-
|
|
467
|
-
const saveHandler = (payload) => {
|
|
468
|
-
dispatch({
|
|
469
|
-
type: "update-entity-type",
|
|
470
|
-
payload,
|
|
471
|
-
});
|
|
472
|
-
setEditorOpen(false);
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
return h("div.edit-type", [
|
|
476
|
-
h(Icon, {
|
|
477
|
-
icon: "edit",
|
|
478
|
-
className: "edit-icon",
|
|
479
|
-
onClick: (e) => {
|
|
480
|
-
e.stopPropagation();
|
|
481
|
-
setEditorOpen(true);
|
|
482
|
-
},
|
|
483
|
-
}),
|
|
484
|
-
h(TypeOverlay, {
|
|
485
|
-
setOverlayOpen: setEditorOpen,
|
|
486
|
-
overlayOpen: editorOpen,
|
|
487
|
-
originalType: type,
|
|
488
|
-
title: "Edit Type",
|
|
489
|
-
saveHandler,
|
|
490
|
-
}),
|
|
491
|
-
]);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function TypeOverlay({
|
|
495
|
-
setOverlayOpen,
|
|
496
|
-
overlayOpen,
|
|
497
|
-
originalType,
|
|
498
|
-
title,
|
|
499
|
-
saveHandler,
|
|
500
|
-
}) {
|
|
501
|
-
const { name, description, color, id } = originalType || {};
|
|
502
|
-
|
|
503
|
-
const [nameInput, setNameInput] = useState(name || "");
|
|
504
|
-
const [descriptionInput, setDescriptionInput] = useState(description || "");
|
|
505
|
-
const [colorInput, setColorInput] = useState(color || "#fff");
|
|
506
|
-
|
|
507
|
-
return h(
|
|
508
|
-
Overlay2,
|
|
509
|
-
{
|
|
510
|
-
isOpen: overlayOpen,
|
|
511
|
-
},
|
|
512
|
-
h(
|
|
513
|
-
"div.overlay-container",
|
|
514
|
-
h("div.add-type-overlay", [
|
|
515
|
-
h("h2.title", [
|
|
516
|
-
title,
|
|
517
|
-
h(Icon, {
|
|
518
|
-
icon: "cross",
|
|
519
|
-
className: "close-icon",
|
|
520
|
-
onClick: () => {
|
|
521
|
-
setOverlayOpen(false);
|
|
522
|
-
},
|
|
523
|
-
style: { cursor: "pointer", color: "red" },
|
|
524
|
-
}),
|
|
525
|
-
]),
|
|
526
|
-
h("div.form-group", [
|
|
527
|
-
h("div.text-inputs", [
|
|
528
|
-
h("div.form-field.name", [
|
|
529
|
-
h("p.label", "Name"),
|
|
530
|
-
h("input", {
|
|
531
|
-
type: "text",
|
|
532
|
-
placeholder: "Enter type name",
|
|
533
|
-
onChange: (e) => setNameInput(e.target.value),
|
|
534
|
-
value: nameInput,
|
|
535
|
-
}),
|
|
536
|
-
]),
|
|
537
|
-
h("div.form-field.form-description", [
|
|
538
|
-
h("p.label", "Description"),
|
|
539
|
-
h("input", {
|
|
540
|
-
type: "text",
|
|
541
|
-
placeholder: "Enter type description",
|
|
542
|
-
onChange: (e) => setDescriptionInput(e.target.value),
|
|
543
|
-
value: descriptionInput,
|
|
544
|
-
}),
|
|
545
|
-
]),
|
|
546
|
-
]),
|
|
547
|
-
h("div.form-field.color", [
|
|
548
|
-
h("p.label", "Color"),
|
|
549
|
-
h(ColorPicker, {
|
|
550
|
-
value: colorInput,
|
|
551
|
-
onChange: (color) => setColorInput(color),
|
|
552
|
-
style: { width: "100%" },
|
|
553
|
-
}),
|
|
554
|
-
]),
|
|
555
|
-
]),
|
|
556
|
-
h(
|
|
557
|
-
SaveButton,
|
|
558
|
-
{
|
|
559
|
-
className: "save-btn",
|
|
560
|
-
small: true,
|
|
561
|
-
onClick: () =>
|
|
562
|
-
saveHandler({
|
|
563
|
-
name: nameInput,
|
|
564
|
-
description: descriptionInput,
|
|
565
|
-
color: colorInput,
|
|
566
|
-
id,
|
|
567
|
-
}),
|
|
568
|
-
},
|
|
569
|
-
"Save changes",
|
|
570
|
-
),
|
|
571
|
-
]),
|
|
572
|
-
),
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
function TypeTag({
|
|
577
|
-
type,
|
|
578
|
-
luminance,
|
|
579
|
-
selectedType,
|
|
580
|
-
setSelectedType,
|
|
581
|
-
dispatch,
|
|
582
|
-
tree,
|
|
583
|
-
selectedNodes,
|
|
584
|
-
selected,
|
|
585
|
-
isSelectedNodes,
|
|
586
|
-
}) {
|
|
587
|
-
const { color, name, id, description } = type;
|
|
588
|
-
const darkMode = useInDarkMode();
|
|
589
|
-
const isSelected = id === selected?.id && selectedNodes.length > 0;
|
|
590
|
-
|
|
591
|
-
const style = getTagStyle(color, {
|
|
592
|
-
active: isSelected,
|
|
593
|
-
highlighted: selectedNodes.length === 0,
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
const payload = {
|
|
597
|
-
id,
|
|
598
|
-
name,
|
|
599
|
-
color,
|
|
600
|
-
description,
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
const ids = collectMatchingIds(tree, id);
|
|
604
|
-
|
|
605
|
-
const handleTagClick = () => {
|
|
606
|
-
if (!isSelectedNodes && selectedType === null) {
|
|
607
|
-
if (ids.length > 0) {
|
|
608
|
-
setSelectedType(type);
|
|
609
|
-
dispatch({ type: "toggle-node-selected", payload: { ids } });
|
|
610
|
-
}
|
|
611
|
-
} else if (isSelectedNodes && selectedType === null) {
|
|
612
|
-
if (id === selected?.id && selectedNodes.length > 0) {
|
|
613
|
-
dispatch({
|
|
614
|
-
type: "toggle-node-selected",
|
|
615
|
-
payload: { ids: selectedNodes },
|
|
616
|
-
});
|
|
617
|
-
} else {
|
|
618
|
-
dispatch({ type: "select-entity-type", payload });
|
|
619
|
-
}
|
|
620
|
-
} else if (isSelectedNodes && selectedType.id === id) {
|
|
621
|
-
setSelectedType(null);
|
|
622
|
-
dispatch({ type: "toggle-node-selected", payload: { ids } });
|
|
623
|
-
} else if (isSelectedNodes && selectedType.id !== id) {
|
|
624
|
-
if (ids.length > 0) {
|
|
625
|
-
setSelectedType(type);
|
|
626
|
-
const oldIds = collectMatchingIds(tree, selectedType.id);
|
|
627
|
-
|
|
628
|
-
dispatch({ type: "toggle-node-selected", payload: { ids: oldIds } });
|
|
629
|
-
dispatch({ type: "toggle-node-selected", payload: { ids } });
|
|
630
|
-
}
|
|
631
|
-
} else {
|
|
632
|
-
console.warn("Unexpected state in TypeTag click handler", {
|
|
633
|
-
isSelectedNodes,
|
|
634
|
-
selectedType,
|
|
635
|
-
selectedNodes,
|
|
636
|
-
ids,
|
|
637
|
-
id,
|
|
638
|
-
selected,
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
return h(
|
|
644
|
-
Popover,
|
|
645
|
-
{
|
|
646
|
-
autoFocus: false,
|
|
647
|
-
content: h("div.description", description || "No description available"),
|
|
648
|
-
interactionKind: "hover",
|
|
649
|
-
},
|
|
650
|
-
h(
|
|
651
|
-
"div.type-tag",
|
|
652
|
-
{
|
|
653
|
-
onClick: handleTagClick,
|
|
654
|
-
style: {
|
|
655
|
-
cursor:
|
|
656
|
-
ids.length > 0 || (isSelectedNodes && !selectedType)
|
|
657
|
-
? "pointer"
|
|
658
|
-
: "",
|
|
659
|
-
color: "black",
|
|
660
|
-
backgroundColor: style.backgroundColor,
|
|
661
|
-
border: isSelected
|
|
662
|
-
? `1px solid var(--text-emphasized-color)`
|
|
663
|
-
: `1px solid var(--background-color)`,
|
|
664
|
-
},
|
|
665
|
-
},
|
|
666
|
-
h("div.type-container", [
|
|
667
|
-
h("div.type-name", name),
|
|
668
|
-
h("div.icons", [
|
|
669
|
-
h(EditType, {
|
|
670
|
-
dispatch,
|
|
671
|
-
type,
|
|
672
|
-
}),
|
|
673
|
-
h(Icon, {
|
|
674
|
-
icon: "cross",
|
|
675
|
-
className: "delete-type-icon",
|
|
676
|
-
style: { color: "red", cursor: "pointer" },
|
|
677
|
-
onClick: (e) => {
|
|
678
|
-
e.stopPropagation();
|
|
679
|
-
dispatch({
|
|
680
|
-
type: "delete-entity-type",
|
|
681
|
-
payload: { id },
|
|
682
|
-
});
|
|
683
|
-
},
|
|
684
|
-
}),
|
|
685
|
-
]),
|
|
686
|
-
]),
|
|
687
|
-
),
|
|
688
|
-
);
|
|
689
|
-
}
|