@macrostrat/feedback-components 1.1.10 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/extractions/index.cjs +201 -0
- package/dist/extractions/index.cjs.map +1 -0
- package/dist/extractions/index.d.ts +30 -0
- package/dist/extractions/index.js +198 -0
- package/dist/extractions/index.js.map +1 -0
- package/dist/extractions/main.module.sass.cjs +12 -0
- package/dist/extractions/main.module.sass.cjs.map +1 -0
- package/dist/extractions/main.module.sass.js +12 -0
- package/dist/extractions/main.module.sass.js.map +1 -0
- package/dist/extractions/types.d.ts +32 -0
- package/dist/feedback/edit-state.cjs +384 -0
- package/dist/feedback/edit-state.cjs.map +1 -0
- package/dist/feedback/edit-state.d.ts +127 -0
- package/dist/feedback/edit-state.js +382 -0
- package/dist/feedback/edit-state.js.map +1 -0
- package/dist/feedback/feedback.module.sass.cjs +47 -0
- package/dist/feedback/feedback.module.sass.cjs.map +1 -0
- package/dist/feedback/feedback.module.sass.js +47 -0
- package/dist/feedback/feedback.module.sass.js.map +1 -0
- package/dist/feedback/graph.cjs +126 -0
- package/dist/feedback/graph.cjs.map +1 -0
- package/dist/feedback/graph.d.ts +9 -0
- package/dist/feedback/graph.js +124 -0
- package/dist/feedback/graph.js.map +1 -0
- package/dist/feedback/index.cjs +350 -0
- package/dist/feedback/index.cjs.map +1 -0
- package/dist/feedback/index.d.ts +15 -0
- package/dist/feedback/index.js +348 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/matches.cjs +246 -0
- package/dist/feedback/matches.cjs.map +1 -0
- package/dist/feedback/matches.d.ts +17 -0
- package/dist/feedback/matches.js +244 -0
- package/dist/feedback/matches.js.map +1 -0
- package/dist/feedback/node.cjs +64 -0
- package/dist/feedback/node.cjs.map +1 -0
- package/dist/feedback/node.d.ts +5 -0
- package/dist/feedback/node.js +63 -0
- package/dist/feedback/node.js.map +1 -0
- package/dist/feedback/text-visualizer.cjs +290 -0
- package/dist/feedback/text-visualizer.cjs.map +1 -0
- package/dist/feedback/text-visualizer.d.ts +36 -0
- package/dist/feedback/text-visualizer.js +288 -0
- package/dist/feedback/text-visualizer.js.map +1 -0
- package/dist/feedback/type-selector/index.cjs +50 -0
- package/dist/feedback/type-selector/index.cjs.map +1 -0
- package/dist/feedback/type-selector/index.d.ts +20 -0
- package/dist/feedback/type-selector/index.js +47 -0
- package/dist/feedback/type-selector/index.js.map +1 -0
- package/dist/feedback/type-selector/main.module.sass.cjs +13 -0
- package/dist/feedback/type-selector/main.module.sass.cjs.map +1 -0
- package/dist/feedback/type-selector/main.module.sass.js +13 -0
- package/dist/feedback/type-selector/main.module.sass.js.map +1 -0
- package/dist/feedback/typelist.cjs +295 -0
- package/dist/feedback/typelist.cjs.map +1 -0
- package/dist/feedback/typelist.d.ts +8 -0
- package/dist/feedback/typelist.js +293 -0
- package/dist/feedback/typelist.js.map +1 -0
- package/dist/feedback/types.d.ts +64 -0
- package/dist/feedback-components.css +343 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -41
- package/src/extractions/index.ts +2 -2
- package/src/feedback/text-visualizer.ts +0 -1
- package/src/feedback/types.ts +2 -2
- package/dist/esm/feedback-components.2364179b.js +0 -287
- package/dist/esm/feedback-components.2364179b.js.map +0 -1
- package/dist/esm/feedback-components.6d32ee91.js +0 -16
- package/dist/esm/feedback-components.6d32ee91.js.map +0 -1
- package/dist/esm/feedback-components.7dd42a9f.js +0 -248
- package/dist/esm/feedback-components.7dd42a9f.js.map +0 -1
- package/dist/esm/feedback-components.7f72e5e9.js +0 -64
- package/dist/esm/feedback-components.7f72e5e9.js.map +0 -1
- package/dist/esm/feedback-components.ad9f284e.js +0 -63
- package/dist/esm/feedback-components.ad9f284e.js.map +0 -1
- package/dist/esm/feedback-components.ba79c0ef.js +0 -204
- package/dist/esm/feedback-components.ba79c0ef.js.map +0 -1
- package/dist/esm/feedback-components.bf93773c.css +0 -17
- package/dist/esm/feedback-components.bf93773c.css.map +0 -1
- package/dist/esm/feedback-components.c6e2c296.js +0 -148
- package/dist/esm/feedback-components.c6e2c296.js.map +0 -1
- package/dist/esm/feedback-components.ca78c2d4.js +0 -287
- package/dist/esm/feedback-components.ca78c2d4.js.map +0 -1
- package/dist/esm/feedback-components.d769ffa5.css +0 -205
- package/dist/esm/feedback-components.d769ffa5.css.map +0 -1
- package/dist/esm/feedback-components.e273ed5b.css +0 -14
- package/dist/esm/feedback-components.e273ed5b.css.map +0 -1
- package/dist/esm/feedback-components.e702eece.js +0 -97
- package/dist/esm/feedback-components.e702eece.js.map +0 -1
- package/dist/esm/feedback-components.edc606bb.js +0 -360
- package/dist/esm/feedback-components.edc606bb.js.map +0 -1
- package/dist/esm/feedback-components.f9850d85.js +0 -19
- package/dist/esm/feedback-components.f9850d85.js.map +0 -1
- package/dist/esm/feedback-components.fa847634.js +0 -453
- package/dist/esm/feedback-components.fa847634.js.map +0 -1
- package/dist/esm/index.d.ts +0 -96
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -1
- package/dist/node/feedback-components.1bd49bf0.js +0 -2
- package/dist/node/feedback-components.1bd49bf0.js.map +0 -1
- package/dist/node/feedback-components.2f391fa4.js +0 -2
- package/dist/node/feedback-components.2f391fa4.js.map +0 -1
- package/dist/node/feedback-components.6a4a1290.js +0 -2
- package/dist/node/feedback-components.6a4a1290.js.map +0 -1
- package/dist/node/feedback-components.70780da4.js +0 -2
- package/dist/node/feedback-components.70780da4.js.map +0 -1
- package/dist/node/feedback-components.794f429b.js +0 -2
- package/dist/node/feedback-components.794f429b.js.map +0 -1
- package/dist/node/feedback-components.83c21466.css +0 -2
- package/dist/node/feedback-components.83c21466.css.map +0 -1
- package/dist/node/feedback-components.97518e90.css +0 -2
- package/dist/node/feedback-components.97518e90.css.map +0 -1
- package/dist/node/feedback-components.9eb1d41a.css +0 -2
- package/dist/node/feedback-components.9eb1d41a.css.map +0 -1
- package/dist/node/feedback-components.acac789b.js +0 -2
- package/dist/node/feedback-components.acac789b.js.map +0 -1
- package/dist/node/feedback-components.c84ff10e.js +0 -2
- package/dist/node/feedback-components.c84ff10e.js.map +0 -1
- package/dist/node/feedback-components.db72d0e1.js +0 -2
- package/dist/node/feedback-components.db72d0e1.js.map +0 -1
- package/dist/node/feedback-components.dc76072c.js +0 -2
- package/dist/node/feedback-components.dc76072c.js.map +0 -1
- package/dist/node/feedback-components.ddd11fe8.js +0 -2
- package/dist/node/feedback-components.ddd11fe8.js.map +0 -1
- package/dist/node/feedback-components.e59a061f.js +0 -2
- package/dist/node/feedback-components.e59a061f.js.map +0 -1
- package/dist/node/feedback-components.feab0bd0.js +0 -2
- package/dist/node/feedback-components.feab0bd0.js.map +0 -1
- package/dist/node/index.js +0 -2
- package/dist/node/index.js.map +0 -1
|
@@ -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,GAuDL,SAAS,EACd,CAAuB,CACvB,CAAoC,CACpC,CAAiB,CACjB,CAAkB,CAClB,EAAuB,EAAE,EAIzB,IAAM,EAAO,EAAY,MAAM,GAAG,IAAI,GAAG,KAAK,CAE1C,EAAgB,EAAE,CAWtB,MARI,AAFJ,CAAA,EAAa,EAAW,GAAG,CAAC,AAAC,GAAS,EAAK,WAAW,GAAtD,EAEe,MAAM,CAAG,GAEtB,CAAA,EAAgB,EACb,OAAO,CAAC,AAAC,GAAS,EAAK,QAAQ,EAAI,EAAE,EACrC,MAAM,CAAC,AAAC,GAAS,EAAW,QAAQ,CAAC,EAAK,IAAI,CAAC,WAAW,KAC1D,GAAG,CAAC,AAAC,GAAS,EAAK,EAAE,CAAA,EAGnB,AAAA,EAAW,EAAa,CAC7B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EAAM,EAAE,AAAC,GAI/C,GAAM,CAAE,MAAO,CAAU,CAAE,MAAO,CAAU,CAAE,CAAG,EAC/C,EAAK,QAAQ,EAEf,EAAM,IAAI,IAAI,GACd,EAAM,IAAI,IAAI,EAChB,CACF,CAEA,MAAO,CAAE,MAAA,EAAO,MAAA,CAAM,CACxB,CAEO,SAAS,EAAa,CAAI,CAAE,CAAE,EACnC,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,Y,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, viewOnly, matchMode, autoSelect = []) {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n let selectedNodes = [];\n autoSelect = autoSelect.map((name)=>name.toLowerCase());\n if (autoSelect.length > 0) // If autoSelect is provided, find the nodes with the matching names\n selectedNodes = initialTree.flatMap((node)=>node.children ?? []).filter((node)=>autoSelect.includes(node.name.toLowerCase())).map((node)=>node.id);\n return (0, $eGztG$useReducer)($330ae695507d96f5$var$treeReducer, {\n initialTree: initialTree,\n tree: initialTree,\n selectedNodes: selectedNodes,\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: \"tree\",\n viewOnly: viewOnly,\n matchMode: matchMode\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 if (action.type === \"toggle-match-mode\") return {\n ...state,\n matchMode: !state.matchMode\n };\n if (action.type === \"toggle-view-only\") return {\n ...state,\n viewOnly: !state.viewOnly,\n selectedNodes: []\n };\n if (state.viewOnly) return $330ae695507d96f5$var$viewMode(state, action);\n if (state.matchMode) return $330ae695507d96f5$var$matchMode(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 \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n // make list of nodes in order\n const allNodes = $330ae695507d96f5$var$flattenAndSort(state.tree);\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node)=>node.id === node1);\n const endIndex = allNodes.findIndex((node)=>node.id === node2);\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node)=>node.id)\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$export$e64eb58334357825(state.tree, ids[0])?.type : null;\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$export$e64eb58334357825(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 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$export$e64eb58334357825(tree, id) {\n for (const node of tree){\n if (node.id === id) return node;\n if (node.children) {\n const found = $330ae695507d96f5$export$e64eb58334357825(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}\nfunction $330ae695507d96f5$var$flattenAndSort(nodes) {\n const result = [];\n function traverse(nodeList) {\n for (const node of nodeList){\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) traverse(node.children);\n }\n }\n traverse(nodes);\n // sort by start\n return result.sort((a, b)=>a.indices[0] - b.indices[0]);\n}\nfunction $330ae695507d96f5$var$matchMode(state, action) {\n if (action.type === \"select-node\" || action.type === \"toggle-node-selected\") {\n const { ids: ids } = action.payload;\n if (ids.length != 1) return state;\n if (state.selectedNodes.length === 1) {\n if (ids[0] === state.selectedNodes[0]) // If the selected node is the same as the current selection, deselect it\n return {\n ...state,\n selectedNodes: []\n };\n }\n const type = action.payload.ids.length > 0 ? $330ae695507d96f5$export$e64eb58334357825(state.tree, ids[0])?.type : null;\n return {\n ...state,\n selectedNodes: ids,\n selectedEntityType: type\n };\n }\n if (action.type === \"add-match\") {\n const { id: id } = action.payload;\n // Find the node path\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n // Build update spec to set the `match` property\n const matchUpdateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n match: {\n $set: action.payload.payload\n }\n });\n const updatedTree = (0, $eGztG$immutabilityhelper)(state.tree, matchUpdateSpec);\n return {\n ...state,\n tree: updatedTree\n };\n }\n if (action.type === \"remove-match\") {\n const { id: id } = action.payload;\n console.log(\"Removing match for node with id:\", id);\n // Find the node path\n const keyPath = $330ae695507d96f5$var$findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n // Build update spec to unset the `match` property\n const matchUpdateSpec = $330ae695507d96f5$var$buildNestedSpec(keyPath, {\n match: {\n $set: null\n }\n });\n const updatedTree = (0, $eGztG$immutabilityhelper)(state.tree, matchUpdateSpec);\n return {\n ...state,\n tree: updatedTree\n };\n }\n return state;\n}\nfunction $330ae695507d96f5$var$viewMode(state, action) {\n if (action.type === \"set-view-mode\") return {\n ...state,\n viewMode: action.payload\n };\n return state;\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$e64eb58334357825 as findNodeById, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=feedback-components.dc76072c.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 viewOnly: boolean;\n matchMode: boolean;\n}\n\ntype TextRange = {\n start: number;\n end: number;\n text: string;\n};\n\ntype TreeAction =\n | {\n type: \"move-node\";\n payload: { dragIds: number[]; parentId: number; index: number };\n }\n | { type: \"delete-node\"; payload: { ids: number[] } }\n | { type: \"select-node\"; payload: { ids: number[] } }\n | { type: \"toggle-node-selected\"; payload: { ids: number[] } }\n | { type: \"set-view-mode\"; payload: ViewMode }\n | { type: \"create-node\"; payload: TextRange }\n | { type: \"select-entity-type\"; payload: EntityType }\n | { type: \"toggle-entity-type-selector\"; payload?: boolean | null }\n | { type: \"deselect\" }\n | { type: \"reset\" }\n | { type: \"delete-entity-type\"; payload: { id: number } }\n | {\n type: \"add-entity-type\";\n payload: { name: string; description: string; color: string };\n }\n | {\n type: \"update-entity-type\";\n payload: { id: number; name: string; description: string; color: string };\n }\n | { type: \"select-range\"; payload: { ids: number[] } }\n | { type: \"add-match\"; payload: { id: number; payload: any } }\n | { type: \"remove-match\"; payload: { id: number } }\n | { type: \"toggle-match-mode\" }\n | { type: \"toggle-view-only\" };\n\nexport type TreeDispatch = Dispatch<TreeAction>;\n\nexport function useUpdatableTree(\n initialTree: TreeData[],\n entityTypes: Map<number, EntityType>,\n viewOnly: boolean,\n matchMode: boolean,\n autoSelect: string[] = [],\n): [TreeState, TreeDispatch] {\n // Get the first entity type\n // issue: grabs second entity instead of selected one\n const type = entityTypes.values().next().value;\n\n let selectedNodes = [];\n autoSelect = autoSelect.map((name) => name.toLowerCase());\n\n if (autoSelect.length > 0) {\n // If autoSelect is provided, find the nodes with the matching names\n selectedNodes = initialTree\n .flatMap((node) => node.children ?? [])\n .filter((node) => autoSelect.includes(node.name.toLowerCase()))\n .map((node) => node.id);\n }\n\n return useReducer(treeReducer, {\n initialTree,\n tree: initialTree,\n selectedNodes,\n entityTypesMap: entityTypes,\n selectedEntityType: type,\n lastInternalId: 0,\n isSelectingEntityType: false,\n viewMode: ViewMode.Tree,\n viewOnly,\n matchMode,\n });\n}\n\nexport const TreeDispatchContext = createContext<TreeDispatch | null>(null);\n\nexport function useTreeDispatch() {\n const dispatch = useContext(TreeDispatchContext);\n if (dispatch == null) {\n throw new Error(\"No dispatch context available\");\n }\n return dispatch;\n}\n\nfunction treeReducer(state: TreeState, action: TreeAction) {\n if (action.type === \"toggle-match-mode\") {\n return { ...state, matchMode: !state.matchMode };\n }\n\n if (action.type === \"toggle-view-only\") {\n return { ...state, viewOnly: !state.viewOnly, selectedNodes: [] };\n }\n\n if (state.viewOnly) return viewMode(state, action);\n\n if (state.matchMode) return matchMode(state, action);\n\n switch (action.type) {\n case \"add-entity-type\": {\n // Add a new entity type to the map\n const { name, description, color } = action.payload;\n const newId = state.lastInternalId - 1;\n const newType: EntityType = {\n id: newId,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n const newEntityTypesMap = new Map(state.entityTypesMap);\n newEntityTypesMap.set(newId, newType);\n\n return {\n ...state,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: newType,\n lastInternalId: newId,\n };\n }\n case \"update-entity-type\": {\n // Update an existing entity type in the map\n const { id, name, description, color } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n\n if (!oldType) {\n console.warn(`Entity type with id ${id} not found`);\n return state;\n }\n\n const updatedType: EntityType = {\n ...oldType,\n name,\n description: description === \"\" ? null : description,\n color,\n };\n\n newEntityTypesMap.set(id, updatedType);\n\n // Update the tree to reflect the new type\n const newTree = updateTreeTypes(state.tree, oldType, updatedType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedEntityType: updatedType,\n };\n }\n case \"select-range\":\n // Select a range of nodes by their IDs\n const payloadIds = action.payload.ids;\n const node1 = payloadIds[0];\n const node2 = payloadIds[1];\n\n // make list of nodes in order\n const allNodes = flattenAndSort(state.tree);\n\n // select all nodes between node1 and node2\n const startIndex = allNodes.findIndex((node) => node.id === node1);\n const endIndex = allNodes.findIndex((node) => node.id === node2);\n\n const selectedNodes = allNodes.slice(startIndex, endIndex + 1);\n\n console.log(\"Selecting range:\", selectedNodes);\n return {\n ...state,\n selectedNodes: selectedNodes.map((node) => node.id),\n };\n\n case \"move-node\":\n // For each node in the tree, if the node is in the dragIds, remove it from the tree and collect it\n const [newTree, removedNodes] = removeNodes(\n state.tree,\n action.payload.dragIds,\n );\n\n let keyPath: (number | \"children\")[] = [];\n if (action.payload.parentId) {\n keyPath = findNode(newTree, action.payload.parentId);\n keyPath.push(\"children\");\n }\n\n // Add removed nodes to the new tree at the correct location\n let updateSpec = buildNestedSpec(keyPath, {\n $splice: [[action.payload.index, 0, ...removedNodes]],\n });\n\n return { ...state, tree: update(newTree, updateSpec) };\n case \"delete-node\":\n // For each node in the tree, if the node is in the ids, remove it from the tree\n const [newTree2, _removedNodes] = removeNodes(\n state.tree,\n action.payload.ids,\n );\n // Get children of the removed nodes\n // If children are not present elsewhere in the tree, insert them\n\n const children = _removedNodes\n .flatMap((node) => node.children ?? [])\n .filter((child) => !nodeIsInTree(newTree2, child.id));\n\n // Reset the selection\n\n return {\n ...state,\n tree: [...newTree2, ...children],\n selectedNodes: state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n ),\n };\n case \"select-node\":\n const { ids } = action.payload;\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n // otherwise fall through to toggle-node-selected for a single ID\n case \"toggle-node-selected\":\n const nodesToAdd = action.payload.ids.filter(\n (id) => !state.selectedNodes.includes(id),\n );\n const nodesToKeep = state.selectedNodes.filter(\n (id) => !action.payload.ids.includes(id),\n );\n\n const newType =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, action.payload.ids[0])?.type\n : null;\n\n return {\n ...state,\n selectedNodes: [...nodesToKeep, ...nodesToAdd],\n selectedEntityType: newType,\n };\n\n case \"create-node\":\n const newId = state.lastInternalId - 1;\n const { text, start, end } = action.payload;\n const node: TreeData = {\n id: newId,\n name: text,\n children: [],\n indices: [start, end],\n type: state.selectedEntityType,\n };\n\n return {\n ...state,\n tree: [...state.tree, node],\n selectedNodes: [newId],\n lastInternalId: newId,\n };\n\n case \"delete-entity-type\": {\n // Remove the entity type from the map\n const { id } = action.payload;\n const newEntityTypesMap = new Map(state.entityTypesMap);\n const oldType = newEntityTypesMap.get(id);\n newEntityTypesMap.delete(id);\n\n const defaultType = newEntityTypesMap.values().next().value;\n const newTree = updateTreeTypes(state.tree, oldType, defaultType);\n\n return {\n ...state,\n tree: newTree,\n entityTypesMap: newEntityTypesMap,\n selectedNodes: [],\n };\n }\n\n /** Entity type selection */\n case \"toggle-entity-type-selector\":\n return {\n ...state,\n isSelectingEntityType: action.payload ?? !state.isSelectingEntityType,\n };\n case \"select-entity-type\": {\n // For each selected node, update the type\n let newTree2 = state.tree;\n for (let id of state.selectedNodes) {\n const keyPath = findNode(state.tree, id);\n const nestedSpec = buildNestedSpec(keyPath, {\n type: { $set: action.payload },\n });\n newTree2 = update(newTree2, nestedSpec);\n }\n\n return {\n ...state,\n tree: newTree2,\n selectedEntityType: action.payload,\n };\n }\n case \"deselect\":\n return { ...state, selectedNodes: [] };\n case \"reset\":\n return {\n ...state,\n tree: state.initialTree,\n selectedNodes: [],\n };\n case \"set-view-mode\":\n return { ...state, viewMode: action.payload };\n }\n}\n\nfunction nodeIsInTree(tree: TreeData[], id: number): boolean {\n for (let node of tree) {\n if (node.id == id) {\n return true;\n } else if (node.children) {\n if (nodeIsInTree(node.children, id)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction buildNestedSpec(\n keyPath: (number | \"children\")[],\n innerSpec: Spec<any>,\n): Spec<TreeData[]> {\n // Build a nested object from a key path\n\n let spec = innerSpec;\n for (let i = keyPath.length - 1; i >= 0; i--) {\n spec = { [keyPath[i]]: spec };\n }\n return spec as any;\n // Since we don't have a \"children\" key at the root, we make the top-level spec an array\n}\n\nfunction findNode(\n tree: TreeData[],\n id: number,\n): (number | \"children\")[] | null {\n // Find the index of the node with the given id in the tree, returning the key path\n for (let i = 0; i < tree.length; i++) {\n if (tree[i].id == id) {\n return [i];\n } else if (tree[i].children) {\n let path = findNode(tree[i].children, id);\n if (path != null) {\n return [i, \"children\", ...path];\n }\n }\n }\n return null;\n}\n\nfunction removeNodes(\n tree: TreeData[],\n ids: number[],\n): [TreeData[], TreeData[]] {\n /** Remove nodes with the given ids from the tree and return the new tree and the removed nodes */\n let newTree: TreeData[] = [];\n let removedNodes: TreeData[] = [];\n\n for (let node of tree) {\n if (ids.includes(node.id)) {\n removedNodes.push(node);\n } else {\n // Recurse into children\n if (node.children) {\n let [newChildren, removedChildren] = removeNodes(node.children, ids);\n node = { ...node, children: newChildren };\n removedNodes.push(...removedChildren);\n }\n newTree.push(node);\n }\n }\n\n return [newTree, removedNodes];\n}\n\nexport interface EntityOutput {\n id: number;\n type: number | null;\n txt_range: number[][];\n name: string;\n match: any | null;\n reasoning: string | null;\n color: string | null;\n children: any[] | null;\n}\n\nexport interface GraphData {\n nodes: EntityOutput[];\n edges: { source: number; dest: number }[];\n}\n\nexport function treeToGraph(tree: TreeData[]): GraphData {\n // Convert the tree to a graph\n let nodes: EntityOutput[] = [];\n let edges: { source: number; dest: number }[] = [];\n const nodeMap = new Map<number, TreeData>();\n\n for (let node of tree) {\n // If we've already found an instance of this node, we don't need to record\n // it again\n if (nodeMap.has(node.id)) {\n continue;\n }\n\n const { indices, id, name, type, children } = node;\n\n const nodeData: EntityOutput = {\n id,\n type: type.id,\n color: type.color,\n name,\n txt_range: [indices],\n reasoning: null,\n match: node.match,\n children,\n };\n\n nodeMap.set(node.id, node);\n nodes.push(nodeData);\n\n if (node.children) {\n for (let child of node.children) {\n edges.push({ source: node.id, dest: child.id });\n }\n\n // Now process the children\n const { nodes: childNodes, edges: childEdges } = treeToGraph(\n node.children,\n );\n nodes.push(...childNodes);\n edges.push(...childEdges);\n }\n }\n\n return { nodes, edges };\n}\n\nexport function findNodeById(tree, id) {\n for (const node of tree) {\n if (node.id === id) {\n return node;\n }\n if (node.children) {\n const found = findNodeById(node.children, id);\n if (found) return found;\n }\n }\n return null;\n}\n\nfunction updateTreeTypes(tree, oldType, defaultType) {\n return tree.map((node) => updateNodeType(node, oldType, defaultType));\n}\n\nfunction updateNodeType(node, oldType, defaultType) {\n const type = node.type.id === oldType.id ? defaultType : node.type;\n\n return {\n ...node,\n type,\n children: node.children\n ? updateTreeTypes(node.children, oldType, defaultType)\n : [],\n };\n}\n\nfunction flattenAndSort(nodes) {\n const result = [];\n\n function traverse(nodeList) {\n for (const node of nodeList) {\n result.push(node);\n if (Array.isArray(node.children) && node.children.length > 0) {\n traverse(node.children);\n }\n }\n }\n\n traverse(nodes);\n\n // sort by start\n return result.sort((a, b) => a.indices[0] - b.indices[0]);\n}\n\nfunction matchMode(state, action) {\n if (action.type === \"select-node\" || action.type === \"toggle-node-selected\") {\n const { ids } = action.payload;\n\n if (ids.length != 1) return state;\n\n if (state.selectedNodes.length === 1) {\n if (ids[0] === state.selectedNodes[0]) {\n // If the selected node is the same as the current selection, deselect it\n return { ...state, selectedNodes: [] };\n }\n }\n\n const type =\n action.payload.ids.length > 0\n ? findNodeById(state.tree, ids[0])?.type\n : null;\n\n return { ...state, selectedNodes: ids, selectedEntityType: type };\n }\n\n if (action.type === \"add-match\") {\n const { id } = action.payload;\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to set the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: action.payload.payload },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n if (action.type === \"remove-match\") {\n const { id } = action.payload;\n\n console.log(\"Removing match for node with id:\", id);\n\n // Find the node path\n const keyPath = findNode(state.tree, id);\n if (!keyPath) {\n console.warn(`Node with id ${id} not found`);\n return state;\n }\n\n // Build update spec to unset the `match` property\n const matchUpdateSpec = buildNestedSpec(keyPath, {\n match: { $set: null },\n });\n\n const updatedTree = update(state.tree, matchUpdateSpec);\n\n return {\n ...state,\n tree: updatedTree,\n };\n }\n\n return state;\n}\n\nfunction viewMode(state, action) {\n if (action.type === \"set-view-mode\") {\n return { ...state, viewMode: action.payload };\n }\n\n return state;\n}\n"],"names":["useReducer","$eGztG$useReducer","createContext","$eGztG$createContext","useContext","$eGztG$useContext","$eGztG$immutabilityhelper","ViewMode","$330ae695507d96f5$export$53ec42062883b2d4","$330ae695507d96f5$export$911bb4b9c8065d3d","initialTree","entityTypes","viewOnly","matchMode","autoSelect","type","values","next","value","selectedNodes","map","name","toLowerCase","length","flatMap","node","children","filter","includes","id","$330ae695507d96f5$var$treeReducer","tree","entityTypesMap","selectedEntityType","lastInternalId","isSelectingEntityType","viewMode","$330ae695507d96f5$export$e5ce04c5b3f58533","$330ae695507d96f5$export$e1068f2d1c68f87e","dispatch","Error","state","action","payload","$330ae695507d96f5$var$matchMode","ids","$330ae695507d96f5$export$e64eb58334357825","keyPath","$330ae695507d96f5$var$findNode","console","warn","matchUpdateSpec","$330ae695507d96f5$var$buildNestedSpec","match","$set","updatedTree","log","description","color","newId","newType","newEntityTypesMap","Map","set","oldType","get","updatedType","newTree","$330ae695507d96f5$var$updateTreeTypes","payloadIds","node1","node2","allNodes","$330ae695507d96f5$var$flattenAndSort","nodes","result","traverse","nodeList","push","Array","isArray","sort","a","b","indices","startIndex","findIndex","endIndex","slice","removedNodes","$330ae695507d96f5$var$removeNodes","dragIds","parentId","updateSpec","$splice","index","newTree2","_removedNodes","child","$330ae695507d96f5$var$nodeIsInTree","nodesToAdd","nodesToKeep","text","start","end","delete","defaultType","innerSpec","spec","i","path","newChildren","removedChildren","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","edges","nodeMap","has","nodeData","txt_range","reasoning","source","dest","childNodes","childEdges","found","$330ae695507d96f5$var$updateNodeType","useUpdatableTree","TreeDispatchContext","useTreeDispatch","findNodeById","treeToGraph"],"version":3,"file":"feedback-components.dc76072c.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./feedback-components.c84ff10e.js";import"./feedback-components.db72d0e1.js";import"./feedback-components.feab0bd0.js";import e from"@macrostrat/hyper";import{useRef as t,useEffect as n}from"react";import{Popover as r}from"@blueprintjs/core";var o=globalThis,a={},l={},i=o.parcelRequirea149;null==i&&((i=function(e){if(e in a)return a[e].exports;if(e in l){var t=l[e];delete l[e];var n={id:e,exports:{}};return a[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){l[e]=t},o.parcelRequirea149=i),i.register;var s=i("9wFEx"),d=i("edvRb"),c=i("jlqgz");let p=e.styled(s&&s.__esModule?s.default:s);function g(e){let{text:t,selectedNodes:n,nodes:r,dispatch:o,allowOverlap:a,matchLinks:l,viewOnly:i}=e;return p("div.feedback-text-wrapper",{tabIndex:0,onKeyDown:e=>{"Backspace"===e.key&&o({type:"delete-node",payload:{ids:n}})}},p(u,{text:t,allTags:function(e,t){let n=[],r=new Set;for(let a of e){var o;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),l=(o=a,t.includes(o.id)),i=(0,d.getTagStyle)(a.backgroundColor,{highlighted:e,active:l}),s={color:i.color,tagStyle:{display:"none"},markStyle:{backgroundColor:i.backgroundColor},...a,backgroundColor:i.backgroundColor};n.push(s),r.add(a.id)}return n}((0,d.buildHighlights)(r,null),n),allowOverlap:a,dispatch:o,selectedNodes:n,viewOnly:i,matchLinks:l}))}function u(e){let{text:o,allTags:a=[],dispatch:l,selectedNodes:i,allowOverlap:s,matchLinks:d,viewOnly:g}=e,u=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},o=[r],a=0;for(let{pos:t,type:r,tag:l}of n){let n=o[o.length-1];if(t>a){let r=e.slice(a,t);n.children.push(r)}if("start"===r){let e={tag:l,children:[],textStart:t};n.children.push(e),o.push(e)}else o.pop();a=t}return a<e.length&&o[o.length-1].children.push(e.slice(a)),r}(o,a),f=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 o=r.toString().length,a=n.toString(),l=o+a.length;return{start:o,end:l,text:a}}({container:f.current});e&&function({tag:e,dispatch:t,text:n,allTags:r,allowOverlap:o}){let{start:a,end:l}=e;if(" "!=n[l-1]){for(;a>0&&/\w/.test(n[a-1]);)a--;for(;l<n.length&&/\w/.test(n[l]);)l++}let i={start:a,end:l,text:n.slice(a,l)};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)&&!o)return console.log("Tag is inside another tag, ignoring");t({type:"create-node",payload:i})}({tag:e,dispatch:l,text:o,allTags:a,allowOverlap:s})};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[o,a,l,s]),p("span",{ref:f},u.children.map((e,t)=>(function e(t,n,o,a,l,i){if("string"==typeof t)return t;let{tag:s,children:d}=t,g=o?.includes(s.id),u=0===o.length||g,f=s.match,h={...s,zIndex:a?-1:1,border:"1px solid "+(void 0!=f&&l?"orange":u?s.color:"transparent"),margin:"-1px"},m=[];if(g){for(let e in d)if(Object.prototype.hasOwnProperty.call(d,e)){let t=d[e];t?.tag?m.push(t.children[0]):m.push(t)}}let y=p("span",{onMouseEnter:e=>{e.stopPropagation()},className:"highlight"+(!i||f?" clickable":""),style:h,onClick:e=>{e.stopPropagation(),e.ctrlKey||e.metaKey||o[0]===s.id&&1===o.length?(e.stopPropagation(),n({type:"toggle-node-selected",payload:{ids:[s.id]}})):e.shiftKey&&o.length>0?n({type:"select-range",payload:{ids:[o[o.length-1],s.id]}}):n({type:"select-node",payload:{ids:[s.id]}})}},g?m.flat():d.map((t,r)=>e(t,n,o,g,l,i)));return i&&f?p(r,{content:p("div.match-link",p(c.MatchTag,{data:f,matchLinks:l})),interactionKind:"hover"},y):y})(e,l,i,!1,d,g)))}export{g as FeedbackText,u as HighlightedText};
|
|
2
|
-
//# sourceMappingURL=feedback-components.ddd11fe8.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,O,oD,A,O,oD,A,Q,M,mB,A,Q,U,C,C,a,C,K,O,A,Q,W,C,K,mB,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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AAE,CAAC,AAAC,CAC3B,IACS,EAAE,QAAQ,EAAI,EAAc,MAAM,CAAG,EAI9C,EAAS,CACP,KAAM,eACN,QAAS,CAAE,IAAK,CAJG,CAAa,CAAC,EAAc,MAAM,CAAG,EAAE,CAI3B,EAAI,EAAE,CAAC,AAAC,CACzC,GAEA,EAAS,CACP,KAAM,cACN,QAAS,CAAE,IAAK,CAAC,EAAI,EAAE,CAAC,AAAC,CAC3B,EAEJ,CACF,EACA,EACI,EAAS,IAAI,GACb,EAAS,GAAG,CAAC,CAAC,EAAY,IACxB,EACE,EACA,EACA,EACA,EACA,EACA,YAKV,AAAI,GAAY,EACP,EACL,EACA,CACE,QAAS,EAAE,iBAAkB,EAAE,EAAA,QAAO,CAAG,CAAE,KAAM,EAAO,WAAA,CAAW,IACnE,gBAAiB,OACnB,EACA,GAIG,CACT,CAAA,EA+CiB,EAAO,EAAU,EAAe,CAAA,EAAO,EAAY,IAGpE,Q,K,Y,C,K,e","sources":["<anon>","packages/feedback-components/src/feedback/text-visualizer.ts"],"sourcesContent":["import \"./feedback-components.c84ff10e.js\";\nimport \"./feedback-components.db72d0e1.js\";\nimport \"./feedback-components.feab0bd0.js\";\nimport $h8ona$macrostrathyper from \"@macrostrat/hyper\";\nimport {useRef as $h8ona$useRef, useEffect as $h8ona$useEffect} from \"react\";\nimport {Popover as $h8ona$Popover} from \"@blueprintjs/core\";\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\n\n\nvar $jlqgz = parcelRequire(\"jlqgz\");\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, allowOverlap: allowOverlap, matchLinks: matchLinks, viewOnly: viewOnly } = 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 allowOverlap: allowOverlap,\n dispatch: dispatch,\n selectedNodes: selectedNodes,\n viewOnly: viewOnly,\n matchLinks: matchLinks\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 let { start: start, end: end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while(start > 0 && /\\w/.test(text[start - 1]))start--;\n while(end < text.length && /\\w/.test(text[end]))end++;\n }\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, matchLinks, viewOnly) {\n if (typeof node === \"string\") return node;\n const { tag: tag, children: children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n const match = tag.match;\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border: \"1px solid \" + (match != undefined && matchLinks ? \"orange\" : showBorder ? tag.color : \"transparent\"),\n margin: \"-1px\"\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 const tagComponent = $d6cf457c7790c03a$var$h(\"span\", {\n onMouseEnter: (e)=>{\n e.stopPropagation();\n },\n className: \"highlight\" + (!viewOnly || match ? \" clickable\" : \"\"),\n style: style,\n onClick: (e)=>{\n e.stopPropagation();\n if (e.ctrlKey || e.metaKey || selectedNodes[0] === tag.id && selectedNodes.length === 1) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: {\n ids: [\n tag.id\n ]\n }\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n dispatch({\n type: \"select-range\",\n payload: {\n ids: [\n lastSelected,\n tag.id\n ]\n }\n });\n } else dispatch({\n type: \"select-node\",\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, matchLinks, viewOnly)));\n if (viewOnly && match) return $d6cf457c7790c03a$var$h((0, $h8ona$Popover), {\n content: $d6cf457c7790c03a$var$h(\"div.match-link\", $d6cf457c7790c03a$var$h((0, $jlqgz.MatchTag), {\n data: match,\n matchLinks: matchLinks\n })),\n interactionKind: \"hover\"\n }, tagComponent);\n return tagComponent;\n}\nfunction $d6cf457c7790c03a$export$190465bec6b893be(props) {\n const { text: text, allTags: allTags = [], dispatch: dispatch, selectedNodes: selectedNodes, allowOverlap: allowOverlap, matchLinks: matchLinks, viewOnly: viewOnly } = 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 ref: spanRef\n }, tree.children.map((child, i)=>$d6cf457c7790c03a$var$renderNode(child, dispatch, selectedNodes, false, matchLinks, viewOnly)));\n}\n\n\nexport {$d6cf457c7790c03a$export$6e107db9091b8219 as FeedbackText, $d6cf457c7790c03a$export$190465bec6b893be as HighlightedText};\n//# sourceMappingURL=feedback-components.ddd11fe8.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\";\nimport { Popover } from \"@blueprintjs/core\";\nimport { MatchTag } from \"./matches\";\nimport { data } from \"packages/feedback-components/stories/test-data\";\n\nconst h = hyper.styled(styles);\n\nexport interface FeedbackTextProps {\n text: string;\n selectedNodes: number[];\n nodes: InternalEntity[];\n updateNodes: (nodes: string[]) => void;\n dispatch: TreeDispatch;\n lineHeight: string;\n allowOverlap?: boolean;\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n viewOnly?: 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 {\n text,\n selectedNodes,\n nodes,\n dispatch,\n allowOverlap,\n matchLinks,\n viewOnly,\n } = props;\n const allTags: AnnotateBlendTag[] = buildTags(\n buildHighlights(nodes, null),\n selectedNodes,\n );\n\n return h(\n \"div.feedback-text-wrapper\",\n {\n tabIndex: 0,\n onKeyDown: (e) => {\n if (e.key === \"Backspace\") {\n dispatch({\n type: \"delete-node\",\n payload: { ids: selectedNodes },\n });\n }\n },\n },\n h(HighlightedText, {\n text,\n allTags,\n allowOverlap,\n dispatch,\n selectedNodes,\n viewOnly,\n matchLinks,\n }),\n );\n}\n\nfunction createTagFromSelection({\n container,\n}: {\n container: HTMLElement | null;\n}) {\n const selection = window.getSelection();\n if (\n !selection ||\n selection.isCollapsed ||\n selection.rangeCount === 0 ||\n !container\n )\n return null;\n\n const range = selection.getRangeAt(0);\n\n if (\n !container.contains(range.startContainer) ||\n !container.contains(range.endContainer)\n ) {\n return null;\n }\n\n const preRange = document.createRange();\n preRange.setStart(container, 0);\n preRange.setEnd(range.startContainer, range.startOffset);\n const start = preRange.toString().length;\n\n const selectedText = range.toString();\n const end = start + selectedText.length;\n\n return {\n start,\n end,\n text: selectedText,\n };\n}\n\nfunction addTag({ tag, dispatch, text, allTags, allowOverlap }) {\n let { start, end } = tag;\n // snap to text\n if (text[end - 1] != \" \") {\n // double clicking word overselects by one, shouldn't increase to next word\n while (start > 0 && /\\w/.test(text[start - 1])) {\n start--;\n }\n while (end < text.length && /\\w/.test(text[end])) {\n end++;\n }\n }\n\n let payload = { start, end, text: text.slice(start, end) };\n\n if (payload.text.trim() === \"\") {\n console.log(\"Blank tag found, ignoring\");\n return;\n }\n\n const duplicate = allTags.find(\n (t) =>\n t.start === payload.start &&\n (t.end === payload.end || t.end === payload.end - 1),\n );\n\n if (duplicate) {\n console.log(\"Duplicate tag found, ignoring\");\n return;\n }\n\n if (payload.text.endsWith(\" \")) {\n payload.text = payload.text.slice(0, -1);\n payload.end -= 1;\n }\n\n const inside = allTags.some(\n (t) => t.start <= payload.start && t.end >= payload.end,\n );\n\n const overlap = allTags.some(\n (t) => t.start < payload.end && t.end > payload.start,\n );\n\n if ((inside || overlap) && !allowOverlap) {\n console.log(\"Tag is inside another tag, ignoring\");\n return;\n }\n\n dispatch({ type: \"create-node\", payload });\n}\n\nfunction nestHighlights(text: string, tags: AnnotateBlendTag[]) {\n const events: Array<{\n pos: number;\n type: \"start\" | \"end\";\n tag: AnnotateBlendTag;\n }> = [];\n\n for (const tag of tags) {\n events.push({ pos: tag.start, type: \"start\", tag });\n events.push({ pos: tag.end, type: \"end\", tag });\n }\n\n events.sort((a, b) => {\n if (a.pos !== b.pos) return a.pos - b.pos;\n if (a.type === \"end\" && b.type === \"start\") return -1;\n if (a.type === \"start\" && b.type === \"end\") return 1;\n return 0;\n });\n\n const root = { children: [], textStart: 0 };\n const stack = [root];\n let lastPos = 0;\n\n for (const { pos, type, tag } of events) {\n const parent = stack[stack.length - 1];\n\n if (pos > lastPos) {\n const slice = text.slice(lastPos, pos);\n parent.children.push(slice);\n }\n\n if (type === \"start\") {\n const newNode = { tag, children: [], textStart: pos };\n parent.children.push(newNode);\n stack.push(newNode);\n } else {\n stack.pop();\n }\n\n lastPos = pos;\n }\n\n if (lastPos < text.length) {\n stack[stack.length - 1].children.push(text.slice(lastPos));\n }\n\n return root;\n}\n\nfunction renderNode(\n node: any,\n dispatch: TreeDispatch,\n selectedNodes: number[],\n parentSelected: boolean,\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n },\n viewOnly?: boolean,\n): any {\n if (typeof node === \"string\") return node;\n\n const { tag, children } = node;\n const isSelected = selectedNodes?.includes(tag.id);\n const showBorder = selectedNodes.length === 0 || isSelected;\n const match = tag.match;\n\n const style = {\n ...tag,\n zIndex: parentSelected ? -1 : 1,\n border:\n \"1px solid \" +\n (match != undefined && matchLinks\n ? \"orange\"\n : showBorder\n ? tag.color\n : \"transparent\"),\n margin: \"-1px\",\n };\n\n let moveText = [];\n if (isSelected) {\n for (const key in children) {\n if (Object.prototype.hasOwnProperty.call(children, key)) {\n const child = children[key];\n if (child?.tag) {\n moveText.push(child.children[0]);\n } else {\n moveText.push(child);\n }\n }\n }\n }\n\n const tagComponent = h(\n \"span\",\n {\n onMouseEnter: (e: MouseEvent) => {\n e.stopPropagation();\n },\n className: \"highlight\" + (!viewOnly || match ? \" clickable\" : \"\"),\n style,\n onClick: (e: MouseEvent) => {\n e.stopPropagation();\n if (\n e.ctrlKey ||\n e.metaKey ||\n (selectedNodes[0] === tag.id && selectedNodes.length === 1)\n ) {\n // Toggle selection on ctrl/cmd click or when node is only selected node\n e.stopPropagation();\n dispatch({\n type: \"toggle-node-selected\",\n payload: { ids: [tag.id] },\n });\n } else if (e.shiftKey && selectedNodes.length > 0) {\n // Select range from last selected node to this one\n const lastSelected = selectedNodes[selectedNodes.length - 1];\n\n dispatch({\n type: \"select-range\",\n payload: { ids: [lastSelected, tag.id] },\n });\n } else {\n dispatch({\n type: \"select-node\",\n payload: { ids: [tag.id] },\n });\n }\n },\n },\n isSelected\n ? moveText.flat()\n : children.map((child: any, i: number) =>\n renderNode(\n child,\n dispatch,\n selectedNodes,\n isSelected,\n matchLinks,\n viewOnly,\n ),\n ),\n );\n\n if (viewOnly && match) {\n return h(\n Popover,\n {\n content: h(\"div.match-link\", h(MatchTag, { data: match, matchLinks })),\n interactionKind: \"hover\",\n },\n tagComponent,\n );\n }\n\n return tagComponent;\n}\n\nexport function HighlightedText(props: {\n text: string;\n allTags: AnnotateBlendTag[];\n lineHeight: string;\n allowOverlap?: boolean;\n dispatch: TreeDispatch;\n selectedNodes: number[];\n matchLinks?: {\n lithology: string;\n strat_name: string;\n lith_att: string;\n };\n viewOnly?: boolean;\n}) {\n const {\n text,\n allTags = [],\n dispatch,\n selectedNodes,\n allowOverlap,\n matchLinks,\n viewOnly,\n } = props;\n\n const tree = nestHighlights(text, allTags);\n\n const spanRef = useRef<HTMLSpanElement>(null);\n\n useEffect(() => {\n const handleMouseUp = () => {\n const tag = createTagFromSelection({ container: spanRef.current });\n if (!tag) return;\n addTag({ tag, dispatch, text, allTags, allowOverlap });\n };\n\n document.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [text, allTags, dispatch, allowOverlap]);\n\n return h(\n \"span\",\n { ref: spanRef },\n tree.children.map((child: any, i: number) =>\n renderNode(child, dispatch, selectedNodes, false, matchLinks, viewOnly),\n ),\n );\n}\n"],"names":["$h8ona$macrostrathyper","useRef","$h8ona$useRef","useEffect","$h8ona$useEffect","Popover","$h8ona$Popover","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","$edvRb","$jlqgz","$d6cf457c7790c03a$var$h","styled","a","__esModule","default","$d6cf457c7790c03a$export$6e107db9091b8219","props","text","selectedNodes","nodes","dispatch","allowOverlap","matchLinks","viewOnly","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","test","trim","console","log","find","t","endsWith","inside","overlap","addEventListener","removeEventListener","ref","map","child","i","$d6cf457c7790c03a$var$renderNode","node","parentSelected","isSelected","showBorder","match","style","zIndex","border","undefined","margin","moveText","Object","prototype","hasOwnProperty","tagComponent","onMouseEnter","stopPropagation","className","onClick","ctrlKey","metaKey","shiftKey","flat","content","MatchTag","data","interactionKind","FeedbackText","HighlightedText"],"version":3,"file":"feedback-components.ddd11fe8.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./feedback-components.db72d0e1.js";import"./feedback-components.dc76072c.js";import"./feedback-components.c84ff10e.js";import e from"@macrostrat/hyper";var t=globalThis,r={},a={},o=t.parcelRequirea149;null==o&&((o=function(e){if(e in r)return r[e].exports;if(e in a){var t=a[e];delete a[e];var o={id:e,exports:{}};return r[e]=o,t.call(o.exports,o,o.exports),o.exports}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(e,t){a[e]=t},t.parcelRequirea149=o),o.register;var n=o("edvRb"),d=o("eedTh"),l=o("9wFEx");let i=e.styled(l&&l.__esModule?l.default:l);var c=function({node:e,style:t,dragHandle:r,tree:a,matchComponent:o,viewOnly:l}){let c=function e(t,r){if(0==r.selectedNodes.length)return!0;for(let e of r.selectedNodes){var a,o;if(a=t.data,o=e.data,a.id==o.id)return!0}return!!(null!=t.parent&&e(t.parent,r))}(e,a),s=function(e,t){for(let o of t.selectedNodes){var r,a;if(r=e.data,a=o.data,r.id==a.id)return!0}return!1}(e,a);console.log("viewOnly",l);let f=(0,d.useTreeDispatch)();return e.data?.type||(e.data.type={name:"lith",color:"rgb(107, 255, 91)"}),i("div.node"+(l?"":".clickable"),{style:t,ref:r},i(n.EntityTag,{data:e.data,active:!l&&s,highlighted:!!l||c,matchComponent:o,onClickType(){f({type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A2BZ,EAAa,IAAI,CA1BtC,EAAW,EAAE,EAAI,EAAS,EAAE,CA2B/B,MAAO,CAAA,CADT,CAIF,MAAO,CAAA,CACT,EAWqC,EAAM,GAEzC,QAAQ,GAAG,CAAC,WAAY,GAExB,IAAM,EAAW,AAAA,CAAA,EAAA,EAAA,eAAc,AAAd,IAMjB,OAJI,AAAC,EAAK,IAAI,EAAE,MACd,CAAA,EAAK,IAAI,CAAC,IAAI,CAAG,CAAE,KAAM,OAAQ,MAAO,mBAAoB,CAAA,EAGvD,EACL,WAAc,CAAA,AAAC,EAA0B,GAAf,YAAe,EACzC,CAAE,MAAA,EAAO,IAAK,CAAW,EACzB,EAAE,EAAA,SAAQ,CAAG,CACX,KAAM,EAAK,IAAI,CACf,OAAQ,CAAA,GAAmB,EAC3B,YAAa,EAAA,GAAkB,EAC/B,eAAA,EACA,cACE,EAAS,CAAE,KAAM,6BAA8B,EACjD,CACF,GAEJ,S,K,O","sources":["<anon>","packages/feedback-components/src/feedback/node.ts"],"sourcesContent":["import \"./feedback-components.db72d0e1.js\";\nimport \"./feedback-components.dc76072c.js\";\nimport \"./feedback-components.c84ff10e.js\";\nimport $hPIF3$macrostrathyper from \"@macrostrat/hyper\";\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 $edvRb = parcelRequire(\"edvRb\");\n\nvar $eedTh = parcelRequire(\"eedTh\");\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\nconst $2e9ede27ff2a3eea$var$h = (0, $hPIF3$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $2e9ede27ff2a3eea$var$isSelected(searchNode, treeNode) {\n return searchNode.id == treeNode.id;\n// We could also select children of the search node here if we wanted to\n}\nfunction $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) return true;\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n // Check if the parent node is highlighted\n if (node.parent != null && $2e9ede27ff2a3eea$var$isNodeHighlighted(node.parent, tree)) return true;\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$isNodeActive(node, tree) {\n for (const selectedNode of tree.selectedNodes){\n if ($2e9ede27ff2a3eea$var$isSelected(node.data, selectedNode.data)) return true;\n }\n return false;\n}\nfunction $2e9ede27ff2a3eea$var$Node({ node: node, style: style, dragHandle: dragHandle, tree: tree, matchComponent: matchComponent, viewOnly: viewOnly }) {\n let highlighted = $2e9ede27ff2a3eea$var$isNodeHighlighted(node, tree);\n let active = $2e9ede27ff2a3eea$var$isNodeActive(node, tree);\n console.log(\"viewOnly\", viewOnly);\n const dispatch = (0, $eedTh.useTreeDispatch)();\n if (!node.data?.type) node.data.type = {\n name: \"lith\",\n color: \"rgb(107, 255, 91)\"\n };\n return $2e9ede27ff2a3eea$var$h(\"div.node\" + (!viewOnly ? \".clickable\" : \"\"), {\n style: style,\n ref: dragHandle\n }, $2e9ede27ff2a3eea$var$h((0, $edvRb.EntityTag), {\n data: node.data,\n active: viewOnly ? false : active,\n highlighted: viewOnly ? true : highlighted,\n matchComponent: matchComponent,\n onClickType () {\n dispatch({\n type: \"toggle-entity-type-selector\"\n });\n }\n }));\n}\nvar $2e9ede27ff2a3eea$export$2e2bcd8739ae039 = $2e9ede27ff2a3eea$var$Node;\n\n\nexport {$2e9ede27ff2a3eea$export$2e2bcd8739ae039 as default};\n//# sourceMappingURL=feedback-components.e59a061f.js.map\n","import { NodeApi, TreeApi } from \"react-arborist\";\nimport { TreeData } from \"./types\";\nimport { EntityTag } from \"../extractions\";\nimport { useTreeDispatch } from \"./edit-state\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nconst h = hyper.styled(styles);\n\nfunction isSelected(searchNode: TreeData, treeNode: TreeData) {\n return searchNode.id == treeNode.id;\n // We could also select children of the search node here if we wanted to\n}\n\nfunction isNodeHighlighted(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n // We treat no selection as all nodes being active. We may add some nuance later\n if (tree.selectedNodes.length == 0) {\n return true;\n }\n\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n\n // Check if the parent node is highlighted\n if (node.parent != null && isNodeHighlighted(node.parent, tree)) {\n return true;\n }\n\n return false;\n}\n\nfunction isNodeActive(node: NodeApi<TreeData>, tree: TreeApi<TreeData>) {\n for (const selectedNode of tree.selectedNodes) {\n if (isSelected(node.data, selectedNode.data)) {\n return true;\n }\n }\n return false;\n}\n\nfunction Node({\n node,\n style,\n dragHandle,\n tree,\n matchComponent,\n viewOnly,\n}: any) {\n let highlighted: boolean = isNodeHighlighted(node, tree);\n let active: boolean = isNodeActive(node, tree);\n\n console.log(\"viewOnly\", viewOnly);\n\n const dispatch = useTreeDispatch();\n\n if (!node.data?.type) {\n node.data.type = { name: \"lith\", color: \"rgb(107, 255, 91)\" };\n }\n\n return h(\n \"div.node\" + (!viewOnly ? \".clickable\" : \"\"),\n { style, ref: dragHandle },\n h(EntityTag, {\n data: node.data,\n active: viewOnly ? false : active,\n highlighted: viewOnly ? true : highlighted,\n matchComponent,\n onClickType() {\n dispatch({ type: \"toggle-entity-type-selector\" });\n },\n }),\n );\n}\n\nexport default Node;\n"],"names":["$hPIF3$macrostrathyper","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$edvRb","$eedTh","$9wFEx","$2e9ede27ff2a3eea$var$h","styled","a","__esModule","default","$2e9ede27ff2a3eea$export$2e2bcd8739ae039","node","style","dragHandle","tree","matchComponent","viewOnly","highlighted","$2e9ede27ff2a3eea$var$isNodeHighlighted","selectedNodes","length","selectedNode","searchNode","treeNode","data","parent","active","$2e9ede27ff2a3eea$var$isNodeActive","console","log","dispatch","useTreeDispatch","type","name","color","ref","EntityTag","onClickType"],"version":3,"file":"feedback-components.e59a061f.js.map","sourceRoot":"../../../../"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./feedback-components.c84ff10e.js";import{Divider as a,Switch as t,Icon as e,Overlay2 as i}from"@blueprintjs/core";import{Select as n}from"@blueprintjs/select";import o from"@macrostrat/hyper";import{useState as r}from"react";import{useAPIResult as c,SaveButton as l,DataField as d,JSONView as s}from"@macrostrat/ui-components";import{LithologyTag as m}from"@macrostrat/data-components";var p=globalThis,h={},u={},v=p.parcelRequirea149;null==v&&((v=function(a){if(a in h)return h[a].exports;if(a in u){var t=u[a];delete u[a];var e={id:a,exports:{}};return h[a]=e,t.call(e.exports,e,e.exports),e.exports}var i=Error("Cannot find module '"+a+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(a,t){u[a]=t},p.parcelRequirea149=v),v.register;var _=v("9wFEx");let f=o.styled(_&&_.__esModule?_.default:_);function y({match:i,setMatchLinks:n,matchLinks:o,selectedNodes:c,tree:l,dispatch:d}){var s,m;let p,[h,u]=r(!1),v=null;return 1===c.length&&(s=l,m=c[0],p=null,s.forEach(function a(t){if(t.id===m)return p=t,!0;if(Array.isArray(t.children)){for(let e of t.children)if(a(e))return!0}return!1}),v=p),f.if(o)("div",[f(a),f(t,{label:"Match mode",checked:void 0!==i,onChange:a=>{n(void 0===i?o||{}:void 0),d({type:"toggle-match-mode"})}}),f.if(v&&i)(b,{data:v?.match,matchLinks:o,dispatch:d,nodeId:v?.id}),f.if(1==c.length&&!v?.match&&i)("div.add-match-container",[f("div.add-type",{onClick:()=>{u(!0)}},[f("p.add-match-text","Add match"),f(e,{icon:"plus"})]),f(k,{isOpen:h,setOverlayOpen:u,nodeMatch:v,dispatch:d})])])}function k({isOpen:a,setOverlayOpen:t,nodeMatch:o,dispatch:d}){let[s,m]=r(o?.name||""),[p,h]=r(f("div","Select a match")),[u,v]=r(!0),[_,y]=r({}),k=c("https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*"+s+"*"),b=k?.map(a=>f(g,{data:a,setPayload:y}));return f(i,{isOpen:a},f("div.overlay-container",f("div.add-type-overlay",[f("h2.title",["Add match with "+o.name,f(e,{icon:"cross",className:"close-icon",onClick:()=>{t(!1)},style:{cursor:"pointer",color:"red"}})]),f("div.form-group",[f(n,{items:b||[],itemRenderer:(a,{handleClick:t})=>f("div.match-item",{onClick:t},a),onItemSelect:a=>{v(!1),h(a)},onQueryChange:a=>m(a),popoverProps:{minimal:!0},query:s,placeholder:"Enter match name"},p)]),f(l,{className:"save-btn",small:!0,onClick:()=>{d({type:"add-match",payload:{id:o.id,payload:_}}),t(!1)},disabled:u},"Save changes")])))}function b({data:a,matchLinks:t,dispatch:i,nodeId:n}){return f.if(a)("div.match-container",[g({data:a,matchLinks:t}),f(e,{icon:"cross",color:"red",className:"close-btn",onClick:()=>{i({type:"remove-match",payload:{id:n}})}})])}function g({data:a,matchLinks:t,setPayload:e}){if(a&&0!==Object.keys(a).length)return a.lith_id||a?.type==="lith"?f("div",{onClick:()=>{"lith"===a.type&&e({lith_id:a.id,name:a.name})}},f(d,{className:"match-item",label:"Stratigraphic name",value:f(m,{data:{name:a.name,id:a.id,color:a.color},onClick:()=>window.open(t.strat_name+"/"+a.strat_name_id,"_blank")})})):a.strat_name_id||a?.type==="strat_name"?f("div",{onClick:()=>{"strat_name"===a.type&&e({strat_name_id:a.id,name:a.name})}},f(d,{className:"match-item",label:"Stratigraphic name",value:f(m,{data:{name:a.name,id:a.id,color:a.color},onClick:()=>window.open(t.strat_name+"/"+a.strat_name_id,"_blank")})})):a.lith_att_id||a?.type==="lith_att"?f("div",{onClick:()=>{"lith_att"===a.type&&e({lith_att_id:a.id,name:a.name})}},f(d,{className:"match-item",label:"Lithology attribute",value:f(m,{data:{name:a.name,id:a.lith_att_id},onClick:()=>window.open(t.lith_att+"/"+a.lith_att_id,"_blank")})})):a.int_id||a?.type==="interval"?f("div",{onClick:()=>{"interval"===a.type&&e({int_id:a.id,name:a.name})}},f(d,{label:"Interval",className:"match-item",value:f(m,{data:{name:a.name,id:a.id},onClick:()=>window.open(t.interval+"/"+a.int_id,"_blank")})})):f(s,{data:a})}export{y as Matches,g as MatchTag};
|
|
2
|
-
//# sourceMappingURL=feedback-components.feab0bd0.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,Q,W,C,C,U,C,C,Q,C,C,Y,C,K,mB,A,Q,U,C,K,qB,A,Q,M,mB,A,Q,Y,C,K,O,A,Q,gB,C,C,c,C,C,a,C,C,Y,C,K,2B,A,Q,gB,C,K,6B,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,SCUA,IAAM,EAAI,AAAA,EAAM,MAAM,C,AAAC,G,AAAA,E,U,C,AAAA,E,O,CAAA,GAEhB,SAAS,EAAQ,CAAA,MACtB,CAAK,CAAA,c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EACL,MACA,CACE,QAAS,KACP,AAAc,aAAd,EAAK,IAAI,EACL,EAAW,CAAE,YAAa,EAAK,EAAE,CAAE,KAAM,EAAK,IAAI,AAAC,EAEzD,CACF,EACA,EAAE,EAAW,CACX,UAAW,aACX,MAAO,sBACP,MAAO,EAAE,EAAc,CACrB,KAAM,CAAE,KAAM,EAAK,IAAI,CAAE,GAAI,EAAK,WAAW,AAAC,EAC9C,QAAS,IACP,OAAO,IAAI,CAAC,EAAW,QAAQ,CAAG,IAAM,EAAK,WAAW,CAAE,SAC9D,EACF,IAIA,EAAK,MAAM,EAAI,GAAM,OAAS,WACzB,EACL,MACA,CACE,QAAS,KACP,AAAc,aAAd,EAAK,IAAI,EACL,EAAW,CAAE,OAAQ,EAAK,EAAE,CAAE,KAAM,EAAK,IAAI,AAAC,EAEpD,CACF,EACA,EAAE,EAAW,CACX,MAAO,WACP,UAAW,aACX,MAAO,EAAE,EAAc,CACrB,KAAM,CAAE,KAAM,EAAK,IAAI,CAAE,GAAI,EAAK,EAAE,AAAC,EACrC,QAAS,IACP,OAAO,IAAI,CAAC,EAAW,QAAQ,CAAG,IAAM,EAAK,MAAM,CAAE,SACzD,EACF,IAIG,EAAE,EAAU,CAAE,KAAA,CAAK,EAC5B,Q,K,O,C,K,Q","sources":["<anon>","packages/feedback-components/src/feedback/matches.ts"],"sourcesContent":["import \"./feedback-components.c84ff10e.js\";\nimport {Divider as $locXJ$Divider, Switch as $locXJ$Switch, Icon as $locXJ$Icon, Overlay2 as $locXJ$Overlay2} from \"@blueprintjs/core\";\nimport {Select as $locXJ$Select} from \"@blueprintjs/select\";\nimport $locXJ$macrostrathyper from \"@macrostrat/hyper\";\nimport {useState as $locXJ$useState} from \"react\";\nimport {useAPIResult as $locXJ$useAPIResult, SaveButton as $locXJ$SaveButton, DataField as $locXJ$DataField, JSONView as $locXJ$JSONView} from \"@macrostrat/ui-components\";\nimport {LithologyTag as $locXJ$LithologyTag} from \"@macrostrat/data-components\";\n\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\n\n\nvar $9wFEx = parcelRequire(\"9wFEx\");\n\n\n\n\nconst $7accc8160d3205c1$var$h = (0, $locXJ$macrostrathyper).styled((0, (/*@__PURE__*/$parcel$interopDefault($9wFEx))));\nfunction $7accc8160d3205c1$export$6479cfcac2b87c0({ match: match, setMatchLinks: setMatchLinks, matchLinks: matchLinks, selectedNodes: selectedNodes, tree: tree, dispatch: dispatch }) {\n const [overlayOpen, setOverlayOpen] = (0, $locXJ$useState)(false);\n let nodeMatch = null;\n if (selectedNodes.length === 1) nodeMatch = $7accc8160d3205c1$var$findMatchingNode(tree, selectedNodes[0]);\n return $7accc8160d3205c1$var$h.if(matchLinks)(\"div\", [\n $7accc8160d3205c1$var$h((0, $locXJ$Divider)),\n $7accc8160d3205c1$var$h((0, $locXJ$Switch), {\n label: \"Match mode\",\n checked: match !== undefined,\n onChange: (e)=>{\n setMatchLinks(match === undefined ? matchLinks || {} : undefined);\n dispatch({\n type: \"toggle-match-mode\"\n });\n }\n }),\n $7accc8160d3205c1$var$h.if(nodeMatch && match)($7accc8160d3205c1$var$Match, {\n data: nodeMatch?.match,\n matchLinks: matchLinks,\n dispatch: dispatch,\n nodeId: nodeMatch?.id\n }),\n $7accc8160d3205c1$var$h.if(selectedNodes.length == 1 && !nodeMatch?.match && match)(\"div.add-match-container\", [\n $7accc8160d3205c1$var$h(\"div.add-type\", {\n onClick: ()=>{\n setOverlayOpen(true);\n }\n }, [\n $7accc8160d3205c1$var$h(\"p.add-match-text\", \"Add match\"),\n $7accc8160d3205c1$var$h((0, $locXJ$Icon), {\n icon: \"plus\"\n })\n ]),\n $7accc8160d3205c1$var$h($7accc8160d3205c1$var$MatchOverlay, {\n isOpen: overlayOpen,\n setOverlayOpen: setOverlayOpen,\n nodeMatch: nodeMatch,\n dispatch: dispatch\n })\n ])\n ]);\n}\nfunction $7accc8160d3205c1$var$findMatchingNode(tree, nodeId) {\n let match = null;\n function traverse(node) {\n if (node.id === nodeId) {\n match = node;\n return true;\n }\n if (Array.isArray(node.children)) for (const child of node.children){\n if (traverse(child)) return true;\n }\n return false;\n }\n tree.forEach(traverse);\n return match;\n}\nfunction $7accc8160d3205c1$var$MatchOverlay({ isOpen: isOpen, setOverlayOpen: setOverlayOpen, nodeMatch: nodeMatch, dispatch: dispatch }) {\n const [inputValue, setInputValue] = (0, $locXJ$useState)(nodeMatch?.name || \"\");\n const [selectedItem, setSelectedItem] = (0, $locXJ$useState)($7accc8160d3205c1$var$h(\"div\", \"Select a match\"));\n const [disabled, setDisabled] = (0, $locXJ$useState)(true);\n const [payload, setPayload] = (0, $locXJ$useState)({});\n const data = (0, $locXJ$useAPIResult)(\"https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*\" + inputValue + \"*\");\n const items = data?.map((data)=>$7accc8160d3205c1$var$h($7accc8160d3205c1$export$5eeb3456842e9e5f, {\n data: data,\n setPayload: setPayload\n }));\n return $7accc8160d3205c1$var$h((0, $locXJ$Overlay2), {\n isOpen: isOpen\n }, $7accc8160d3205c1$var$h(\"div.overlay-container\", $7accc8160d3205c1$var$h(\"div.add-type-overlay\", [\n $7accc8160d3205c1$var$h(\"h2.title\", [\n \"Add match with \" + nodeMatch.name,\n $7accc8160d3205c1$var$h((0, $locXJ$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 $7accc8160d3205c1$var$h(\"div.form-group\", [\n $7accc8160d3205c1$var$h((0, $locXJ$Select), {\n items: items || [],\n itemRenderer: (item, { handleClick: handleClick })=>{\n return $7accc8160d3205c1$var$h(\"div.match-item\", {\n onClick: handleClick\n }, item);\n },\n onItemSelect: (item)=>{\n setDisabled(false);\n setSelectedItem(item);\n },\n onQueryChange: (query)=>setInputValue(query),\n popoverProps: {\n minimal: true\n },\n query: inputValue,\n placeholder: \"Enter match name\"\n }, selectedItem)\n ]),\n $7accc8160d3205c1$var$h((0, $locXJ$SaveButton), {\n className: \"save-btn\",\n small: true,\n onClick: ()=>{\n // Handle save changes\n dispatch({\n type: \"add-match\",\n payload: {\n id: nodeMatch.id,\n payload: payload\n }\n });\n setOverlayOpen(false);\n },\n disabled: disabled\n }, \"Save changes\")\n ])));\n}\nfunction $7accc8160d3205c1$var$Match({ data: data, matchLinks: matchLinks, dispatch: dispatch, nodeId: nodeId }) {\n return $7accc8160d3205c1$var$h.if(data)(\"div.match-container\", [\n $7accc8160d3205c1$export$5eeb3456842e9e5f({\n data: data,\n matchLinks: matchLinks\n }),\n $7accc8160d3205c1$var$h((0, $locXJ$Icon), {\n icon: \"cross\",\n color: \"red\",\n className: \"close-btn\",\n onClick: ()=>{\n dispatch({\n type: \"remove-match\",\n payload: {\n id: nodeId\n }\n });\n }\n })\n ]);\n}\nfunction $7accc8160d3205c1$export$5eeb3456842e9e5f({ data: data, matchLinks: matchLinks, setPayload: setPayload }) {\n if (!data || Object.keys(data).length === 0) return;\n if (data.lith_id || data?.type === \"lith\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n data.type === \"lith\" && setPayload({\n lith_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.id,\n color: data.color\n },\n onClick: ()=>window.open(matchLinks.strat_name + \"/\" + data.strat_name_id, \"_blank\")\n })\n }));\n if (data.strat_name_id || data?.type === \"strat_name\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n data.type === \"strat_name\" && setPayload({\n strat_name_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.id,\n color: data.color\n },\n onClick: ()=>window.open(matchLinks.strat_name + \"/\" + data.strat_name_id, \"_blank\")\n })\n }));\n if (data.lith_att_id || data?.type === \"lith_att\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n data.type === \"lith_att\" && setPayload({\n lith_att_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n className: \"match-item\",\n label: \"Lithology attribute\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.lith_att_id\n },\n onClick: ()=>window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\")\n })\n }));\n if (data.int_id || data?.type === \"interval\") return $7accc8160d3205c1$var$h(\"div\", {\n onClick: ()=>{\n data.type === \"interval\" && setPayload({\n int_id: data.id,\n name: data.name\n });\n }\n }, $7accc8160d3205c1$var$h((0, $locXJ$DataField), {\n label: \"Interval\",\n className: \"match-item\",\n value: $7accc8160d3205c1$var$h((0, $locXJ$LithologyTag), {\n data: {\n name: data.name,\n id: data.id\n },\n onClick: ()=>window.open(matchLinks.interval + \"/\" + data.int_id, \"_blank\")\n })\n }));\n return $7accc8160d3205c1$var$h((0, $locXJ$JSONView), {\n data: data\n });\n}\n\n\nexport {$7accc8160d3205c1$export$6479cfcac2b87c0 as Matches, $7accc8160d3205c1$export$5eeb3456842e9e5f as MatchTag};\n//# sourceMappingURL=feedback-components.feab0bd0.js.map\n","import { Switch } from \"@blueprintjs/core\";\nimport { Select } from \"@blueprintjs/select\";\nimport styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\nimport { useState } from \"react\";\nimport { Icon, Divider, Overlay2 } from \"@blueprintjs/core\";\nimport { JSONView, SaveButton } from \"@macrostrat/ui-components\";\nimport { useAPIResult, DataField } from \"@macrostrat/ui-components\";\nimport { LithologyTag } from \"@macrostrat/data-components\";\n\nconst h = hyper.styled(styles);\n\nexport function Matches({\n match,\n setMatchLinks,\n matchLinks,\n selectedNodes,\n tree,\n dispatch,\n}) {\n const [overlayOpen, setOverlayOpen] = useState(false);\n\n let nodeMatch = null;\n if (selectedNodes.length === 1) {\n nodeMatch = findMatchingNode(tree, selectedNodes[0]);\n }\n\n return h.if(matchLinks)(\"div\", [\n h(Divider),\n h(Switch, {\n label: \"Match mode\",\n checked: match !== undefined,\n onChange: (e) => {\n setMatchLinks(match === undefined ? matchLinks || {} : undefined);\n dispatch({ type: \"toggle-match-mode\" });\n },\n }),\n h.if(nodeMatch && match)(Match, {\n data: nodeMatch?.match,\n matchLinks: matchLinks,\n dispatch,\n nodeId: nodeMatch?.id,\n }),\n h.if(selectedNodes.length == 1 && !nodeMatch?.match && match)(\n \"div.add-match-container\",\n [\n h(\n \"div.add-type\",\n {\n onClick: () => {\n setOverlayOpen(true);\n },\n },\n [h(\"p.add-match-text\", \"Add match\"), h(Icon, { icon: \"plus\" })],\n ),\n h(MatchOverlay, {\n isOpen: overlayOpen,\n setOverlayOpen,\n nodeMatch,\n dispatch,\n }),\n ],\n ),\n ]);\n}\n\nfunction findMatchingNode(tree, nodeId) {\n let match = null;\n\n function traverse(node) {\n if (node.id === nodeId) {\n match = node;\n return true;\n }\n if (Array.isArray(node.children)) {\n for (const child of node.children) {\n if (traverse(child)) return true;\n }\n }\n return false;\n }\n\n tree.forEach(traverse);\n return match;\n}\n\nfunction MatchOverlay({ isOpen, setOverlayOpen, nodeMatch, dispatch }) {\n const [inputValue, setInputValue] = useState(nodeMatch?.name || \"\");\n const [selectedItem, setSelectedItem] = useState(h(\"div\", \"Select a match\"));\n const [disabled, setDisabled] = useState(true);\n const [payload, setPayload] = useState({});\n\n const data = useAPIResult(\n \"https://dev.macrostrat.org/api/pg/type_lookup?name=ilike.*\" +\n inputValue +\n \"*\",\n );\n const items = data?.map((data) => h(MatchTag, { data, setPayload }));\n\n return h(\n Overlay2,\n {\n isOpen,\n },\n h(\n \"div.overlay-container\",\n h(\"div.add-type-overlay\", [\n h(\"h2.title\", [\n \"Add match with \" + nodeMatch.name,\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(\n Select,\n {\n items: items || [],\n itemRenderer: (item, { handleClick }) => {\n return h(\"div.match-item\", { onClick: handleClick }, item);\n },\n onItemSelect: (item) => {\n setDisabled(false);\n setSelectedItem(item);\n },\n onQueryChange: (query) => setInputValue(query),\n popoverProps: { minimal: true },\n query: inputValue,\n placeholder: \"Enter match name\",\n },\n selectedItem,\n ),\n ]),\n h(\n SaveButton,\n {\n className: \"save-btn\",\n small: true,\n onClick: () => {\n // Handle save changes\n dispatch({\n type: \"add-match\",\n payload: { id: nodeMatch.id, payload },\n });\n setOverlayOpen(false);\n },\n disabled,\n },\n \"Save changes\",\n ),\n ]),\n ),\n );\n}\n\nfunction Match({ data, matchLinks, dispatch, nodeId }) {\n return h.if(data)(\"div.match-container\", [\n MatchTag({ data, matchLinks }),\n h(Icon, {\n icon: \"cross\",\n color: \"red\",\n className: \"close-btn\",\n onClick: () => {\n dispatch({ type: \"remove-match\", payload: { id: nodeId } });\n },\n }),\n ]);\n}\n\ninterface MatchTagProps {\n data: any;\n matchLinks?: Record<string, string>;\n setPayload?: (payload: Record<string, any>) => void;\n}\n\nexport function MatchTag({ data, matchLinks, setPayload }: MatchTagProps) {\n if (!data || Object.keys(data).length === 0) return;\n\n if (data.lith_id || data?.type === \"lith\") {\n return h(\n \"div\",\n {\n onClick: () => {\n data.type === \"lith\"\n ? setPayload({ lith_id: data.id, name: data.name })\n : null;\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id, color: data.color },\n onClick: () =>\n window.open(\n matchLinks.strat_name + \"/\" + data.strat_name_id,\n \"_blank\",\n ),\n }),\n }),\n );\n }\n\n if (data.strat_name_id || data?.type === \"strat_name\") {\n return h(\n \"div\",\n {\n onClick: () => {\n data.type === \"strat_name\"\n ? setPayload({ strat_name_id: data.id, name: data.name })\n : null;\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Stratigraphic name\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id, color: data.color },\n onClick: () =>\n window.open(\n matchLinks.strat_name + \"/\" + data.strat_name_id,\n \"_blank\",\n ),\n }),\n }),\n );\n }\n\n if (data.lith_att_id || data?.type === \"lith_att\") {\n return h(\n \"div\",\n {\n onClick: () => {\n data.type === \"lith_att\"\n ? setPayload({ lith_att_id: data.id, name: data.name })\n : null;\n },\n },\n h(DataField, {\n className: \"match-item\",\n label: \"Lithology attribute\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.lith_att_id },\n onClick: () =>\n window.open(matchLinks.lith_att + \"/\" + data.lith_att_id, \"_blank\"),\n }),\n }),\n );\n }\n\n if (data.int_id || data?.type === \"interval\") {\n return h(\n \"div\",\n {\n onClick: () => {\n data.type === \"interval\"\n ? setPayload({ int_id: data.id, name: data.name })\n : null;\n },\n },\n h(DataField, {\n label: \"Interval\",\n className: \"match-item\",\n value: h(LithologyTag, {\n data: { name: data.name, id: data.id },\n onClick: () =>\n window.open(matchLinks.interval + \"/\" + data.int_id, \"_blank\"),\n }),\n }),\n );\n }\n\n return h(JSONView, { data });\n}\n"],"names":["Divider","$locXJ$Divider","Switch","$locXJ$Switch","Icon","$locXJ$Icon","Overlay2","$locXJ$Overlay2","Select","$locXJ$Select","$locXJ$macrostrathyper","useState","$locXJ$useState","useAPIResult","$locXJ$useAPIResult","SaveButton","$locXJ$SaveButton","DataField","$locXJ$DataField","JSONView","$locXJ$JSONView","LithologyTag","$locXJ$LithologyTag","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$9wFEx","$7accc8160d3205c1$var$h","styled","a","__esModule","default","$7accc8160d3205c1$export$6479cfcac2b87c0","match","setMatchLinks","matchLinks","selectedNodes","tree","dispatch","nodeId","overlayOpen","setOverlayOpen","nodeMatch","length","forEach","traverse","node","Array","isArray","children","child","if","label","checked","undefined","onChange","e","type","$7accc8160d3205c1$var$Match","data","onClick","icon","$7accc8160d3205c1$var$MatchOverlay","isOpen","inputValue","setInputValue","name","selectedItem","setSelectedItem","disabled","setDisabled","payload","setPayload","items","map","$7accc8160d3205c1$export$5eeb3456842e9e5f","className","style","cursor","color","itemRenderer","item","handleClick","onItemSelect","onQueryChange","query","popoverProps","minimal","placeholder","small","Object","keys","lith_id","value","window","open","strat_name","strat_name_id","lith_att_id","lith_att","int_id","interval","Matches","MatchTag"],"version":3,"file":"feedback-components.feab0bd0.js.map","sourceRoot":"../../../../"}
|
package/dist/node/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./feedback-components.db72d0e1.js";import"./feedback-components.70780da4.js";function e(e,a){return Object.keys(a).forEach(function(t){"default"===t||"__esModule"===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})}),e}var a=globalThis,t={},r={},c=a.parcelRequirea149;null==c&&((c=function(e){if(e in t)return t[e].exports;if(e in r){var a=r[e];delete r[e];var c={id:e,exports:{}};return t[e]=c,a.call(c.exports,c,c.exports),c.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,a){r[e]=a},a.parcelRequirea149=c),c.register;var o={},n=c("edvRb"),d=c("aZPCw");e(o,n),e(o,d);export{$8c534c0378e15a46$export$c4b91360064ad200 as buildHighlights,$8c534c0378e15a46$export$d60b563f571177d as enhanceData,$8c534c0378e15a46$export$35baa338324d8550 as getTagStyle,$8c534c0378e15a46$export$2b07158757c249e0 as ExtractionContext,$8c534c0378e15a46$export$4eb2a0ce903ce967 as ModelInfo,$8c534c0378e15a46$export$117e56c71b172cde as EntityTag,$2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent,$330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"A,M,oD,A,O,oD,C,S,E,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,O,S,C,c,C,I,C,E,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,C,E,E,E,S,E,E,S,E,E,G,E,E,U,6C,e,C,4C,W,C,6C,W,C,6C,iB,C,6C,S,C,6C,S,C,6C,iB,C,6C,W","sources":["<anon>","packages/feedback-components/src/index.ts"],"sourcesContent":["import \"./feedback-components.db72d0e1.js\";\nimport \"./feedback-components.70780da4.js\";\n\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirea149\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirea149\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nvar $c688386f08592f9c$exports = {};\n\nvar $edvRb = parcelRequire(\"edvRb\");\n\nvar $aZPCw = parcelRequire(\"aZPCw\");\n$parcel$exportWildcard($c688386f08592f9c$exports, $edvRb);\n$parcel$exportWildcard($c688386f08592f9c$exports, $aZPCw);\n\n\nexport {$8c534c0378e15a46$export$c4b91360064ad200 as buildHighlights, $8c534c0378e15a46$export$d60b563f571177d as enhanceData, $8c534c0378e15a46$export$35baa338324d8550 as getTagStyle, $8c534c0378e15a46$export$2b07158757c249e0 as ExtractionContext, $8c534c0378e15a46$export$4eb2a0ce903ce967 as ModelInfo, $8c534c0378e15a46$export$117e56c71b172cde as EntityTag, $2c86488f2f3c1edd$export$a90600c9da52b40c as FeedbackComponent, $330ae695507d96f5$export$8d9dbb7a64bf2a5e as treeToGraph};\n//# sourceMappingURL=index.js.map\n","export * from \"./extractions\";\nexport * from \"./feedback\";\n"],"names":["$parcel$exportWildcard","dest","source","Object","keys","forEach","key","prototype","hasOwnProperty","call","defineProperty","enumerable","get","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","err","Error","code","register","$c688386f08592f9c$exports","$edvRb","$aZPCw","$8c534c0378e15a46$export$c4b91360064ad200","buildHighlights","$8c534c0378e15a46$export$d60b563f571177d","enhanceData","$8c534c0378e15a46$export$35baa338324d8550","getTagStyle","$8c534c0378e15a46$export$2b07158757c249e0","ExtractionContext","$8c534c0378e15a46$export$4eb2a0ce903ce967","ModelInfo","$8c534c0378e15a46$export$117e56c71b172cde","EntityTag","$2c86488f2f3c1edd$export$a90600c9da52b40c","FeedbackComponent","$330ae695507d96f5$export$8d9dbb7a64bf2a5e","treeToGraph"],"version":3,"file":"index.js.map","sourceRoot":"../../../../"}
|