@macrostrat/feedback-components 1.0.0

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -0
  3. package/dist/edit-state.e8edb13a.js +251 -0
  4. package/dist/edit-state.e8edb13a.js.map +1 -0
  5. package/dist/extractions.54be85f8.js +177 -0
  6. package/dist/extractions.54be85f8.js.map +1 -0
  7. package/dist/feedback.46c2b5c4.js +252 -0
  8. package/dist/feedback.46c2b5c4.js.map +1 -0
  9. package/dist/feedback.module.7e16830e.css +44 -0
  10. package/dist/feedback.module.7e16830e.css.map +1 -0
  11. package/dist/feedback.module.c28cbac7.js +28 -0
  12. package/dist/feedback.module.c28cbac7.js.map +1 -0
  13. package/dist/graph.cb42b871.js +83 -0
  14. package/dist/graph.cb42b871.js.map +1 -0
  15. package/dist/index.d.ts +145 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +9 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/main.module.21bbfaf4.js +19 -0
  20. package/dist/main.module.21bbfaf4.js.map +1 -0
  21. package/dist/main.module.ca3db294.js +16 -0
  22. package/dist/main.module.ca3db294.js.map +1 -0
  23. package/dist/main.module.d6508c0e.css +14 -0
  24. package/dist/main.module.d6508c0e.css.map +1 -0
  25. package/dist/main.module.f9f92ece.css +17 -0
  26. package/dist/main.module.f9f92ece.css.map +1 -0
  27. package/dist/node.30d0b8c3.js +59 -0
  28. package/dist/node.30d0b8c3.js.map +1 -0
  29. package/dist/text-visualizer.77af0d24.js +101 -0
  30. package/dist/text-visualizer.77af0d24.js.map +1 -0
  31. package/dist/type-selector.e75dd247.js +62 -0
  32. package/dist/type-selector.e75dd247.js.map +1 -0
  33. package/package.json +48 -0
  34. package/src/extractions/index.ts +219 -0
  35. package/src/extractions/main.module.sass +10 -0
  36. package/src/extractions/types.ts +30 -0
  37. package/src/feedback/edit-state.ts +311 -0
  38. package/src/feedback/feedback.module.sass +37 -0
  39. package/src/feedback/graph.ts +98 -0
  40. package/src/feedback/index.ts +271 -0
  41. package/src/feedback/node.ts +65 -0
  42. package/src/feedback/text-visualizer.ts +116 -0
  43. package/src/feedback/type-selector/index.ts +75 -0
  44. package/src/feedback/type-selector/main.module.sass +13 -0
  45. package/src/feedback/types.ts +76 -0
  46. package/src/index.ts +2 -0
  47. package/stories/feedback.stories.ts +40 -0
  48. package/stories/test-data.ts +330 -0
@@ -0,0 +1,252 @@
1
+ import "./feedback.module.7e16830e.css";
2
+ import $2Wjkf$feedbackmodulec28cbac7js from "./feedback.module.c28cbac7.js";
3
+ import $b6b9741bf83336eb$export$2e2bcd8739ae039 from "./node.30d0b8c3.js";
4
+ import {FeedbackText as $156a3efbc315814c$export$6e107db9091b8219} from "./text-visualizer.77af0d24.js";
5
+ import {ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967} from "./extractions.54be85f8.js";
6
+ import {useUpdatableTree as $b79bf29960412ca7$export$911bb4b9c8065d3d, TreeDispatchContext as $b79bf29960412ca7$export$e5ce04c5b3f58533, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./edit-state.e8edb13a.js";
7
+ import {OmniboxSelector as $fda9ef5406c1cfb4$export$d8660660a589068c} from "./type-selector.e75dd247.js";
8
+ import {GraphView as $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566} from "./graph.cb42b871.js";
9
+ import $2Wjkf$macrostrathyper from "@macrostrat/hyper";
10
+ import {Tree as $2Wjkf$Tree} from "react-arborist";
11
+ import {useRef as $2Wjkf$useRef, useCallback as $2Wjkf$useCallback, useEffect as $2Wjkf$useEffect} from "react";
12
+ import {SegmentedControl as $2Wjkf$SegmentedControl, Card as $2Wjkf$Card, ButtonGroup as $2Wjkf$ButtonGroup} from "@blueprintjs/core";
13
+ import {FlexRow as $2Wjkf$FlexRow, CancelButton as $2Wjkf$CancelButton, SaveButton as $2Wjkf$SaveButton, DataField as $2Wjkf$DataField} from "@macrostrat/ui-components";
14
+ import $2Wjkf$useelementdimensions from "use-element-dimensions";
15
+
16
+
17
+ function $parcel$interopDefault(a) {
18
+ return a && a.__esModule ? a.default : a;
19
+ }
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ const $71d20dff35996763$var$h = (0, $2Wjkf$macrostrathyper).styled((0, ($parcel$interopDefault($2Wjkf$feedbackmodulec28cbac7js))));
34
+ function $71d20dff35996763$var$setsAreTheSame(a, b) {
35
+ if (a.size !== b.size) return false;
36
+ for (const item of a){
37
+ if (!b.has(item)) return false;
38
+ }
39
+ return true;
40
+ }
41
+ function $71d20dff35996763$export$a90600c9da52b40c({ entities: entities = [], text: text, model: model, entityTypes: entityTypes, matchComponent: matchComponent, onSave: onSave }) {
42
+ // Get the input arguments
43
+ const [state, dispatch] = (0, $b79bf29960412ca7$export$911bb4b9c8065d3d)(entities.map($71d20dff35996763$var$processEntity), entityTypes);
44
+ const { selectedNodes: selectedNodes, tree: tree, selectedEntityType: selectedEntityType, isSelectingEntityType: isSelectingEntityType } = state;
45
+ const [{ width: width, height: height }, ref] = (0, $2Wjkf$useelementdimensions)();
46
+ return $71d20dff35996763$var$h((0, $b79bf29960412ca7$export$e5ce04c5b3f58533).Provider, {
47
+ value: dispatch
48
+ }, [
49
+ $71d20dff35996763$var$h((0, $156a3efbc315814c$export$6e107db9091b8219), {
50
+ text: text,
51
+ dispatch: dispatch,
52
+ // @ts-ignore
53
+ nodes: tree,
54
+ selectedNodes: selectedNodes
55
+ }),
56
+ $71d20dff35996763$var$h((0, $2Wjkf$FlexRow), {
57
+ alignItems: "baseline",
58
+ justifyContent: "space-between"
59
+ }, [
60
+ $71d20dff35996763$var$h((0, $03d8811e9c9b360d$export$4eb2a0ce903ce967), {
61
+ data: model
62
+ }),
63
+ $71d20dff35996763$var$h((0, $2Wjkf$SegmentedControl), {
64
+ options: [
65
+ {
66
+ label: "Tree",
67
+ value: "tree"
68
+ },
69
+ {
70
+ label: "Graph",
71
+ value: "graph"
72
+ }
73
+ ],
74
+ value: state.viewMode,
75
+ small: true,
76
+ onValueChange (value) {
77
+ console.log("Setting view mode", value);
78
+ dispatch({
79
+ type: "set-view-mode",
80
+ payload: value
81
+ });
82
+ }
83
+ })
84
+ ]),
85
+ $71d20dff35996763$var$h("div.entity-panel", {
86
+ ref: ref
87
+ }, [
88
+ $71d20dff35996763$var$h((0, $2Wjkf$Card), {
89
+ className: "control-panel"
90
+ }, [
91
+ $71d20dff35996763$var$h((0, $2Wjkf$ButtonGroup), {
92
+ vertical: true,
93
+ fill: true,
94
+ minimal: true,
95
+ alignText: "left"
96
+ }, [
97
+ $71d20dff35996763$var$h((0, $2Wjkf$CancelButton), {
98
+ icon: "trash",
99
+ disabled: state.initialTree == state.tree,
100
+ onClick () {
101
+ dispatch({
102
+ type: "reset"
103
+ });
104
+ }
105
+ }, "Reset"),
106
+ $71d20dff35996763$var$h((0, $2Wjkf$SaveButton), {
107
+ onClick () {
108
+ onSave(state.tree);
109
+ },
110
+ disabled: state.initialTree == state.tree
111
+ }, "Save")
112
+ ]),
113
+ $71d20dff35996763$var$h($71d20dff35996763$var$EntityTypeSelector, {
114
+ entityTypes: entityTypes,
115
+ selected: selectedEntityType,
116
+ onChange (payload) {
117
+ dispatch({
118
+ type: "select-entity-type",
119
+ payload: payload
120
+ });
121
+ },
122
+ isOpen: isSelectingEntityType,
123
+ setOpen: (isOpen)=>dispatch({
124
+ type: "toggle-entity-type-selector",
125
+ payload: isOpen
126
+ })
127
+ })
128
+ ]),
129
+ $71d20dff35996763$var$h.if(state.viewMode == "tree")($71d20dff35996763$var$ManagedSelectionTree, {
130
+ selectedNodes: selectedNodes,
131
+ dispatch: dispatch,
132
+ tree: tree,
133
+ width: width,
134
+ height: height,
135
+ matchComponent: matchComponent
136
+ }),
137
+ $71d20dff35996763$var$h.if(state.viewMode == "graph")((0, $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566), {
138
+ tree: tree,
139
+ width: width,
140
+ height: height
141
+ })
142
+ ])
143
+ ]);
144
+ }
145
+ function $71d20dff35996763$var$processEntity(entity) {
146
+ // @ts-ignore
147
+ return {
148
+ ...entity,
149
+ // @ts-ignore
150
+ term_type: entity.type.name,
151
+ txt_range: [
152
+ entity.indices
153
+ ],
154
+ children: entity.children?.map($71d20dff35996763$var$processEntity) ?? []
155
+ };
156
+ }
157
+ function $71d20dff35996763$var$EntityTypeSelector({ entityTypes: entityTypes, selected: selected, isOpen: isOpen, setOpen: setOpen, onChange: onChange }) {
158
+ // Show all entity types when selected is null
159
+ const _selected = selected != null ? selected : undefined;
160
+ return $71d20dff35996763$var$h((0, $2Wjkf$DataField), {
161
+ label: "Entity type",
162
+ inline: true
163
+ }, [
164
+ $71d20dff35996763$var$h("code.bp5-code", {
165
+ onClick () {
166
+ setOpen((d)=>!d);
167
+ }
168
+ }, selected.name),
169
+ $71d20dff35996763$var$h((0, $fda9ef5406c1cfb4$export$d8660660a589068c), {
170
+ isOpen: isOpen,
171
+ items: Array.from(entityTypes.values()),
172
+ selectedItem: _selected,
173
+ onSelectItem (item) {
174
+ setOpen(false);
175
+ onChange(item);
176
+ },
177
+ onClose () {
178
+ setOpen(false);
179
+ }
180
+ })
181
+ ]);
182
+ }
183
+ function $71d20dff35996763$var$ManagedSelectionTree(props) {
184
+ const { selectedNodes: selectedNodes, dispatch: dispatch, tree: tree, height: height, width: width, matchComponent: matchComponent, ...rest } = props;
185
+ const ref = (0, $2Wjkf$useRef)();
186
+ const _Node = (0, $2Wjkf$useCallback)((props)=>$71d20dff35996763$var$h((0, $b6b9741bf83336eb$export$2e2bcd8739ae039), {
187
+ ...props,
188
+ matchComponent: matchComponent
189
+ }), [
190
+ matchComponent
191
+ ]);
192
+ (0, $2Wjkf$useEffect)(()=>{
193
+ if (ref.current == null) return;
194
+ // Check if selection matches current
195
+ const selection = new Set(selectedNodes.map((d)=>d.toString()));
196
+ const currentSelection = ref.current.selectedIds;
197
+ if ($71d20dff35996763$var$setsAreTheSame(selection, currentSelection)) return;
198
+ // If the selection is the same, do nothing
199
+ // Set selection
200
+ ref.current.setSelection({
201
+ ids: selectedNodes.map((d)=>d.toString()),
202
+ anchor: null,
203
+ mostRecent: null
204
+ });
205
+ }, [
206
+ selectedNodes
207
+ ]);
208
+ return $71d20dff35996763$var$h((0, $2Wjkf$Tree), {
209
+ className: "selection-tree",
210
+ height: height,
211
+ width: width,
212
+ ref: ref,
213
+ data: tree,
214
+ onMove ({ dragIds: dragIds, parentId: parentId, index: index }) {
215
+ dispatch({
216
+ type: "move-node",
217
+ payload: {
218
+ dragIds: dragIds.map((d)=>parseInt(d)),
219
+ parentId: parentId ? parseInt(parentId) : null,
220
+ index: index
221
+ }
222
+ });
223
+ },
224
+ onDelete ({ ids: ids }) {
225
+ dispatch({
226
+ type: "delete-node",
227
+ payload: {
228
+ ids: ids.map((d)=>parseInt(d))
229
+ }
230
+ });
231
+ },
232
+ onSelect (nodes) {
233
+ let ids = nodes.map((d)=>parseInt(d.id));
234
+ if (ids.length == 1 && ids[0] == selectedNodes[0]) // Deselect
235
+ ids = [];
236
+ dispatch({
237
+ type: "select-node",
238
+ payload: {
239
+ ids: ids
240
+ }
241
+ });
242
+ },
243
+ children: _Node,
244
+ idAccessor (d) {
245
+ return d.id.toString();
246
+ }
247
+ });
248
+ }
249
+
250
+
251
+ export {$71d20dff35996763$export$a90600c9da52b40c as FeedbackComponent, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e as treeToGraph};
252
+ //# sourceMappingURL=feedback.46c2b5c4.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,0EAAK;AAE5B,SAAS,qCAAkB,CAAS,EAAE,CAAS;IAC7C,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EAAE,OAAO;IAC9B,KAAK,MAAM,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AAS;oBAAE,KAAK,IAAI,GAAG,CAAC,CAAC,IAAM,SAAS;gBAAI;YAC9C;QACF;QACA,UAAS,KAAK;YACZ,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC,IAAM,SAAS,EAAE,EAAE;YACxC,IAAI,IAAI,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE,IAAI,aAAa,CAAC,EAAE,EAC/C,WAAW;YACX,MAAM,EAAE;YAEV,SAAS;gBAAE,MAAM;gBAAe,SAAS;yBAAE;gBAAI;YAAE;QACnD;QACA,UAAU;QACV,YAAW,CAAW;YACpB,OAAO,EAAE,EAAE,CAAC,QAAQ;QACtB;IACF;AACF","sources":["packages/feedback-components/src/feedback/index.ts"],"sourcesContent":["import styles from \"./feedback.module.sass\";\nimport hyper from \"@macrostrat/hyper\";\n\nimport { Tree, TreeApi } from \"react-arborist\";\nimport Node from \"./node\";\nimport { FeedbackText } from \"./text-visualizer\";\nimport type { InternalEntity, TreeData } from \"./types\";\nimport type { Entity } from \"../extractions\";\nimport { ModelInfo } from \"../extractions\";\nimport {\n TreeDispatchContext,\n treeToGraph,\n useUpdatableTree,\n ViewMode,\n} from \"./edit-state\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport { ButtonGroup, Card, SegmentedControl } from \"@blueprintjs/core\";\nimport { OmniboxSelector } from \"./type-selector\";\nimport {\n CancelButton,\n DataField,\n FlexBox,\n FlexRow,\n SaveButton,\n} from \"@macrostrat/ui-components\";\nimport useElementDimensions from \"use-element-dimensions\";\nimport { GraphView } from \"./graph\";\n\nexport type { GraphData } from \"./edit-state\";\nexport { treeToGraph } from \"./edit-state\";\nexport type { TreeData } from \"./types\";\n\nconst h = hyper.styled(styles);\n\nfunction setsAreTheSame<T>(a: Set<T>, b: Set<T>) {\n if (a.size !== b.size) return false;\n for (const item of a) {\n if (!b.has(item)) return false;\n }\n return true;\n}\n\nexport function FeedbackComponent({\n entities = [],\n text,\n model,\n entityTypes,\n matchComponent,\n onSave,\n}) {\n // Get the input arguments\n\n const [state, dispatch] = useUpdatableTree(\n entities.map(processEntity) as any,\n entityTypes\n );\n\n const { selectedNodes, tree, selectedEntityType, isSelectingEntityType } =\n state;\n\n const [{ width, height }, ref] = useElementDimensions();\n\n return h(TreeDispatchContext.Provider, { value: dispatch }, [\n h(FeedbackText, {\n text,\n dispatch,\n // @ts-ignore\n nodes: tree,\n selectedNodes,\n }),\n h(FlexRow, { alignItems: \"baseline\", justifyContent: \"space-between\" }, [\n h(ModelInfo, { data: model }),\n h(SegmentedControl, {\n options: [\n { label: \"Tree\", value: \"tree\" },\n { label: \"Graph\", value: \"graph\" },\n ],\n value: state.viewMode,\n small: true,\n onValueChange(value: ViewMode) {\n console.log(\"Setting view mode\", value);\n dispatch({ type: \"set-view-mode\", payload: value });\n },\n }),\n ]),\n h(\n \"div.entity-panel\",\n {\n ref,\n },\n [\n h(Card, { className: \"control-panel\" }, [\n h(\n ButtonGroup,\n {\n vertical: true,\n fill: true,\n minimal: true,\n alignText: \"left\",\n },\n [\n h(\n CancelButton,\n {\n icon: \"trash\",\n disabled: state.initialTree == state.tree,\n onClick() {\n dispatch({ type: \"reset\" });\n },\n },\n \"Reset\"\n ),\n h(\n SaveButton,\n {\n onClick() {\n onSave(state.tree);\n },\n disabled: state.initialTree == state.tree,\n },\n \"Save\"\n ),\n ]\n ),\n h(EntityTypeSelector, {\n entityTypes,\n selected: selectedEntityType,\n onChange(payload) {\n dispatch({ type: \"select-entity-type\", payload });\n },\n isOpen: isSelectingEntityType,\n setOpen: (isOpen: boolean) =>\n dispatch({\n type: \"toggle-entity-type-selector\",\n payload: isOpen,\n }),\n }),\n ]),\n h.if(state.viewMode == \"tree\")(ManagedSelectionTree, {\n selectedNodes,\n dispatch,\n tree,\n width,\n height,\n matchComponent,\n }),\n h.if(state.viewMode == \"graph\")(GraphView, {\n tree,\n width,\n height,\n }),\n ]\n ),\n ]);\n}\n\nfunction processEntity(entity: Entity): InternalEntity {\n // @ts-ignore\n return {\n ...entity,\n // @ts-ignore\n term_type: entity.type.name,\n txt_range: [entity.indices],\n children: entity.children?.map(processEntity) ?? [],\n };\n}\n\nfunction EntityTypeSelector({\n entityTypes,\n selected,\n isOpen,\n setOpen,\n onChange,\n}) {\n // Show all entity types when selected is null\n const _selected = selected != null ? selected : undefined;\n return h(DataField, { label: \"Entity type\", inline: true }, [\n h(\n \"code.bp5-code\",\n {\n onClick() {\n setOpen((d) => !d);\n },\n },\n selected.name\n ),\n h(OmniboxSelector, {\n isOpen,\n items: Array.from(entityTypes.values()),\n selectedItem: _selected,\n onSelectItem(item) {\n setOpen(false);\n onChange(item);\n },\n onClose() {\n setOpen(false);\n },\n }),\n ]);\n}\n\nfunction ManagedSelectionTree(props) {\n const {\n selectedNodes,\n dispatch,\n tree,\n height,\n width,\n matchComponent,\n ...rest\n } = props;\n\n const ref = useRef<TreeApi<TreeData>>();\n\n const _Node = useCallback(\n (props) => h(Node, { ...props, matchComponent }),\n [matchComponent]\n );\n\n useEffect(() => {\n if (ref.current == null) return;\n // Check if selection matches current\n const selection = new Set(selectedNodes.map((d) => d.toString()));\n const currentSelection = ref.current.selectedIds;\n if (setsAreTheSame(selection, currentSelection)) return;\n // If the selection is the same, do nothing\n\n // Set selection\n ref.current.setSelection({\n ids: selectedNodes.map((d) => d.toString()),\n anchor: null,\n mostRecent: null,\n });\n }, [selectedNodes]);\n\n return h(Tree, {\n className: \"selection-tree\",\n height,\n width,\n ref,\n data: tree,\n onMove({ dragIds, parentId, index }) {\n dispatch({\n type: \"move-node\",\n payload: {\n dragIds: dragIds.map((d) => parseInt(d)),\n parentId: parentId ? parseInt(parentId) : null,\n index,\n },\n });\n },\n onDelete({ ids }) {\n dispatch({\n type: \"delete-node\",\n payload: { ids: ids.map((d) => parseInt(d)) },\n });\n },\n onSelect(nodes) {\n let ids = nodes.map((d) => parseInt(d.id));\n if (ids.length == 1 && ids[0] == selectedNodes[0]) {\n // Deselect\n ids = [];\n }\n dispatch({ type: \"select-node\", payload: { ids } });\n },\n children: _Node,\n idAccessor(d: TreeData) {\n return d.id.toString();\n },\n });\n}\n"],"names":[],"version":3,"file":"feedback.46c2b5c4.js.map"}
@@ -0,0 +1,44 @@
1
+ .QoX8-W_feedback-component {
2
+ width: 800px;
3
+ position: relative;
4
+ }
5
+
6
+ .QoX8-W_feedback-component > svg {
7
+ width: 800px;
8
+ }
9
+
10
+ .QoX8-W_node {
11
+ cursor: pointer;
12
+ }
13
+
14
+ .QoX8-W_feedback-text {
15
+ margin-bottom: 2em;
16
+ }
17
+
18
+ .QoX8-W_entity-panel {
19
+ max-height: 600px;
20
+ position: relative;
21
+ }
22
+
23
+ .QoX8-W_control-panel {
24
+ max-width: 15em;
25
+ padding: .2em .5em;
26
+ position: absolute;
27
+ top: 1em;
28
+ right: 1em;
29
+ }
30
+
31
+ .QoX8-W_entity-panel {
32
+ background: var(--panel-secondary-background-color);
33
+ min-height: 100px;
34
+ box-shadow: 0 0 0 1px var(--panel-border-color) inset;
35
+ border-radius: 4px;
36
+ flex: 1;
37
+ padding: 1em;
38
+ }
39
+
40
+ .QoX8-W_selection-tree {
41
+ margin: -1em 0;
42
+ padding: 1em 0;
43
+ }
44
+ /*# sourceMappingURL=feedback.module.7e16830e.css.map */
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;AAIE;;;;AAGF;;;;AAIA;;;;AAGA;;;;;AAIA;;;;;;;;AAOA;;;;;;;;;AASA","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n"],"names":[],"version":3,"file":"feedback.module.7e16830e.css.map"}
@@ -0,0 +1,28 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+ var $49c87ee97f392268$exports = {};
6
+
7
+ $parcel$export($49c87ee97f392268$exports, "control-panel", () => $49c87ee97f392268$export$a0a23f31d5562853, (v) => $49c87ee97f392268$export$a0a23f31d5562853 = v);
8
+ $parcel$export($49c87ee97f392268$exports, "entity-panel", () => $49c87ee97f392268$export$38f2cd12e45697e, (v) => $49c87ee97f392268$export$38f2cd12e45697e = v);
9
+ $parcel$export($49c87ee97f392268$exports, "feedback-component", () => $49c87ee97f392268$export$579bd45c78bf5510, (v) => $49c87ee97f392268$export$579bd45c78bf5510 = v);
10
+ $parcel$export($49c87ee97f392268$exports, "feedback-text", () => $49c87ee97f392268$export$890489be1870bed5, (v) => $49c87ee97f392268$export$890489be1870bed5 = v);
11
+ $parcel$export($49c87ee97f392268$exports, "node", () => $49c87ee97f392268$export$35059013cd4a06db, (v) => $49c87ee97f392268$export$35059013cd4a06db = v);
12
+ $parcel$export($49c87ee97f392268$exports, "selection-tree", () => $49c87ee97f392268$export$3ae1b51693c80a9c, (v) => $49c87ee97f392268$export$3ae1b51693c80a9c = v);
13
+ var $49c87ee97f392268$export$a0a23f31d5562853;
14
+ var $49c87ee97f392268$export$38f2cd12e45697e;
15
+ var $49c87ee97f392268$export$579bd45c78bf5510;
16
+ var $49c87ee97f392268$export$890489be1870bed5;
17
+ var $49c87ee97f392268$export$35059013cd4a06db;
18
+ var $49c87ee97f392268$export$3ae1b51693c80a9c;
19
+ $49c87ee97f392268$export$a0a23f31d5562853 = `QoX8-W_control-panel`;
20
+ $49c87ee97f392268$export$38f2cd12e45697e = `QoX8-W_entity-panel`;
21
+ $49c87ee97f392268$export$579bd45c78bf5510 = `QoX8-W_feedback-component`;
22
+ $49c87ee97f392268$export$890489be1870bed5 = `QoX8-W_feedback-text`;
23
+ $49c87ee97f392268$export$35059013cd4a06db = `QoX8-W_node`;
24
+ $49c87ee97f392268$export$3ae1b51693c80a9c = `QoX8-W_selection-tree`;
25
+
26
+
27
+ export {$49c87ee97f392268$exports as default};
28
+ //# sourceMappingURL=feedback.module.c28cbac7.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,2CAAiC,CAAC,mBAAmB,CAAC;AACtD,4CAAuC,CAAC,yBAAyB,CAAC;AAClE,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,4CAAyB,CAAC,WAAW,CAAC;AACtC,4CAAmC,CAAC,qBAAqB,CAAC","sources":["packages/feedback-components/src/feedback/feedback.module.sass"],"sourcesContent":[".feedback-component\n position: relative\n width: 800px\n\n & > svg\n width: 800px\n\n.node\n cursor: pointer\n\n\n.feedback-text\n margin-bottom: 2em\n\n.entity-panel\n position: relative\n max-height: 600px\n\n.control-panel\n max-width: 15em\n position: absolute\n top: 1em\n right: 1em\n padding: 0.2em 0.5em\n\n.entity-panel\n flex: 1\n min-height: 100px\n padding: 1em\n background: var(--panel-secondary-background-color)\n border-radius: 4px\n // Inset box shadow\n box-shadow: 0 0 0 1px var(--panel-border-color) inset\n\n.selection-tree\n margin: -1em 0\n padding: 1em 0\n"],"names":[],"version":3,"file":"feedback.module.c28cbac7.js.map"}
@@ -0,0 +1,83 @@
1
+ import {treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./edit-state.e8edb13a.js";
2
+ import $aW1K8$macrostrathyper from "@macrostrat/hyper";
3
+ import {forceSimulation as $aW1K8$forceSimulation, forceLink as $aW1K8$forceLink, forceManyBody as $aW1K8$forceManyBody, forceCenter as $aW1K8$forceCenter, forceCollide as $aW1K8$forceCollide} from "d3-force";
4
+ import {useState as $aW1K8$useState, useEffect as $aW1K8$useEffect} from "react";
5
+ import {Spinner as $aW1K8$Spinner} from "@blueprintjs/core";
6
+
7
+
8
+
9
+
10
+
11
+
12
+ function $ff8c3e7f2bc22925$export$6a7fe3ef90e8d566(props) {
13
+ // A graph view with react-flow
14
+ // Get positions of nodes using force simulation
15
+ const { tree: tree, width: width, height: height } = props;
16
+ const [nodes, setNodes] = (0, $aW1K8$useState)(null);
17
+ const [links, setLinks] = (0, $aW1K8$useState)(null);
18
+ (0, $aW1K8$useEffect)(()=>{
19
+ const { nodes: nodes, edges: edges } = (0, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e)(tree);
20
+ const nodesMap = new Map(nodes.map((d)=>[
21
+ d.id,
22
+ d
23
+ ]));
24
+ const links = edges.map((d)=>{
25
+ return {
26
+ source: nodesMap.get(d.source),
27
+ target: nodesMap.get(d.dest),
28
+ strength: 1
29
+ };
30
+ });
31
+ const simulation = (0, $aW1K8$forceSimulation)(nodes).force("link", (0, $aW1K8$forceLink)(links)).force("charge", (0, $aW1K8$forceManyBody)().strength(-50)).force("center", (0, $aW1K8$forceCenter)(width / 2, height / 2)).force("collide", (0, $aW1K8$forceCollide)().radius(20)).on("tick", ()=>{
32
+ // Update the positions of the nodes
33
+ // setNodes(nodes);
34
+ console.log("Simulation tick");
35
+ }).on("end", ()=>{
36
+ // Update the positions of the nodes
37
+ setNodes(nodes);
38
+ setLinks(links);
39
+ });
40
+ return ()=>{
41
+ simulation.stop();
42
+ };
43
+ }, [
44
+ tree,
45
+ width,
46
+ height
47
+ ]);
48
+ if (nodes == null || links == null) return (0, $aW1K8$macrostrathyper)((0, $aW1K8$Spinner));
49
+ console.log("Graph", nodes, links);
50
+ return (0, $aW1K8$macrostrathyper)("div.graph-view", {
51
+ style: {
52
+ width: width,
53
+ height: height
54
+ }
55
+ }, [
56
+ (0, $aW1K8$macrostrathyper)("svg", {
57
+ width: width,
58
+ height: height
59
+ }, [
60
+ (0, $aW1K8$macrostrathyper)("g.nodes", nodes.map((d)=>{
61
+ return (0, $aW1K8$macrostrathyper)("circle", {
62
+ cx: d.x,
63
+ cy: d.y,
64
+ r: 5,
65
+ fill: "blue"
66
+ });
67
+ })),
68
+ (0, $aW1K8$macrostrathyper)("g.links", links.map((d)=>{
69
+ return (0, $aW1K8$macrostrathyper)("line", {
70
+ x1: d.source.x,
71
+ y1: d.source.y,
72
+ x2: d.target.x,
73
+ y2: d.target.y,
74
+ stroke: "black"
75
+ });
76
+ }))
77
+ ])
78
+ ]);
79
+ }
80
+
81
+
82
+ export {$ff8c3e7f2bc22925$export$6a7fe3ef90e8d566 as GraphView};
83
+ //# sourceMappingURL=graph.cb42b871.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAgBO,SAAS,0CAAU,KAIzB;IACC,+BAA+B;IAC/B,gDAAgD;IAChD,MAAM,QAAE,IAAI,SAAE,KAAK,UAAE,MAAM,EAAE,GAAG;IAEhC,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAyB;IAC1D,MAAM,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAyB;IAE1D,CAAA,GAAA,gBAAQ,EAAE;QACR,MAAM,SAAE,KAAK,SAAE,KAAK,EAAE,GAAG,CAAA,GAAA,yCAAU,EAAE;QAErC,MAAM,WAAW,IAAI,IACnB,MAAM,GAAG,CAAC,CAAC,IAAM;gBAAC,EAAE,EAAE;gBAAE;aAAE;QAG5B,MAAM,QAAQ,MAAM,GAAG,CAAC,CAAC;YACvB,OAAO;gBACL,QAAQ,SAAS,GAAG,CAAC,EAAE,MAAM;gBAC7B,QAAQ,SAAS,GAAG,CAAC,EAAE,IAAI;gBAC3B,UAAU;YACZ;QACF;QAEA,MAAM,aAAa,CAAA,GAAA,sBAAc,EAAE,OAChC,KAAK,CAAC,QAAQ,CAAA,GAAA,gBAAQ,EAAE,QACxB,KAAK,CAAC,UAAU,CAAA,GAAA,oBAAY,IAAI,QAAQ,CAAC,MACzC,KAAK,CAAC,UAAU,CAAA,GAAA,kBAAU,EAAE,QAAQ,GAAG,SAAS,IAChD,KAAK,CAAC,WAAW,CAAA,GAAA,mBAAW,IAAI,MAAM,CAAC,KACvC,EAAE,CAAC,QAAQ;YACV,oCAAoC;YACpC,mBAAmB;YACnB,QAAQ,GAAG,CAAC;QACd,GACC,EAAE,CAAC,OAAO;YACT,oCAAoC;YACpC,SAAS;YACT,SAAS;QACX;QAEF,OAAO;YACL,WAAW,IAAI;QACjB;IACF,GAAG;QAAC;QAAM;QAAO;KAAO;IAExB,IAAI,SAAS,QAAQ,SAAS,MAC5B,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,cAAM;IAGjB,QAAQ,GAAG,CAAC,SAAS,OAAO;IAE5B,OAAO,CAAA,GAAA,sBAAA,EAAE,kBAAkB;QAAE,OAAO;mBAAE;oBAAO;QAAO;IAAE,GAAG;QACvD,CAAA,GAAA,sBAAA,EAAE,OAAO;mBAAE;oBAAO;QAAO,GAAG;YAC1B,CAAA,GAAA,sBAAA,EACE,WACA,MAAM,GAAG,CAAC,CAAC;gBACT,OAAO,CAAA,GAAA,sBAAA,EAAE,UAAU;oBACjB,IAAI,EAAE,CAAC;oBACP,IAAI,EAAE,CAAC;oBACP,GAAG;oBACH,MAAM;gBACR;YACF;YAEF,CAAA,GAAA,sBAAA,EACE,WACA,MAAM,GAAG,CAAC,CAAC;gBACT,OAAO,CAAA,GAAA,sBAAA,EAAE,QAAQ;oBACf,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,CAAC;oBACd,QAAQ;gBACV;YACF;SAEH;KACF;AACH","sources":["packages/feedback-components/src/feedback/graph.ts"],"sourcesContent":["import { TreeData } from \"./types\";\nimport { treeToGraph } from \"./edit-state\";\nimport h from \"@macrostrat/hyper\";\n\nimport {\n forceSimulation,\n SimulationNodeDatum,\n SimulationLinkDatum,\n forceCenter,\n forceLink,\n forceManyBody,\n forceCollide,\n} from \"d3-force\";\nimport { useEffect, useState } from \"react\";\nimport { Spinner } from \"@blueprintjs/core\";\n\nexport function GraphView(props: {\n tree: TreeData[];\n width: number;\n height: number;\n}) {\n // A graph view with react-flow\n // Get positions of nodes using force simulation\n const { tree, width, height } = props;\n\n const [nodes, setNodes] = useState<SimulationNodeDatum[]>(null);\n const [links, setLinks] = useState<SimulationLinkDatum[]>(null);\n\n useEffect(() => {\n const { nodes, edges } = treeToGraph(tree);\n\n const nodesMap = new Map<number, SimulationNodeDatum>(\n nodes.map((d) => [d.id, d])\n );\n\n const links = edges.map((d) => {\n return {\n source: nodesMap.get(d.source),\n target: nodesMap.get(d.dest),\n strength: 1,\n };\n });\n\n const simulation = forceSimulation(nodes)\n .force(\"link\", forceLink(links))\n .force(\"charge\", forceManyBody().strength(-50))\n .force(\"center\", forceCenter(width / 2, height / 2))\n .force(\"collide\", forceCollide().radius(20))\n .on(\"tick\", () => {\n // Update the positions of the nodes\n // setNodes(nodes);\n console.log(\"Simulation tick\");\n })\n .on(\"end\", () => {\n // Update the positions of the nodes\n setNodes(nodes);\n setLinks(links);\n });\n\n return () => {\n simulation.stop();\n };\n }, [tree, width, height]);\n\n if (nodes == null || links == null) {\n return h(Spinner);\n }\n\n console.log(\"Graph\", nodes, links);\n\n return h(\"div.graph-view\", { style: { width, height } }, [\n h(\"svg\", { width, height }, [\n h(\n \"g.nodes\",\n nodes.map((d) => {\n return h(\"circle\", {\n cx: d.x,\n cy: d.y,\n r: 5,\n fill: \"blue\",\n });\n })\n ),\n h(\n \"g.links\",\n links.map((d) => {\n return h(\"line\", {\n x1: d.source.x,\n y1: d.source.y,\n x2: d.target.x,\n y2: d.target.y,\n stroke: \"black\",\n });\n })\n ),\n ]),\n ]);\n}\n"],"names":[],"version":3,"file":"graph.cb42b871.js.map"}
@@ -0,0 +1,145 @@
1
+ import { CSSProperties, HTMLAttributes, DetailedReactHTMLElement, DOMAttributes, DOMElement, FunctionComponentElement, Dispatch, ProviderProps } from "react";
2
+ import { TagProps } from "@blueprintjs/core";
3
+ type EntityType = {
4
+ name: string;
5
+ color: string;
6
+ id: number;
7
+ };
8
+ type Match = any;
9
+ export interface Entity {
10
+ id: number;
11
+ name: string;
12
+ type?: number;
13
+ indices: [number, number];
14
+ children: Entity[];
15
+ match?: Match;
16
+ }
17
+ type Highlight = {
18
+ start: number;
19
+ end: number;
20
+ tag?: string;
21
+ text?: string;
22
+ backgroundColor?: string;
23
+ borderColor?: string;
24
+ id: number;
25
+ parents?: number[];
26
+ };
27
+ export interface EntityExt extends Omit<Entity, "type" | "children"> {
28
+ type: EntityType;
29
+ children: EntityExt[];
30
+ parents?: number[];
31
+ }
32
+ export function buildHighlights(entities: EntityExt[], parent: EntityExt | null): Highlight[];
33
+ export function enhanceData(extractionData: any, models: any, entityTypes: any): any;
34
+ export function getTagStyle(baseColor: string, options: {
35
+ highlighted?: boolean;
36
+ inDarkMode?: boolean;
37
+ active?: boolean;
38
+ }): CSSProperties;
39
+ export function ExtractionContext({ data, entityTypes, matchComponent, }: {
40
+ data: any;
41
+ entityTypes: Map<number, EntityType>;
42
+ matchComponent: MatchComponent;
43
+ }): DetailedReactHTMLElement<HTMLAttributes<HTMLElement>, HTMLElement>;
44
+ export function ModelInfo({ data }: {
45
+ data: any;
46
+ }): DOMElement<DOMAttributes<Element>, Element>;
47
+ export type MatchComponent = (props: {
48
+ data: any;
49
+ }) => any;
50
+ type EntityTagProps = {
51
+ data: EntityExt;
52
+ highlighted?: boolean;
53
+ active?: boolean;
54
+ onClickType?: (type: EntityType) => void;
55
+ matchComponent?: MatchComponent;
56
+ };
57
+ export function EntityTag({ data, highlighted, active, onClickType, matchComponent, }: EntityTagProps): FunctionComponentElement<TagProps>;
58
+ export type TreeData = EntityExt;
59
+ enum ViewMode {
60
+ Tree = "tree",
61
+ Graph = "graph"
62
+ }
63
+ type TextRange = {
64
+ start: number;
65
+ end: number;
66
+ text: string;
67
+ };
68
+ type TreeAction = {
69
+ type: "move-node";
70
+ payload: {
71
+ dragIds: number[];
72
+ parentId: number;
73
+ index: number;
74
+ };
75
+ } | {
76
+ type: "delete-node";
77
+ payload: {
78
+ ids: number[];
79
+ };
80
+ } | {
81
+ type: "select-node";
82
+ payload: {
83
+ ids: number[];
84
+ };
85
+ } | {
86
+ type: "toggle-node-selected";
87
+ payload: {
88
+ ids: number[];
89
+ };
90
+ } | {
91
+ type: "set-view-mode";
92
+ payload: ViewMode;
93
+ } | {
94
+ type: "create-node";
95
+ payload: TextRange;
96
+ } | {
97
+ type: "select-entity-type";
98
+ payload: EntityType;
99
+ } | {
100
+ type: "toggle-entity-type-selector";
101
+ payload?: boolean | null;
102
+ } | {
103
+ type: "deselect";
104
+ } | {
105
+ type: "reset";
106
+ };
107
+ type TreeDispatch = Dispatch<TreeAction>;
108
+ interface EntityOutput {
109
+ id: number;
110
+ type: number | null;
111
+ txt_range: number[][];
112
+ name: string;
113
+ match: any | null;
114
+ reasoning: string | null;
115
+ }
116
+ export interface GraphData {
117
+ nodes: EntityOutput[];
118
+ edges: {
119
+ source: number;
120
+ dest: number;
121
+ }[];
122
+ }
123
+ export function treeToGraph(tree: TreeData[]): GraphData;
124
+ declare namespace InfiniteScrollView {
125
+ var defaultProps: {
126
+ hasMore(res: any): boolean;
127
+ getItems(d: any): any;
128
+ getCount(d: any): any;
129
+ getNextParams(response: any, params: any): any;
130
+ placeholder: (p: APIPlaceholderProps) => React.ComponentElement<$$parcel$import$212<HTMLElement>, Spinner>;
131
+ };
132
+ }
133
+ declare namespace ThreeColumnLayout {
134
+ var Panels: typeof SidePanel;
135
+ }
136
+ export function FeedbackComponent({ entities, text, model, entityTypes, matchComponent, onSave, }: {
137
+ entities?: any[];
138
+ text: any;
139
+ model: any;
140
+ entityTypes: any;
141
+ matchComponent: any;
142
+ onSave: any;
143
+ }): FunctionComponentElement<ProviderProps<TreeDispatch>>;
144
+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components/src/src/extractions/types.ts","packages/feedback-components/color-utils/src/index.ts","packages/feedback-components/src/src/extractions/index.ts","packages/feedback-components/src/src/feedback/types.ts","packages/feedback-components/src/src/feedback/edit-state.ts","packages/feedback-components/src/src/feedback/node.ts","packages/feedback-components/src/src/feedback/text-visualizer.ts","packages/feedback-components/src/src/feedback/type-selector/index.ts","packages/feedback-components/ui-components/src/api/types.ts","packages/feedback-components/ui-components/src/util/query-string.ts","packages/feedback-components/ui-components/src/util/state-hooks.ts","packages/feedback-components/ui-components/src/util/layout-hooks.ts","packages/feedback-components/ui-components/src/util/local-storage.ts","packages/feedback-components/ui-components/src/util/json-view.ts","packages/feedback-components/ui-components/src/util/scroll-helpers.ts","packages/feedback-components/ui-components/src/util/migration-helpers.ts","packages/feedback-components/ui-components/src/util/box-model.ts","packages/feedback-components/ui-components/src/util/event-hooks.ts","packages/feedback-components/ui-components/src/util/flexbox.ts","packages/feedback-components/ui-components/src/util/size-aware-label.ts","packages/feedback-components/ui-components/src/util/index.ts","packages/feedback-components/ui-components/src/api/provider.ts","packages/feedback-components/ui-components/src/api/data-provider.ts","packages/feedback-components/ui-components/src/api/indexing.ts","packages/feedback-components/ui-components/src/api/frontend.ts","packages/feedback-components/ui-components/src/api/paged.ts","packages/feedback-components/ui-components/src/api/index.ts","packages/feedback-components/ui-components/src/infinite-scroll.ts","packages/feedback-components/ui-components/src/buttons/delete-button.ts","packages/feedback-components/ui-components/src/buttons/index.ts","packages/feedback-components/ui-components/src/collapse-panel/index.ts","packages/feedback-components/ui-components/src/link-card.ts","packages/feedback-components/ui-components/src/file-upload/index.ts","packages/feedback-components/ui-components/src/image.ts","packages/feedback-components/ui-components/src/model-editor.ts","packages/feedback-components/ui-components/src/toaster.ts","packages/feedback-components/ui-components/src/citations/author-list.ts","packages/feedback-components/ui-components/src/citations/index.ts","packages/feedback-components/ui-components/src/geodeepdive/reference-card.ts","packages/feedback-components/ui-components/src/geodeepdive/index.ts","packages/feedback-components/ui-components/src/text.ts","packages/feedback-components/ui-components/src/dark-mode.ts","packages/feedback-components/ui-components/src/form-controls/slider.ts","packages/feedback-components/ui-components/src/form-controls/index.ts","packages/feedback-components/ui-components/src/settings/index.ts","packages/feedback-components/ui-components/src/error-boundary.ts","packages/feedback-components/ui-components/src/patterns/composite-image.ts","packages/feedback-components/ui-components/src/patterns/index.ts","packages/feedback-components/ui-components/src/collapse-card.ts","packages/feedback-components/ui-components/src/modal-panel/draggable-overlay.ts","packages/feedback-components/ui-components/src/modal-panel/index.ts","packages/feedback-components/ui-components/src/page-layouts/index.ts","packages/feedback-components/ui-components/src/dev-panel/_inner.ts","packages/feedback-components/ui-components/src/dev-panel/index.ts","packages/feedback-components/ui-components/src/data/index.ts","packages/feedback-components/ui-components/src/index.ts","packages/feedback-components/src/src/feedback/graph.ts","packages/feedback-components/src/src/feedback/index.ts","packages/feedback-components/src/src/index.ts","packages/feedback-components/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"export * from \"./extractions\";\nexport * from \"./feedback\";\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import {buildHighlights as $03d8811e9c9b360d$export$c4b91360064ad200, enhanceData as $03d8811e9c9b360d$export$d60b563f571177d, getTagStyle as $03d8811e9c9b360d$export$35baa338324d8550, ExtractionContext as $03d8811e9c9b360d$export$2b07158757c249e0, ModelInfo as $03d8811e9c9b360d$export$4eb2a0ce903ce967, EntityTag as $03d8811e9c9b360d$export$117e56c71b172cde} from "./extractions.54be85f8.js";
2
+ import {FeedbackComponent as $71d20dff35996763$export$a90600c9da52b40c, treeToGraph as $b79bf29960412ca7$export$8d9dbb7a64bf2a5e} from "./feedback.46c2b5c4.js";
3
+
4
+
5
+
6
+
7
+
8
+ export {$03d8811e9c9b360d$export$c4b91360064ad200 as buildHighlights, $03d8811e9c9b360d$export$d60b563f571177d as enhanceData, $03d8811e9c9b360d$export$35baa338324d8550 as getTagStyle, $03d8811e9c9b360d$export$2b07158757c249e0 as ExtractionContext, $03d8811e9c9b360d$export$4eb2a0ce903ce967 as ModelInfo, $03d8811e9c9b360d$export$117e56c71b172cde as EntityTag, $71d20dff35996763$export$a90600c9da52b40c as FeedbackComponent, $b79bf29960412ca7$export$8d9dbb7a64bf2a5e as treeToGraph};
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"","sources":["packages/feedback-components/src/index.ts"],"sourcesContent":["export * from \"./extractions\";\nexport * from \"./feedback\";\n"],"names":[],"version":3,"file":"index.js.map"}
@@ -0,0 +1,19 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+ var $f8bcd91cbf17e53f$exports = {};
6
+
7
+ $parcel$export($f8bcd91cbf17e53f$exports, "item-container", () => $f8bcd91cbf17e53f$export$68a2d1df2d976de8, (v) => $f8bcd91cbf17e53f$export$68a2d1df2d976de8 = v);
8
+ $parcel$export($f8bcd91cbf17e53f$exports, "selected", () => $f8bcd91cbf17e53f$export$d90250155de6d7e7, (v) => $f8bcd91cbf17e53f$export$d90250155de6d7e7 = v);
9
+ $parcel$export($f8bcd91cbf17e53f$exports, "swatch", () => $f8bcd91cbf17e53f$export$c672d9950c40fe0a, (v) => $f8bcd91cbf17e53f$export$c672d9950c40fe0a = v);
10
+ var $f8bcd91cbf17e53f$export$68a2d1df2d976de8;
11
+ var $f8bcd91cbf17e53f$export$d90250155de6d7e7;
12
+ var $f8bcd91cbf17e53f$export$c672d9950c40fe0a;
13
+ $f8bcd91cbf17e53f$export$68a2d1df2d976de8 = `WofFTa_item-container`;
14
+ $f8bcd91cbf17e53f$export$d90250155de6d7e7 = `WofFTa_selected`;
15
+ $f8bcd91cbf17e53f$export$c672d9950c40fe0a = `WofFTa_swatch`;
16
+
17
+
18
+ export {$f8bcd91cbf17e53f$exports as default};
19
+ //# sourceMappingURL=main.module.21bbfaf4.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AAFA,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,eAAe,CAAC;AAC9C,4CAA2B,CAAC,aAAa,CAAC","sources":["packages/feedback-components/src/feedback/type-selector/main.module.sass"],"sourcesContent":[".item-container\n min-height: 40px\n display: flex\n align-items: center\n gap: 1em\n\n &.selected\n background-color: var(--panel-background-color)\n\n.swatch\n width: 30px\n height: 30px\n border-radius: 4px\n"],"names":[],"version":3,"file":"main.module.21bbfaf4.js.map"}