@macrostrat/feedback-components 1.1.0 → 1.1.2
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 +20 -0
- package/dist/esm/{feedback-components.7cd9b6cc.js → feedback-components.3b3a5357.js} +53 -30
- package/dist/esm/feedback-components.3b3a5357.js.map +1 -0
- package/dist/esm/{feedback-components.921dcd46.js → feedback-components.46a7a347.js} +42 -14
- package/dist/esm/feedback-components.46a7a347.js.map +1 -0
- package/dist/esm/{feedback-components.87533431.js → feedback-components.5509fab3.js} +5 -5
- package/dist/esm/{feedback-components.87533431.js.map → feedback-components.5509fab3.js.map} +1 -1
- package/dist/esm/{feedback-components.6a6c8af5.js → feedback-components.586103e8.js} +108 -82
- package/dist/esm/feedback-components.586103e8.js.map +1 -0
- package/dist/esm/{feedback-components.4359bc80.js → feedback-components.95dbe7d7.js} +13 -1
- package/dist/esm/feedback-components.95dbe7d7.js.map +1 -0
- package/dist/esm/{feedback-components.bf5f7cf7.js → feedback-components.fa1d3641.js} +29 -2
- package/dist/esm/feedback-components.fa1d3641.js.map +1 -0
- package/dist/esm/{feedback-components.b7d9b015.css → feedback-components.fb60c70d.css} +38 -14
- package/dist/esm/feedback-components.fb60c70d.css.map +1 -0
- package/dist/esm/index.d.ts +3 -82
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/node/feedback-components.561466ac.js +2 -0
- package/dist/node/feedback-components.561466ac.js.map +1 -0
- package/dist/node/feedback-components.571ee23c.js +2 -0
- package/dist/node/feedback-components.571ee23c.js.map +1 -0
- package/dist/node/{feedback-components.e8aa70b8.js → feedback-components.a39f7653.js} +2 -2
- package/dist/node/{feedback-components.e8aa70b8.js.map → feedback-components.a39f7653.js.map} +1 -1
- package/dist/node/feedback-components.b7946db4.js +2 -0
- package/dist/node/feedback-components.b7946db4.js.map +1 -0
- package/dist/node/feedback-components.c459cc27.js +2 -0
- package/dist/node/feedback-components.c459cc27.js.map +1 -0
- package/dist/node/feedback-components.c88cb37f.css +2 -0
- package/dist/node/feedback-components.c88cb37f.css.map +1 -0
- package/dist/node/feedback-components.ec54a1e7.js +2 -0
- package/dist/node/feedback-components.ec54a1e7.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +3 -3
- package/src/feedback/edit-state.ts +41 -3
- package/src/feedback/feedback.module.sass +30 -10
- package/src/feedback/graph.ts +27 -10
- package/src/feedback/index.ts +146 -112
- package/src/feedback/text-visualizer.ts +43 -17
- package/dist/esm/feedback-components.4359bc80.js.map +0 -1
- package/dist/esm/feedback-components.6a6c8af5.js.map +0 -1
- package/dist/esm/feedback-components.7cd9b6cc.js.map +0 -1
- package/dist/esm/feedback-components.921dcd46.js.map +0 -1
- package/dist/esm/feedback-components.b7d9b015.css.map +0 -1
- package/dist/esm/feedback-components.bf5f7cf7.js.map +0 -1
- package/dist/node/feedback-components.15e1316d.js +0 -2
- package/dist/node/feedback-components.15e1316d.js.map +0 -1
- package/dist/node/feedback-components.65d8488e.js +0 -2
- package/dist/node/feedback-components.65d8488e.js.map +0 -1
- package/dist/node/feedback-components.6681dbde.js +0 -2
- package/dist/node/feedback-components.6681dbde.js.map +0 -1
- package/dist/node/feedback-components.77b6fc89.css +0 -2
- package/dist/node/feedback-components.77b6fc89.css.map +0 -1
- package/dist/node/feedback-components.7caa447a.js +0 -2
- package/dist/node/feedback-components.7caa447a.js.map +0 -1
- package/dist/node/feedback-components.e2f3c4b7.js +0 -2
- package/dist/node/feedback-components.e2f3c4b7.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,Q,C,K,gB,A,Q,Y,C,C,U,C,C,e,C,C,a,C,K,O,A,Q,oB,C,C,Q,C,C,e,C,C,W,C,C,Q,C,C,Y,C,C,W,C,K,mB,A,Q,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,qBACN,QAAS,CAAE,GAAA,CAAG,CAChB,EACF,CACF,GACD,EACF,GAGP,Q,K,iB,C,6C,W","sources":["<anon>","packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["import \"./feedback-components.65d8488e.js\";\nimport \"./feedback-components.e8aa70b8.js\";\nimport \"./feedback-components.6681dbde.js\";\nimport \"./feedback-components.8b03e8be.js\";\nimport \"./feedback-components.e2f3c4b7.js\";\nimport \"./feedback-components.acac789b.js\";\nimport \"./feedback-components.7caa447a.js\";\nimport $ajJMX$macrostrathyper from \"@macrostrat/hyper\";\nimport {Tree as $ajJMX$Tree} from \"react-arborist\";\nimport {useState as $ajJMX$useState, useRef as $ajJMX$useRef, useCallback as $ajJMX$useCallback, useEffect as $ajJMX$useEffect} from \"react\";\nimport {SegmentedControl as $ajJMX$SegmentedControl, Card as $ajJMX$Card, ButtonGroup as $ajJMX$ButtonGroup, Divider as $ajJMX$Divider, Icon as $ajJMX$Icon, Overlay2 as $ajJMX$Overlay2, Popover as $ajJMX$Popover} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $ajJMX$ErrorBoundary, FlexRow as $ajJMX$FlexRow, CancelButton as $ajJMX$CancelButton, SaveButton as $ajJMX$SaveButton, useInDarkMode as $ajJMX$useInDarkMode} from \"@macrostrat/ui-components\";\nimport $ajJMX$useelementdimensions from \"use-element-dimensions\";\nimport {asChromaColor as $ajJMX$asChromaColor} from \"@macrostrat/color-utils\";\nimport {ColorPicker as $ajJMX$ColorPicker} from \"@macrostrat/data-sheet\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $2c86488f2f3c1edd$exports = {};\n\n$parcel$export($2c86488f2f3c1edd$exports, \"FeedbackComponent\", () => $2c86488f2f3c1edd$export$a90600c9da52b40c);\n$parcel$export($2c86488f2f3c1edd$exports, \"treeToGraph\", () => (parcelRequire(\"eedTh\")).treeToGraph);\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\nvar $bQY4Q = parcelRequire(\"bQY4Q\");\n\nvar $3OP12 = parcelRequire(\"3OP12\");\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\n\n\nvar $iKZjQ = parcelRequire(\"iKZjQ\");\n\n\n\nvar $bK9Of = parcelRequire(\"bK9Of\");\n\n\nconst $2c86488f2f3c1edd$var$h = (0, $ajJMX$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2c86488f2f3c1edd$var$setsAreTheSame(a, b) {\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}\nfunction $2c86488f2f3c1edd$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave, lineHeight: lineHeight, allowOverlap: allowOverlap }) {\n // Get the input arguments\n const [state, dispatch] = (0, $eedTh.useUpdatableTree)(entities.map($2c86488f2f3c1edd$var$processEntity), entityTypes);\n const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType, entityTypesMap: entityTypesMap } = state;\n const [{ width: width, height: height }, ref] = (0, $ajJMX$useelementdimensions)();\n return $2c86488f2f3c1edd$var$h((0, $eedTh.TreeDispatchContext).Provider, {\n value: dispatch\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ErrorBoundary), {\n description: \"An error occurred while rendering the feedback text component.\"\n }, $2c86488f2f3c1edd$var$h((0, $3OP12.FeedbackText), {\n text: text,\n dispatch: dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes: selectedNodes,\n lineHeight: lineHeight,\n allowOverlap: allowOverlap\n })),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$FlexRow), {\n alignItems: \"baseline\",\n justifyContent: \"space-between\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $edvRb.ModelInfo), {\n data: model\n }),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SegmentedControl), {\n options: [\n {\n label: \"Tree\",\n value: \"tree\"\n },\n {\n label: \"Graph\",\n value: \"graph\"\n }\n ],\n value: state.viewMode,\n small: true,\n onValueChange (value) {\n console.log(\"Setting view mode\", value);\n dispatch({\n type: \"set-view-mode\",\n payload: value\n });\n }\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.entity-panel\", {\n ref: ref\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Card), {\n className: \"control-panel\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ButtonGroup), {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\"\n }, [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$CancelButton), {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick () {\n dispatch({\n type: \"reset\"\n });\n }\n }, \"Reset\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SaveButton), {\n onClick () {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree\n }, \"Save\")\n ]),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Divider)),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$EntityTypeSelector, {\n entityTypes: entityTypesMap,\n selected: selectedEntityType,\n onChange (payload) {\n dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n },\n dispatch: dispatch,\n tree: tree,\n selectedNodes: selectedNodes,\n isOpen: isSelectingEntityType,\n setOpen: (isOpen)=>dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen\n })\n })\n ]),\n $2c86488f2f3c1edd$var$h.if(state.viewMode == \"tree\")($2c86488f2f3c1edd$var$ManagedSelectionTree, {\n selectedNodes: selectedNodes,\n dispatch: dispatch,\n tree: tree,\n width: width,\n height: height,\n matchComponent: matchComponent\n }),\n $2c86488f2f3c1edd$var$h.if(state.viewMode == \"graph\")((0, $bK9Of.GraphView), {\n tree: tree,\n width: width,\n height: height,\n dispatch: dispatch,\n selectedNodes: selectedNodes\n })\n ])\n ]);\n}\nfunction $2c86488f2f3c1edd$var$processEntity(entity) {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [\n entity.indices\n ],\n children: entity.children?.map($2c86488f2f3c1edd$var$processEntity) ?? []\n };\n}\nfunction $2c86488f2f3c1edd$var$EntityTypeSelector({ entityTypes: entityTypes, selected: selected, isOpen: isOpen, setOpen: setOpen, onChange: onChange, tree: tree, dispatch: dispatch, selectedNodes: selectedNodes = [] }) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n const [inputValue, setInputValue] = (0, $ajJMX$useState)(\"\");\n const types = Array.from(entityTypes.values());\n const items = inputValue !== \"\" ? types.filter((d)=>d.name.toLowerCase().includes(inputValue.toLowerCase())) : types;\n return $2c86488f2f3c1edd$var$h(\"div.entity-type-selector\", [\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeList, {\n types: entityTypes,\n selected: _selected,\n dispatch: dispatch,\n selectedNodes: selectedNodes,\n tree: tree\n }),\n $2c86488f2f3c1edd$var$h((0, $iKZjQ.OmniboxSelector), {\n isOpen: isOpen,\n items: 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}\nfunction $2c86488f2f3c1edd$var$countNodes(tree) {\n if (!tree) return 0;\n let count = 0;\n function recurse(nodes) {\n for (const node of nodes){\n count++;\n if (node.children && Array.isArray(node.children)) recurse(node.children);\n }\n }\n recurse(tree);\n return count;\n}\nfunction $2c86488f2f3c1edd$var$ManagedSelectionTree(props) {\n const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent } = props;\n const ref = (0, $ajJMX$useRef)();\n // Use a ref to track clicks (won't cause rerender)\n const clickedRef = (0, $ajJMX$useRef)(false);\n const _Node = (0, $ajJMX$useCallback)((props)=>$2c86488f2f3c1edd$var$h((0, $bQY4Q.default), {\n ...props,\n matchComponent: matchComponent\n }), [\n matchComponent\n ]);\n // Update Tree selection when selectedNodes change\n (0, $ajJMX$useEffect)(()=>{\n if (ref.current == null) return;\n const selection = new Set(selectedNodes.map((d)=>d.toString()));\n const currentSelection = ref.current.selectedIds;\n if ($2c86488f2f3c1edd$var$setsAreTheSame(selection, currentSelection)) return;\n ref.current.setSelection({\n ids: selectedNodes.map((d)=>d.toString()),\n anchor: null,\n mostRecent: null\n });\n }, [\n selectedNodes\n ]);\n // Mark clicked when user clicks inside the tree container\n function handleClick() {\n clickedRef.current = true;\n }\n const handleSelect = (0, $ajJMX$useCallback)((nodes)=>{\n if (!clickedRef.current) return;\n clickedRef.current = false;\n console.log(\"Clicked nodes:\", nodes);\n let ids = nodes.map((d)=>parseInt(d.id));\n if (ids.length === 1 && ids[0] === selectedNodes[0]) ids = [];\n dispatch({\n type: \"select-node\",\n payload: {\n ids: ids\n }\n });\n }, [\n selectedNodes,\n dispatch\n ]);\n return $2c86488f2f3c1edd$var$h(\"div.selection-tree-wrapper\", {\n onPointerDown: handleClick\n }, $2c86488f2f3c1edd$var$h((0, $ajJMX$Tree), {\n className: \"selection-tree\",\n height: height,\n width: width,\n ref: ref,\n data: tree,\n onMove ({ dragIds: dragIds, parentId: parentId, index: index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d)=>parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index: index\n }\n });\n },\n onDelete ({ ids: ids }) {\n dispatch({\n type: \"delete-node\",\n payload: {\n ids: ids.map((d)=>parseInt(d))\n }\n });\n },\n onSelect: handleSelect,\n children: _Node,\n idAccessor (d) {\n return d.id.toString();\n }\n }));\n}\nfunction $2c86488f2f3c1edd$var$TypeList({ types: types, selected: selected, dispatch: dispatch, selectedNodes: selectedNodes, tree: tree }) {\n const [selectedType, setSelectedType] = (0, $ajJMX$useState)(null);\n const isSelectedNodes = selectedNodes.length > 0;\n const darkMode = (0, $ajJMX$useInDarkMode)();\n const luminance = darkMode ? 0.9 : 0.4;\n return $2c86488f2f3c1edd$var$h(\"div.type-list-container\", [\n $2c86488f2f3c1edd$var$h(\"div.type-list-header\", isSelectedNodes && !selectedType ? \"Change selected nodes to:\" : \"Entity Types\"),\n $2c86488f2f3c1edd$var$h(\"div.type-list\", Array.from(types.values()).map((type)=>$2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeTag, {\n type: type,\n luminance: luminance,\n selectedType: selectedType,\n setSelectedType: setSelectedType,\n dispatch: dispatch,\n tree: tree,\n selectedNodes: selectedNodes,\n selected: selected,\n isSelectedNodes: isSelectedNodes\n }))),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$AddType, {\n dispatch: dispatch\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$collectMatchingIds(tree, id) {\n const ids = [];\n function traverse(node) {\n if (node.type.id === id) ids.push(node.id);\n if (Array.isArray(node.children)) node.children.forEach(traverse);\n }\n tree.forEach(traverse);\n return ids;\n}\nfunction $2c86488f2f3c1edd$var$AddType({ dispatch: dispatch }) {\n const [overlayOpen, setOverlayOpen] = (0, $ajJMX$useState)(false);\n const saveHandler = (payload)=>{\n dispatch({\n type: \"add-entity-type\",\n payload: payload\n });\n setOverlayOpen(false);\n };\n return $2c86488f2f3c1edd$var$h(\"div.add-type-container\", [\n $2c86488f2f3c1edd$var$h(\"div.add-type\", {\n onClick: ()=>setOverlayOpen(true)\n }, [\n $2c86488f2f3c1edd$var$h(\"p.add-type-text\", \"Add new type\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"plus\"\n })\n ]),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeOverlay, {\n setOverlayOpen: setOverlayOpen,\n overlayOpen: overlayOpen,\n title: \"Add New Type\",\n saveHandler: saveHandler\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$EditType({ dispatch: dispatch, type: type }) {\n const [editorOpen, setEditorOpen] = (0, $ajJMX$useState)(false);\n const saveHandler = (payload)=>{\n dispatch({\n type: \"update-entity-type\",\n payload: payload\n });\n setEditorOpen(false);\n };\n return $2c86488f2f3c1edd$var$h(\"div.edit-type\", [\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"edit\",\n className: \"edit-icon\",\n onClick: (e)=>{\n e.stopPropagation();\n setEditorOpen(true);\n }\n }),\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$TypeOverlay, {\n setOverlayOpen: setEditorOpen,\n overlayOpen: editorOpen,\n originalType: type,\n title: \"Edit Type\",\n saveHandler: saveHandler\n })\n ]);\n}\nfunction $2c86488f2f3c1edd$var$TypeOverlay({ setOverlayOpen: setOverlayOpen, overlayOpen: overlayOpen, originalType: originalType, title: title, saveHandler: saveHandler }) {\n const { name: name, description: description, color: color, id: id } = originalType || {};\n const [nameInput, setNameInput] = (0, $ajJMX$useState)(name || \"\");\n const [descriptionInput, setDescriptionInput] = (0, $ajJMX$useState)(description || \"\");\n const [colorInput, setColorInput] = (0, $ajJMX$useState)(color || \"#fff\");\n return $2c86488f2f3c1edd$var$h((0, $ajJMX$Overlay2), {\n isOpen: overlayOpen\n }, $2c86488f2f3c1edd$var$h(\"div.overlay-container\", $2c86488f2f3c1edd$var$h(\"div.add-type-overlay\", [\n $2c86488f2f3c1edd$var$h(\"h2.title\", [\n title,\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"cross\",\n className: \"close-icon\",\n onClick: ()=>{\n setOverlayOpen(false);\n },\n style: {\n cursor: \"pointer\",\n color: \"red\"\n }\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.form-group\", [\n $2c86488f2f3c1edd$var$h(\"div.text-inputs\", [\n $2c86488f2f3c1edd$var$h(\"div.form-field.name\", [\n $2c86488f2f3c1edd$var$h(\"p.label\", \"Name\"),\n $2c86488f2f3c1edd$var$h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type name\",\n onChange: (e)=>setNameInput(e.target.value),\n value: nameInput\n })\n ]),\n $2c86488f2f3c1edd$var$h(\"div.form-field.form-description\", [\n $2c86488f2f3c1edd$var$h(\"p.label\", \"Description\"),\n $2c86488f2f3c1edd$var$h(\"input\", {\n type: \"text\",\n placeholder: \"Enter type description\",\n onChange: (e)=>setDescriptionInput(e.target.value),\n value: descriptionInput\n })\n ])\n ]),\n $2c86488f2f3c1edd$var$h(\"div.form-field.color\", [\n $2c86488f2f3c1edd$var$h(\"p.label\", \"Color\"),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$ColorPicker), {\n value: colorInput,\n onChange: (color)=>setColorInput(color),\n style: {\n width: \"100%\"\n }\n })\n ])\n ]),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$SaveButton), {\n className: \"save-btn\",\n small: true,\n onClick: ()=>saveHandler({\n name: nameInput,\n description: descriptionInput,\n color: colorInput,\n id: id\n })\n }, \"Save changes\")\n ])));\n}\nfunction $2c86488f2f3c1edd$var$TypeTag({ type: type, luminance: luminance, selectedType: selectedType, setSelectedType: setSelectedType, dispatch: dispatch, tree: tree, selectedNodes: selectedNodes, selected: selected, isSelectedNodes: isSelectedNodes }) {\n const { color: color, name: name, id: id, description: description } = type;\n const chromaColor = (0, $ajJMX$asChromaColor)(color ?? \"#000000\");\n const darkMode = (0, $ajJMX$useInDarkMode)();\n const payload = {\n id: id,\n name: name,\n color: color,\n description: description\n };\n const ids = $2c86488f2f3c1edd$var$collectMatchingIds(tree, id);\n const handleTagClick = ()=>{\n if (!isSelectedNodes && selectedType === null) {\n if (ids.length > 0) {\n setSelectedType(type);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n }\n } else if (isSelectedNodes && selectedType === null) {\n if (id === selected?.id && selectedNodes.length > 0) dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: selectedNodes\n }\n });\n else dispatch({\n type: \"select-entity-type\",\n payload: payload\n });\n } else if (isSelectedNodes && selectedType.id === id) {\n setSelectedType(null);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n } else if (isSelectedNodes && selectedType.id !== id) {\n if (ids.length > 0) {\n setSelectedType(type);\n const oldIds = $2c86488f2f3c1edd$var$collectMatchingIds(tree, selectedType.id);\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: oldIds\n }\n });\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: ids\n }\n });\n }\n } else console.warn(\"Unexpected state in TypeTag click handler\", {\n isSelectedNodes: isSelectedNodes,\n selectedType: selectedType,\n selectedNodes: selectedNodes,\n ids: ids,\n id: id,\n selected: selected\n });\n };\n return $2c86488f2f3c1edd$var$h((0, $ajJMX$Popover), {\n autoFocus: false,\n content: $2c86488f2f3c1edd$var$h(\"div.description\", description || \"No description available\"),\n interactionKind: \"hover\"\n }, $2c86488f2f3c1edd$var$h(\"div.type-tag\", {\n onClick: handleTagClick,\n style: {\n cursor: ids.length > 0 || isSelectedNodes && !selectedType ? \"pointer\" : \"\",\n color: darkMode ? \"white\" : \"black\",\n backgroundColor: chromaColor?.luminance(1 - luminance).hex(),\n border: id === selected?.id && selectedNodes.length > 0 ? `1px solid var(--text-emphasized-color)` : `1px solid var(--background-color)`\n }\n }, $2c86488f2f3c1edd$var$h(\"div.type-container\", [\n $2c86488f2f3c1edd$var$h(\"div.type-name\", name),\n $2c86488f2f3c1edd$var$h(\"div.icons\", [\n $2c86488f2f3c1edd$var$h($2c86488f2f3c1edd$var$EditType, {\n dispatch: dispatch,\n type: type\n }),\n $2c86488f2f3c1edd$var$h((0, $ajJMX$Icon), {\n icon: \"cross\",\n className: \"delete-type-icon\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n onClick: (e)=>{\n e.stopPropagation();\n dispatch({\n type: \"delete-entity-type\",\n payload: {\n id: id\n }\n });\n }\n })\n ])\n ])));\n}\n\n\nexport {$2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.15e1316d.js.map\n","import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { Tree, TreeApi } from \"react-arborist\";\nimport Node from \"./node\";\nimport { FeedbackText } from \"./text-visualizer\";\nimport type { InternalEntity, TreeData } from \"./types\";\nimport type { Entity } from \"../extractions\";\nimport { ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef, 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\";\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 lineHeight,\n allowOverlap,\n}) {\n // Get the input arguments\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes,\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(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 lineHeight,\n allowOverlap,\n }),\n ),\n h(FlexRow, { alignItems: \"baseline\", justifyContent: \"space-between\" }, [\n h(ModelInfo, { data: model }),\n h(SegmentedControl, {\n options: [\n { label: \"Tree\", value: \"tree\" },\n { label: \"Graph\", value: \"graph\" },\n ],\n value: state.viewMode,\n small: true,\n onValueChange(value: ViewMode) {\n console.log(\"Setting view mode\", value);\n dispatch({ type: \"set-view-mode\", payload: value });\n },\n }),\n ]),\n h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h(Card, { className: \"control-panel\" }, [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\n },\n [\n h(\n CancelButton,\n {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick() {\n dispatch({ type: \"reset\" });\n },\n },\n \"Reset\",\n ),\n h(\n SaveButton,\n {\n onClick() {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree,\n },\n \"Save\",\n ),\n ],\n ),\n h(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 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\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 handleSelect = useCallback(\n (nodes) => {\n if (!clickedRef.current) return;\n clickedRef.current = false;\n console.log(\"Clicked nodes:\", nodes);\n\n let ids = nodes.map((d) => parseInt(d.id));\n if (ids.length === 1 && ids[0] === selectedNodes[0]) {\n ids = [];\n }\n\n dispatch({ type: \"select-node\", payload: { ids } });\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 chromaColor = asChromaColor(color ?? \"#000000\");\n const darkMode = useInDarkMode();\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: darkMode ? \"white\" : \"black\",\n backgroundColor: chromaColor?.luminance(1 - luminance).hex(),\n border:\n id === selected?.id && selectedNodes.length > 0\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":["$ajJMX$macrostrathyper","Tree","$ajJMX$Tree","useState","$ajJMX$useState","useRef","$ajJMX$useRef","useCallback","$ajJMX$useCallback","useEffect","$ajJMX$useEffect","SegmentedControl","$ajJMX$SegmentedControl","Card","$ajJMX$Card","ButtonGroup","$ajJMX$ButtonGroup","Divider","$ajJMX$Divider","Icon","$ajJMX$Icon","Overlay2","$ajJMX$Overlay2","Popover","$ajJMX$Popover","ErrorBoundary","$ajJMX$ErrorBoundary","FlexRow","$ajJMX$FlexRow","CancelButton","$ajJMX$CancelButton","SaveButton","$ajJMX$SaveButton","useInDarkMode","$ajJMX$useInDarkMode","$ajJMX$useelementdimensions","asChromaColor","$ajJMX$asChromaColor","ColorPicker","$ajJMX$ColorPicker","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$2c86488f2f3c1edd$exports","$2c86488f2f3c1edd$export$a90600c9da52b40c","treeToGraph","$9wFEx","$bQY4Q","$3OP12","$edvRb","$eedTh","$iKZjQ","$bK9Of","$2c86488f2f3c1edd$var$h","styled","a","__esModule","default","entities","text","model","entityTypes","matchComponent","onSave","lineHeight","allowOverlap","state","dispatch","useUpdatableTree","map","$2c86488f2f3c1edd$var$processEntity","selectedNodes","tree","selectedEntityType","isSelectingEntityType","entityTypesMap","width","height","ref","TreeDispatchContext","Provider","value","description","FeedbackText","nodes","alignItems","justifyContent","ModelInfo","data","options","label","viewMode","small","onValueChange","console","log","type","payload","className","vertical","fill","minimal","alignText","icon","disabled","initialTree","onClick","$2c86488f2f3c1edd$var$EntityTypeSelector","selected","onChange","isOpen","setOpen","if","$2c86488f2f3c1edd$var$ManagedSelectionTree","GraphView","entity","term_type","name","txt_range","indices","children","_selected","undefined","inputValue","setInputValue","types","Array","from","values","items","filter","d","toLowerCase","includes","$2c86488f2f3c1edd$var$TypeList","OmniboxSelector","selectedItem","onSelectItem","item","onQueryChange","query","onClose","props","clickedRef","_Node","current","$2c86488f2f3c1edd$var$setsAreTheSame","b","size","has","Set","toString","selectedIds","setSelection","ids","anchor","mostRecent","onPointerDown","onMove","dragIds","parentId","index","parseInt","onDelete","onSelect","length","idAccessor","selectedType","setSelectedType","isSelectedNodes","luminance","darkMode","$2c86488f2f3c1edd$var$TypeTag","$2c86488f2f3c1edd$var$AddType","$2c86488f2f3c1edd$var$collectMatchingIds","forEach","traverse","node","push","isArray","overlayOpen","setOverlayOpen","$2c86488f2f3c1edd$var$TypeOverlay","title","saveHandler","$2c86488f2f3c1edd$var$EditType","editorOpen","setEditorOpen","stopPropagation","originalType","color","nameInput","setNameInput","descriptionInput","setDescriptionInput","colorInput","setColorInput","style","cursor","placeholder","target","chromaColor","autoFocus","content","interactionKind","warn","backgroundColor","hex","border","FeedbackComponent","$330ae695507d96f5$export$8d9dbb7a64bf2a5e"],"version":3,"file":"feedback-components.15e1316d.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e,t,o,n){Object.defineProperty(e,t,{get:o,set:n,enumerable:!0,configurable:!0})}var t,o,n,a,p,r,i,c,l,d,Q,W,X,_,y,s,f,g,b,u,x={};e(x,"add-type",()=>t,e=>t=e),e(x,"add-type-overlay",()=>o,e=>o=e),e(x,"control-panel",()=>n,e=>n=e),e(x,"description",()=>a,e=>a=e),e(x,"entity-panel",()=>p,e=>p=e),e(x,"feedback-component",()=>r,e=>r=e),e(x,"feedback-text",()=>i,e=>i=e),e(x,"feedback-text-wrapper",()=>c,e=>c=e),e(x,"form-group",()=>l,e=>l=e),e(x,"highlight",()=>d,e=>d=e),e(x,"icons",()=>Q,e=>Q=e),e(x,"node",()=>W,e=>W=e),e(x,"overlay-container",()=>X,e=>X=e),e(x,"selected",()=>_,e=>_=e),e(x,"selection-tree",()=>y,e=>y=e),e(x,"text-inputs",()=>s,e=>s=e),e(x,"title",()=>f,e=>f=e),e(x,"type-container",()=>g,e=>g=e),e(x,"type-list",()=>b,e=>b=e),e(x,"type-tag",()=>u,e=>u=e),t="QoX8-W_add-type",o="QoX8-W_add-type-overlay",n="QoX8-W_control-panel",a="QoX8-W_description",p="QoX8-W_entity-panel",r="QoX8-W_feedback-component",i="QoX8-W_feedback-text",c="QoX8-W_feedback-text-wrapper",l="QoX8-W_form-group",d="QoX8-W_highlight",Q="QoX8-W_icons",W="QoX8-W_node",X="QoX8-W_overlay-container",_="QoX8-W_selected",y="QoX8-W_selection-tree",s="QoX8-W_text-inputs",f="QoX8-W_title",g="QoX8-W_type-container",b="QoX8-W_type-list",u="QoX8-W_type-tag";export{x as default};
|
|
2
|
-
//# sourceMappingURL=feedback-components.65d8488e.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,ICAA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,E,E,C,E,E,E,W,I,E,A,G,E,G,E,E,mB,I,E,A,G,E,G,E,E,gB,I,E,A,G,E,G,E,E,c,I,E,A,G,E,G,E,E,e,I,E,A,G,E,G,E,E,qB,I,E,A,G,E,G,E,E,gB,I,E,A,G,E,G,E,E,wB,I,E,A,G,E,G,E,E,a,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,Q,I,E,A,G,E,G,E,E,O,I,E,A,G,E,G,E,E,oB,I,E,A,G,E,G,E,E,W,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,G,E,E,c,I,E,A,G,E,G,E,E,Q,I,E,A,G,E,G,E,E,iB,I,E,A,G,E,G,E,E,Y,I,E,A,G,E,G,E,E,W,I,E,A,G,E,GAnBA,EAA6B,kBAC7B,EAAqC,0BACrC,EAAkC,uBAClC,EAAgC,qBAChC,EAAiC,sBACjC,EAAuC,4BACvC,EAAkC,uBAClC,EAA0C,+BAC1C,EAA+B,oBAC/B,EAA8B,mBAC9B,EAA0B,eAC1B,EAAyB,cACzB,EAAsC,2BACtC,EAA6B,kBAC7B,EAAmC,wBACnC,EAAgC,qBAChC,EAA0B,eAC1B,EAAmC,wBACnC,EAA8B,mBAC9B,EAA6B,yB,K,O","sources":["<anon>","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":["\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\nvar $01ca2f1f49a3a114$exports = {};\n\n$parcel$export($01ca2f1f49a3a114$exports, \"add-type\", () => $01ca2f1f49a3a114$export$cb889aaddfa2926c, (v) => $01ca2f1f49a3a114$export$cb889aaddfa2926c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"add-type-overlay\", () => $01ca2f1f49a3a114$export$5f8f750fd71deeed, (v) => $01ca2f1f49a3a114$export$5f8f750fd71deeed = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"control-panel\", () => $01ca2f1f49a3a114$export$a0a23f31d5562853, (v) => $01ca2f1f49a3a114$export$a0a23f31d5562853 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"description\", () => $01ca2f1f49a3a114$export$6d59db4903f20f7d, (v) => $01ca2f1f49a3a114$export$6d59db4903f20f7d = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"entity-panel\", () => $01ca2f1f49a3a114$export$38f2cd12e45697e, (v) => $01ca2f1f49a3a114$export$38f2cd12e45697e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-component\", () => $01ca2f1f49a3a114$export$579bd45c78bf5510, (v) => $01ca2f1f49a3a114$export$579bd45c78bf5510 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-text\", () => $01ca2f1f49a3a114$export$890489be1870bed5, (v) => $01ca2f1f49a3a114$export$890489be1870bed5 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"feedback-text-wrapper\", () => $01ca2f1f49a3a114$export$6bd0fd0a746c88f, (v) => $01ca2f1f49a3a114$export$6bd0fd0a746c88f = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"form-group\", () => $01ca2f1f49a3a114$export$55a1f87a143fb302, (v) => $01ca2f1f49a3a114$export$55a1f87a143fb302 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"highlight\", () => $01ca2f1f49a3a114$export$e4043f67d36cbb26, (v) => $01ca2f1f49a3a114$export$e4043f67d36cbb26 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"icons\", () => $01ca2f1f49a3a114$export$df03f54e09e486fa, (v) => $01ca2f1f49a3a114$export$df03f54e09e486fa = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"node\", () => $01ca2f1f49a3a114$export$35059013cd4a06db, (v) => $01ca2f1f49a3a114$export$35059013cd4a06db = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"overlay-container\", () => $01ca2f1f49a3a114$export$6a1093e41947f68e, (v) => $01ca2f1f49a3a114$export$6a1093e41947f68e = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selected\", () => $01ca2f1f49a3a114$export$d90250155de6d7e7, (v) => $01ca2f1f49a3a114$export$d90250155de6d7e7 = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"selection-tree\", () => $01ca2f1f49a3a114$export$3ae1b51693c80a9c, (v) => $01ca2f1f49a3a114$export$3ae1b51693c80a9c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"text-inputs\", () => $01ca2f1f49a3a114$export$bc7581b048bdc9d, (v) => $01ca2f1f49a3a114$export$bc7581b048bdc9d = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"title\", () => $01ca2f1f49a3a114$export$fb184b623420d9be, (v) => $01ca2f1f49a3a114$export$fb184b623420d9be = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-container\", () => $01ca2f1f49a3a114$export$b2d17fca990bb66c, (v) => $01ca2f1f49a3a114$export$b2d17fca990bb66c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-list\", () => $01ca2f1f49a3a114$export$915fe2ca68846e4c, (v) => $01ca2f1f49a3a114$export$915fe2ca68846e4c = v);\n$parcel$export($01ca2f1f49a3a114$exports, \"type-tag\", () => $01ca2f1f49a3a114$export$5e5acbc770fb0e4, (v) => $01ca2f1f49a3a114$export$5e5acbc770fb0e4 = v);\nvar $01ca2f1f49a3a114$export$cb889aaddfa2926c;\nvar $01ca2f1f49a3a114$export$5f8f750fd71deeed;\nvar $01ca2f1f49a3a114$export$a0a23f31d5562853;\nvar $01ca2f1f49a3a114$export$6d59db4903f20f7d;\nvar $01ca2f1f49a3a114$export$38f2cd12e45697e;\nvar $01ca2f1f49a3a114$export$579bd45c78bf5510;\nvar $01ca2f1f49a3a114$export$890489be1870bed5;\nvar $01ca2f1f49a3a114$export$6bd0fd0a746c88f;\nvar $01ca2f1f49a3a114$export$55a1f87a143fb302;\nvar $01ca2f1f49a3a114$export$e4043f67d36cbb26;\nvar $01ca2f1f49a3a114$export$df03f54e09e486fa;\nvar $01ca2f1f49a3a114$export$35059013cd4a06db;\nvar $01ca2f1f49a3a114$export$6a1093e41947f68e;\nvar $01ca2f1f49a3a114$export$d90250155de6d7e7;\nvar $01ca2f1f49a3a114$export$3ae1b51693c80a9c;\nvar $01ca2f1f49a3a114$export$bc7581b048bdc9d;\nvar $01ca2f1f49a3a114$export$fb184b623420d9be;\nvar $01ca2f1f49a3a114$export$b2d17fca990bb66c;\nvar $01ca2f1f49a3a114$export$915fe2ca68846e4c;\nvar $01ca2f1f49a3a114$export$5e5acbc770fb0e4;\n$01ca2f1f49a3a114$export$cb889aaddfa2926c = `QoX8-W_add-type`;\n$01ca2f1f49a3a114$export$5f8f750fd71deeed = `QoX8-W_add-type-overlay`;\n$01ca2f1f49a3a114$export$a0a23f31d5562853 = `QoX8-W_control-panel`;\n$01ca2f1f49a3a114$export$6d59db4903f20f7d = `QoX8-W_description`;\n$01ca2f1f49a3a114$export$38f2cd12e45697e = `QoX8-W_entity-panel`;\n$01ca2f1f49a3a114$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;\n$01ca2f1f49a3a114$export$890489be1870bed5 = `QoX8-W_feedback-text`;\n$01ca2f1f49a3a114$export$6bd0fd0a746c88f = `QoX8-W_feedback-text-wrapper`;\n$01ca2f1f49a3a114$export$55a1f87a143fb302 = `QoX8-W_form-group`;\n$01ca2f1f49a3a114$export$e4043f67d36cbb26 = `QoX8-W_highlight`;\n$01ca2f1f49a3a114$export$df03f54e09e486fa = `QoX8-W_icons`;\n$01ca2f1f49a3a114$export$35059013cd4a06db = `QoX8-W_node`;\n$01ca2f1f49a3a114$export$6a1093e41947f68e = `QoX8-W_overlay-container`;\n$01ca2f1f49a3a114$export$d90250155de6d7e7 = `QoX8-W_selected`;\n$01ca2f1f49a3a114$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;\n$01ca2f1f49a3a114$export$bc7581b048bdc9d = `QoX8-W_text-inputs`;\n$01ca2f1f49a3a114$export$fb184b623420d9be = `QoX8-W_title`;\n$01ca2f1f49a3a114$export$b2d17fca990bb66c = `QoX8-W_type-container`;\n$01ca2f1f49a3a114$export$915fe2ca68846e4c = `QoX8-W_type-list`;\n$01ca2f1f49a3a114$export$5e5acbc770fb0e4 = `QoX8-W_type-tag`;\n\n\nexport {$01ca2f1f49a3a114$exports as default};\n//# sourceMappingURL=feedback-components.65d8488e.js.map\n",null],"names":["$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$01ca2f1f49a3a114$export$cb889aaddfa2926c","$01ca2f1f49a3a114$export$5f8f750fd71deeed","$01ca2f1f49a3a114$export$a0a23f31d5562853","$01ca2f1f49a3a114$export$6d59db4903f20f7d","$01ca2f1f49a3a114$export$38f2cd12e45697e","$01ca2f1f49a3a114$export$579bd45c78bf5510","$01ca2f1f49a3a114$export$890489be1870bed5","$01ca2f1f49a3a114$export$6bd0fd0a746c88f","$01ca2f1f49a3a114$export$55a1f87a143fb302","$01ca2f1f49a3a114$export$e4043f67d36cbb26","$01ca2f1f49a3a114$export$df03f54e09e486fa","$01ca2f1f49a3a114$export$35059013cd4a06db","$01ca2f1f49a3a114$export$6a1093e41947f68e","$01ca2f1f49a3a114$export$d90250155de6d7e7","$01ca2f1f49a3a114$export$3ae1b51693c80a9c","$01ca2f1f49a3a114$export$bc7581b048bdc9d","$01ca2f1f49a3a114$export$fb184b623420d9be","$01ca2f1f49a3a114$export$b2d17fca990bb66c","$01ca2f1f49a3a114$export$915fe2ca68846e4c","$01ca2f1f49a3a114$export$5e5acbc770fb0e4","$01ca2f1f49a3a114$exports","default"],"version":3,"file":"feedback-components.65d8488e.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./feedback-components.65d8488e.js";import"./feedback-components.8b03e8be.js";import e from"@macrostrat/hyper";import{useRef as t,useEffect as n}from"react";var r=globalThis,l={},a={},o=r.parcelRequirea149;null==o&&((o=function(e){if(e in l)return l[e].exports;if(e in a){var t=a[e];delete a[e];var n={id:e,exports:{}};return l[e]=n,t.call(n.exports,n,n.exports),n.exports}var r=Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,t){a[e]=t},r.parcelRequirea149=o),o.register;var i=o("9wFEx"),s=o("edvRb");let d=e.styled(i&&i.__esModule?i.default:i);function c(e){let{text:t,selectedNodes:n,nodes:r,dispatch:l,lineHeight:a,allowOverlap:o}=e;return d("div.feedback-text-wrapper",{tabIndex:0,onKeyDown:e=>{"Backspace"===e.key&&l({type:"delete-node",payload:{ids:n}})}},d(p,{text:t,allTags:function(e,t){let n=[],r=new Set;for(let a of e){var l;if(r.has(a.id))continue;let e=function(e,t){return 0===t.length||((t.includes(e.id)||e.parents?.some(e=>t.includes(e)))??!1)}(a,t),o=(l=a,t.includes(l.id)),i=(0,s.getTagStyle)(a.backgroundColor,{highlighted:e,active:o}),d={color:i.color,tagStyle:{display:"none"},markStyle:{backgroundColor:i.backgroundColor},...a,backgroundColor:i.backgroundColor};n.push(d),r.add(a.id)}return n}((0,s.buildHighlights)(r,null),n),lineHeight:a,allowOverlap:o,dispatch:l,selectedNodes:n}))}function p(e){let{text:r,allTags:l=[],lineHeight:a,dispatch:o,selectedNodes:i,allowOverlap:s}=e,c=function(e,t){let n=[];for(let e of t)n.push({pos:e.start,type:"start",tag:e}),n.push({pos:e.end,type:"end",tag:e});n.sort((e,t)=>e.pos!==t.pos?e.pos-t.pos:"end"===e.type&&"start"===t.type?-1:+("start"===e.type&&"end"===t.type));let r={children:[],textStart:0},l=[r],a=0;for(let{pos:t,type:r,tag:o}of n){let n=l[l.length-1];if(t>a){let r=e.slice(a,t);n.children.push(r)}if("start"===r){let e={tag:o,children:[],textStart:t};n.children.push(e),l.push(e)}else l.pop();a=t}return a<e.length&&l[l.length-1].children.push(e.slice(a)),r}(r,l),p=t(null);return n(()=>{let e=()=>{let e=function({container:e}){let t=window.getSelection();if(!t||t.isCollapsed||0===t.rangeCount||!e)return null;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer))return null;let r=document.createRange();r.setStart(e,0),r.setEnd(n.startContainer,n.startOffset);let l=r.toString().length,a=n.toString(),o=l+a.length;return{start:l,end:o,text:a}}({container:p.current});e&&function({tag:e,dispatch:t,text:n,allTags:r,allowOverlap:l}){let{start:a,end:o}=e,i={start:a,end:o,text:n.slice(a,o)};if(""===i.text.trim())return console.log("Blank tag found, ignoring");if(r.find(e=>e.start===i.start&&(e.end===i.end||e.end===i.end-1)))return console.log("Duplicate tag found, ignoring");i.text.endsWith(" ")&&(i.text=i.text.slice(0,-1),i.end-=1);let s=r.some(e=>e.start<=i.start&&e.end>=i.end),d=r.some(e=>e.start<i.end&&e.end>i.start);if((s||d)&&!l)return console.log("Tag is inside another tag, ignoring");t({type:"create-node",payload:i})}({tag:e,dispatch:o,text:r,allTags:l,allowOverlap:s})};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[r,l,o,s]),d("span",{style:{lineHeight:a},ref:p},c.children.map((e,t)=>(function e(t,n,r,l){if("string"==typeof t)return t;let{tag:a,children:o}=t,i=r?.includes(a.id),s={...a,zIndex:l?-1:1},c=[];if(i){for(let e in o)if(Object.prototype.hasOwnProperty.call(o,e)){let t=o[e];t?.tag?c.push(t.children[0]):c.push(t)}}return d("span",{className:"highlight",style:s,onClick:e=>{e.stopPropagation(),n({type:"toggle-node-selected",payload:{ids:[a.id]}})}},i?c.flat():o.map((t,l)=>e(t,n,r,i)))})(e,o,i,!1)))}export{c as FeedbackText,p as HighlightedText};
|
|
2
|
-
//# sourceMappingURL=feedback-components.6681dbde.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,O,oD,A,Q,M,mB,A,Q,U,C,C,a,C,K,O,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,SCSA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAgEhB,SAAS,EAAa,CAAwB,EAEnD,GAAM,CAAA,KAAE,CAAI,CAAA,cAAE,CAAa,CAAA,MAAE,CAAK,CAAA,SAAE,CAAQ,CAAA,WAAE,CAAU,CAAA,aAAE,CAAY,CAAE,CACtE,EAMF,OAAO,EACL,4BACA,CACE,SAAU,EACV,UAAW,AAAC,IACN,AAAU,cAAV,EAAE,GAAG,EACP,EAAS,CACP,KAAM,cACN,QAAS,CAAE,IAAK,CAAc,CAChC,EAEJ,CACF,EACA,EAAE,EAAiB,CACjB,KAAA,EACA,QApBgC,AAxDtC,SACE,CAAuB,CACvB,CAAuB,EAEvB,IAAI,EAA2B,EAAE,CAE3B,EAAW,IAAI,IAErB,IAAK,IAAM,KAAa,EAAY,KA+BpB,EA7Bd,GAAI,EAAS,GAAG,CAAC,EAAU,EAAE,EAAG,SAEhC,IAAM,EAAc,AA+BxB,SAAuB,CAAc,CAAE,CAAuB,SAC5D,AAA6B,IAAzB,E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AU,EAAe,IAGrD,CAAA,EAwCiB,EAAO,EAAU,EAAe,CAAA,IAGjD,Q,K,Y,C,K,e","sources":["<anon>","packages/feedback-components/src/feedback/text-visualizer.ts"],"sourcesContent":["import \"./feedback-components.65d8488e.js\";\nimport \"./feedback-components.8b03e8be.js\";\nimport $h8ona$macrostrathyper from \"@macrostrat/hyper\";\nimport {useRef as $h8ona$useRef, useEffect as $h8ona$useEffect} from \"react\";\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 $9wFEx = parcelRequire(\"9wFEx\");\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nconst $d6cf457c7790c03a$var$h = (0, $h8ona$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $d6cf457c7790c03a$var$buildTags(highlights, selectedNodes) {\n let tags = [];\n // If entity ID has already been seen, don't add it again\n const entities = new Set();\n for (const highlight of highlights){\n // Don't add multiply-linked entities multiple times\n if (entities.has(highlight.id)) continue;\n const highlighted = $d6cf457c7790c03a$var$isHighlighted(highlight, selectedNodes);\n const active = $d6cf457c7790c03a$var$isActive(highlight, selectedNodes);\n const tagStyle = (0, $edvRb.getTagStyle)(highlight.backgroundColor, {\n highlighted: highlighted,\n active: active\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 tags.push(tag);\n entities.add(highlight.id);\n }\n return tags;\n}\nfunction $d6cf457c7790c03a$var$isActive(tag, selectedNodes) {\n return selectedNodes.includes(tag.id);\n}\nfunction $d6cf457c7790c03a$var$isHighlighted(tag, selectedNodes) {\n if (selectedNodes.length === 0) return true;\n return (selectedNodes.includes(tag.id) || tag.parents?.some((d)=>selectedNodes.includes(d))) ?? false;\n}\nfunction $d6cf457c7790c03a$export$6e107db9091b8219(props) {\n // Convert input to tags\n const { text: text, selectedNodes: selectedNodes, nodes: nodes, dispatch: dispatch, lineHeight: lineHeight, allowOverlap: allowOverlap } = props;\n const allTags = $d6cf457c7790c03a$var$buildTags((0, $edvRb.buildHighlights)(nodes, null), selectedNodes);\n return $d6cf457c7790c03a$var$h(\"div.feedback-text-wrapper\", {\n tabIndex: 0,\n onKeyDown: (e)=>{\n if (e.key === \"Backspace\") dispatch({\n type: \"delete-node\",\n payload: {\n ids: selectedNodes\n }\n });\n }\n }, $d6cf457c7790c03a$var$h($d6cf457c7790c03a$export$190465bec6b893be, {\n text: text,\n allTags: allTags,\n lineHeight: lineHeight,\n allowOverlap: allowOverlap,\n dispatch: dispatch,\n selectedNodes: selectedNodes\n }));\n}\nfunction $d6cf457c7790c03a$var$createTagFromSelection({ container: container }) {\n const selection = window.getSelection();\n if (!selection || selection.isCollapsed || selection.rangeCount === 0 || !container) return null;\n const range = selection.getRangeAt(0);\n if (!container.contains(range.startContainer) || !container.contains(range.endContainer)) return null;\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n const selectedText = range.toString();\n const end = start + selectedText.length;\n return {\n start: start,\n end: end,\n text: selectedText\n };\n}\nfunction $d6cf457c7790c03a$var$addTag({ tag: tag, dispatch: dispatch, text: text, allTags: allTags, allowOverlap: allowOverlap }) {\n const { start: start, end: end } = tag;\n let payload = {\n start: start,\n end: end,\n text: text.slice(start, end)\n };\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n const duplicate = allTags.find((t)=>t.start === payload.start && (t.end === payload.end || t.end === payload.end - 1));\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n const inside = allTags.some((t)=>t.start <= payload.start && t.end >= payload.end);\n const overlap = allTags.some((t)=>t.start < payload.end && t.end > payload.start);\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n dispatch({\n type: \"create-node\",\n payload: payload\n });\n}\nfunction $d6cf457c7790c03a$var$nestHighlights(text, tags) {\n const events = [];\n for (const tag of tags){\n events.push({\n pos: tag.start,\n type: \"start\",\n tag: tag\n });\n events.push({\n pos: tag.end,\n type: \"end\",\n tag: 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 const root = {\n children: [],\n textStart: 0\n };\n const stack = [\n root\n ];\n let lastPos = 0;\n for (const { pos: pos, type: type, tag: tag } of events){\n const parent = stack[stack.length - 1];\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n if (type === \"start\") {\n const newNode = {\n tag: tag,\n children: [],\n textStart: pos\n };\n parent.children.push(newNode);\n stack.push(newNode);\n } else stack.pop();\n lastPos = pos;\n }\n if (lastPos < text.length) stack[stack.length - 1].children.push(text.slice(lastPos));\n return root;\n}\nfunction $d6cf457c7790c03a$var$renderNode(node, dispatch, selectedNodes, parentSelected) {\n if (typeof node === \"string\") return node;\n const { tag: tag, children: children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1\n };\n let moveText = [];\n if (isSelected) {\n for(const key in children)if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) moveText.push(child.children[0]);\n else moveText.push(child);\n }\n }\n return $d6cf457c7790c03a$var$h(\"span\", {\n className: \"highlight\",\n style: style,\n onClick: (e)=>{\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n tag.id\n ]\n }\n });\n }\n }, isSelected ? moveText.flat() : children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, isSelected)));\n}\nfunction $d6cf457c7790c03a$export$190465bec6b893be(props) {\n const { text: text, allTags: allTags = [], lineHeight: lineHeight, dispatch: dispatch, selectedNodes: selectedNodes, allowOverlap: allowOverlap } = props;\n const tree = $d6cf457c7790c03a$var$nestHighlights(text, allTags);\n const spanRef = (0, $h8ona$useRef)(null);\n (0, $h8ona$useEffect)(()=>{\n const handleMouseUp = ()=>{\n const tag = $d6cf457c7790c03a$var$createTagFromSelection({\n container: spanRef.current\n });\n if (!tag) return;\n $d6cf457c7790c03a$var$addTag({\n tag: tag,\n dispatch: dispatch,\n text: text,\n allTags: allTags,\n allowOverlap: allowOverlap\n });\n };\n document.addEventListener(\"mouseup\", handleMouseUp);\n return ()=>{\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [\n text,\n allTags,\n dispatch,\n allowOverlap\n ]);\n return $d6cf457c7790c03a$var$h(\"span\", {\n style: {\n lineHeight: lineHeight\n },\n ref: spanRef\n }, tree.children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, false)));\n}\n\n\nexport {$d6cf457c7790c03a$export$6e107db9091b8219 as FeedbackText, $d6cf457c7790c03a$export$190465bec6b893be as HighlightedText};\n//# sourceMappingURL=feedback-components.6681dbde.js.map\n","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\";\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}\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, lineHeight, allowOverlap } =\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 lineHeight,\n allowOverlap,\n dispatch,\n selectedNodes,\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 const { start, end } = tag;\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): any {\n if (typeof node === \"string\") return node;\n\n const { tag, children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\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 return h(\n \"span\",\n {\n className: \"highlight\",\n style,\n onClick: (e: MouseEvent) => {\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [tag.id] },\n });\n },\n },\n isSelected\n ? moveText.flat()\n : children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, isSelected),\n ),\n );\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}) {\n const {\n text,\n allTags = [],\n lineHeight,\n dispatch,\n selectedNodes,\n allowOverlap,\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 { style: { lineHeight }, ref: spanRef },\n tree.children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, false),\n ),\n );\n}\n"],"names":["$h8ona$macrostrathyper","useRef","$h8ona$useRef","useEffect","$h8ona$useEffect","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","$edvRb","$d6cf457c7790c03a$var$h","styled","a","__esModule","default","$d6cf457c7790c03a$export$6e107db9091b8219","props","text","selectedNodes","nodes","dispatch","lineHeight","allowOverlap","tabIndex","onKeyDown","e","key","type","payload","ids","$d6cf457c7790c03a$export$190465bec6b893be","allTags","$d6cf457c7790c03a$var$buildTags","highlights","tags","entities","Set","highlight","tag","has","highlighted","$d6cf457c7790c03a$var$isHighlighted","length","includes","parents","some","d","active","tagStyle","getTagStyle","backgroundColor","color","display","markStyle","push","add","buildHighlights","tree","$d6cf457c7790c03a$var$nestHighlights","events","pos","start","end","sort","b","root","children","textStart","stack","lastPos","parent","slice","newNode","pop","spanRef","handleMouseUp","$d6cf457c7790c03a$var$createTagFromSelection","container","selection","window","getSelection","isCollapsed","rangeCount","range","getRangeAt","contains","startContainer","endContainer","preRange","document","createRange","setStart","setEnd","startOffset","toString","selectedText","current","$d6cf457c7790c03a$var$addTag","trim","console","log","find","t","endsWith","inside","overlap","addEventListener","removeEventListener","style","ref","map","child","i","$d6cf457c7790c03a$var$renderNode","node","parentSelected","isSelected","zIndex","moveText","Object","prototype","hasOwnProperty","className","onClick","stopPropagation","flat","FeedbackText","HighlightedText"],"version":3,"file":"feedback-components.6681dbde.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
.QoX8-W_feedback-component{width:800px;position:relative}.QoX8-W_feedback-component>svg{width:800px}.QoX8-W_node{cursor:pointer}circle{cursor:pointer;border:1px solid #000}.QoX8-W_selected{border:1px solid #fff}.QoX8-W_feedback-text{margin-bottom:2em}.QoX8-W_entity-panel{max-height:600px;position:relative}.QoX8-W_control-panel{padding:.2em .5em;position:absolute;top:1em;right:1em}.QoX8-W_entity-panel{background:var(--panel-secondary-background-color);min-height:100px;box-shadow:0 0 0 1px var(--panel-border-color)inset;border-radius:4px;flex:1;padding:1em}.QoX8-W_selection-tree{margin:-1em 0;padding:1em 0;width:70%!important}.QoX8-W_type-list{grid-template-rows:repeat(10,auto);grid-auto-flow:column;gap:.2em;display:grid}.QoX8-W_type-list .QoX8-W_type-tag{border-radius:.2em;padding:.2em .5em}.QoX8-W_description{max-width:300px;padding:.5em}mark{cursor:pointer;border-radius:.2em;color:#000!important}[role=treeitem]{width:auto!important}.QoX8-W_highlight{cursor:pointer;zIndex:10;border-radius:.2em;padding:.2em 0;position:relative}.QoX8-W_feedback-text-wrapper{z-index:0;position:relative;overflow:visible}.QoX8-W_type-container{justify-content:space-between;align-items:center;column-gap:1em;display:flex}.QoX8-W_add-type{cursor:pointer;justify-content:space-between;align-items:center;padding:0 .5em;display:flex}.QoX8-W_add-type p{margin:0}.QoX8-W_overlay-container{justify-content:center;align-items:center;width:100vw;height:80vh;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay{background-color:var(--secondary-color);border-radius:.2em;flex-direction:column;gap:1em;padding:.5em 1em;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_title{justify-content:space-between;align-items:center;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay h2{margin:0}.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group{gap:3em;display:flex}.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group .QoX8-W_text-inputs{flex-direction:column;gap:1em;display:flex}.QoX8-W_icons{gap:.25em;display:flex}
|
|
2
|
-
/*# sourceMappingURL=feedback-components.77b6fc89.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"ACAA,yDAIE,2CAGF,4BAGA,4CAIA,uCAGA,wCAGA,wDAIA,4EAMA,kLASA,uEAKA,iGAME,wEAIF,iDAIA,4DAKA,qCAGA,+FAOA,2EAKA,oGAMA,6GAOE,4BAGF,yGAOE,0KAQE,+HAKA,+DAGA,2FAIE,qIAKN","sources":["feedback-components.77b6fc89.css","packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".QoX8-W_feedback-component {\n width: 800px;\n position: relative;\n}\n\n.QoX8-W_feedback-component > svg {\n width: 800px;\n}\n\n.QoX8-W_node {\n cursor: pointer;\n}\n\ncircle {\n cursor: pointer;\n border: 1px solid #000;\n}\n\n.QoX8-W_selected {\n border: 1px solid #fff;\n}\n\n.QoX8-W_feedback-text {\n margin-bottom: 2em;\n}\n\n.QoX8-W_entity-panel {\n max-height: 600px;\n position: relative;\n}\n\n.QoX8-W_control-panel {\n padding: .2em .5em;\n position: absolute;\n top: 1em;\n right: 1em;\n}\n\n.QoX8-W_entity-panel {\n background: var(--panel-secondary-background-color);\n min-height: 100px;\n box-shadow: 0 0 0 1px var(--panel-border-color) inset;\n border-radius: 4px;\n flex: 1;\n padding: 1em;\n}\n\n.QoX8-W_selection-tree {\n margin: -1em 0;\n padding: 1em 0;\n width: 70% !important;\n}\n\n.QoX8-W_type-list {\n grid-template-rows: repeat(10, auto);\n grid-auto-flow: column;\n gap: .2em;\n display: grid;\n}\n\n.QoX8-W_type-list .QoX8-W_type-tag {\n border-radius: .2em;\n padding: .2em .5em;\n}\n\n.QoX8-W_description {\n max-width: 300px;\n padding: .5em;\n}\n\nmark {\n cursor: pointer;\n border-radius: .2em;\n color: #000 !important;\n}\n\n[role=\"treeitem\"] {\n width: auto !important;\n}\n\n.QoX8-W_highlight {\n cursor: pointer;\n zIndex: 10;\n border-radius: .2em;\n padding: .2em 0;\n position: relative;\n}\n\n.QoX8-W_feedback-text-wrapper {\n z-index: 0;\n position: relative;\n overflow: visible;\n}\n\n.QoX8-W_type-container {\n justify-content: space-between;\n align-items: center;\n column-gap: 1em;\n display: flex;\n}\n\n.QoX8-W_add-type {\n cursor: pointer;\n justify-content: space-between;\n align-items: center;\n padding: 0 .5em;\n display: flex;\n}\n\n.QoX8-W_add-type p {\n margin: 0;\n}\n\n.QoX8-W_overlay-container {\n justify-content: center;\n align-items: center;\n width: 100vw;\n height: 80vh;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay {\n background-color: var(--secondary-color);\n border-radius: .2em;\n flex-direction: column;\n gap: 1em;\n padding: .5em 1em;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_title {\n justify-content: space-between;\n align-items: center;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay h2 {\n margin: 0;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group {\n gap: 3em;\n display: flex;\n}\n\n.QoX8-W_overlay-container .QoX8-W_add-type-overlay .QoX8-W_form-group .QoX8-W_text-inputs {\n flex-direction: column;\n gap: 1em;\n display: flex;\n}\n\n.QoX8-W_icons {\n gap: .25em;\n display: flex;\n}\n/*# sourceMappingURL=feedback-components.77b6fc89.css.map */\n",".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\ncircle\n cursor: pointer\n border: 1px solid black\n\n.selected\n border: 1px solid white\n \n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n width: 70% !important\n \n.type-list\n display: grid\n grid-auto-flow: column\n grid-template-rows: repeat(10, auto)\n gap: 0.2em\n\n .type-tag\n padding: .2em .5em\n border-radius: .2em\n\n.description\n max-width: 300px\n padding: .5em\n\nmark\n border-radius: .2em\n cursor: pointer\n color: black !important\n\n[role=\"treeitem\"]\n width: auto !important\n\n.highlight\n cursor: pointer\n padding: .2em 0\n border-radius: .2em\n position: relative\n zIndex: 10\n\n.feedback-text-wrapper \n position: relative\n z-index: 0\n overflow: visible\n\n.type-container\n display: flex\n justify-content: space-between\n align-items: center\n column-gap: 1em\n\n.add-type\n cursor: pointer\n display: flex\n justify-content: space-between\n padding: 0 .5em\n align-items: center\n\n p\n margin: 0\n\n.overlay-container\n height: 80vh\n width: 100vw\n display: flex\n justify-content: center\n align-items: center\n\n .add-type-overlay\n background-color: var(--secondary-color)\n padding: .5em 1em\n display: flex\n flex-direction: column\n gap: 1em\n border-radius: .2em\n\n .title\n display: flex\n justify-content: space-between\n align-items: center\n\n h2\n margin: 0\n\n .form-group\n display: flex\n gap: 3em\n\n .text-inputs\n display: flex\n flex-direction: column\n gap: 1em\n\n.icons\n display: flex\n gap: .25em"],"names":[],"version":3,"file":"feedback-components.77b6fc89.css.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./feedback-components.e2f3c4b7.js";import"./feedback-components.8b03e8be.js";import e from"@macrostrat/hyper";import{forceSimulation as r,forceLink as t,forceManyBody as o,forceCenter as i,forceCollide as a}from"d3-force";import{useState as c,useEffect as n}from"react";import{Spinner as s}from"@blueprintjs/core";import{ErrorBoundary as l}from"@macrostrat/ui-components";var d=globalThis,p={},u={},g=d.parcelRequirea149;null==g&&((g=function(e){if(e in p)return p[e].exports;if(e in u){var r=u[e];delete u[e];var t={id:e,exports:{}};return p[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){u[e]=r},d.parcelRequirea149=g),g.register;var h=g("eedTh"),f=g("edvRb");function m(d){let{tree:p,width:u,height:g,dispatch:m,selectedNodes:b}=d,[k,y]=c(null),[x,v]=c(null);return(n(()=>{let{nodes:e,edges:c}=(0,h.treeToGraph)(p),n=new Map(e.map(e=>[e.id,e])),s=c.map(e=>({source:n.get(e.source),target:n.get(e.dest),strength:1})),l=r(e).force("link",t(s)).force("charge",o().strength(-50)).force("center",i(u/2,g/2)).force("collide",a().radius(20)).on("tick",()=>{console.log("Simulation tick")}).on("end",()=>{y(e),v(s)});return()=>{l.stop()}},[p,u,g]),null==k||null==x)?e(s):(console.log("Graph",k,x,b),e(l,{description:"An error occurred while rendering the graph view."},e("div.graph-view",{style:{width:u,height:g}},[e("svg",{width:u,height:g},[e("g.links",x.map(r=>e("line",{x1:r.source.x,y1:r.source.y,x2:r.target.x,y2:r.target.y,stroke:"black"}))),e("g.nodes",k.map(r=>{var t,o,i;let a=b.includes(r.id),c=(t=r.id,o=b,i=k,0===o.length||o.includes(t)||i.some(e=>o.includes(e.id)&&e.children.some(e=>e.id===t))),n=(0,f.getTagStyle)(r.color,{highlighted:c,active:a});return e("circle",{cx:r.x,cy:r.y,r:5,fill:n.backgroundColor||"blue",onClick:e=>{e.stopPropagation(),m({type:"toggle-node-selected",payload:{ids:[r.id]}})},className:a?"selected":"",stroke:a?"white":"black",strokeWidth:2},e("title",r.name||`Node ${r.id}`))}))])])))}export{m as GraphView};
|
|
2
|
-
//# sourceMappingURL=feedback-components.7caa447a.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,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,K,mB,A,Q,iB,C,K,2B,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,CAAE,IAAK,CAAC,EAAE,EAAE,CAAC,AAAC,CACzB,EACF,EACA,UAAW,EAAS,WAAa,GACjC,OAnBW,EAAS,QAAU,QAoB9B,YAAa,CACf,EACA,AAAA,EAAE,QAAS,EAAE,IAAI,EAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAA,CAAE,EAEvC,IAEH,EACF,GAEL,Q,K,S","sources":["<anon>","packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import \"./feedback-components.e2f3c4b7.js\";\nimport \"./feedback-components.8b03e8be.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} from \"@blueprintjs/core\";\nimport {ErrorBoundary as $9bqpz$ErrorBoundary} from \"@macrostrat/ui-components\";\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\n\n\n\n\n\nvar $edvRb = parcelRequire(\"edvRb\");\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 } = props;\n const [nodes, setNodes] = (0, $9bqpz$useState)(null);\n const [links, setLinks] = (0, $9bqpz$useState)(null);\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 (0, $9bqpz$macrostrathyper)((0, $9bqpz$Spinner));\n console.log(\"Graph\", nodes, links, selectedNodes);\n return (0, $9bqpz$macrostrathyper)((0, $9bqpz$ErrorBoundary), {\n description: \"An error occurred while rendering the graph view.\"\n }, (0, $9bqpz$macrostrathyper)(\"div.graph-view\", {\n style: {\n width: width,\n height: height\n }\n }, [\n (0, $9bqpz$macrostrathyper)(\"svg\", {\n width: width,\n height: height\n }, [\n (0, $9bqpz$macrostrathyper)(\"g.links\", links.map((d)=>{\n return (0, $9bqpz$macrostrathyper)(\"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 (0, $9bqpz$macrostrathyper)(\"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 (0, $9bqpz$macrostrathyper)(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: style.backgroundColor || \"blue\",\n onClick: (e)=>{\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n d.id\n ]\n }\n });\n },\n className: active ? \"selected\" : \"\",\n stroke: stroke,\n strokeWidth: 2\n }, (0, $9bqpz$macrostrathyper)(\"title\", d.name || `Node ${d.id}`));\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.7caa447a.js.map\n","import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport h from \"@macrostrat/hyper\";\n\nimport {\n forceSimulation,\n SimulationNodeDatum,\n SimulationLinkDatum,\n forceCenter,\n forceLink,\n forceManyBody,\n forceCollide,\n} from \"d3-force\";\nimport { useEffect, useState } from \"react\";\nimport { Spinner, Popover } from \"@blueprintjs/core\";\nimport { ErrorBoundary } from \"@macrostrat/ui-components\";\nimport { getTagStyle } from \"../extractions\";\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\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(\"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(\n \"circle\",\n {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: style.backgroundColor || \"blue\",\n onClick: (e) => {\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [d.id] },\n });\n },\n className: active ? \"selected\" : \"\",\n stroke,\n strokeWidth: 2,\n },\n h(\"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","ErrorBoundary","$9bqpz$ErrorBoundary","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$eedTh","$edvRb","$8732cb0ae0ae3dfd$export$6a7fe3ef90e8d566","props","tree","width","height","dispatch","selectedNodes","nodes","setNodes","links","setLinks","edges","treeToGraph","nodesMap","Map","map","d","source","get","target","dest","strength","simulation","force","radius","on","console","log","stop","description","style","x1","x","y1","y","x2","y2","stroke","active","includes","highlighted","length","some","node","children","child","getTagStyle","color","cx","cy","r","fill","backgroundColor","onClick","e","stopPropagation","type","payload","ids","className","strokeWidth","name","GraphView"],"version":3,"file":"feedback-components.7caa447a.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{useReducer as e,createContext as t,useContext as l}from"react";import n from"immutability-helper";var r,d=((r={}).Tree="tree",r.Graph="graph",r);function i(t,l){let n=l.values().next().value;return e(o,{initialTree:t,tree:t,selectedNodes:[],entityTypesMap:l,selectedEntityType:n,lastInternalId:0,isSelectingEntityType:!1,viewMode:"tree"})}let a=t(null);function s(){let e=l(a);if(null==e)throw Error("No dispatch context available");return e}function o(e,t){switch(t.type){case"add-entity-type":{let{name:l,description:n,color:r}=t.payload,d=e.lastInternalId-1,i={id:d,name:l,description:""===n?null:n,color:r},a=new Map(e.entityTypesMap);return a.set(d,i),{...e,entityTypesMap:a,selectedEntityType:i,lastInternalId:d}}case"update-entity-type":{let{id:l,name:n,description:r,color:d}=t.payload,i=new Map(e.entityTypesMap),a=i.get(l);if(!a)return console.warn(`Entity type with id ${l} not found`),e;let s={...a,name:n,description:""===r?null:r,color:d};i.set(l,s);let o=h(e.tree,a,s);return{...e,tree:o,entityTypesMap:i,selectedEntityType:s}}case"move-node":let[l,r]=y(e.tree,t.payload.dragIds),d=[];t.payload.parentId&&(d=p(l,t.payload.parentId)).push("children");let i=c(d,{$splice:[[t.payload.index,0,...r]]});return{...e,tree:n(l,i)};case"delete-node":let[a,s]=y(e.tree,t.payload.ids),o=s.flatMap(e=>e.children??[]).filter(e=>!function e(t,l){for(let n of t)if(n.id==l)return!0;else if(n.children&&e(n.children,l))return!0;return!1}(a,e.id));return{...e,tree:[...a,...o],selectedNodes:e.selectedNodes.filter(e=>!t.payload.ids.includes(e))};case"select-node":let{ids:u}=t.payload,T=t.payload.ids.length>0?f(e.tree,u[0])?.type:null;return console.log("Selecting nodes:",u,"Type:",T),{...e,selectedNodes:u,selectedEntityType:T};case"toggle-node-selected":let g=t.payload.ids.filter(t=>!e.selectedNodes.includes(t)),m=e.selectedNodes.filter(e=>!t.payload.ids.includes(e)),$=t.payload.ids.length>0?f(e.tree,t.payload.ids[0])?.type:null;return{...e,selectedNodes:[...m,...g],selectedEntityType:$};case"create-node":let x=e.lastInternalId-1,{text:M,start:I,end:N}=t.payload,w={id:x,name:M,children:[],indices:[I,N],type:e.selectedEntityType};return{...e,tree:[...e.tree,w],selectedNodes:[x],lastInternalId:x};case"delete-entity-type":{console.log("Deleting entity type:",t.payload.id);let{id:l}=t.payload,n=new Map(e.entityTypesMap),r=n.get(l);n.delete(l);let d=n.values().next().value,i=h(e.tree,r,d);return{...e,tree:i,entityTypesMap:n,selectedNodes:[]}}case"toggle-entity-type-selector":return{...e,isSelectingEntityType:t.payload??!e.isSelectingEntityType};case"select-entity-type":{let l=e.tree;for(let r of e.selectedNodes)l=n(l,c(p(e.tree,r),{type:{$set:t.payload}}));return{...e,tree:l,selectedEntityType:t.payload}}case"deselect":return{...e,selectedNodes:[]};case"reset":return{...e,tree:e.initialTree,selectedNodes:[]};case"set-view-mode":return{...e,viewMode:t.payload}}}function c(e,t){let l=t;for(let t=e.length-1;t>=0;t--)l={[e[t]]:l};return l}function p(e,t){for(let l=0;l<e.length;l++)if(e[l].id==t)return[l];else if(e[l].children){let n=p(e[l].children,t);if(null!=n)return[l,"children",...n]}return null}function y(e,t){let l=[],n=[];for(let r of e)if(t.includes(r.id))n.push(r);else{if(r.children){let[e,l]=y(r.children,t);r={...r,children:e},n.push(...l)}l.push(r)}return[l,n]}function u(e){let t=[],l=[],n=new Map;for(let r of e){if(n.has(r.id))continue;let{indices:e,id:d,name:i,type:a,children:s}=r,o={id:d,type:a.id,color:a.color,name:i,txt_range:[e],reasoning:null,match:r.match,children:s};if(n.set(r.id,r),t.push(o),r.children){for(let e of r.children)l.push({source:r.id,dest:e.id});let{nodes:e,edges:n}=u(r.children);t.push(...e),l.push(...n)}}return{nodes:t,edges:l}}function f(e,t){for(let l of e){if(l.id===t)return l;if(l.children){let e=f(l.children,t);if(e)return e}}return null}function h(e,t,l){return e.map(e=>(function(e,t,l){let n=e.type.id===t.id?l:e.type;return{...e,type:n,children:e.children?h(e.children,t,l):[]}})(e,t,l))}export{d as ViewMode,i as useUpdatableTree,a as TreeDispatchContext,s as useTreeDispatch,u as treeToGraph};
|
|
2
|
-
//# sourceMappingURL=feedback-components.e2f3c4b7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,O,c,C,C,iB,C,C,c,C,K,O,A,Q,M,qB,CCKO,IAAK,EAAA,G,CAAA,E,C,G,I,C,O,E,K,C,QAAA,GAgDL,SAAS,EACd,CAAuB,CACvB,CAAoC,EAIpC,IAAM,EAAO,EAAY,MAAM,GAAG,IAAI,GAAG,KAAK,CAE9C,OAAO,AAAA,EAAW,EAAa,CAC7B,YAAA,EACA,KAAM,EACN,cAAe,EAAE,CACjB,eAAgB,EAChB,mBAAoB,EACpB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AAS,EAAa,CAAI,CAAE,CAAE,EAC5B,IAAK,IAAM,KAAQ,EAAM,CACvB,GAAI,EAAK,EAAE,GAAK,EACd,OAAO,EAET,GAAI,EAAK,QAAQ,CAAE,CACjB,IAAM,EAAQ,EAAa,EAAK,QAAQ,CAAE,GAC1C,GAAI,EAAO,OAAO,CACpB,CACF,CACA,OAAO,IACT,CAEA,SAAS,EAAgB,CAAI,CAAE,CAAO,CAAE,CAAW,EACjD,OAAO,EAAK,GAAG,CAAC,AAAC,GAAS,AAG5B,CAAA,SAAwB,CAAI,CAAE,CAAO,CAAE,CAAW,EAChD,IAAM,EAAO,EAAK,IAAI,CAAC,EAAE,GAAK,EAAQ,EAAE,CAAG,EAAc,EAAK,IAAI,CAElE,MAAO,CACL,GAAG,CAAI,CACP,KAAA,EACA,SAAU,EAAK,QAAQ,CACnB,EAAgB,EAAK,QAAQ,CAAE,EAAS,GACxC,EAAE,AACR,CACF,CAAA,EAb2C,EAAM,EAAS,GAC1D,Q,K,Q,C,K,gB,C,K,mB,C,K,e,C,K,W","sources":["<anon>","packages/feedback-components/src/feedback/edit-state.ts"],"sourcesContent":["import {useReducer as $eGztG$useReducer, createContext as $eGztG$createContext, useContext as $eGztG$useContext} from \"react\";\nimport $eGztG$immutabilityhelper from \"immutability-helper\";\n\n\n\nvar $330ae695507d96f5$export$53ec42062883b2d4 = /*#__PURE__*/ function(ViewMode) {\n ViewMode[\"Tree\"] = \"tree\";\n ViewMode[\"Graph\"] = \"graph\";\n return ViewMode;\n}({});\nfunction $330ae695507d96f5$export$911bb4b9c8065d3d(initialTree, entityTypes) {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n return (0, $eGztG$useReducer)($330ae695507d96f5$var$treeReducer, {\n initialTree: initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: \"tree\"\n });\n}\nconst $330ae695507d96f5$export$e5ce04c5b3f58533 = (0, $eGztG$createContext)(null);\nfunction $330ae695507d96f5$export$e1068f2d1c68f87e() {\n const dispatch = (0, $eGztG$useContext)($330ae695507d96f5$export$e5ce04c5b3f58533);\n if (dispatch == null) throw new Error(\"No dispatch context available\");\n return dispatch;\n}\nfunction $330ae695507d96f5$var$treeReducer(state, action) {\n switch(action.type){\n case \"add-entity-type\":\n {\n // Add a new entity type to the map\n const { name: name, description: description, color: color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType = {\n id: newId,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId\n };\n }\n case \"update-entity-type\":\n {\n // Update an existing entity type in the map\n const { id: id, name: name, description: description, color: color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n const updatedType = {\n ...oldType,\n name: name,\n description: description === \"\" ? null : description,\n color: color\n };\n newEntityTypesMap.set(id, updatedType);\n // Update the tree to reflect the new type\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, updatedType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType\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] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.dragIds);\n let keyPath = [];\n if (action.payload.parentId) {\n keyPath = $330ae695507d96f5$var$findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n // Add removed nodes to the new tree at the correct location\n let updateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n $splice: [\n [\n action.payload.index,\n 0,\n ...removedNodes\n ]\n ]\n });\n return {\n ...state,\n tree: (0, $eGztG$immutabilityhelper)(newTree, updateSpec)\n };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = $330ae695507d96f5$var$removeNodes(state.tree, action.payload.ids);\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n const children = _removedNodes.flatMap((node)=>node.children ?? []).filter((child)=>!$330ae695507d96f5$var$nodeIsInTree(newTree2, child.id));\n // Reset the selection\n return {\n ...state,\n tree: [\n ...newTree2,\n ...children\n ],\n selectedNodes: state.selectedNodes.filter((id)=>!action.payload.ids.includes(id))\n };\n case \"select-node\":\n const { ids: ids } = action.payload;\n const type = action.payload.ids.length > 0 ? $330ae695507d96f5$var$findNodeById(state.tree, ids[0])?.type : null;\n console.log(\"Selecting nodes:\", ids, \"Type:\", type);\n return {\n ...state,\n selectedNodes: ids,\n selectedEntityType: type\n };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter((id)=>!state.selectedNodes.includes(id));\n const nodesToKeep = state.selectedNodes.filter((id)=>!action.payload.ids.includes(id));\n const newType = action.payload.ids.length > 0 ? $330ae695507d96f5$var$findNodeById(state.tree, action.payload.ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: [\n ...nodesToKeep,\n ...nodesToAdd\n ],\n selectedEntityType: newType\n };\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text: text, start: start, end: end } = action.payload;\n const node = {\n id: newId,\n name: text,\n children: [],\n indices: [\n start,\n end\n ],\n type: state.selectedEntityType\n };\n return {\n ...state,\n tree: [\n ...state.tree,\n node\n ],\n selectedNodes: [\n newId\n ],\n lastInternalId: newId\n };\n case \"delete-entity-type\":\n {\n // Remove the entity type from the map\n console.log(\"Deleting entity type:\", action.payload.id);\n const { id: id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = $330ae695507d96f5$var$updateTreeTypes(state.tree, oldType, defaultType);\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: []\n };\n }\n /** Entity type selection */ case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType\n };\n case \"select-entity-type\":\n {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes){\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n const nestedSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n type: {\n $set: action.payload\n }\n });\n newTree2 = (0, $eGztG$immutabilityhelper)(newTree2, nestedSpec);\n }\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload\n };\n }\n case \"deselect\":\n return {\n ...state,\n selectedNodes: []\n };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: []\n };\n case \"set-view-mode\":\n return {\n ...state,\n viewMode: action.payload\n };\n }\n}\nfunction $330ae695507d96f5$var$nodeIsInTree(tree, id) {\n for (let node of tree){\n if (node.id == id) return true;\n else if (node.children) {\n if ($330ae695507d96f5$var$nodeIsInTree(node.children, id)) return true;\n }\n }\n return false;\n}\nfunction $330ae695507d96f5$var$buildNestedSpec(keyPath, innerSpec) {\n // Build a nested object from a key path\n let spec = innerSpec;\n for(let i = keyPath.length - 1; i >= 0; i--)spec = {\n [keyPath[i]]: spec\n };\n return spec;\n// Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\nfunction $330ae695507d96f5$var$findNode(tree, id) {\n // Find the index of the node with the given id in the tree, returning the key path\n for(let i = 0; i < tree.length; i++){\n if (tree[i].id == id) return [\n i\n ];\n else if (tree[i].children) {\n let path = $330ae695507d96f5$var$findNode(tree[i].children, id);\n if (path != null) return [\n i,\n \"children\",\n ...path\n ];\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$removeNodes(tree, ids) {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */ let newTree = [];\n let removedNodes = [];\n for (let node of tree)if (ids.includes(node.id)) removedNodes.push(node);\n else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = $330ae695507d96f5$var$removeNodes(node.children, ids);\n node = {\n ...node,\n children: newChildren\n };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n return [\n newTree,\n removedNodes\n ];\n}\nfunction $330ae695507d96f5$export$8d9dbb7a64bf2a5e(tree) {\n // Convert the tree to a graph\n let nodes = [];\n let edges = [];\n const nodeMap = new Map();\n for (let node of tree){\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) continue;\n const { indices: indices, id: id, name: name, type: type, children: children } = node;\n const nodeData = {\n id: id,\n type: type.id,\n color: type.color,\n name: name,\n txt_range: [\n indices\n ],\n reasoning: null,\n match: node.match,\n children: children\n };\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n if (node.children) {\n for (let child of node.children)edges.push({\n source: node.id,\n dest: child.id\n });\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = $330ae695507d96f5$export$8d9dbb7a64bf2a5e(node.children);\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n return {\n nodes: nodes,\n edges: edges\n };\n}\nfunction $330ae695507d96f5$var$findNodeById(tree, id) {\n for (const node of tree){\n if (node.id === id) return node;\n if (node.children) {\n const found = $330ae695507d96f5$var$findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\nfunction $330ae695507d96f5$var$updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node)=>$330ae695507d96f5$var$updateNodeType(node, oldType, defaultType));\n}\nfunction $330ae695507d96f5$var$updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n return {\n ...node,\n type: type,\n children: node.children ? $330ae695507d96f5$var$updateTreeTypes(node.children, oldType, defaultType) : []\n };\n}\n\n\nexport {$330ae695507d96f5$export$53ec42062883b2d4 as ViewMode, $330ae695507d96f5$export$911bb4b9c8065d3d as useUpdatableTree, $330ae695507d96f5$export$e5ce04c5b3f58533 as TreeDispatchContext, $330ae695507d96f5$export$e1068f2d1c68f87e as useTreeDispatch, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.e2f3c4b7.js.map\n","import { TreeData } from \"./types\";\nimport { createContext, Dispatch, useContext, useReducer } from \"react\";\nimport update, { Spec } from \"immutability-helper\";\nimport { EntityType } from \"../extractions/types\";\n\nexport enum ViewMode {\n Tree = \"tree\",\n Graph = \"graph\",\n}\n\ninterface TreeState {\n initialTree: TreeData[];\n tree: TreeData[];\n selectedNodes: number[];\n entityTypesMap: Map<number, EntityType>;\n selectedEntityType: EntityType;\n lastInternalId: number;\n isSelectingEntityType: boolean;\n viewMode: ViewMode;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { 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\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes: [],\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n 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 \"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 console.log(\"Selecting nodes:\", ids, \"Type:\", type);\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 console.log(\"Deleting entity type:\", action.payload.id);\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\nfunction 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"],"names":["useReducer","$eGztG$useReducer","createContext","$eGztG$createContext","useContext","$eGztG$useContext","$eGztG$immutabilityhelper","ViewMode","$330ae695507d96f5$export$53ec42062883b2d4","$330ae695507d96f5$export$911bb4b9c8065d3d","initialTree","entityTypes","type","values","next","value","$330ae695507d96f5$var$treeReducer","tree","selectedNodes","entityTypesMap","selectedEntityType","lastInternalId","isSelectingEntityType","viewMode","$330ae695507d96f5$export$e5ce04c5b3f58533","$330ae695507d96f5$export$e1068f2d1c68f87e","dispatch","Error","state","action","name","description","color","payload","newId","newType","id","newEntityTypesMap","Map","set","oldType","get","console","warn","updatedType","newTree","$330ae695507d96f5$var$updateTreeTypes","removedNodes","$330ae695507d96f5$var$removeNodes","dragIds","keyPath","parentId","$330ae695507d96f5$var$findNode","push","updateSpec","$330ae695507d96f5$var$buildNestedSpec","$splice","index","newTree2","_removedNodes","ids","children","flatMap","node","filter","child","$330ae695507d96f5$var$nodeIsInTree","includes","length","$330ae695507d96f5$var$findNodeById","log","nodesToAdd","nodesToKeep","text","start","end","indices","delete","defaultType","$set","innerSpec","spec","i","path","newChildren","removedChildren","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","nodes","edges","nodeMap","has","nodeData","txt_range","reasoning","match","source","dest","childNodes","childEdges","found","map","$330ae695507d96f5$var$updateNodeType","useUpdatableTree","TreeDispatchContext","useTreeDispatch","treeToGraph"],"version":3,"file":"feedback-components.e2f3c4b7.js.map","sourceRoot":"../../../../"}
|