@macrostrat/feedback-components 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/esm/{feedback-components.586103e8.js → feedback-components.1e7da538.js} +17 -8
- package/dist/esm/feedback-components.1e7da538.js.map +1 -0
- package/dist/esm/{feedback-components.5509fab3.js → feedback-components.45d25912.js} +2 -2
- package/dist/esm/{feedback-components.5509fab3.js.map → feedback-components.45d25912.js.map} +1 -1
- package/dist/esm/{feedback-components.5df2a926.js → feedback-components.707e3490.js} +5 -7
- package/dist/esm/feedback-components.707e3490.js.map +1 -0
- package/dist/esm/{feedback-components.3b3a5357.js → feedback-components.832b2eae.js} +15 -4
- package/dist/esm/feedback-components.832b2eae.js.map +1 -0
- package/dist/esm/{feedback-components.46a7a347.js → feedback-components.f577ebea.js} +90 -9
- package/dist/esm/feedback-components.f577ebea.js.map +1 -0
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/node/feedback-components.25f1909a.js +2 -0
- package/dist/node/feedback-components.25f1909a.js.map +1 -0
- package/dist/node/feedback-components.4cd6b208.js +2 -0
- package/dist/node/feedback-components.4cd6b208.js.map +1 -0
- package/dist/node/feedback-components.9328e8ba.js +2 -0
- package/dist/node/feedback-components.9328e8ba.js.map +1 -0
- package/dist/node/feedback-components.b22d37d1.js +2 -0
- package/dist/node/feedback-components.b22d37d1.js.map +1 -0
- package/dist/node/{feedback-components.a39f7653.js → feedback-components.f9abf0d6.js} +2 -2
- package/dist/node/{feedback-components.a39f7653.js.map → feedback-components.f9abf0d6.js.map} +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +3 -2
- package/src/extractions/index.ts +7 -2
- package/src/extractions/types.ts +1 -0
- package/src/feedback/graph.ts +17 -4
- package/src/feedback/index.ts +11 -0
- package/src/feedback/text-visualizer.ts +115 -5
- package/dist/esm/feedback-components.3b3a5357.js.map +0 -1
- package/dist/esm/feedback-components.46a7a347.js.map +0 -1
- package/dist/esm/feedback-components.586103e8.js.map +0 -1
- package/dist/esm/feedback-components.5df2a926.js.map +0 -1
- package/dist/node/feedback-components.561466ac.js +0 -2
- package/dist/node/feedback-components.561466ac.js.map +0 -1
- package/dist/node/feedback-components.571ee23c.js +0 -2
- package/dist/node/feedback-components.571ee23c.js.map +0 -1
- package/dist/node/feedback-components.8b03e8be.js +0 -2
- package/dist/node/feedback-components.8b03e8be.js.map +0 -1
- package/dist/node/feedback-components.ec54a1e7.js +0 -2
- package/dist/node/feedback-components.ec54a1e7.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
|
|
|
4
4
|
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.1.3] - 2025-07-16
|
|
8
|
+
|
|
9
|
+
- Graph node clicking logic same as graph and tree
|
|
10
|
+
- "Show matches" switch to displayed matchs on tag hover
|
|
11
|
+
|
|
7
12
|
## [1.1.2] - 2025-07-10
|
|
8
13
|
|
|
9
14
|
- Increased the default line spacing in the paragraph text (made it configurable
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "./feedback-components.fb60c70d.css";
|
|
2
2
|
import $bvJLP$feedbackcomponents95dbe7d7js from "./feedback-components.95dbe7d7.js";
|
|
3
|
-
import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./feedback-components.
|
|
4
|
-
import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./feedback-components.
|
|
5
|
-
import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./feedback-components.
|
|
3
|
+
import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./feedback-components.45d25912.js";
|
|
4
|
+
import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./feedback-components.f577ebea.js";
|
|
5
|
+
import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./feedback-components.707e3490.js";
|
|
6
6
|
import {TreeDispatchContext as $b79bf29960412ca7$export$e5ce04c5b3f58533, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e, useUpdatableTree as $b79bf29960412ca7$export$911bb4b9c8065d3d} from "./feedback-components.fa1d3641.js";
|
|
7
7
|
import {OmniboxSelector as $fda9ef5406c1cfb4$export$d8660660a589068c} from "./feedback-components.ad9f284e.js";
|
|
8
|
-
import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./feedback-components.
|
|
8
|
+
import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./feedback-components.832b2eae.js";
|
|
9
9
|
import $bvJLP$macrostrathyper from "@macrostrat/hyper";
|
|
10
10
|
import {Tree as $bvJLP$Tree} from "react-arborist";
|
|
11
11
|
import {useState as $bvJLP$useState, useRef as $bvJLP$useRef, useCallback as $bvJLP$useCallback, useEffect as $bvJLP$useEffect} from "react";
|
|
12
|
-
import {SegmentedControl as $bvJLP$SegmentedControl, Card as $bvJLP$Card, ButtonGroup as $bvJLP$ButtonGroup, Divider as $bvJLP$Divider, Icon as $bvJLP$Icon, Overlay2 as $bvJLP$Overlay2, Popover as $bvJLP$Popover} from "@blueprintjs/core";
|
|
12
|
+
import {SegmentedControl as $bvJLP$SegmentedControl, Card as $bvJLP$Card, ButtonGroup as $bvJLP$ButtonGroup, Switch as $bvJLP$Switch, Divider as $bvJLP$Divider, Icon as $bvJLP$Icon, Overlay2 as $bvJLP$Overlay2, Popover as $bvJLP$Popover} from "@blueprintjs/core";
|
|
13
13
|
import {ErrorBoundary as $bvJLP$ErrorBoundary, FlexRow as $bvJLP$FlexRow, CancelButton as $bvJLP$CancelButton, SaveButton as $bvJLP$SaveButton, useInDarkMode as $bvJLP$useInDarkMode} from "@macrostrat/ui-components";
|
|
14
14
|
import $bvJLP$useelementdimensions from "use-element-dimensions";
|
|
15
15
|
import {ColorPicker as $bvJLP$ColorPicker} from "@macrostrat/data-sheet";
|
|
@@ -40,9 +40,10 @@ function $71d20dff35996763$var$setsAreTheSame(a, b) {
|
|
|
40
40
|
}
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap }) {
|
|
43
|
+
function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, allowOverlap: allowOverlap, matchLinks: matchLinks }) {
|
|
44
44
|
// Get the input arguments
|
|
45
45
|
const [state, dispatch] = (0, $b79bf29960412ca7$export$911bb4b9c8065d3d)(entities.map($71d20dff35996763$var$processEntity), entityTypes);
|
|
46
|
+
const [match, setMatchLinks] = (0, $bvJLP$useState)(matchLinks || {});
|
|
46
47
|
const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType, entityTypesMap: entityTypesMap } = state;
|
|
47
48
|
const [{ width: width, height: height }, ref] = (0, $bvJLP$useelementdimensions)();
|
|
48
49
|
return $71d20dff35996763$var$h("div.page-wrapper", [
|
|
@@ -57,7 +58,8 @@ function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], te
|
|
|
57
58
|
// @ts-ignore
|
|
58
59
|
nodes: tree,
|
|
59
60
|
selectedNodes: selectedNodes,
|
|
60
|
-
allowOverlap: allowOverlap
|
|
61
|
+
allowOverlap: allowOverlap,
|
|
62
|
+
matchLinks: match
|
|
61
63
|
})),
|
|
62
64
|
$71d20dff35996763$var$h((0, $bvJLP$FlexRow), {
|
|
63
65
|
alignItems: "baseline",
|
|
@@ -118,6 +120,13 @@ function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], te
|
|
|
118
120
|
minimal: true,
|
|
119
121
|
alignText: "left"
|
|
120
122
|
}, [
|
|
123
|
+
$71d20dff35996763$var$h.if(matchLinks)((0, $bvJLP$Switch), {
|
|
124
|
+
label: "Show matches",
|
|
125
|
+
checked: match !== null,
|
|
126
|
+
onChange: (e)=>{
|
|
127
|
+
setMatchLinks(match === null ? matchLinks || {} : null);
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
121
130
|
$71d20dff35996763$var$h((0, $bvJLP$CancelButton), {
|
|
122
131
|
icon: "trash",
|
|
123
132
|
disabled: state.initialTree == state.tree,
|
|
@@ -575,4 +584,4 @@ function $71d20dff35996763$var$TypeTag({ type: type, luminance: luminance, selec
|
|
|
575
584
|
|
|
576
585
|
|
|
577
586
|
export {$71d20dff35996763$export$a90600c9da52b40c as FeedbackComponent, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e as treeToGraph};
|
|
578
|
-
//# sourceMappingURL=feedback-components.
|
|
587
|
+
//# sourceMappingURL=feedback-components.1e7da538.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,8EAAK;AAE5B,SAAS,qCAAkB,CAAS,EAAE,CAAS;IAC7C,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EAAE,OAAO;IAC9B,KAAK,MAAM,QAAQ,EAAG;QACpB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,OAAO;IAC3B;IACA,OAAO;AACT;AAEO,SAAS,0CAAkB,YAChC,WAAW,EAAE,QACb,IAAI,SACJ,KAAK,eACL,WAAW,kBACX,cAAc,UACd,MAAM,gBACN,YAAY,cACZ,UAAU,EACX;IACC,0BAA0B;IAC1B,MAAM,C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ACA;2BACA;iBACA;gBACA;sBACA;QACF;IAEJ;IAEA,OAAO,wBACL,CAAA,GAAA,cAAM,GACN;QACE,WAAW;QACX,SAAS,wBAAE,mBAAmB,eAAe;QAC7C,iBAAiB;IACnB,GACA,wBACE,gBACA;QACE,SAAS;QACT,OAAO;YACL,QACE,IAAI,MAAM,GAAG,KAAM,mBAAmB,CAAC,eACnC,YACA;YACN,OAAO;YACP,iBAAiB,MAAM,eAAe;YACtC,QAAQ,aACJ,CAAC,sCAAsC,CAAC,GACxC,CAAC,iCAAiC,CAAC;QACzC;IACF,GACA,wBAAE,sBAAsB;QACtB,wBAAE,iBAAiB;QACnB,wBAAE,aAAa;YACb,wBAAE,gCAAU;0BACV;sBACA;YACF;YACA,wBAAE,CAAA,GAAA,WAAG,GAAG;gBACN,MAAM;gBACN,WAAW;gBACX,OAAO;oBAAE,OAAO;oBAAO,QAAQ;gBAAU;gBACzC,SAAS,CAAC;oBACR,EAAE,eAAe;oBACjB,SAAS;wBACP,MAAM;wBACN,SAAS;gCAAE;wBAAG;oBAChB;gBACF;YACF;SACD;KACF;AAGP","sources":["packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { Tree, TreeApi } from \"react-arborist\";\nimport Node from \"./node\";\nimport { FeedbackText } from \"./text-visualizer\";\nimport type { InternalEntity, TreeData } from \"./types\";\nimport type { Entity } from \"../extractions\";\nimport { getTagStyle, ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport {\n ButtonGroup,\n Card,\n SegmentedControl,\n Icon,\n Popover,\n Divider,\n Overlay2,\n} from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n ErrorBoundary,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport { ColorPicker } from \"@macrostrat/data-sheet\";\nimport { Switch } from \"@blueprintjs/core\";\n\nexport type { GraphData } from \"./edit-state\";\nexport { treeToGraph } from \"./edit-state\";\nexport type { TreeData } from \"./types\";\n\nconst h = hyper.styled(styles);\n\nfunction setsAreTheSame<T>(a: Set<T>, b: Set<T>) {\n if (a.size !== b.size) return false;\n for (const item of a) {\n if (!b.has(item)) return false;\n }\n return true;\n}\n\nexport function FeedbackComponent({\n entities = [],\n text,\n model,\n entityTypes,\n matchComponent,\n onSave,\n allowOverlap,\n matchLinks,\n}) {\n // Get the input arguments\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes,\n );\n const [match, setMatchLinks] = useState(matchLinks || {});\n\n const {\n selectedNodes,\n tree,\n selectedEntityType,\n isSelectingEntityType,\n entityTypesMap,\n } = state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(\"div.page-wrapper\", [\n h(\n \"div.feedback-container\",\n h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(\n ErrorBoundary,\n {\n description:\n \"An error occurred while rendering the feedback text component.\",\n },\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n allowOverlap,\n matchLinks: match,\n }),\n ),\n h(\n FlexRow,\n { alignItems: \"baseline\", justifyContent: \"space-between\" },\n [\n h(ModelInfo, { data: model }),\n h(SegmentedControl, {\n options: [\n { label: \"Tree\", value: \"tree\" },\n { label: \"Graph\", value: \"graph\" },\n ],\n value: state.viewMode,\n small: true,\n onValueChange(value: ViewMode) {\n console.log(\"Setting view mode\", value);\n dispatch({ type: \"set-view-mode\", payload: value });\n },\n }),\n ],\n ),\n h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h.if(state.viewMode == \"tree\")(ManagedSelectionTree, {\n selectedNodes,\n dispatch,\n tree,\n width,\n height,\n matchComponent,\n }),\n h.if(state.viewMode == \"graph\")(GraphView, {\n tree,\n width,\n height,\n dispatch,\n selectedNodes,\n }),\n ],\n ),\n ]),\n ),\n h(Card, { className: \"control-panel\" }, [\n h(\"div.control-content\", [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\n },\n [\n h.if(matchLinks)(Switch, {\n label: \"Show matches\",\n checked: match !== null,\n onChange: (e) => {\n setMatchLinks(match === null ? matchLinks || {} : null);\n },\n }),\n h(\n CancelButton,\n {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick() {\n dispatch({ type: \"reset\" });\n },\n },\n \"Reset\",\n ),\n h(\n SaveButton,\n {\n onClick() {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree,\n },\n \"Save\",\n ),\n ],\n ),\n h(Divider),\n h(EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n dispatch,\n tree,\n selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\n }),\n ]),\n ]),\n ]);\n}\n\nfunction processEntity(entity: Entity): InternalEntity {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [entity.indices],\n children: entity.children?.map(processEntity) ?? [],\n };\n}\n\nfunction EntityTypeSelector({\n entityTypes,\n selected,\n isOpen,\n setOpen,\n onChange,\n tree,\n dispatch,\n selectedNodes = [],\n}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = useState(\"\");\n const types = Array.from(entityTypes.values());\n\n const items =\n inputValue !== \"\"\n ? types.filter((d) =>\n d.name.toLowerCase().includes(inputValue.toLowerCase()),\n )\n : types;\n\n return h(\"div.entity-type-selector\", [\n h(TypeList, {\n types: entityTypes,\n selected: _selected,\n dispatch,\n selectedNodes,\n tree,\n }),\n h(OmniboxSelector, {\n isOpen,\n items,\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onQueryChange(query) {\n setInputValue(query);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n\n function recurse(nodes) {\n for (const node of nodes) {\n count++;\n if (node.children && Array.isArray(node.children)) {\n recurse(node.children);\n }\n }\n }\n\n recurse(tree);\n return count;\n}\n\nfunction ManagedSelectionTree(props) {\n const { selectedNodes, dispatch, tree, height, width, matchComponent } =\n props;\n\n const ref = useRef<TreeApi<TreeData>>();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = useRef(false);\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent],\n );\n\n // Update Tree selection when selectedNodes change\n useEffect(() => {\n if (ref.current == null) return;\n\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n\n const ctrlPressedRef = useRef(false);\n\n useEffect(() => {\n const down = (e) => {\n if (e.ctrlKey || e.metaKey) ctrlPressedRef.current = true;\n };\n const up = () => (ctrlPressedRef.current = false);\n\n window.addEventListener(\"keydown\", down);\n window.addEventListener(\"keyup\", up);\n return () => {\n window.removeEventListener(\"keydown\", down);\n window.removeEventListener(\"keyup\", up);\n };\n }, []);\n\n const handleSelect = useCallback(\n (nodes) => {\n if (!clickedRef.current) return;\n clickedRef.current = false;\n const isMultiSelect = ctrlPressedRef.current;\n\n let ids = nodes.map((d) => parseInt(d.id));\n\n if (isMultiSelect) {\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else {\n if (ids.length === 1 && ids[0] === selectedNodes[0]) {\n ids = [];\n }\n\n dispatch({ type: \"select-node\", payload: { ids } });\n }\n },\n [selectedNodes, dispatch],\n );\n\n return h(\n \"div.selection-tree-wrapper\",\n { onPointerDown: handleClick },\n h(Tree, {\n className: \"selection-tree\",\n height,\n width,\n ref,\n data: tree,\n onMove({ dragIds, parentId, index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d) => parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index,\n },\n });\n },\n onDelete({ ids }) {\n dispatch({\n type: \"delete-node\",\n payload: { ids: ids.map((d) => parseInt(d)) },\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor(d) {\n return d.id.toString();\n },\n }),\n );\n}\n\nfunction TypeList({ types, selected, dispatch, selectedNodes, tree }) {\n const [selectedType, setSelectedType] = useState(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = useInDarkMode();\n const luminance = darkMode ? 0.9 : 0.4;\n\n return h(\"div.type-list-container\", [\n h(\n \"div.type-list-header\",\n isSelectedNodes && !selectedType\n ? \"Change selected nodes to:\"\n : \"Entity Types\",\n ),\n h(\n \"div.type-list\",\n Array.from(types.values()).map((type) =>\n h(TypeTag, {\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n }),\n ),\n ),\n h(AddType, { dispatch }),\n ]);\n}\n\nfunction collectMatchingIds(tree, id) {\n const ids = [];\n\n function traverse(node) {\n if (node.type.id === id) {\n ids.push(node.id);\n }\n if (Array.isArray(node.children)) {\n node.children.forEach(traverse);\n }\n }\n\n tree.forEach(traverse);\n return ids;\n}\n\nfunction AddType({ dispatch }) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"add-entity-type\",\n payload,\n });\n setOverlayOpen(false);\n };\n\n return h(\"div.add-type-container\", [\n h(\"div.add-type\", { onClick: () => setOverlayOpen(true) }, [\n h(\"p.add-type-text\", \"Add new type\"),\n h(Icon, { icon: \"plus\" }),\n ]),\n h(TypeOverlay, {\n setOverlayOpen,\n overlayOpen,\n title: \"Add New Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction EditType({ dispatch, type }) {\n const [editorOpen, setEditorOpen] = useState(false);\n\n const saveHandler = (payload) => {\n dispatch({\n type: \"update-entity-type\",\n payload,\n });\n setEditorOpen(false);\n };\n\n return h(\"div.edit-type\", [\n h(Icon, {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e) => {\n e.stopPropagation();\n setEditorOpen(true);\n },\n }),\n h(TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler,\n }),\n ]);\n}\n\nfunction TypeOverlay({\n setOverlayOpen,\n overlayOpen,\n originalType,\n title,\n saveHandler,\n}) {\n const { name, description, color, id } = originalType || {};\n\n const [nameInput, setNameInput] = useState(name || \"\");\n const [descriptionInput, setDescriptionInput] = useState(description || \"\");\n const [colorInput, setColorInput] = useState(color || \"#fff\");\n\n return h(\n Overlay2,\n {\n isOpen: overlayOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n title,\n h(Icon, {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: () => {\n setOverlayOpen(false);\n },\n style: { cursor: \"pointer\", color: \"red\" },\n }),\n ]),\n h(\"div.form-group\", [\n h(\"div.text-inputs\", [\n h(\"div.form-field.name\", [\n h(\"p.label\", \"Name\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e) => setNameInput(e.target.value),\n value: nameInput,\n }),\n ]),\n h(\"div.form-field.form-description\", [\n h(\"p.label\", \"Description\"),\n h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e) => setDescriptionInput(e.target.value),\n value: descriptionInput,\n }),\n ]),\n ]),\n h(\"div.form-field.color\", [\n h(\"p.label\", \"Color\"),\n h(ColorPicker, {\n value: colorInput,\n onChange: (color) => setColorInput(color),\n style: { width: \"100%\" },\n }),\n ]),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () =>\n saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id,\n }),\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n\nfunction TypeTag({\n type,\n luminance,\n selectedType,\n setSelectedType,\n dispatch,\n tree,\n selectedNodes,\n selected,\n isSelectedNodes,\n}) {\n const { color, name, id, description } = type;\n const darkMode = useInDarkMode();\n const isSelected = id === selected?.id && selectedNodes.length > 0;\n\n const style = getTagStyle(color, {\n active: isSelected,\n highlighted: selectedNodes.length === 0,\n });\n\n const payload = {\n id,\n name,\n color,\n description,\n };\n\n const ids = collectMatchingIds(tree, id);\n\n const handleTagClick = () => {\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) {\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: selectedNodes },\n });\n } else {\n dispatch({ type: \"select-entity-type\", payload });\n }\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = collectMatchingIds(tree, selectedType.id);\n\n dispatch({ type: \"toggle-node-selected\", payload: { ids: oldIds } });\n dispatch({ type: \"toggle-node-selected\", payload: { ids } });\n }\n } else {\n console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes,\n selectedType,\n selectedNodes,\n ids,\n id,\n selected,\n });\n }\n };\n\n return h(\n Popover,\n {\n autoFocus: false,\n content: h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\",\n },\n h(\n \"div.type-tag\",\n {\n onClick: handleTagClick,\n style: {\n cursor:\n ids.length > 0 || (isSelectedNodes && !selectedType)\n ? \"pointer\"\n : \"\",\n color: \"black\",\n backgroundColor: style.backgroundColor,\n border: isSelected\n ? `1px solid var(--text-emphasized-color)`\n : `1px solid var(--background-color)`,\n },\n },\n h(\"div.type-container\", [\n h(\"div.type-name\", name),\n h(\"div.icons\", [\n h(EditType, {\n dispatch,\n type,\n }),\n h(Icon, {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: { color: \"red\", cursor: \"pointer\" },\n onClick: (e) => {\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: { id },\n });\n },\n }),\n ]),\n ]),\n ),\n );\n}\n"],"names":[],"version":3,"file":"feedback-components.1e7da538.js.map"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {EntityTag as $03d8811e9c9b360d$export$117e56c71b172cde} from "./feedback-components.
|
|
1
|
+
import {EntityTag as $03d8811e9c9b360d$export$117e56c71b172cde} from "./feedback-components.707e3490.js";
|
|
2
2
|
import {useTreeDispatch as $b79bf29960412ca7$export$e1068f2d1c68f87e} from "./feedback-components.fa1d3641.js";
|
|
3
3
|
import "./feedback-components.fb60c70d.css";
|
|
4
4
|
import $gIldz$feedbackcomponents95dbe7d7js from "./feedback-components.95dbe7d7.js";
|
|
@@ -61,4 +61,4 @@ var $b6b9741bf83336eb$export$2e2bcd8739ae039 = $b6b9741bf83336eb$var$Node;
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
export {$b6b9741bf83336eb$export$2e2bcd8739ae039 as default};
|
|
64
|
-
//# sourceMappingURL=feedback-components.
|
|
64
|
+
//# sourceMappingURL=feedback-components.45d25912.js.map
|
package/dist/esm/{feedback-components.5509fab3.js.map → feedback-components.45d25912.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;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import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n // console.log(\"Node render\", node.data, highlighted, active);\n\n if (!node.data?.type) {\n node.data.type = { name: \"lith\", color: \"rgb(107, 255, 91)\" };\n }\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n }),\n );\n}\n\nexport default Node;\n"],"names":[],"version":3,"file":"feedback-components.
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAOA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,8EAAK;AAE5B,SAAS,iCAAW,UAAoB,EAAE,QAAkB;IAC1D,OAAO,WAAW,EAAE,IAAI,SAAS,EAAE;AACnC,wEAAwE;AAC1E;AAEA,SAAS,wCAAkB,IAAuB,EAAE,IAAuB;IACzE,gFAAgF;IAChF,IAAI,KAAK,aAAa,CAAC,MAAM,IAAI,GAC/B,OAAO;IAGT,KAAK,MAAM,gBAAgB,KAAK,aAAa,CAAE;QAC7C,IAAI,iCAAW,KAAK,IAAI,EAAE,aAAa,IAAI,GACzC,OAAO;IAEX;IAEA,0CAA0C;IAC1C,IAAI,KAAK,MAAM,IAAI,QAAQ,wCAAkB,KAAK,MAAM,EAAE,OACxD,OAAO;IAGT,OAAO;AACT;AAEA,SAAS,mCAAa,IAAuB,EAAE,IAAuB;IACpE,KAAK,MAAM,gBAAgB,KAAK,aAAa,CAAE;QAC7C,IAAI,iCAAW,KAAK,IAAI,EAAE,aAAa,IAAI,GACzC,OAAO;IAEX;IACA,OAAO;AACT;AAEA,SAAS,2BAAK,QAAE,IAAI,SAAE,KAAK,cAAE,UAAU,QAAE,IAAI,kBAAE,cAAc,EAAO;IAClE,IAAI,cAAuB,wCAAkB,MAAM;IACnD,IAAI,SAAkB,mCAAa,MAAM;IAEzC,MAAM,WAAW,CAAA,GAAA,yCAAc;IAE/B,8DAA8D;IAE9D,IAAI,CAAC,KAAK,IAAI,EAAE,MACd,KAAK,IAAI,CAAC,IAAI,GAAG;QAAE,MAAM;QAAQ,OAAO;IAAoB;IAG9D,OAAO,wBACL,YACA;eAAE;QAAO,KAAK;IAAW,GACzB,wBAAE,CAAA,GAAA,yCAAQ,GAAG;QACX,MAAM,KAAK,IAAI;gBACf;qBACA;wBACA;QACA;YACE,SAAS;gBAAE,MAAM;YAA8B;QACjD;IACF;AAEJ;IAEA,2CAAe","sources":["packages/feedback-components/src/feedback/node.ts"],"sourcesContent":["import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({ node, style, dragHandle, tree, matchComponent }: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n const dispatch = useTreeDispatch();\n\n // console.log(\"Node render\", node.data, highlighted, active);\n\n if (!node.data?.type) {\n node.data.type = { name: \"lith\", color: \"rgb(107, 255, 91)\" };\n }\n\n return h(\n \"div.node\",\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active,\n highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n }),\n );\n}\n\nexport default Node;\n"],"names":[],"version":3,"file":"feedback-components.45d25912.js.map"}
|
|
@@ -32,7 +32,8 @@ function $03d8811e9c9b360d$export$c4b91360064ad200(entities, parent) {
|
|
|
32
32
|
backgroundColor: entity.type?.color,
|
|
33
33
|
tag: entity.type?.name ?? "lith",
|
|
34
34
|
id: entity.id,
|
|
35
|
-
parents: parents
|
|
35
|
+
parents: parents,
|
|
36
|
+
match: entity.match
|
|
36
37
|
});
|
|
37
38
|
highlights.push(...$03d8811e9c9b360d$export$c4b91360064ad200(entity.children ?? [], entity));
|
|
38
39
|
}
|
|
@@ -45,7 +46,7 @@ function $03d8811e9c9b360d$export$d60b563f571177d(extractionData, models, entity
|
|
|
45
46
|
entities: extractionData.entities?.map((d)=>$03d8811e9c9b360d$var$enhanceEntity(d, entityTypes))
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
|
-
function $03d8811e9c9b360d$export$35baa338324d8550(baseColor, options) {
|
|
49
|
+
function $03d8811e9c9b360d$export$35baa338324d8550(baseColor, options = {}) {
|
|
49
50
|
const _baseColor = (0, $9y0hV$asChromaColor)(baseColor ?? "#fff");
|
|
50
51
|
const { highlighted: highlighted = true, inDarkMode: inDarkMode = (0, $9y0hV$useDarkMode)().isEnabled, active: active = false } = options;
|
|
51
52
|
let mixAmount = highlighted ? 0.8 : 0.5;
|
|
@@ -59,10 +60,7 @@ function $03d8811e9c9b360d$export$35baa338324d8550(baseColor, options) {
|
|
|
59
60
|
const borderColor = highlighted ? _baseColor.mix(mixTarget, mixAmount / 1.1).hex() : "transparent";
|
|
60
61
|
let backgroundColor = active ? _baseColor.alpha(backgroundAlpha).hex() : $03d8811e9c9b360d$var$normalizeColor(_baseColor.alpha(backgroundAlpha).hex());
|
|
61
62
|
// handle white backgrounds in light mode
|
|
62
|
-
if (!inDarkMode && backgroundColor === "#ffffff")
|
|
63
|
-
console.log("Adjusting background color for light mode:", backgroundColor);
|
|
64
|
-
backgroundColor = "#f0f0f0";
|
|
65
|
-
}
|
|
63
|
+
if (!inDarkMode && backgroundColor === "#ffffff") backgroundColor = "#f0f0f0";
|
|
66
64
|
return {
|
|
67
65
|
color: color,
|
|
68
66
|
backgroundColor: backgroundColor,
|
|
@@ -202,4 +200,4 @@ function $03d8811e9c9b360d$var$isHighlighted(id, selectedNodes, nodes) {
|
|
|
202
200
|
|
|
203
201
|
|
|
204
202
|
export {$03d8811e9c9b360d$export$c4b91360064ad200 as buildHighlights, $03d8811e9c9b360d$export$d60b563f571177d as enhanceData, $03d8811e9c9b360d$export$35baa338324d8550 as getTagStyle, $03d8811e9c9b360d$export$2b07158757c249e0 as ExtractionContext, $03d8811e9c9b360d$export$4eb2a0ce903ce967 as ModelInfo, $03d8811e9c9b360d$export$117e56c71b172cde as EntityTag};
|
|
205
|
-
//# sourceMappingURL=feedback-components.
|
|
203
|
+
//# sourceMappingURL=feedback-components.707e3490.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAWA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,8EAAK;AAErB,SAAS,0CACd,QAAqB,EACrB,MAAwB;IAExB,IAAI,aAAa,EAAE;IACnB,IAAI,UAAU,EAAE;IAChB,IAAI,UAAU,MACZ,UAAU;QAAC,OAAO,EAAE;WAAM,OAAO,OAAO,IAAI,EAAE;KAAE;IAGlD,KAAK,MAAM,UAAU,SAAU;QAC7B,WAAW,IAAI,CAAC;YACd,OAAO,OAAO,OAAO,CAAC,EAAE;YACxB,KAAK,OAAO,OAAO,CAAC,EAAE;YACtB,MAAM,OAAO,IAAI;YACjB,iBAAiB,OAAO,IAAI,EAAE;YAC9B,KAAK,OAAO,IAAI,EAAE,QAAQ;YAC1B,IAAI,OAAO,EAAE;qBACb;YACA,OAAO,OAAO,KAAK;QACrB;QACA,WAAW,IAAI,IAAI,0CAAgB,OAAO,QAAQ,IAAI,EAAE,EAAE;IAC5D;IACA,OAAO;AACT;AAEO,SAAS,yCAAY,cAAc,EAAE,MAAM,EAAE,WAAW;IAC7D,OAAO;QACL,GAAG,cAAc;QACjB,OAAO,OAAO,GAAG,CAAC,eAAe,QAAQ;QACzC,UAAU,eAAe,QAAQ,EAAE,IAAI,CAAC,IACtC,oCAAc,GAAG;IAErB;AACF;AAEO,SAAS,0CACd,SAAiB,EACjB,UAKI,CAAC,CAAC;IAEN,MAAM,aAAa,CAAA,GAAA,oBAAY,EAAE,aAAa;IAC9C,MAAM,eACJ,cAAc,kBACd,aAAa,CAAA,GAAA,kBAAU,I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,WAAW,KAAK,CAAC,GAAG,IAAI;IAE7C,MAAM,QAAQ,CAAC,IAAI,KAAO,KAAK,KAAK,CAAC,AAAC,CAAA,IAAI,CAAA,IAAK,KAAK,IAAI;IAExD,MAAM,WAAW,MAAM,GAAG;IAC1B,MAAM,WAAW,MAAM,GAAG;IAC1B,MAAM,WAAW,MAAM,GAAG;IAE1B,OACE,MACA,SAAS,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,OAClC,SAAS,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,OAClC,SAAS,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG;AAEtC;AAEA,SAAS,oCAAc,EAAU,EAAE,aAAuB,EAAE,KAAY;IACtE,IAAI,eAAe,WAAW,GAAG,OAAO;IACxC,OACE,eAAe,SAAS,OACxB,OAAO,KACL,CAAC,OACC,eAAe,SAAS,KAAK,EAAE,KAC/B,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAU,MAAM,EAAE,KAAK;AAGnD","sources":["packages/feedback-components/src/extractions/index.ts"],"sourcesContent":["import styles from \"./main.module.sass\";\nimport classNames from \"classnames\";\nimport { Tag } from \"@blueprintjs/core\";\nimport type { Entity, EntityExt, Highlight, EntityType } from \"./types\";\nimport { CSSProperties } from \"react\";\nimport { asChromaColor } from \"@macrostrat/color-utils\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useDarkMode } from \"@macrostrat/ui-components\";\n\nexport type { Entity, EntityExt };\n\nconst h = hyper.styled(styles);\n\nexport function buildHighlights(\n entities: EntityExt[],\n parent: EntityExt | null,\n): Highlight[] {\n let highlights = [];\n let parents = [];\n if (parent != null) {\n parents = [parent.id, ...(parent.parents ?? [])];\n }\n\n for (const entity of entities) {\n highlights.push({\n start: entity.indices[0],\n end: entity.indices[1],\n text: entity.name,\n backgroundColor: entity.type?.color,\n tag: entity.type?.name ?? \"lith\",\n id: entity.id,\n parents,\n match: entity.match,\n });\n highlights.push(...buildHighlights(entity.children ?? [], entity));\n }\n return highlights;\n}\n\nexport function enhanceData(extractionData, models, entityTypes) {\n return {\n ...extractionData,\n model: models.get(extractionData.model_id),\n entities: extractionData.entities?.map((d) =>\n enhanceEntity(d, entityTypes),\n ),\n };\n}\n\nexport function getTagStyle(\n baseColor: string,\n options: {\n highlighted?: boolean;\n inDarkMode?: boolean;\n active?: boolean;\n showMatches?: boolean;\n } = {},\n): CSSProperties {\n const _baseColor = asChromaColor(baseColor ?? \"#fff\");\n const {\n highlighted = true,\n inDarkMode = useDarkMode().isEnabled,\n active = false,\n } = options;\n\n let mixAmount = highlighted ? 0.8 : 0.5;\n let backgroundAlpha = highlighted ? 0.8 : 0.2;\n\n if (active) {\n mixAmount = 1;\n backgroundAlpha = 1;\n }\n\n const mixTarget = \"black\";\n\n const color = active ? \"#000\" : _baseColor.mix(mixTarget, mixAmount).hex();\n const borderColor = highlighted\n ? _baseColor.mix(mixTarget, mixAmount / 1.1).hex()\n : \"transparent\";\n\n let backgroundColor = active\n ? _baseColor.alpha(backgroundAlpha).hex()\n : normalizeColor(_baseColor.alpha(backgroundAlpha).hex());\n\n // handle white backgrounds in light mode\n if (!inDarkMode && backgroundColor === \"#ffffff\") {\n backgroundColor = \"#f0f0f0\";\n }\n\n return {\n color,\n backgroundColor,\n boxSizing: \"border-box\",\n borderStyle: \"solid\",\n borderColor,\n borderWidth: \"1.5px\",\n fontWeight: active ? \"bold\" : \"normal\",\n fontSize: \"0.9em\",\n };\n}\n\nfunction enhanceEntity(\n entity: Entity,\n entityTypes: Map<number, EntityType>,\n): EntityExt {\n return {\n ...entity,\n type: addColor(entityTypes.get(entity.type), entity.match != null),\n children: entity.children?.map((d) => enhanceEntity(d, entityTypes)),\n };\n}\n\nfunction addColor(entityType: EntityType, match = false) {\n const color = asChromaColor(entityType.color ?? \"#fff\").brighten(\n match ? 1 : 2,\n );\n\n return { ...entityType, color: color.css() };\n}\n\nexport function ExtractionContext({\n data,\n entityTypes,\n matchComponent,\n}: {\n data: any;\n entityTypes: Map<number, EntityType>;\n matchComponent: MatchComponent;\n}) {\n const highlights = buildHighlights(data.entities, null);\n\n return h(\"div\", [\n h(\"p\", h(HighlightedText, { text: data.paragraph_text, highlights })),\n h(ModelInfo, { data: data.model }),\n h(\n \"ul.entities\",\n data.entities.map((d) => h(ExtractionInfo, { data: d, matchComponent })),\n ),\n ]);\n}\n\nexport function ModelInfo({ data }) {\n return h(\"p.model-name\", [\"Model: \", h(\"code.bp5-code\", data.name)]);\n}\n\nexport type MatchComponent = (props: { data: any }) => any;\n\ntype EntityTagProps = {\n data: EntityExt;\n highlighted?: boolean;\n active?: boolean;\n onClickType?: (type: EntityType) => void;\n matchComponent?: MatchComponent;\n};\n\nexport function EntityTag({\n data,\n highlighted = true,\n active = false,\n onClickType,\n matchComponent = null,\n}: EntityTagProps) {\n const { name, type, match } = data;\n\n const className = classNames(\n {\n matched: match != null,\n type: data.type?.name ?? \"lith\",\n },\n \"entity\",\n );\n\n const style = getTagStyle(type?.color, { highlighted, active });\n\n let _matchLink = null;\n if (match != null && matchComponent != null) {\n _matchLink = h(matchComponent, { data: match });\n }\n\n return h(Tag, { style, className }, [\n h(\"span.entity-name\", name),\n \" \",\n h(\n \"code.entity-type.bp5-code\",\n {\n onClick(evt) {\n if (active && onClickType != null) {\n onClickType(type);\n evt.stopPropagation();\n }\n },\n },\n [type?.name, _matchLink],\n ),\n ]);\n}\n\nfunction ExtractionInfo({\n data,\n matchComponent = null,\n}: {\n data: EntityExt;\n matchComponent: MatchComponent;\n}) {\n const children = data.children ?? [];\n\n return h(\"li.entity-row\", [\n h(EntityTag, { data, matchComponent }),\n h.if(children.length > 0)([\n h(\n \"ul.children\",\n children.map((d) => h(ExtractionInfo, { data: d, matchComponent })),\n ),\n ]),\n ]);\n}\n\nfunction HighlightedText(props: { text: string; highlights: Highlight[] }) {\n const { text, highlights = [] } = props;\n const parts = [];\n let start = 0;\n\n const sortedHighlights = highlights.sort((a, b) => a.start - b.start);\n const deconflictedHighlights = sortedHighlights.map((highlight, i) => {\n if (i === 0) return highlight;\n const prev = sortedHighlights[i - 1];\n if (highlight.start < prev.end) {\n highlight.start = prev.end;\n }\n return highlight;\n });\n\n for (const highlight of deconflictedHighlights) {\n const { start: s, end, ...rest } = highlight;\n parts.push(text.slice(start, s));\n parts.push(h(\"span.highlight\", { style: rest }, text.slice(s, end)));\n start = end;\n }\n parts.push(text.slice(start));\n return h(\"span\", parts);\n}\n\nfunction normalizeColor(hex8) {\n const background = useDarkMode().isEnabled ? \"#000000\" : \"#ffffff\";\n\n const r = parseInt(hex8.slice(1, 3), 16);\n const g = parseInt(hex8.slice(3, 5), 16);\n const b = parseInt(hex8.slice(5, 7), 16);\n const a = parseInt(hex8.slice(7, 9), 16) / 255;\n\n const bgR = parseInt(background.slice(1, 3), 16);\n const bgG = parseInt(background.slice(3, 5), 16);\n const bgB = parseInt(background.slice(5, 7), 16);\n\n const blend = (fg, bg) => Math.round((1 - a) * bg + a * fg);\n\n const blendedR = blend(r, bgR);\n const blendedG = blend(g, bgG);\n const blendedB = blend(b, bgB);\n\n return (\n \"#\" +\n blendedR.toString(16).padStart(2, \"0\") +\n blendedG.toString(16).padStart(2, \"0\") +\n blendedB.toString(16).padStart(2, \"0\")\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: any[]) {\n if (selectedNodes?.length === 0) return true;\n return (\n selectedNodes?.includes(id) ||\n nodes?.some(\n (node) =>\n selectedNodes?.includes(node.id) &&\n node.children.some((child) => child.id === id),\n )\n );\n}\n"],"names":[],"version":3,"file":"feedback-components.707e3490.js.map"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./feedback-components.fa1d3641.js";
|
|
2
2
|
import "./feedback-components.fb60c70d.css";
|
|
3
3
|
import $phGch$feedbackcomponents95dbe7d7js from "./feedback-components.95dbe7d7.js";
|
|
4
|
-
import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550} from "./feedback-components.
|
|
4
|
+
import {getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550} from "./feedback-components.707e3490.js";
|
|
5
5
|
import $phGch$macrostrathyper from "@macrostrat/hyper";
|
|
6
6
|
import {forceSimulation as $phGch$forceSimulation, forceLink as $phGch$forceLink, forceManyBody as $phGch$forceManyBody, forceCenter as $phGch$forceCenter, forceCollide as $phGch$forceCollide} from "d3-force";
|
|
7
7
|
import {useState as $phGch$useState, useEffect as $phGch$useEffect} from "react";
|
|
@@ -103,8 +103,19 @@ function $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566(props) {
|
|
|
103
103
|
fill: style.backgroundColor || "blue",
|
|
104
104
|
onClick: (e)=>{
|
|
105
105
|
e.stopPropagation();
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
if (e.ctrlKey || e.metaKey || selectedNodes[0] === d.id && selectedNodes.length === 1) {
|
|
107
|
+
// Toggle selection on ctrl/cmd click or when node is only selected node
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
dispatch({
|
|
110
|
+
type: "toggle-node-selected",
|
|
111
|
+
payload: {
|
|
112
|
+
ids: [
|
|
113
|
+
d.id
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
} else dispatch({
|
|
118
|
+
type: "select-node",
|
|
108
119
|
payload: {
|
|
109
120
|
ids: [
|
|
110
121
|
d.id
|
|
@@ -134,4 +145,4 @@ function $ff8c3e7f2bc22925$var$isHighlighted(id, selectedNodes, nodes) {
|
|
|
134
145
|
|
|
135
146
|
|
|
136
147
|
export {$ff8c3e7f2bc22925$export$6a7fe3ef90e8d566 as GraphView};
|
|
137
|
-
//# sourceMappingURL=feedback-components.
|
|
148
|
+
//# sourceMappingURL=feedback-components.832b2eae.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GA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AAM;oCACN,SAAS;wCAAE,KAAK;4CAAC,EAAE,EAAE;yCAAC;oCAAC;gCACzB;4BACF,OACE,SAAS;gCACP,MAAM;gCACN,SAAS;oCAAE,KAAK;wCAAC,EAAE,EAAE;qCAAC;gCAAC;4BACzB;wBAEJ;wBACA,WAAW,SAAS,aAAa;gCACjC;wBACA,aAAa;oBACf;oBACA,wBAAE,EAAE,CAAC,YACH,QACA;wBACE,GAAG,EAAE,CAAC,GAAG;wBACT,GAAG,EAAE,CAAC,GAAG;wBACT,WAAW;oBACb,GACA,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;oBAE1B,wBAAE,EAAE,CAAC,CAAC,YAAY,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;iBACpD;YACH;SAEH;KACF;AAEL;AAEA,SAAS,oCAAc,EAAU,EAAE,aAAuB,EAAE,KAAiB;IAC3E,IAAI,cAAc,MAAM,KAAK,GAAG,OAAO;IACvC,OACE,cAAc,QAAQ,CAAC,OACvB,MAAM,IAAI,CACR,CAAC,OACC,cAAc,QAAQ,CAAC,KAAK,EAAE,KAC9B,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAU,MAAM,EAAE,KAAK;AAGnD","sources":["packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport {\n forceSimulation,\n SimulationNodeDatum,\n SimulationLinkDatum,\n forceCenter,\n forceLink,\n forceManyBody,\n forceCollide,\n} from \"d3-force\";\nimport { useEffect, useState } from \"react\";\nimport { Spinner, Switch } from \"@blueprintjs/core\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { getTagStyle } from \"../extractions\";\n\nconst h = hyper.styled(styles);\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n dispatch: (action: any) => void;\n selectedNodes: number[];\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height, dispatch, selectedNodes } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\n const [showLabels, setShowLabels] = useState(false);\n\n useEffect(() => {\n const { nodes, edges } = treeToGraph(tree);\n\n const nodesMap = new Map<number, SimulationNodeDatum>(\n nodes.map((d) => [d.id, d]),\n );\n\n const links = edges.map((d) => {\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1,\n };\n });\n\n const simulation = forceSimulation(nodes)\n .force(\"link\", forceLink(links))\n .force(\"charge\", forceManyBody().strength(-50))\n .force(\"center\", forceCenter(width / 2, height / 2))\n .force(\"collide\", forceCollide().radius(20))\n .on(\"tick\", () => {\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n })\n .on(\"end\", () => {\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n\n return () => {\n simulation.stop();\n };\n }, [tree, width, height]);\n\n if (nodes == null || links == null) {\n return h(Spinner);\n }\n\n console.log(\"Graph\", nodes, links, selectedNodes);\n\n return h(\n ErrorBoundary,\n {\n description: \"An error occurred while rendering the graph view.\",\n },\n h(\"div.graph-view\", { style: { width, height } }, [\n h(Switch, {\n className: \"show-labels-switch\",\n label: \"Show Labels\",\n checked: showLabels,\n onChange: (e) => setShowLabels(e.target.checked),\n }),\n h(\"svg\", { width, height }, [\n h(\n \"g.links\",\n links.map((d) => {\n return h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\",\n });\n }),\n ),\n h(\n \"g.nodes\",\n nodes.map((d) => {\n const active = selectedNodes.includes(d.id);\n const stroke = active ? \"white\" : \"black\";\n const highlighted = isHighlighted(d.id, selectedNodes, nodes);\n const style = getTagStyle(d.color, { highlighted, active });\n\n return h(\"g\", [\n h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 8,\n fill: style.backgroundColor || \"blue\",\n onClick: (e) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === d.id && selectedNodes.length === 1)\n ) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [d.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [d.id] },\n });\n }\n },\n className: active ? \"selected\" : \"\",\n stroke,\n strokeWidth: 2,\n }),\n h.if(showLabels)(\n \"text\",\n {\n x: d.x + 10,\n y: d.y + 4,\n className: \"node-label\",\n },\n d.name || `Node ${d.id}`,\n ),\n h.if(!showLabels)(\"title\", d.name || `Node ${d.id}`),\n ]);\n }),\n ),\n ]),\n ]),\n );\n}\n\nfunction isHighlighted(id: number, selectedNodes: number[], nodes: TreeData[]) {\n if (selectedNodes.length === 0) return true;\n return (\n selectedNodes.includes(id) ||\n nodes.some(\n (node) =>\n selectedNodes.includes(node.id) &&\n node.children.some((child) => child.id === id),\n )\n );\n}\n"],"names":[],"version":3,"file":"feedback-components.832b2eae.js.map"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import "./feedback-components.fb60c70d.css";
|
|
2
2
|
import $aogpP$feedbackcomponents95dbe7d7js from "./feedback-components.95dbe7d7.js";
|
|
3
|
-
import {buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200, getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550} from "./feedback-components.
|
|
3
|
+
import {buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200, getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550} from "./feedback-components.707e3490.js";
|
|
4
4
|
import $aogpP$macrostrathyper from "@macrostrat/hyper";
|
|
5
5
|
import {useRef as $aogpP$useRef, useEffect as $aogpP$useEffect} from "react";
|
|
6
|
+
import {Popover as $aogpP$Popover} from "@blueprintjs/core";
|
|
7
|
+
import {DataField as $aogpP$DataField, JSONView as $aogpP$JSONView} from "@macrostrat/ui-components";
|
|
8
|
+
import {LithologyTag as $aogpP$LithologyTag} from "@macrostrat/data-components";
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
function $parcel$interopDefault(a) {
|
|
@@ -12,6 +15,9 @@ function $parcel$interopDefault(a) {
|
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
15
21
|
const $156a3efbc315814c$var$h = (0, $aogpP$macrostrathyper).styled((0, ($parcel$interopDefault($aogpP$feedbackcomponents95dbe7d7js))));
|
|
16
22
|
function $156a3efbc315814c$var$buildTags(highlights, selectedNodes) {
|
|
17
23
|
let tags = [];
|
|
@@ -51,7 +57,7 @@ function $156a3efbc315814c$var$isHighlighted(tag, selectedNodes) {
|
|
|
51
57
|
}
|
|
52
58
|
function $156a3efbc315814c$export$6e107db9091b8219(props) {
|
|
53
59
|
// Convert input to tags
|
|
54
|
-
const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch, allowOverlap: allowOverlap } = props;
|
|
60
|
+
const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch, allowOverlap: allowOverlap, matchLinks: matchLinks } = props;
|
|
55
61
|
const allTags = $156a3efbc315814c$var$buildTags((0, $03d8811e9c9b360d$export$c4b91360064ad200)(nodes, null), selectedNodes);
|
|
56
62
|
return $156a3efbc315814c$var$h("div.feedback-text-wrapper", {
|
|
57
63
|
tabIndex: 0,
|
|
@@ -68,7 +74,8 @@ function $156a3efbc315814c$export$6e107db9091b8219(props) {
|
|
|
68
74
|
allTags: allTags,
|
|
69
75
|
allowOverlap: allowOverlap,
|
|
70
76
|
dispatch: dispatch,
|
|
71
|
-
selectedNodes: selectedNodes
|
|
77
|
+
selectedNodes: selectedNodes,
|
|
78
|
+
matchLinks: matchLinks
|
|
72
79
|
}));
|
|
73
80
|
}
|
|
74
81
|
function $156a3efbc315814c$var$createTagFromSelection({ container: container }) {
|
|
@@ -173,7 +180,7 @@ function $156a3efbc315814c$var$nestHighlights(text, tags) {
|
|
|
173
180
|
if (lastPos < text.length) stack[stack.length - 1].children.push(text.slice(lastPos));
|
|
174
181
|
return root;
|
|
175
182
|
}
|
|
176
|
-
function $156a3efbc315814c$var$renderNode(node, dispatch, selectedNodes, parentSelected) {
|
|
183
|
+
function $156a3efbc315814c$var$renderNode(node, dispatch, selectedNodes, parentSelected, matchLinks) {
|
|
177
184
|
if (typeof node === "string") return node;
|
|
178
185
|
const { tag: tag, children: children } = node;
|
|
179
186
|
const isSelected = selectedNodes?.includes(tag.id);
|
|
@@ -192,7 +199,11 @@ function $156a3efbc315814c$var$renderNode(node, dispatch, selectedNodes, parentS
|
|
|
192
199
|
else moveText.push(child);
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
|
-
|
|
202
|
+
const match = tag.match;
|
|
203
|
+
const TagComponent = $156a3efbc315814c$var$h("span", {
|
|
204
|
+
onMouseEnter: (e)=>{
|
|
205
|
+
e.stopPropagation();
|
|
206
|
+
},
|
|
196
207
|
className: "highlight",
|
|
197
208
|
style: style,
|
|
198
209
|
onClick: (e)=>{
|
|
@@ -229,10 +240,18 @@ function $156a3efbc315814c$var$renderNode(node, dispatch, selectedNodes, parentS
|
|
|
229
240
|
}
|
|
230
241
|
});
|
|
231
242
|
}
|
|
232
|
-
}, isSelected ? moveText.flat() : children.map((child, i)=>$156a3efbc315814c$var$renderNode(child, dispatch, selectedNodes, isSelected)));
|
|
243
|
+
}, isSelected ? moveText.flat() : children.map((child, i)=>$156a3efbc315814c$var$renderNode(child, dispatch, selectedNodes, isSelected, matchLinks)));
|
|
244
|
+
return matchLinks && match ? $156a3efbc315814c$var$h((0, $aogpP$Popover), {
|
|
245
|
+
autoFocus: false,
|
|
246
|
+
content: $156a3efbc315814c$var$h("div.description", $156a3efbc315814c$var$h($156a3efbc315814c$var$Match, {
|
|
247
|
+
data: match,
|
|
248
|
+
matchLinks: matchLinks
|
|
249
|
+
})),
|
|
250
|
+
interactionKind: "hover"
|
|
251
|
+
}, TagComponent) : TagComponent;
|
|
233
252
|
}
|
|
234
253
|
function $156a3efbc315814c$export$190465bec6b893be(props) {
|
|
235
|
-
const { text: text, allTags: allTags = [], dispatch: dispatch, selectedNodes: selectedNodes, allowOverlap: allowOverlap } = props;
|
|
254
|
+
const { text: text, allTags: allTags = [], dispatch: dispatch, selectedNodes: selectedNodes, allowOverlap: allowOverlap, matchLinks: matchLinks } = props;
|
|
236
255
|
const tree = $156a3efbc315814c$var$nestHighlights(text, allTags);
|
|
237
256
|
const spanRef = (0, $aogpP$useRef)(null);
|
|
238
257
|
(0, $aogpP$useEffect)(()=>{
|
|
@@ -261,9 +280,71 @@ function $156a3efbc315814c$export$190465bec6b893be(props) {
|
|
|
261
280
|
]);
|
|
262
281
|
return $156a3efbc315814c$var$h("span", {
|
|
263
282
|
ref: spanRef
|
|
264
|
-
}, tree.children.map((child, i)=>$156a3efbc315814c$var$renderNode(child, dispatch, selectedNodes, false)));
|
|
283
|
+
}, tree.children.map((child, i)=>$156a3efbc315814c$var$renderNode(child, dispatch, selectedNodes, false, matchLinks)));
|
|
284
|
+
}
|
|
285
|
+
function $156a3efbc315814c$var$Match({ data: data, matchLinks: matchLinks }) {
|
|
286
|
+
if (data.lith_id) return $156a3efbc315814c$var$h((0, $aogpP$DataField), {
|
|
287
|
+
label: "Lithology",
|
|
288
|
+
value: $156a3efbc315814c$var$h((0, $aogpP$LithologyTag), {
|
|
289
|
+
data: {
|
|
290
|
+
name: data.name,
|
|
291
|
+
id: data.lith_id,
|
|
292
|
+
color: data.color
|
|
293
|
+
},
|
|
294
|
+
onClick: (e)=>{
|
|
295
|
+
e.stopPropagation();
|
|
296
|
+
if (matchLinks.lithology) window.open(matchLinks.lithology + "/" + data.lith_id, "_blank");
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
if (data.strat_name_id) return $156a3efbc315814c$var$h("div", [
|
|
301
|
+
$156a3efbc315814c$var$h((0, $aogpP$DataField), {
|
|
302
|
+
label: "Stratigraphic name",
|
|
303
|
+
value: $156a3efbc315814c$var$h((0, $aogpP$LithologyTag), {
|
|
304
|
+
data: {
|
|
305
|
+
name: data.name,
|
|
306
|
+
id: data.strat_name_id,
|
|
307
|
+
color: data.color
|
|
308
|
+
},
|
|
309
|
+
onClick: (e)=>{
|
|
310
|
+
e.stopPropagation();
|
|
311
|
+
if (matchLinks.strat_name) window.open(matchLinks.strat_name + "/" + data.strat_name_id, "_blank");
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
}),
|
|
315
|
+
$156a3efbc315814c$var$h.if(data.concept_id)((0, $aogpP$DataField), {
|
|
316
|
+
label: "Stratigraphic concept",
|
|
317
|
+
value: $156a3efbc315814c$var$h((0, $aogpP$LithologyTag), {
|
|
318
|
+
data: {
|
|
319
|
+
name: data.name,
|
|
320
|
+
id: data.concept_id,
|
|
321
|
+
color: data.color
|
|
322
|
+
},
|
|
323
|
+
onClick: (e)=>{
|
|
324
|
+
e.stopPropagation();
|
|
325
|
+
if (matchLinks.concept) window.open(matchLinks.concept + "/" + data.concept_id, "_blank");
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
})
|
|
329
|
+
]);
|
|
330
|
+
if (data.lith_att_id) return $156a3efbc315814c$var$h((0, $aogpP$DataField), {
|
|
331
|
+
label: "Lithology attribute",
|
|
332
|
+
value: $156a3efbc315814c$var$h((0, $aogpP$LithologyTag), {
|
|
333
|
+
data: {
|
|
334
|
+
name: data.name,
|
|
335
|
+
id: data.lith_att_id
|
|
336
|
+
},
|
|
337
|
+
onClick: (e)=>{
|
|
338
|
+
e.stopPropagation();
|
|
339
|
+
if (matchLinks.lith_att) window.open(matchLinks.lith_att + "/" + data.lith_att_id, "_blank");
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
});
|
|
343
|
+
return $156a3efbc315814c$var$h((0, $aogpP$JSONView), {
|
|
344
|
+
data: data
|
|
345
|
+
});
|
|
265
346
|
}
|
|
266
347
|
|
|
267
348
|
|
|
268
349
|
export {$156a3efbc315814c$export$6e107db9091b8219 as FeedbackText, $156a3efbc315814c$export$190465bec6b893be as HighlightedText};
|
|
269
|
-
//# sourceMappingURL=feedback-components.
|
|
350
|
+
//# sourceMappingURL=feedback-components.f577ebea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAYA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,8EAAK;AAiB5B,SAAS,gCACP,UAAuB,EACvB,aAAuB;IAEvB,IAAI,OAA2B,EAAE;IACjC,yDAAyD;IACzD,MAAM,WAAW,IAAI;IAErB,KAAK,MAAM,aAAa,WAAY;QAClC,oDAAoD;QACpD,IAAI,SAAS,GAAG,CAAC,UAAU,EAAE,GAAG;QAEhC,MAAM,cAAc,oCAAc,WAAW;QAC7C,MAAM,SAAS,+BAAS,WAAW;QACnC,MAAM,WAAW,CAAA,GAAA,yCAAU,EAAE,UAAU,eAAe,EAAE;yBACtD;oBACA;QACF;QAEA,MAAM,MAAM;YACV,OAAO,SAAS,KAAK;YACrB,UAAU;gBACR,SAAS;YACX;YACA,WAAW;gBACT,iBAAiB,SAAS,eAAe;YAC3C;YACA,GAAG,SAAS;YACZ,iBAAiB,SAAS,eAAe;QAC3C;QAEA,KAAK,IAAI,CAAC;QAEV,SAAS,GAAG,CAAC,UAAU,EAAE;IAC3B;IAEA,OAAO;AACT;AAEA,SAAS,+BAAS,GAAc,EAAE,aAAuB;IACvD,OAAO,cAAc,QAAQ,CAAC,IAAI,EAAE;AACtC;AAEA,SAAS,oCAAc,GAAc,EAAE,aAAuB;IAC5D,IAAI,cAAc,MAAM,KAAK,GAAG,OAAO;IACvC,OACE,AAAC,CAAA,cAAc,QAAQ,CAAC,IAAI,EAAE,KAC5B,IAAI,OAAO,EAAE,KAAK,CAAC,IAAM,cAAc,QAA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feedback/text-visualizer.ts"],"sourcesContent":["import { AnnotateBlendTag } from \"react-text-annotate-blend\";\nimport { InternalEntity } from \"./types\";\nimport { TreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { buildHighlights, getTagStyle } from \"../extractions\";\nimport { Highlight } from \"../extractions/types\";\nimport { useEffect, useRef } from \"react\";\nimport { Popover } from \"@blueprintjs/core\";\nimport { DataField, JSONView } from \"@macrostrat/ui-components\";\nimport { LithologyList, LithologyTag } from \"@macrostrat/data-components\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n lineHeight: string;\n allowOverlap?: boolean;\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n}\n\nfunction buildTags(\n highlights: Highlight[],\n selectedNodes: number[],\n): AnnotateBlendTag[] {\n let tags: AnnotateBlendTag[] = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set<number>();\n\n for (const highlight of highlights) {\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n\n const highlighted = isHighlighted(highlight, selectedNodes);\n const active = isActive(highlight, selectedNodes);\n const tagStyle = getTagStyle(highlight.backgroundColor, {\n highlighted,\n active,\n });\n\n const tag = {\n color: tagStyle.color,\n tagStyle: {\n display: \"none\",\n },\n markStyle: {\n backgroundColor: tagStyle.backgroundColor,\n },\n ...highlight,\n backgroundColor: tagStyle.backgroundColor,\n };\n\n tags.push(tag);\n\n entities.add(highlight.id);\n }\n\n return tags;\n}\n\nfunction isActive(tag: Highlight, selectedNodes: number[]) {\n return selectedNodes.includes(tag.id);\n}\n\nfunction isHighlighted(tag: Highlight, selectedNodes: number[]) {\n if (selectedNodes.length === 0) return true;\n return (\n (selectedNodes.includes(tag.id) ||\n tag.parents?.some((d) => selectedNodes.includes(d))) ??\n false\n );\n}\n\nexport function FeedbackText(props: FeedbackTextProps) {\n // Convert input to tags\n const { text, selectedNodes, nodes, dispatch, allowOverlap, matchLinks } =\n props;\n const allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes,\n );\n\n return h(\n \"div.feedback-text-wrapper\",\n {\n tabIndex: 0,\n onKeyDown: (e) => {\n if (e.key === \"Backspace\") {\n dispatch({\n type: \"delete-node\",\n payload: { ids: selectedNodes },\n });\n }\n },\n },\n h(HighlightedText, {\n text,\n allTags,\n allowOverlap,\n dispatch,\n selectedNodes,\n matchLinks,\n }),\n );\n}\n\nfunction createTagFromSelection({\n container,\n}: {\n container: HTMLElement | null;\n}) {\n const selection = window.getSelection();\n if (\n !selection ||\n selection.isCollapsed ||\n selection.rangeCount === 0 ||\n !container\n )\n return null;\n\n const range = selection.getRangeAt(0);\n\n if (\n !container.contains(range.startContainer) ||\n !container.contains(range.endContainer)\n ) {\n return null;\n }\n\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n\n const selectedText = range.toString();\n const end = start + selectedText.length;\n\n return {\n start,\n end,\n text: selectedText,\n };\n}\n\nfunction addTag({ tag, dispatch, text, allTags, allowOverlap }) {\n let { start, end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while (start > 0 && /\\w/.test(text[start - 1])) {\n start--;\n }\n while (end < text.length && /\\w/.test(text[end])) {\n end++;\n }\n }\n\n let payload = { start, end, text: text.slice(start, end) };\n\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n\n const duplicate = allTags.find(\n (t) =>\n t.start === payload.start &&\n (t.end === payload.end || t.end === payload.end - 1),\n );\n\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n\n const inside = allTags.some(\n (t) => t.start <= payload.start && t.end >= payload.end,\n );\n\n const overlap = allTags.some(\n (t) => t.start < payload.end && t.end > payload.start,\n );\n\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n\n dispatch({ type: \"create-node\", payload });\n}\n\nfunction nestHighlights(text: string, tags: AnnotateBlendTag[]) {\n const events: Array<{\n pos: number;\n type: \"start\" | \"end\";\n tag: AnnotateBlendTag;\n }> = [];\n\n for (const tag of tags) {\n events.push({ pos: tag.start, type: \"start\", tag });\n events.push({ pos: tag.end, type: \"end\", tag });\n }\n\n events.sort((a, b) => {\n if (a.pos !== b.pos) return a.pos - b.pos;\n if (a.type === \"end\" && b.type === \"start\") return -1;\n if (a.type === \"start\" && b.type === \"end\") return 1;\n return 0;\n });\n\n const root = { children: [], textStart: 0 };\n const stack = [root];\n let lastPos = 0;\n\n for (const { pos, type, tag } of events) {\n const parent = stack[stack.length - 1];\n\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n\n if (type === \"start\") {\n const newNode = { tag, children: [], textStart: pos };\n parent.children.push(newNode);\n stack.push(newNode);\n } else {\n stack.pop();\n }\n\n lastPos = pos;\n }\n\n if (lastPos < text.length) {\n stack[stack.length - 1].children.push(text.slice(lastPos));\n }\n\n return root;\n}\n\nfunction renderNode(\n node: any,\n dispatch: TreeDispatch,\n selectedNodes: number[],\n parentSelected: boolean,\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n },\n): any {\n if (typeof node === \"string\") return node;\n\n const { tag, children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border: \"1px solid \" + (showBorder ? tag.color : \"transparent\"),\n margin: \"-1px\",\n };\n\n let moveText = [];\n if (isSelected) {\n for (const key in children) {\n if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) {\n moveText.push(child.children[0]);\n } else {\n moveText.push(child);\n }\n }\n }\n }\n\n const match = tag.match;\n\n const TagComponent = h(\n \"span\",\n {\n onMouseEnter: (e: MouseEvent) => {\n e.stopPropagation();\n },\n className: \"highlight\",\n style,\n onClick: (e: MouseEvent) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === tag.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: [tag.id] },\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n\n dispatch({\n type: \"select-range\",\n payload: { ids: [lastSelected, tag.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [tag.id] },\n });\n }\n },\n },\n isSelected\n ? moveText.flat()\n : children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, isSelected, matchLinks),\n ),\n );\n\n return matchLinks && match\n ? h(\n Popover,\n {\n autoFocus: false,\n content: h(\"div.description\", h(Match, { data: match, matchLinks })),\n interactionKind: \"hover\",\n },\n TagComponent,\n )\n : TagComponent;\n}\n\nexport function HighlightedText(props: {\n text: string;\n allTags: AnnotateBlendTag[];\n lineHeight: string;\n allowOverlap?: boolean;\n dispatch: TreeDispatch;\n selectedNodes: number[];\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n}) {\n const {\n text,\n allTags = [],\n dispatch,\n selectedNodes,\n allowOverlap,\n matchLinks,\n } = props;\n\n const tree = nestHighlights(text, allTags);\n\n const spanRef = useRef<HTMLSpanElement>(null);\n\n useEffect(() => {\n const handleMouseUp = () => {\n const tag = createTagFromSelection({ container: spanRef.current });\n if (!tag) return;\n addTag({ tag, dispatch, text, allTags, allowOverlap });\n };\n\n document.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [text, allTags, dispatch, allowOverlap]);\n\n return h(\n \"span\",\n { ref: spanRef },\n tree.children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, false, matchLinks),\n ),\n );\n}\n\nfunction Match({ data, matchLinks }) {\n if (data.lith_id) {\n return h(DataField, {\n label: \"Lithology\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.lithology) {\n window.open(matchLinks.lithology + \"/\" + data.lith_id, \"_blank\");\n }\n },\n }),\n });\n }\n\n if (data.strat_name_id) {\n return h(\"div\", [\n h(DataField, {\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.strat_name_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.strat_name) {\n window.open(\n matchLinks.strat_name + \"/\" + data.strat_name_id,\n \"_blank\",\n );\n }\n },\n }),\n }),\n h.if(data.concept_id)(DataField, {\n label: \"Stratigraphic concept\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.concept_id, color: data.color },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.concept) {\n window.open(matchLinks.concept + \"/\" + data.concept_id, \"_blank\");\n }\n },\n }),\n }),\n ]);\n }\n\n if (data.lith_att_id) {\n return h(DataField, {\n label: \"Lithology attribute\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_att_id },\n onClick: (e) => {\n e.stopPropagation();\n if (matchLinks.lith_att) {\n window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\");\n }\n },\n }),\n });\n }\n\n return h(JSONView, { data });\n}\n"],"names":[],"version":3,"file":"feedback-components.f577ebea.js.map"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ type Highlight = {
|
|
|
24
24
|
borderColor?: string;
|
|
25
25
|
id: number;
|
|
26
26
|
parents?: number[];
|
|
27
|
+
match?: Match;
|
|
27
28
|
};
|
|
28
29
|
export interface EntityExt extends Omit<Entity, "type" | "children"> {
|
|
29
30
|
type: EntityType;
|
|
@@ -35,10 +36,11 @@ declare namespace ThreeColumnLayout {
|
|
|
35
36
|
}
|
|
36
37
|
export function buildHighlights(entities: EntityExt[], parent: EntityExt | null): Highlight[];
|
|
37
38
|
export function enhanceData(extractionData: any, models: any, entityTypes: any): any;
|
|
38
|
-
export function getTagStyle(baseColor: string, options
|
|
39
|
+
export function getTagStyle(baseColor: string, options?: {
|
|
39
40
|
highlighted?: boolean;
|
|
40
41
|
inDarkMode?: boolean;
|
|
41
42
|
active?: boolean;
|
|
43
|
+
showMatches?: boolean;
|
|
42
44
|
}): CSSProperties;
|
|
43
45
|
export function ExtractionContext({ data, entityTypes, matchComponent, }: {
|
|
44
46
|
data: any;
|
|
@@ -78,7 +80,7 @@ export interface GraphData {
|
|
|
78
80
|
}[];
|
|
79
81
|
}
|
|
80
82
|
export function treeToGraph(tree: TreeData[]): GraphData;
|
|
81
|
-
export function FeedbackComponent({ entities, text, model, entityTypes, matchComponent, onSave, allowOverlap, }: {
|
|
83
|
+
export function FeedbackComponent({ entities, text, model, entityTypes, matchComponent, onSave, allowOverlap, matchLinks, }: {
|
|
82
84
|
entities?: any[];
|
|
83
85
|
text: any;
|
|
84
86
|
model: any;
|
|
@@ -86,6 +88,7 @@ export function FeedbackComponent({ entities, text, model, entityTypes, matchCom
|
|
|
86
88
|
matchComponent: any;
|
|
87
89
|
onSave: any;
|
|
88
90
|
allowOverlap: any;
|
|
91
|
+
matchLinks: any;
|
|
89
92
|
}): DOMElement<DOMAttributes<Element>, Element>;
|
|
90
93
|
|
|
91
94
|
//# sourceMappingURL=index.d.ts.map
|