@macrostrat/feedback-components 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/dist/esm/{feedback-components.0d16f68a.js → feedback-components.2364179b.js} +5 -5
- package/dist/esm/{feedback-components.0d16f68a.js.map → feedback-components.2364179b.js.map} +1 -1
- package/dist/esm/{feedback-components.a35aed63.js → feedback-components.7dd42a9f.js} +4 -4
- package/dist/esm/{feedback-components.a35aed63.js.map → feedback-components.7dd42a9f.js.map} +1 -1
- package/dist/esm/{feedback-components.263bc4a5.js → feedback-components.7f72e5e9.js} +11 -11
- package/dist/esm/feedback-components.7f72e5e9.js.map +1 -0
- package/dist/esm/{feedback-components.707e3490.js → feedback-components.ba79c0ef.js} +2 -1
- package/dist/esm/feedback-components.ba79c0ef.js.map +1 -0
- package/dist/esm/{feedback-components.c0ded32f.js → feedback-components.c6e2c296.js} +6 -6
- package/dist/esm/{feedback-components.c0ded32f.js.map → feedback-components.c6e2c296.js.map} +1 -1
- package/dist/esm/{feedback-components.3cb322a5.js → feedback-components.ca78c2d4.js} +6 -6
- package/dist/esm/{feedback-components.3cb322a5.js.map → feedback-components.ca78c2d4.js.map} +1 -1
- package/dist/esm/{feedback-components.3c6291c9.css → feedback-components.d769ffa5.css} +1 -5
- package/dist/esm/feedback-components.d769ffa5.css.map +1 -0
- package/dist/esm/{feedback-components.b7fe8db7.js → feedback-components.e702eece.js} +1 -4
- package/dist/esm/feedback-components.e702eece.js.map +1 -0
- package/dist/esm/{feedback-components.5242166d.js → feedback-components.edc606bb.js} +17 -16
- package/dist/esm/feedback-components.edc606bb.js.map +1 -0
- package/dist/esm/{feedback-components.3d7fd2df.js → feedback-components.fa847634.js} +9 -4
- package/dist/esm/feedback-components.fa847634.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 +2 -2
- package/dist/node/{feedback-components.79d7b18c.js → feedback-components.1bd49bf0.js} +2 -2
- package/dist/node/{feedback-components.79d7b18c.js.map → feedback-components.1bd49bf0.js.map} +1 -1
- package/dist/node/{feedback-components.6e969752.js → feedback-components.6a4a1290.js} +2 -2
- package/dist/node/{feedback-components.6e969752.js.map → feedback-components.6a4a1290.js.map} +1 -1
- package/dist/node/feedback-components.70780da4.js +2 -0
- package/dist/node/feedback-components.70780da4.js.map +1 -0
- package/dist/node/feedback-components.97518e90.css +2 -0
- package/dist/node/feedback-components.97518e90.css.map +1 -0
- package/dist/node/feedback-components.c84ff10e.js +2 -0
- package/dist/node/feedback-components.c84ff10e.js.map +1 -0
- package/dist/node/feedback-components.db72d0e1.js +2 -0
- package/dist/node/feedback-components.db72d0e1.js.map +1 -0
- package/dist/node/feedback-components.dc76072c.js +2 -0
- package/dist/node/feedback-components.dc76072c.js.map +1 -0
- package/dist/node/{feedback-components.1ec0e5c7.js → feedback-components.ddd11fe8.js} +2 -2
- package/dist/node/{feedback-components.1ec0e5c7.js.map → feedback-components.ddd11fe8.js.map} +1 -1
- package/dist/node/feedback-components.e59a061f.js +2 -0
- package/dist/node/feedback-components.e59a061f.js.map +1 -0
- package/dist/node/{feedback-components.ad3ad94e.js → feedback-components.feab0bd0.js} +2 -2
- package/dist/node/{feedback-components.ad3ad94e.js.map → feedback-components.feab0bd0.js.map} +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +2 -2
- package/src/extractions/index.ts +1 -0
- package/src/feedback/edit-state.ts +14 -2
- package/src/feedback/feedback.module.sass +0 -3
- package/src/feedback/index.ts +4 -3
- package/src/feedback/node.ts +13 -6
- package/dist/esm/feedback-components.263bc4a5.js.map +0 -1
- package/dist/esm/feedback-components.3c6291c9.css.map +0 -1
- package/dist/esm/feedback-components.3d7fd2df.js.map +0 -1
- package/dist/esm/feedback-components.5242166d.js.map +0 -1
- package/dist/esm/feedback-components.707e3490.js.map +0 -1
- package/dist/esm/feedback-components.b7fe8db7.js.map +0 -1
- package/dist/node/feedback-components.104b4099.css +0 -2
- package/dist/node/feedback-components.104b4099.css.map +0 -1
- package/dist/node/feedback-components.4c09ec76.js +0 -2
- package/dist/node/feedback-components.4c09ec76.js.map +0 -1
- package/dist/node/feedback-components.8caef76e.js +0 -2
- package/dist/node/feedback-components.8caef76e.js.map +0 -1
- package/dist/node/feedback-components.b22d37d1.js +0 -2
- package/dist/node/feedback-components.b22d37d1.js.map +0 -1
- package/dist/node/feedback-components.cf680c38.js +0 -2
- package/dist/node/feedback-components.cf680c38.js.map +0 -1
- package/dist/node/feedback-components.e1fe112f.js +0 -2
- package/dist/node/feedback-components.e1fe112f.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./feedback-components.
|
|
2
|
-
import $bvJLP$
|
|
3
|
-
import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./feedback-components.
|
|
4
|
-
import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./feedback-components.
|
|
5
|
-
import {ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./feedback-components.
|
|
6
|
-
import {TreeDispatchContext as $b79bf29960412ca7$export$e5ce04c5b3f58533, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e, useUpdatableTree as $b79bf29960412ca7$export$911bb4b9c8065d3d} from "./feedback-components.
|
|
1
|
+
import "./feedback-components.d769ffa5.css";
|
|
2
|
+
import $bvJLP$feedbackcomponentse702eecejs from "./feedback-components.e702eece.js";
|
|
3
|
+
import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./feedback-components.7f72e5e9.js";
|
|
4
|
+
import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./feedback-components.ca78c2d4.js";
|
|
5
|
+
import {ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./feedback-components.ba79c0ef.js";
|
|
6
|
+
import {TreeDispatchContext as $b79bf29960412ca7$export$e5ce04c5b3f58533, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e, useUpdatableTree as $b79bf29960412ca7$export$911bb4b9c8065d3d} from "./feedback-components.fa847634.js";
|
|
7
7
|
import {OmniboxSelector as $fda9ef5406c1cfb4$export$d8660660a589068c} from "./feedback-components.ad9f284e.js";
|
|
8
|
-
import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./feedback-components.
|
|
9
|
-
import {Matches as $a878a21b0c10bfdc$export$6479cfcac2b87c0} from "./feedback-components.
|
|
10
|
-
import {TypeList as $18030469a9425911$export$9ebd91d75ddb6a8b} from "./feedback-components.
|
|
8
|
+
import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./feedback-components.c6e2c296.js";
|
|
9
|
+
import {Matches as $a878a21b0c10bfdc$export$6479cfcac2b87c0} from "./feedback-components.7dd42a9f.js";
|
|
10
|
+
import {TypeList as $18030469a9425911$export$9ebd91d75ddb6a8b} from "./feedback-components.2364179b.js";
|
|
11
11
|
import $bvJLP$macrostrathyper from "@macrostrat/hyper";
|
|
12
12
|
import {Tree as $bvJLP$Tree} from "react-arborist";
|
|
13
13
|
import {useState as $bvJLP$useState, useRef as $bvJLP$useRef, useCallback as $bvJLP$useCallback, useEffect as $bvJLP$useEffect} from "react";
|
|
@@ -34,7 +34,7 @@ function $parcel$interopDefault(a) {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
const $71d20dff35996763$var$h = (0, $bvJLP$macrostrathyper).styled((0, ($parcel$interopDefault($bvJLP$
|
|
37
|
+
const $71d20dff35996763$var$h = (0, $bvJLP$macrostrathyper).styled((0, ($parcel$interopDefault($bvJLP$feedbackcomponentse702eecejs))));
|
|
38
38
|
function $71d20dff35996763$var$setsAreTheSame(a, b) {
|
|
39
39
|
if (a.size !== b.size) return false;
|
|
40
40
|
for (const item of a){
|
|
@@ -42,12 +42,12 @@ function $71d20dff35996763$var$setsAreTheSame(a, b) {
|
|
|
42
42
|
}
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
|
-
function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap, matchLinks: matchLinks, view: view = false }) {
|
|
45
|
+
function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap, matchLinks: matchLinks, view: view = false, autoSelect: autoSelect = [] }) {
|
|
46
46
|
const [viewOnly, setViewOnly] = (0, $bvJLP$useState)(view);
|
|
47
47
|
const [match, setMatchLinks] = (0, $bvJLP$useState)(matchLinks);
|
|
48
48
|
const matchMode = match !== undefined;
|
|
49
49
|
// Get the input arguments
|
|
50
|
-
const [state, dispatch] = (0, $b79bf29960412ca7$export$911bb4b9c8065d3d)(entities.map($71d20dff35996763$var$processEntity), entityTypes, viewOnly, matchMode);
|
|
50
|
+
const [state, dispatch] = (0, $b79bf29960412ca7$export$911bb4b9c8065d3d)(entities.map($71d20dff35996763$var$processEntity), entityTypes, viewOnly, matchMode, autoSelect);
|
|
51
51
|
const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType, entityTypesMap: entityTypesMap } = state;
|
|
52
52
|
const [{ width: width, height: height }, ref] = (0, $bvJLP$useelementdimensions)();
|
|
53
53
|
return $71d20dff35996763$var$h("div.page-wrapper", [
|
|
@@ -260,9 +260,11 @@ function $71d20dff35996763$var$ManagedSelectionTree(props) {
|
|
|
260
260
|
const clickedRef = (0, $bvJLP$useRef)(false);
|
|
261
261
|
const _Node = (0, $bvJLP$useCallback)((props)=>$71d20dff35996763$var$h((0, $b6b9741bf83336eb$export$2e2bcd8739ae039), {
|
|
262
262
|
...props,
|
|
263
|
-
matchComponent: matchComponent
|
|
263
|
+
matchComponent: matchComponent,
|
|
264
|
+
viewOnly: viewOnly
|
|
264
265
|
}), [
|
|
265
|
-
matchComponent
|
|
266
|
+
matchComponent,
|
|
267
|
+
viewOnly
|
|
266
268
|
]);
|
|
267
269
|
// Update Tree selection when selectedNodes change
|
|
268
270
|
(0, $bvJLP$useEffect)(()=>{
|
|
@@ -348,7 +350,6 @@ function $71d20dff35996763$var$ManagedSelectionTree(props) {
|
|
|
348
350
|
onSelect: handleSelect,
|
|
349
351
|
children: _Node,
|
|
350
352
|
idAccessor (d) {
|
|
351
|
-
if (viewOnly) return -1;
|
|
352
353
|
return d.id.toString();
|
|
353
354
|
}
|
|
354
355
|
}));
|
|
@@ -356,4 +357,4 @@ function $71d20dff35996763$var$ManagedSelectionTree(props) {
|
|
|
356
357
|
|
|
357
358
|
|
|
358
359
|
export {$71d20dff35996763$export$a90600c9da52b40c as FeedbackComponent, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e as treeToGraph};
|
|
359
|
-
//# sourceMappingURL=feedback-components.
|
|
360
|
+
//# sourceMappingURL=feedback-components.edc606bb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,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,QACV,OAAO,mBACP,aAAa,EAAE,EAChB;IACC,MAAM,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IACzC,MAAM,CAAC,OAAO,cAAc,GAAG,CAAA,G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ACtC;IACF,GAAG,EAAE;IAEL,MAAM,eAAe,CAAA,GAAA,kBAAU,EAC7B,CAAC;QACC,IAAI,CAAC,WAAW,OAAO,EAAE;QACzB,WAAW,OAAO,GAAG;QACrB,MAAM,gBAAgB,eAAe,OAAO;QAE5C,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC,IAAM,SAAS,EAAE,EAAE;QAExC,IAAI,eACF,SAAS;YAAE,MAAM;YAAwB,SAAS;qBAAE;YAAI;QAAE;aACrD;YACL,IAAI,IAAI,MAAM,KAAK,KAAK,GAAG,CAAC,EAAE,KAAK,aAAa,CAAC,EAAE,EACjD,MAAM,EAAE;YAGV,SAAS;gBAAE,MAAM;gBAAe,SAAS;yBAAE;gBAAI;YAAE;QACnD;IACF,GACA;QAAC;QAAe;KAAS;IAG3B,OAAO,wBACL,8BACA;QAAE,eAAe;IAAY,GAC7B,wBAAE,CAAA,GAAA,WAAG,GAAG;QACN,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,UAAU;QACV,UAAU;QACV,YAAW,CAAC;YACV,OAAO,EAAE,EAAE,CAAC,QAAQ;QACtB;IACF;AAEJ","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 Divider,\n} from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n ErrorBoundary,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\n\nimport { Matches } from \"./matches\";\nimport { TypeList } from \"./typelist\";\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 view = false,\n autoSelect = [],\n}) {\n const [viewOnly, setViewOnly] = useState(view);\n const [match, setMatchLinks] = useState(matchLinks);\n const matchMode = match !== undefined;\n\n // Get the input arguments\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes,\n viewOnly,\n matchMode,\n autoSelect,\n );\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.if(!view)(SegmentedControl, {\n options: [\n { label: \"View\", value: \"view\" },\n { label: \"Edit\", value: \"edit\" },\n ],\n value: viewOnly ? \"view\" : \"edit\",\n small: true,\n onValueChange() {\n setViewOnly(!viewOnly);\n dispatch({ type: \"toggle-view-only\" });\n },\n role: \"toolbar\",\n }),\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 viewOnly,\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 viewOnly,\n }),\n h.if(state.viewMode == \"graph\")(GraphView, {\n tree,\n width,\n height,\n dispatch,\n selectedNodes,\n viewOnly,\n }),\n ],\n ),\n ]),\n ),\n h(Card, { className: \"control-panel\" }, [\n h(\"div.control-content\", [\n h.if(!viewOnly)(\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.if(!viewOnly)(Matches, {\n match,\n setMatchLinks,\n matchLinks,\n selectedNodes,\n tree,\n dispatch,\n }),\n h.if(!viewOnly)(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 viewOnly,\n matchMode,\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 viewOnly,\n matchMode,\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 viewOnly: viewOnly || matchMode,\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 {\n selectedNodes,\n dispatch,\n tree,\n height,\n width,\n matchComponent,\n viewOnly,\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, viewOnly }),\n [matchComponent, viewOnly],\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"],"names":[],"version":3,"file":"feedback-components.edc606bb.js.map"}
|
|
@@ -8,14 +8,18 @@ var $b79bf29960412ca7$export$53ec42062883b2d4 = /*#__PURE__*/ function(ViewMode)
|
|
|
8
8
|
ViewMode["Graph"] = "graph";
|
|
9
9
|
return ViewMode;
|
|
10
10
|
}({});
|
|
11
|
-
function $b79bf29960412ca7$export$911bb4b9c8065d3d(initialTree, entityTypes, viewOnly, matchMode) {
|
|
11
|
+
function $b79bf29960412ca7$export$911bb4b9c8065d3d(initialTree, entityTypes, viewOnly, matchMode, autoSelect = []) {
|
|
12
12
|
// Get the first entity type
|
|
13
13
|
// issue: grabs second entity instead of selected one
|
|
14
14
|
const type = entityTypes.values().next().value;
|
|
15
|
+
let selectedNodes = [];
|
|
16
|
+
autoSelect = autoSelect.map((name)=>name.toLowerCase());
|
|
17
|
+
if (autoSelect.length > 0) // If autoSelect is provided, find the nodes with the matching names
|
|
18
|
+
selectedNodes = initialTree.flatMap((node)=>node.children ?? []).filter((node)=>autoSelect.includes(node.name.toLowerCase())).map((node)=>node.id);
|
|
15
19
|
return (0, $abOVY$useReducer)($b79bf29960412ca7$var$treeReducer, {
|
|
16
20
|
initialTree: initialTree,
|
|
17
21
|
tree: initialTree,
|
|
18
|
-
selectedNodes:
|
|
22
|
+
selectedNodes: selectedNodes,
|
|
19
23
|
entityTypesMap: entityTypes,
|
|
20
24
|
selectedEntityType: type,
|
|
21
25
|
lastInternalId: 0,
|
|
@@ -38,7 +42,8 @@ function $b79bf29960412ca7$var$treeReducer(state, action) {
|
|
|
38
42
|
};
|
|
39
43
|
if (action.type === "toggle-view-only") return {
|
|
40
44
|
...state,
|
|
41
|
-
viewOnly: !state.viewOnly
|
|
45
|
+
viewOnly: !state.viewOnly,
|
|
46
|
+
selectedNodes: []
|
|
42
47
|
};
|
|
43
48
|
if (state.viewOnly) return $b79bf29960412ca7$var$viewMode(state, action);
|
|
44
49
|
if (state.matchMode) return $b79bf29960412ca7$var$matchMode(state, action);
|
|
@@ -445,4 +450,4 @@ function $b79bf29960412ca7$var$viewMode(state, action) {
|
|
|
445
450
|
|
|
446
451
|
|
|
447
452
|
export {$b79bf29960412ca7$export$53ec42062883b2d4 as ViewMode, $b79bf29960412ca7$export$911bb4b9c8065d3d as useUpdatableTree, $b79bf29960412ca7$export$e5ce04c5b3f58533 as TreeDispatchContext, $b79bf29960412ca7$export$e1068f2d1c68f87e as useTreeDispatch, $b79bf29960412ca7$export$e64eb58334357825 as findNodeById, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e as treeToGraph};
|
|
448
|
-
//# sourceMappingURL=feedback-components.
|
|
453
|
+
//# sourceMappingURL=feedback-components.fa847634.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;AAKO,IAAA,AAAK,mEAAA;;;WAAA;;AAuDL,SAAS,0CACd,WAAuB,EACvB,WAAoC,EACpC,QAAiB,EACjB,SAAkB,EAClB,aAAuB,EAAE;IAEzB,4BAA4B;IAC5B,qDAAqD;IACrD,MAAM,OAAO,YAAY,MAAM,GAAG,IAAI,GAAG,KAAK;IAE9C,IAAI,gBAAgB,EAAE;IACtB,aAAa,WAAW,GAAG,CAAC,CAAC,OAAS,KAAK,WAAW;IAEtD,IAAI,WAAW,MAAM,GAAG,GACtB,oEAAoE;IACpE,gBAAgB,YACb,OAAO,CAAC,CAAC,OAAS,KAAK,QAAQ,IAAI,EAAE,EACrC,MAAM,CAAC,CAAC,OAAS,WAAW,QAAQ,CAAC,KAAK,IAAI,CAAC,WAAW,KAC1D,GAAG,CAAC,CAAC,OAAS,KAAK,EAAE;IAG1B,OAAO,CAAA,GAAA,iBAAS,EAAE,mCAAa;qBAC7B;QACA,MAAM;uBACN;QACA,gBAAgB;QAChB,oBAAoB;QACpB,gBAAgB;QAChB,uBAAuB;QACvB,QAAQ;kBACR;mBACA;IACF;AACF;AAEO,MAAM,4CAAsB,CAAA,GAAA,oBAAY,EAAuB;AAE/D,SAAS;IACd,MAAM,WAAW,CAAA,GAAA,iBAAS,EAAE;IAC5B,IAAI,YAAY,MACd,MAAM,IAAI,MAAM;I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AI,OAAO,IAAI,KAAK,iBAClB,OAAO;QAAE,GAAG,KAAK;QAAE,UAAU,OAAO,OAAO;IAAC;IAG9C,OAAO;AACT","sources":["packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["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 viewOnly: boolean;\n matchMode: boolean;\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 | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } }\n | { type: \"add-match\"; payload: { id: number; payload: any } }\n | { type: \"remove-match\"; payload: { id: number } }\n | { type: \"toggle-match-mode\" }\n | { type: \"toggle-view-only\" };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n viewOnly: boolean,\n matchMode: boolean,\n autoSelect: string[] = [],\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n let selectedNodes = [];\n autoSelect = autoSelect.map((name) => name.toLowerCase());\n\n if (autoSelect.length > 0) {\n // If autoSelect is provided, find the nodes with the matching names\n selectedNodes = initialTree\n .flatMap((node) => node.children ?? [])\n .filter((node) => autoSelect.includes(node.name.toLowerCase()))\n .map((node) => node.id);\n }\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 viewOnly,\n matchMode,\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 if (action.type === \"toggle-match-mode\") {\n return { ...state, matchMode: !state.matchMode };\n }\n\n if (action.type === \"toggle-view-only\") {\n return { ...state, viewOnly: !state.viewOnly, selectedNodes: [] };\n }\n\n if (state.viewOnly) return viewMode(state, action);\n\n if (state.matchMode) return matchMode(state, action);\n\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\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\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\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\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\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 case \"delete-entity-type\": {\n // Remove the entity type from the map\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\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 color: string | null;\n children: any[] | 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, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\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\nexport function findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n\nfunction matchMode(state, action) {\n if (action.type === \"select-node\" || action.type === \"toggle-node-selected\") {\n const { ids } = action.payload;\n\n if (ids.length != 1) return state;\n\n if (state.selectedNodes.length === 1) {\n if (ids[0] === state.selectedNodes[0]) {\n // If the selected node is the same as the current selection, deselect it\n return { ...state, selectedNodes: [] };\n }\n }\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n }\n\n if (action.type === \"add-match\") {\n const { id } = action.payload;\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to set the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: action.payload.payload },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n if (action.type === \"remove-match\") {\n const { id } = action.payload;\n\n console.log(\"Removing match for node with id:\", id);\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to unset the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: null },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n return state;\n}\n\nfunction viewMode(state, action) {\n if (action.type === \"set-view-mode\") {\n return { ...state, viewMode: action.payload };\n }\n\n return state;\n}\n"],"names":[],"version":3,"file":"feedback-components.fa847634.js.map"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export interface GraphData {
|
|
|
80
80
|
}[];
|
|
81
81
|
}
|
|
82
82
|
export function treeToGraph(tree: TreeData[]): GraphData;
|
|
83
|
-
export function FeedbackComponent({ entities, text, model, entityTypes, matchComponent, onSave, allowOverlap, matchLinks, view, }: {
|
|
83
|
+
export function FeedbackComponent({ entities, text, model, entityTypes, matchComponent, onSave, allowOverlap, matchLinks, view, autoSelect, }: {
|
|
84
84
|
entities?: any[];
|
|
85
85
|
text: any;
|
|
86
86
|
model: any;
|
|
@@ -90,6 +90,7 @@ export function FeedbackComponent({ entities, text, model, entityTypes, matchCom
|
|
|
90
90
|
allowOverlap: any;
|
|
91
91
|
matchLinks: any;
|
|
92
92
|
view?: boolean;
|
|
93
|
+
autoSelect?: any[];
|
|
93
94
|
}): DOMEl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GAAG,IAAI,CAAC;CACxB;AAED;IACE,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAED,4BAA4B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CA4CvD;A2GnZD,kCAAkC,EAChC,QAAa,EACb,IAAI,EACJ,KAAK,EACL,WAAW,EACX,cAAc,EACd,MAAM,EACN,YAAY,EACZ,UAAU,EACV,IAAY,GACb;;;;;;;;;;CAAA,+CAuKA","sources":["packages/feedback-components/src/src/extractions/types.ts","packages/feedback-components/color-utils/src/index.ts","packages/feedback-components/ui-components/src/api/types.ts","packages/feedback-components/ui-components/src/util/query-string.ts","packages/feedback-components/ui-components/src/util/state-hooks.ts","packages/feedback-components/ui-components/src/util/layout-hooks.ts","packages/feedback-components/ui-components/src/util/local-storage.ts","packages/feedback-components/ui-components/src/util/json-view.ts","packages/feedback-components/ui-components/src/util/scroll-helpers.ts","packages/feedback-components/ui-components/src/util/migration-helpers.ts","packages/feedback-components/ui-components/src/util/box-model.ts","packages/feedback-components/ui-components/src/util/event-hooks.ts","packages/feedback-components/ui-components/src/util/flexbox.ts","packages/feedback-components/ui-components/src/util/size-aware-label.ts","packages/feedback-components/ui-components/src/util/index.ts","packages/feedback-components/ui-components/src/api/provider.ts","packages/feedback-components/ui-components/src/api/data-provider.ts","packages/feedback-components/ui-components/src/api/indexing.ts","packages/feedback-components/ui-components/src/api/frontend.ts","packages/feedback-components/ui-components/src/api/paged.ts","packages/feedback-components/ui-components/src/api/index.ts","packages/feedback-components/ui-components/src/infinite-scroll.ts","packages/feedback-components/ui-components/src/postgrest-infinite-scroll.ts","packages/feedback-components/ui-components/src/buttons/delete-button.ts","packages/feedback-components/ui-components/src/buttons/index.ts","packages/feedback-components/ui-components/src/collapse-panel/index.ts","packages/feedback-components/ui-components/src/link-card.ts","packages/feedback-components/ui-components/src/file-upload/index.ts","packages/feedback-components/ui-components/src/image.ts","packages/feedback-components/ui-components/src/model-editor.ts","packages/feedback-components/ui-components/src/toaster.ts","packages/feedback-components/ui-components/src/citations/author-list.ts","packages/feedback-components/ui-components/src/citations/index.ts","packages/feedback-components/ui-components/src/geodeepdive/reference-card.ts","packages/feedback-components/ui-components/src/geodeepdive/index.ts","packages/feedback-components/ui-components/src/text.ts","packages/feedback-components/ui-components/src/dark-mode.ts","packages/feedback-components/ui-components/src/form-controls/slider.ts","packages/feedback-components/ui-components/src/form-controls/index.ts","packages/feedback-components/ui-components/src/settings/index.ts","packages/feedback-components/ui-components/src/error-boundary.ts","packages/feedback-components/ui-components/src/patterns/composite-image.ts","packages/feedback-components/ui-components/src/patterns/index.ts","packages/feedback-components/ui-components/src/collapse-card.ts","packages/feedback-components/ui-components/src/modal-panel/draggable-overlay.ts","packages/feedback-components/ui-components/src/modal-panel/index.ts","packages/feedback-components/ui-components/src/page-layouts/index.ts","packages/feedback-components/ui-components/src/dev-panel/_inner.ts","packages/feedback-components/ui-components/src/dev-panel/index.ts","packages/feedback-components/ui-components/src/data/index.ts","packages/feedback-components/ui-components/src/index.ts","packages/feedback-components/src/src/extractions/index.ts","packages/feedback-components/src/src/feedback/types.ts","packages/feedback-components/src/src/feedback/edit-state.ts","packages/feedback-components/src/src/feedback/node.ts","packages/feedback-components/data-components/src/components/hierarchy/index.ts","packages/feedback-components/data-components/src/components/prevalent-taxa/prevalent-taxa.ts","packages/feedback-components/data-components/src/components/prevalent-taxa/index.ts","packages/feedback-components/data-components/src/components/unit-details/tag.ts","packages/feedback-components/stratigraphy-utils/src/age-ranges.ts","packages/feedback-components/stratigraphy-utils/src/measurements.ts","packages/feedback-components/stratigraphy-utils/src/index.ts","packages/feedback-components/data-components/src/components/unit-details/base.ts","packages/feedback-components/data-components/src/components/unit-details/lithology-tag.ts","packages/feedback-components/data-components/src/components/unit-details/index.ts","packages/feedback-components/data-components/src/components/index.ts","packages/feedback-components/data-components/src/dz-spectrum/gradients.ts","packages/feedback-components/data-components/src/dz-spectrum/kernel-density.ts","packages/feedback-components/data-components/src/dz-spectrum/index.ts","packages/feedback-components/mapbox-utils/src/position.ts","packages/feedback-components/mapbox-utils/src/focus-state.ts","packages/feedback-components/mapbox-utils/src/labels.ts","packages/feedback-components/mapbox-utils/src/preprocess-styles.ts","packages/feedback-components/mapbox-utils/src/utils.ts","packages/feedback-components/mapbox-utils/src/view-info.ts","packages/feedback-components/mapbox-utils/src/style-helpers.ts","packages/feedback-components/mapbox-utils/src/index.ts","packages/feedback-components/data-components/src/field-locations/base.ts","packages/feedback-components/data-components/src/field-locations/checkins.ts","packages/feedback-components/data-components/src/field-locations/spots.ts","packages/feedback-components/mapbox-react/src/context.ts","packages/feedback-components/mapbox-react/src/hooks.ts","packages/feedback-components/mapbox-react/src/controls.ts","packages/feedback-components/mapbox-react/src/terrain.ts","packages/feedback-components/mapbox-react/src/debugger.ts","packages/feedback-components/mapbox-react/src/focus-state.ts","packages/feedback-components/map-styles/src/layer-helpers/symbol-layers.ts","packages/feedback-components/map-styles/src/layer-helpers/geology-layers.ts","packages/feedback-components/map-styles/src/layer-helpers/pattern-fill.ts","packages/feedback-components/map-styles/src/layer-helpers/utils.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/symbols/index.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/icon-image.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/symbol-layer.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/index.ts","packages/feedback-components/map-styles/src/layer-helpers/cross-sections.ts","packages/feedback-components/map-styles/src/layer-helpers/index.ts","packages/feedback-components/map-styles/src/styles/line-symbols.ts","packages/feedback-components/map-styles/src/styles/layers.ts","packages/feedback-components/map-styles/src/styles/index.ts","packages/feedback-components/map-styles/src/index.ts","packages/feedback-components/mapbox-react/src/layer-managers/line-symbols.ts","packages/feedback-components/mapbox-react/src/layer-managers/map-sources.ts","packages/feedback-components/mapbox-react/src/layer-managers/index.ts","packages/feedback-components/mapbox-react/src/index.ts","packages/feedback-components/map-interface/src/context-panel/index.ts","packages/feedback-components/map-interface/src/location-info/utils.ts","packages/feedback-components/map-interface/src/location-info/hash-string.ts","packages/feedback-components/map-interface/src/location-info/index.ts","packages/feedback-components/map-interface/src/location-panel/header.ts","packages/feedback-components/map-interface/src/controls.ts","packages/feedback-components/map-interface/src/container.ts","packages/feedback-components/map-interface/src/location-panel/index.ts","packages/feedback-components/map-interface/src/dev/xray.ts","packages/feedback-components/map-interface/src/utils.ts","packages/feedback-components/map-interface/src/helpers.ts","packages/feedback-components/map-interface/src/map-view.ts","packages/feedback-components/map-interface/src/dev/tile-extent.ts","packages/feedback-components/map-interface/src/expansion-panel/headers.ts","packages/feedback-components/map-interface/src/expansion-panel/index.ts","packages/feedback-components/map-interface/src/dev/vector-tile-features.ts","packages/feedback-components/map-interface/src/dev/map-page.ts","packages/feedback-components/map-interface/src/dev/index.ts","packages/feedback-components/map-interface/src/map-panel/utils/fossils.ts","packages/feedback-components/map-interface/src/map-panel/utils/formatting.ts","packages/feedback-components/map-interface/src/map-panel/utils/index.ts","packages/feedback-components/map-interface/src/map-panel/components/info-blocks.ts","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/macrostrat-linked.ts","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/physiography.ts","packages/feedback-components/map-interface/src/map-panel/components/transitions/index.ts","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/reg-strat.ts","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/xdd-panel/Article.tsx","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/xdd-panel/Journal.tsx","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/xdd-panel/index.ts","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/fossil-collections/collections.tsx","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/fossil-collections/index.ts","packages/feedback-components/map-interface/src/map-panel/components/info-drawer/index.ts","packages/feedback-components/map-interface/src/map-panel/index.ts","packages/feedback-components/map-interface/src/index.ts","packages/feedback-components/data-components/src/field-locations/rockd-checkins/index.ts","packages/feedback-components/data-components/src/field-locations/index.ts","packages/feedback-components/data-components/src/index.ts","packages/feedback-components/src/src/feedback/matches.ts","packages/feedback-components/src/stories/test-data.ts","packages/feedback-components/src/src/feedback/text-visualizer.ts","packages/feedback-components/src/src/feedback/type-selector/index.ts","packages/feedback-components/src/src/feedback/graph.ts","packages/feedback-components/data-sheet/src/components/editor-popup.ts","packages/.storybook/main.ts","packages/feedback-components/data-sheet/src/components/colors.ts","packages/feedback-components/data-sheet/src/components/text-areas.ts","packages/feedback-components/data-sheet/src/components/actions.ts","packages/feedback-components/data-sheet/src/components/index.ts","packages/feedback-components/data-sheet/src/utils/column-spec.ts","packages/feedback-components/data-sheet/src/utils/index.ts","packages/feedback-components/data-sheet/src/provider.ts","packages/feedback-components/data-sheet/src/core.ts","packages/feedback-components/data-sheet/src/postgrest-table/data-loaders.ts","packages/feedback-components/data-sheet/src/postgrest-table/index.ts","packages/feedback-components/data-sheet/src/index.ts","packages/feedback-components/src/src/feedback/typelist.ts","packages/feedback-components/src/src/feedback/index.ts","packages/feedback-components/src/src/index.ts","packages/feedback-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"export * from \"./extractions\";\nexport * from \"./feedback\";\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
|
1
|
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MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAED,4BAA4B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CA4CvD;AyG/ZD,kCAAkC,EAChC,QAAa,EACb,IAAI,EACJ,KAAK,EACL,WAAW,EACX,cAAc,EACd,MAAM,EACN,YAAY,EACZ,UAAU,EACV,IAAY,EACZ,UAAe,GAChB;;;;;;;;;;;CAAA,+CAwKA","sources":["packages/feedback-components/src/src/extractions/types.ts","packages/feedback-components/color-utils/src/index.ts","packages/feedback-components/ui-components/src/api/types.ts","packages/feedback-components/ui-components/src/util/query-string.ts","packages/feedback-components/ui-components/src/util/state-hooks.ts","packages/feedback-components/ui-components/src/util/layout-hooks.ts","packages/feedback-components/ui-components/src/util/local-storage.ts","packages/feedback-components/ui-components/src/util/json-view.ts","packages/feedback-components/ui-components/src/util/scroll-helpers.ts","packages/feedback-components/ui-components/src/util/migration-helpers.ts","packages/feedback-components/ui-components/src/util/box-model.ts","packages/feedback-components/ui-components/src/util/event-hooks.ts","packages/feedback-components/ui-components/src/util/flexbox.ts","packages/feedback-components/ui-components/src/util/size-aware-label.ts","packages/feedback-components/ui-components/src/util/index.ts","packages/feedback-components/ui-components/src/api/provider.ts","packages/feedback-components/ui-components/src/api/data-provider.ts","packages/feedback-components/ui-components/src/api/indexing.ts","packages/feedback-components/ui-components/src/api/frontend.ts","packages/feedback-components/ui-components/src/api/paged.ts","packages/feedback-components/ui-components/src/api/index.ts","packages/feedback-components/ui-components/src/infinite-scroll.ts","packages/feedback-components/ui-components/src/postgrest-infinite-scroll.ts","packages/feedback-components/ui-components/src/buttons/delete-button.ts","packages/feedback-components/ui-components/src/buttons/index.ts","packages/feedback-components/ui-components/src/collapse-panel/index.ts","packages/feedback-components/ui-components/src/link-card.ts","packages/feedback-components/ui-components/src/file-upload/index.ts","packages/feedback-components/ui-components/src/image.ts","packages/feedback-components/ui-components/src/model-editor.ts","packages/feedback-components/ui-components/src/toaster.ts","packages/feedback-components/ui-components/src/citations/author-list.ts","packages/feedback-components/ui-components/src/citations/index.ts","packages/feedback-components/ui-components/src/geodeepdive/reference-card.ts","packages/feedback-components/ui-components/src/geodeepdive/index.ts","packages/feedback-components/ui-components/src/text.ts","packages/feedback-components/ui-components/src/dark-mode.ts","packages/feedback-components/ui-components/src/form-controls/slider.ts","packages/feedback-components/ui-components/src/form-controls/index.ts","packages/feedback-components/ui-components/src/settings/index.ts","packages/feedback-components/ui-components/src/error-boundary.ts","packages/feedback-components/ui-components/src/patterns/composite-image.ts","packages/feedback-components/ui-components/src/patterns/index.ts","packages/feedback-components/ui-components/src/collapse-card.ts","packages/feedback-components/ui-components/src/modal-panel/draggable-overlay.ts","packages/feedback-components/ui-components/src/modal-panel/index.ts","packages/feedback-components/ui-components/src/page-layouts/index.ts","packages/feedback-components/ui-components/src/dev-panel/_inner.ts","packages/feedback-components/ui-components/src/dev-panel/index.ts","packages/feedback-components/ui-components/src/data/index.ts","packages/feedback-components/ui-components/src/index.ts","packages/feedback-components/src/src/extractions/index.ts","packages/feedback-components/src/src/feedback/types.ts","packages/feedback-components/src/src/feedback/edit-state.ts","packages/feedback-components/src/src/feedback/node.ts","packages/feedback-components/data-components/src/components/hierarchy/index.ts","packages/feedback-components/data-components/src/components/prevalent-taxa/prevalent-taxa.ts","packages/feedback-components/data-components/src/components/prevalent-taxa/index.ts","packages/feedback-components/data-components/src/components/unit-details/tag.ts","packages/feedback-components/stratigraphy-utils/src/age-ranges.ts","packages/feedback-components/stratigraphy-utils/src/measurements.ts","packages/feedback-components/stratigraphy-utils/src/index.ts","packages/feedback-components/data-components/src/components/unit-details/base.ts","packages/feedback-components/data-components/src/components/unit-details/lithology-tag.ts","packages/feedback-components/data-components/src/components/unit-details/index.ts","packages/feedback-components/data-components/src/components/index.ts","packages/feedback-components/data-components/src/dz-spectrum/gradients.ts","packages/feedback-components/data-components/src/dz-spectrum/kernel-density.ts","packages/feedback-components/data-components/src/dz-spectrum/index.ts","packages/feedback-components/mapbox-utils/src/position.ts","packages/feedback-components/mapbox-utils/src/focus-state.ts","packages/feedback-components/mapbox-utils/src/labels.ts","packages/feedback-components/mapbox-utils/src/preprocess-styles.ts","packages/feedback-components/mapbox-utils/src/utils.ts","packages/feedback-components/mapbox-utils/src/view-info.ts","packages/feedback-components/mapbox-utils/src/style-helpers.ts","packages/feedback-components/mapbox-utils/src/index.ts","packages/feedback-components/data-components/src/field-locations/base.ts","packages/feedback-components/data-components/src/field-locations/checkins.ts","packages/feedback-components/data-components/src/field-locations/spots.ts","packages/feedback-components/mapbox-react/src/context.ts","packages/feedback-components/mapbox-react/src/hooks.ts","packages/feedback-components/mapbox-react/src/controls.ts","packages/feedback-components/mapbox-react/src/terrain.ts","packages/feedback-components/mapbox-react/src/debugger.ts","packages/feedback-components/mapbox-react/src/focus-state.ts","packages/feedback-components/map-styles/src/layer-helpers/symbol-layers.ts","packages/feedback-components/map-styles/src/layer-helpers/geology-layers.ts","packages/feedback-components/map-styles/src/layer-helpers/pattern-fill.ts","packages/feedback-components/map-styles/src/layer-helpers/utils.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/symbols/index.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/icon-image.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/symbol-layer.ts","packages/feedback-components/map-styles/src/layer-helpers/point-features/index.ts","packages/feedback-components/map-styles/src/layer-helpers/cross-sections.ts","packages/feedback-components/map-styles/src/layer-helpers/index.ts","packages/feedback-components/map-styles/src/styles/line-symbols.ts","packages/feedback-components/map-styles/src/styles/layers.ts","packages/feedback-components/map-styles/src/styles/index.ts","packages/feedback-components/map-styles/src/index.ts","packages/feedback-components/mapbox-react/src/layer-managers/line-symbols.ts","packages/feedback-components/mapbox-react/src/layer-managers/map-sources.ts","packages/feedback-components/mapbox-react/src/layer-managers/index.ts","packages/feedback-components/mapbox-react/src/index.ts","packages/feedback-components/map-interface/src/context-panel/index.ts","packages/feedback-components/map-interface/src/location-info/utils.ts","packages/feedback-components/map-interface/src/location-info/hash-string.ts","packages/feedback-components/map-interface/src/location-info/index.ts","packages/feedback-components/map-interface/src/location-panel/header.ts","packages/feedback-components/map-interface/src/controls.ts","packages/feedback-components/map-interface/src/container.ts","packages/feedback-components/map-interface/src/location-panel/index.ts","packages/feedback-components/map-interface/src/dev/xray.ts","packages/feedback-components/map-interface/src/utils.ts","packages/feedback-components/map-interface/src/helpers.ts","packages/feedback-components/map-interface/src/map-view.ts","packages/feedback-components/map-interface/src/dev/tile-extent.ts","packages/feedback-components/map-interface/src/expansion-panel/headers.ts","packages/feedback-components/map-interface/src/expansion-panel/index.ts","packages/feedback-components/map-interface/src/dev/vector-tile-features.ts","packages/feedback-components/map-interface/src/dev/map-page.ts","packages/feedback-components/map-interface/src/dev/index.ts","packages/feedback-components/map-interface/src/location-details/utils/fossils.ts","packages/feedback-components/map-interface/src/location-details/utils/formatting.ts","packages/feedback-components/map-interface/src/location-details/utils/index.ts","packages/feedback-components/map-interface/src/location-details/fossil-collections/collections.tsx","packages/feedback-components/map-interface/src/location-details/fossil-collections/index.ts","packages/feedback-components/map-interface/src/location-details/xdd-panel/Article.tsx","packages/feedback-components/map-interface/src/location-details/xdd-panel/Journal.tsx","packages/feedback-components/map-interface/src/location-details/xdd-panel/index.ts","packages/feedback-components/map-interface/src/location-details/reg-strat.ts","packages/feedback-components/map-interface/src/location-details/physiography.ts","packages/feedback-components/map-interface/src/location-details/info-blocks.ts","packages/feedback-components/map-interface/src/location-details/macrostrat-linked.ts","packages/feedback-components/map-interface/src/location-details/index.ts","packages/feedback-components/map-interface/src/index.ts","packages/feedback-components/data-components/src/field-locations/rockd-checkins/index.ts","packages/feedback-components/data-components/src/field-locations/index.ts","packages/feedback-components/data-components/src/index.ts","packages/feedback-components/src/src/feedback/matches.ts","packages/feedback-components/src/stories/test-data.ts","packages/feedback-components/src/src/feedback/text-visualizer.ts","packages/feedback-components/src/src/feedback/type-selector/index.ts","packages/feedback-components/src/src/feedback/graph.ts","packages/feedback-components/data-sheet/src/components/editor-popup.ts","packages/.storybook/main.ts","packages/feedback-components/data-sheet/src/components/colors.ts","packages/feedback-components/data-sheet/src/components/text-areas.ts","packages/feedback-components/data-sheet/src/components/actions.ts","packages/feedback-components/data-sheet/src/components/index.ts","packages/feedback-components/data-sheet/src/utils/column-spec.ts","packages/feedback-components/data-sheet/src/utils/index.ts","packages/feedback-components/data-sheet/src/provider.ts","packages/feedback-components/data-sheet/src/core.ts","packages/feedback-components/data-sheet/src/postgrest-table/data-loaders.ts","packages/feedback-components/data-sheet/src/postgrest-table/index.ts","packages/feedback-components/data-sheet/src/index.ts","packages/feedback-components/src/src/feedback/typelist.ts","packages/feedback-components/src/src/feedback/index.ts","packages/feedback-components/src/src/index.ts","packages/feedback-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"export * from \"./extractions\";\nexport * from \"./feedback\";\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200, enhanceData as $03d8811e9c9b360d$export$d60b563f571177d, getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, ExtractionContext as $03d8811e9c9b360d$export$2b07158757c249e0, ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967, EntityTag as $03d8811e9c9b360d$export$117e56c71b172cde} from "./feedback-components.
|
|
2
|
-
import {FeedbackComponent as $71d20dff35996763$export$a90600c9da52b40c, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./feedback-components.
|
|
1
|
+
import {buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200, enhanceData as $03d8811e9c9b360d$export$d60b563f571177d, getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, ExtractionContext as $03d8811e9c9b360d$export$2b07158757c249e0, ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967, EntityTag as $03d8811e9c9b360d$export$117e56c71b172cde} from "./feedback-components.ba79c0ef.js";
|
|
2
|
+
import {FeedbackComponent as $71d20dff35996763$export$a90600c9da52b40c, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./feedback-components.edc606bb.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./feedback-components.
|
|
2
|
-
//# sourceMappingURL=feedback-components.
|
|
1
|
+
import"./feedback-components.dc76072c.js";import"./feedback-components.c84ff10e.js";import"./feedback-components.db72d0e1.js";import e from"@macrostrat/hyper";import{forceSimulation as r,forceLink as t,forceManyBody as o,forceCenter as a,forceCollide as i}from"d3-force";import{useState as l,useEffect as s}from"react";import{Spinner as c,Switch as n}from"@blueprintjs/core";import{ErrorBoundary as d}from"@macrostrat/ui-components";var p=globalThis,h={},g={},f=p.parcelRequirea149;null==f&&((f=function(e){if(e in h)return h[e].exports;if(e in g){var r=g[e];delete g[e];var t={id:e,exports:{}};return h[e]=t,r.call(t.exports,t,t.exports),t.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,r){g[e]=r},p.parcelRequirea149=f),f.register;var u=f("eedTh"),m=f("9wFEx"),y=f("edvRb");let b=e.styled(m&&m.__esModule?m.default:m);function k(e){let{tree:p,width:h,height:g,dispatch:f,selectedNodes:m,viewOnly:k}=e,[x,w]=l(null),[v,S]=l(null),[_,E]=l(!1);return(s(()=>{let{nodes:e,edges:l}=(0,u.treeToGraph)(p),s=new Map(e.map(e=>[e.id,e])),c=l.map(e=>({source:s.get(e.source),target:s.get(e.dest),strength:1})),n=r(e).force("link",t(c)).force("charge",o().strength(-50)).force("center",a(h/2,g/2)).force("collide",i().radius(20)).on("tick",()=>{console.log("Simulation tick")}).on("end",()=>{w(e),S(c)});return()=>{n.stop()}},[p,h,g]),null==x||null==v)?b(c):(console.log("Graph",x,v,m),b(d,{description:"An error occurred while rendering the graph view."},b("div.graph-view",{style:{width:h,height:g}},[b(n,{className:"show-labels-switch",label:"Show Labels",checked:_,onChange:e=>E(e.target.checked)}),b("svg",{width:h,height:g},[b("g.links",v.map(e=>b("line",{x1:e.source.x,y1:e.source.y,x2:e.target.x,y2:e.target.y,stroke:"black"}))),b("g.nodes",x.map(e=>{var r,t,o;let a=m.includes(e.id),i=(r=e.id,t=m,o=x,0===t.length||t.includes(r)||o.some(e=>t.includes(e.id)&&e.children.some(e=>e.id===r))),l=(0,y.getTagStyle)(e.color,{highlighted:i,active:a});return b("g",[b("circle",{cx:e.x,cy:e.y,r:8,fill:l.backgroundColor||"blue",onClick:r=>{r.stopPropagation(),r.ctrlKey||r.metaKey||m[0]===e.id&&1===m.length?(r.stopPropagation(),f({type:"toggle-node-selected",payload:{ids:[e.id]}})):f({type:"select-node",payload:{ids:[e.id]}})},className:a?"selected":k?"":" clickable",stroke:a?"white":"black",strokeWidth:2}),b.if(_)("text",{x:e.x+10,y:e.y+4,className:"node-label"},e.name||`Node ${e.id}`),b.if(!_)("title",e.name||`Node ${e.id}`)])}))])])))}export{k as GraphView};
|
|
2
|
+
//# sourceMappingURL=feedback-components.1bd49bf0.js.map
|
package/dist/node/{feedback-components.79d7b18c.js.map → feedback-components.1bd49bf0.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,mB,C,C,a,C,C,iB,C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AAM,EAAE,GAAK,KA3DjC,EAAQ,AAAA,CAAA,EAAA,EAAA,WAAU,AAAV,EAAY,EAAE,KAAK,CAAE,CAAE,YAAA,EAAa,OAAA,CAAO,GAEzD,OAAO,EAAE,IAAK,CACZ,EAAE,SAAU,CACV,GAAI,EAAE,CAAC,CACP,GAAI,EAAE,CAAC,CACP,EAAG,EACH,KAAM,EAAM,eAAe,EAAI,OAC/B,QAAS,AAAC,IACR,EAAE,eAAe,GAEf,EAAE,OAAO,EACT,EAAE,OAAO,EACR,CAAa,CAAC,EAAE,GAAK,EAAE,EAAE,EAAI,AAAyB,IAAzB,EAAc,MAAM,EAGlD,EAAE,eAAe,GACjB,EAAS,CACP,KAAM,uBACN,QAAS,CAAE,IAAK,CAAC,EAAE,EAAE,CAAC,AAAC,CACzB,IAEA,EAAS,CACP,KAAM,cACN,QAAS,CAAE,IAAK,CAAC,EAAE,EAAE,CAAC,AAAC,CACzB,EAEJ,EACA,UAAW,EACP,WACM,EAAW,GAAK,aAC1B,OAjCW,EAAS,QAAU,QAkC9B,YAAa,CACf,GACA,EAAE,EAAE,CAAC,GACH,OACA,CACE,EAAG,EAAE,CAAC,CAAG,GACT,EAAG,EAAE,CAAC,CAAG,EACT,UAAW,YACb,EACA,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EAE1B,EAAE,EAAE,CAAC,CAAC,GAAY,QAAS,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EACpD,CACH,IAEH,EACF,GAEL,Q,K,S","sources":["<anon>","packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import \"./feedback-components.8caef76e.js\";\nimport \"./feedback-components.e1fe112f.js\";\nimport \"./feedback-components.b22d37d1.js\";\nimport $9bqpz$macrostrathyper from \"@macrostrat/hyper\";\nimport {forceSimulation as $9bqpz$forceSimulation, forceLink as $9bqpz$forceLink, forceManyBody as $9bqpz$forceManyBody, forceCenter as $9bqpz$forceCenter, forceCollide as $9bqpz$forceCollide} from \"d3-force\";\nimport {useState as $9bqpz$useState, useEffect as $9bqpz$useEffect} from \"react\";\nimport {Spinner as $9bqpz$Spinner, Switch as $9bqpz$Switch} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $9bqpz$ErrorBoundary} from \"@macrostrat/ui-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\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;\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\n\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\nconst $8732cb0ae0ae3dfd$var$h = (0, $9bqpz$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566(props) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree: tree, width: width, height: height, dispatch: dispatch, selectedNodes: selectedNodes, viewOnly: viewOnly } = props;\n const [nodes, setNodes] = (0, $9bqpz$useState)(null);\n const [links, setLinks] = (0, $9bqpz$useState)(null);\n const [showLabels, setShowLabels] = (0, $9bqpz$useState)(false);\n (0, $9bqpz$useEffect)(()=>{\n const { nodes: nodes, edges: edges } = (0, $eedTh.treeToGraph)(tree);\n const nodesMap = new Map(nodes.map((d)=>[\n d.id,\n d\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 const simulation = (0, $9bqpz$forceSimulation)(nodes).force(\"link\", (0, $9bqpz$forceLink)(links)).force(\"charge\", (0, $9bqpz$forceManyBody)().strength(-50)).force(\"center\", (0, $9bqpz$forceCenter)(width / 2, height / 2)).force(\"collide\", (0, $9bqpz$forceCollide)().radius(20)).on(\"tick\", ()=>{\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n }).on(\"end\", ()=>{\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n return ()=>{\n simulation.stop();\n };\n }, [\n tree,\n width,\n height\n ]);\n if (nodes == null || links == null) return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Spinner));\n console.log(\"Graph\", nodes, links, selectedNodes);\n return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$ErrorBoundary), {\n description: \"An error occurred while rendering the graph view.\"\n }, $8732cb0ae0ae3dfd$var$h(\"div.graph-view\", {\n style: {\n width: width,\n height: height\n }\n }, [\n $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Switch), {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e)=>setShowLabels(e.target.checked)\n }),\n $8732cb0ae0ae3dfd$var$h(\"svg\", {\n width: width,\n height: height\n }, [\n $8732cb0ae0ae3dfd$var$h(\"g.links\", links.map((d)=>{\n return $8732cb0ae0ae3dfd$var$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 $8732cb0ae0ae3dfd$var$h(\"g.nodes\", nodes.map((d)=>{\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = $8732cb0ae0ae3dfd$var$isHighlighted(d.id, selectedNodes, nodes);\n const style = (0, $edvRb.getTagStyle)(d.color, {\n highlighted: highlighted,\n active: active\n });\n return $8732cb0ae0ae3dfd$var$h(\"g\", [\n $8732cb0ae0ae3dfd$var$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 (e.ctrlKey || e.metaKey || selectedNodes[0] === d.id && selectedNodes.length === 1) {\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: {\n ids: [\n d.id\n ]\n }\n });\n } else dispatch({\n type: \"select-node\",\n payload: {\n ids: [\n d.id\n ]\n }\n });\n },\n className: active ? \"selected\" : \"\" + (viewOnly ? \"\" : \" clickable\"),\n stroke: stroke,\n strokeWidth: 2\n }),\n $8732cb0ae0ae3dfd$var$h.if(showLabels)(\"text\", {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\"\n }, d.name || `Node ${d.id}`),\n $8732cb0ae0ae3dfd$var$h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`)\n ]);\n }))\n ])\n ]));\n}\nfunction $8732cb0ae0ae3dfd$var$isHighlighted(id, selectedNodes, nodes) {\n if (selectedNodes.length === 0) return true;\n return selectedNodes.includes(id) || nodes.some((node)=>selectedNodes.includes(node.id) && node.children.some((child)=>child.id === id));\n}\n\n\nexport {$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566 as GraphView};\n//# sourceMappingURL=feedback-components.79d7b18c.js.map\n","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 viewOnly?: boolean;\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height, dispatch, selectedNodes, viewOnly } = 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\n ? \"selected\"\n : \"\" + (viewOnly ? \"\" : \" clickable\"),\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":["$9bqpz$macrostrathyper","forceSimulation","$9bqpz$forceSimulation","forceLink","$9bqpz$forceLink","forceManyBody","$9bqpz$forceManyBody","forceCenter","$9bqpz$forceCenter","forceCollide","$9bqpz$forceCollide","useState","$9bqpz$useState","useEffect","$9bqpz$useEffect","Spinner","$9bqpz$Spinner","Switch","$9bqpz$Switch","ErrorBoundary","$9bqpz$ErrorBoundary","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$eedTh","$9wFEx","$edvRb","$8732cb0ae0ae3dfd$var$h","styled","a","__esModule","default","$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566","props","tree","width","height","dispatch","selectedNodes","viewOnly","nodes","setNodes","links","setLinks","showLabels","setShowLabels","edges","treeToGraph","nodesMap","Map","map","d","source","get","target","dest","strength","simulation","force","radius","on","console","log","stop","description","style","className","label","checked","onChange","e","x1","x","y1","y","x2","y2","stroke","active","includes","highlighted","length","some","node","children","child","getTagStyle","color","cx","cy","r","fill","backgroundColor","onClick","stopPropagation","ctrlKey","metaKey","type","payload","ids","strokeWidth","if","name","GraphView"],"version":3,"file":"feedback-components.79d7b18c.js.map","sourceRoot":"../../../../"}
|
|
1
|
+
{"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,mB,C,C,a,C,C,iB,C,C,e,C,C,gB,C,K,U,A,Q,Y,C,C,a,C,K,O,A,Q,W,C,C,U,C,K,mB,A,Q,iB,C,K,2B,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,E,S,E,E,S,E,E,SCkBA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAU,CAOzB,EAGC,GAAM,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAA,OAAE,CAAM,CAAA,SAAE,CAAQ,CAAA,cAAE,CAAa,CAAA,SAAE,CAAQ,CAAE,CAAG,EAE7D,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAAC,EAAO,EAAS,CAAG,AAAA,EAAgC,MACpD,CAAC,EAAY,EAA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G,EAAE,CAAC,CAAG,EACT,UAAW,YACb,EACA,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EAE1B,EAAE,EAAE,CAAC,CAAC,GAAY,QAAS,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EACpD,CACH,IAEH,EACF,GAEL,Q,K,S","sources":["<anon>","packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import \"./feedback-components.dc76072c.js\";\nimport \"./feedback-components.c84ff10e.js\";\nimport \"./feedback-components.db72d0e1.js\";\nimport $9bqpz$macrostrathyper from \"@macrostrat/hyper\";\nimport {forceSimulation as $9bqpz$forceSimulation, forceLink as $9bqpz$forceLink, forceManyBody as $9bqpz$forceManyBody, forceCenter as $9bqpz$forceCenter, forceCollide as $9bqpz$forceCollide} from \"d3-force\";\nimport {useState as $9bqpz$useState, useEffect as $9bqpz$useEffect} from \"react\";\nimport {Spinner as $9bqpz$Spinner, Switch as $9bqpz$Switch} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $9bqpz$ErrorBoundary} from \"@macrostrat/ui-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\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;\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\n\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\nconst $8732cb0ae0ae3dfd$var$h = (0, $9bqpz$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566(props) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree: tree, width: width, height: height, dispatch: dispatch, selectedNodes: selectedNodes, viewOnly: viewOnly } = props;\n const [nodes, setNodes] = (0, $9bqpz$useState)(null);\n const [links, setLinks] = (0, $9bqpz$useState)(null);\n const [showLabels, setShowLabels] = (0, $9bqpz$useState)(false);\n (0, $9bqpz$useEffect)(()=>{\n const { nodes: nodes, edges: edges } = (0, $eedTh.treeToGraph)(tree);\n const nodesMap = new Map(nodes.map((d)=>[\n d.id,\n d\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 const simulation = (0, $9bqpz$forceSimulation)(nodes).force(\"link\", (0, $9bqpz$forceLink)(links)).force(\"charge\", (0, $9bqpz$forceManyBody)().strength(-50)).force(\"center\", (0, $9bqpz$forceCenter)(width / 2, height / 2)).force(\"collide\", (0, $9bqpz$forceCollide)().radius(20)).on(\"tick\", ()=>{\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n }).on(\"end\", ()=>{\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n return ()=>{\n simulation.stop();\n };\n }, [\n tree,\n width,\n height\n ]);\n if (nodes == null || links == null) return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Spinner));\n console.log(\"Graph\", nodes, links, selectedNodes);\n return $8732cb0ae0ae3dfd$var$h((0, $9bqpz$ErrorBoundary), {\n description: \"An error occurred while rendering the graph view.\"\n }, $8732cb0ae0ae3dfd$var$h(\"div.graph-view\", {\n style: {\n width: width,\n height: height\n }\n }, [\n $8732cb0ae0ae3dfd$var$h((0, $9bqpz$Switch), {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e)=>setShowLabels(e.target.checked)\n }),\n $8732cb0ae0ae3dfd$var$h(\"svg\", {\n width: width,\n height: height\n }, [\n $8732cb0ae0ae3dfd$var$h(\"g.links\", links.map((d)=>{\n return $8732cb0ae0ae3dfd$var$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 $8732cb0ae0ae3dfd$var$h(\"g.nodes\", nodes.map((d)=>{\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = $8732cb0ae0ae3dfd$var$isHighlighted(d.id, selectedNodes, nodes);\n const style = (0, $edvRb.getTagStyle)(d.color, {\n highlighted: highlighted,\n active: active\n });\n return $8732cb0ae0ae3dfd$var$h(\"g\", [\n $8732cb0ae0ae3dfd$var$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 (e.ctrlKey || e.metaKey || selectedNodes[0] === d.id && selectedNodes.length === 1) {\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: {\n ids: [\n d.id\n ]\n }\n });\n } else dispatch({\n type: \"select-node\",\n payload: {\n ids: [\n d.id\n ]\n }\n });\n },\n className: active ? \"selected\" : \"\" + (viewOnly ? \"\" : \" clickable\"),\n stroke: stroke,\n strokeWidth: 2\n }),\n $8732cb0ae0ae3dfd$var$h.if(showLabels)(\"text\", {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\"\n }, d.name || `Node ${d.id}`),\n $8732cb0ae0ae3dfd$var$h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`)\n ]);\n }))\n ])\n ]));\n}\nfunction $8732cb0ae0ae3dfd$var$isHighlighted(id, selectedNodes, nodes) {\n if (selectedNodes.length === 0) return true;\n return selectedNodes.includes(id) || nodes.some((node)=>selectedNodes.includes(node.id) && node.children.some((child)=>child.id === id));\n}\n\n\nexport {$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566 as GraphView};\n//# sourceMappingURL=feedback-components.1bd49bf0.js.map\n","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 viewOnly?: boolean;\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height, dispatch, selectedNodes, viewOnly } = 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\n ? \"selected\"\n : \"\" + (viewOnly ? \"\" : \" clickable\"),\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":["$9bqpz$macrostrathyper","forceSimulation","$9bqpz$forceSimulation","forceLink","$9bqpz$forceLink","forceManyBody","$9bqpz$forceManyBody","forceCenter","$9bqpz$forceCenter","forceCollide","$9bqpz$forceCollide","useState","$9bqpz$useState","useEffect","$9bqpz$useEffect","Spinner","$9bqpz$Spinner","Switch","$9bqpz$Switch","ErrorBoundary","$9bqpz$ErrorBoundary","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$eedTh","$9wFEx","$edvRb","$8732cb0ae0ae3dfd$var$h","styled","a","__esModule","default","$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566","props","tree","width","height","dispatch","selectedNodes","viewOnly","nodes","setNodes","links","setLinks","showLabels","setShowLabels","edges","treeToGraph","nodesMap","Map","map","d","source","get","target","dest","strength","simulation","force","radius","on","console","log","stop","description","style","className","label","checked","onChange","e","x1","x","y1","y","x2","y2","stroke","active","includes","highlighted","length","some","node","children","child","getTagStyle","color","cx","cy","r","fill","backgroundColor","onClick","stopPropagation","ctrlKey","metaKey","type","payload","ids","strokeWidth","if","name","GraphView"],"version":3,"file":"feedback-components.1bd49bf0.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./feedback-components.
|
|
2
|
-
//# sourceMappingURL=feedback-components.
|
|
1
|
+
import"./feedback-components.c84ff10e.js";import"./feedback-components.db72d0e1.js";import e from"@macrostrat/hyper";import{useState as t}from"react";import{Icon as o,Overlay2 as i,Popover as l}from"@blueprintjs/core";import{useInDarkMode as d,SaveButton as a}from"@macrostrat/ui-components";import{ColorPicker as r}from"@macrostrat/data-sheet";var n=globalThis,s={},p={},c=n.parcelRequirea149;null==c&&((c=function(e){if(e in s)return s[e].exports;if(e in p){var t=p[e];delete p[e];var o={id:e,exports:{}};return s[e]=o,t.call(o.exports,o,o.exports),o.exports}var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(e,t){p[e]=t},n.parcelRequirea149=c),c.register;var y=c("9wFEx"),u=c("edvRb");let v=e.styled(y&&y.__esModule?y.default:y);function m({types:e,selected:o,dispatch:i,selectedNodes:l,tree:a,viewOnly:r}){let[n,s]=t(null),p=l.length>0,c=d()?.9:.4;return v("div.type-list-container",[v("div.type-list-header",p&&!n?"Change selected nodes to:":"Entity Types"),v("div.type-list",Array.from(e.values()).map(e=>v(O,{type:e,luminance:c,selectedType:n,setSelectedType:s,dispatch:i,viewOnly:r,tree:a,selectedNodes:l,selected:o,isSelectedNodes:p}))),v.if(!r)(g,{dispatch:i})])}function f(e,t){let o=[];return e.forEach(function e(i){i.type.id===t&&o.push(i.id),Array.isArray(i.children)&&i.children.forEach(e)}),o}function g({dispatch:e}){let[i,l]=t(!1);return v("div.add-type-container",[v("div.add-type",{onClick:()=>l(!0)},[v("p.add-type-text","Add new type"),v(o,{icon:"plus"})]),v(b,{setOverlayOpen:l,overlayOpen:i,title:"Add New Type",saveHandler:t=>{e({type:"add-entity-type",payload:t}),l(!1)}})])}function h({dispatch:e,type:i}){let[l,d]=t(!1);return v("div.edit-type",[v(o,{icon:"edit",className:"edit-icon",onClick:e=>{e.stopPropagation(),d(!0)}}),v(b,{setOverlayOpen:d,overlayOpen:l,originalType:i,title:"Edit Type",saveHandler:t=>{e({type:"update-entity-type",payload:t}),d(!1)}})])}function b({setOverlayOpen:e,overlayOpen:l,originalType:d,title:n,saveHandler:s}){let{name:p,description:c,color:y,id:u}=d||{},[m,f]=t(p||""),[g,h]=t(c||""),[b,O]=t(y||"#fff");return v(i,{isOpen:l},v("div.overlay-container",v("div.add-type-overlay",[v("h2.title",[n,v(o,{icon:"cross",className:"close-icon",onClick:()=>{e(!1)},style:{cursor:"pointer",color:"red"}})]),v("div.form-group",[v("div.text-inputs",[v("div.form-field.name",[v("p.label","Name"),v("input",{type:"text",placeholder:"Enter type name",onChange:e=>f(e.target.value),value:m})]),v("div.form-field.form-description",[v("p.label","Description"),v("input",{type:"text",placeholder:"Enter type description",onChange:e=>h(e.target.value),value:g})])]),v("div.form-field.color",[v("p.label","Color"),v(r,{value:b,onChange:e=>O(e),style:{width:"100%"}})])]),v(a,{className:"save-btn",small:!0,onClick:()=>s({name:m,description:g,color:b,id:u})},"Save changes")])))}function O({type:e,luminance:t,selectedType:i,setSelectedType:a,dispatch:r,tree:n,selectedNodes:s,selected:p,isSelectedNodes:c,viewOnly:y}){let{color:m,name:g,id:b,description:O}=e;d();let x=b===p?.id&&s.length>0,N=(0,u.getTagStyle)(m,{active:x,highlighted:0===s.length}),T={id:b,name:g,color:m,description:O},k=f(n,b);return v(l,{autoFocus:!1,content:v("div.description",O||"No description available"),interactionKind:"hover"},v("div.type-tag",{onClick:()=>{c||null!==i?c&&null===i?b===p?.id&&s.length>0?r({type:"toggle-node-selected",payload:{ids:s}}):r({type:"select-entity-type",payload:T}):c&&i.id===b?(a(null),r({type:"toggle-node-selected",payload:{ids:k}})):c&&i.id!==b?k.length>0&&(a(e),r({type:"toggle-node-selected",payload:{ids:f(n,i.id)}}),r({type:"toggle-node-selected",payload:{ids:k}})):console.warn("Unexpected state in TypeTag click handler",{isSelectedNodes:c,selectedType:i,selectedNodes:s,ids:k,id:b,selected:p}):k.length>0&&(a(e),r({type:"toggle-node-selected",payload:{ids:k}}))},style:{cursor:(k.length>0||c&&!i)&&!y?"pointer":"",color:"black",backgroundColor:N.backgroundColor,border:x?"1px solid var(--text-emphasized-color)":"1px solid var(--background-color)"}},v("div.type-container",[v("div.type-name",g),v.if(!y)("div.icons",[v(h,{dispatch:r,type:e}),v(o,{icon:"cross",className:"delete-type-icon",style:{color:"red",cursor:"pointer"},onClick:e=>{e.stopPropagation(),r({type:"delete-entity-type",payload:{id:b}})}})])])))}export{m as TypeList};
|
|
2
|
+
//# sourceMappingURL=feedback-components.6a4a1290.js.map
|