sample-ui-component-library 0.0.50-dev → 0.0.52-dev

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.
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from "react";
2
- import { FileEarmark, XLg } from "react-bootstrap-icons";
2
+ import { FileEarmark, XLg, CircleFill } from "react-bootstrap-icons";
3
3
  import { useDraggable } from "@dnd-kit/core";
4
4
  import PropTypes from "prop-types";
5
5
 
@@ -19,7 +19,7 @@ const INACTIVE_TAB_FG_COLOR = "#969690";
19
19
  * @param {String} label
20
20
  * @returns
21
21
  */
22
- export const Tab = ({ id, parentId, node }) => {
22
+ export const Tab = ({ id, isDirty, parentId, node }) => {
23
23
  const [tabStyle, setTabStyle] = useState();
24
24
 
25
25
  const { selectTab, closeTab, state } = useEditor();
@@ -70,6 +70,11 @@ export const Tab = ({ id, parentId, node }) => {
70
70
  {...attributes}
71
71
  >
72
72
  <div className="tab-content">
73
+ {isDirty &&
74
+ <div className="icon">
75
+ <CircleFill size={6}/>
76
+ </div>
77
+ }
73
78
  <div className="icon">
74
79
  <FileEarmark size={14} style={{ pointerEvents: "none" }} />
75
80
  </div>
@@ -22,7 +22,7 @@ export const Tabs = () => {
22
22
  if (state.tabs?.length >= 0 && state.parentTabGroupId != null) {
23
23
  drawTabs(state.tabs, state.parentTabGroupId);
24
24
  }
25
- }, [state.tabs, state.parentTabGroupId]);
25
+ }, [state.tabs, state.modifiedIndicator, state.parentTabGroupId]);
26
26
 
27
27
  /**
28
28
  * Draw the tabs provided in the tabs info. This includes the gutters
@@ -34,7 +34,7 @@ export const Tabs = () => {
34
34
  const list = [];
35
35
  tabs.forEach((tab, index) => {
36
36
  list.push(<Gutter key={tab.uid + "-gutter"} id={tabGroupId + "-" + index} index={index} parentId={tabGroupId} />);
37
- list.push(<Tab key={tab.uid} id={tabGroupId + "-" + tab.uid} parentId={tabGroupId} node={tab} />);
37
+ list.push(<Tab key={tab.uid} isDirty={tab.isDirty} id={tabGroupId + "-" + tab.uid} parentId={tabGroupId} node={tab} />);
38
38
  });
39
39
  list.push(<Gutter key="last-gutter" id={tabGroupId + "-" + tabs.length} index={tabs.length} parentId={tabGroupId} />);
40
40
  setTabsList(list);
@@ -46,23 +46,33 @@ const Template = (args) => {
46
46
 
47
47
  const [dragPreviewLabel, setDragPreviewLabel] = useState(<></>);
48
48
  const [selectTool, setSelectTool] = useState("select");
49
+ const [mappedIds, setMappedIds] = useState([
50
+ "c4f43010-71ef-46e6-bf38-0548d3a34012",
51
+ "8bf2605a-1940-49de-9b2f-0efa22bf658c"
52
+ ]);
49
53
 
50
54
  const editorRef = useRef();
51
55
 
52
56
  useLayoutEffect(() => {
53
57
  editorRef.current.setTabGroupId("tab-group-1");
54
- flattenTree(WorkspaceSampleTree.tree).forEach((node, index) => {
58
+ flattenTree(WorkspaceSampleTree.tree).slice(1,5).forEach((node, index) => {
55
59
  if (node.type === "file") {
56
60
  editorRef.current.addTab(node);
57
61
  }
58
62
  });
59
63
 
60
- const result = flattenTree(WorkspaceSampleTree.tree).find(
61
- (obj) => obj.name === "TransactionDB.py"
62
- );
63
- editorRef.current.addTab(result);translator_mapping
64
- editorRef.current.setMapping("TransactionDB.py", transactiondb_mapping);
65
- editorRef.current.setMapping("FrenchTranslator.py", translator_mapping);
64
+ // const result = flattenTree(WorkspaceSampleTree.tree).find(
65
+ // (obj) => obj.name === "TransactionDB.py"
66
+ // );
67
+ // editorRef.current.addTab(result);translator_mapping
68
+ // editorRef.current.setMapping("TransactionDB.py", transactiondb_mapping);
69
+ // editorRef.current.setMapping("FrenchTranslator.py", translator_mapping);
70
+ // editorRef.current.setMappedIds(mappedIds);
71
+
72
+ // setTimeout(() => {
73
+ // console.log(editorRef.current.getTabs());
74
+ // console.log(editorRef.current.getActiveTab());
75
+ // }, 5000);
66
76
  }, []);
67
77
 
68
78
  const [dragging, setDragging] = useState(false);
@@ -139,6 +149,16 @@ const Template = (args) => {
139
149
  }
140
150
  }, [editorRef]);
141
151
 
152
+ const onSelectAbstraction = useCallback((entry) => {
153
+ action("Abstraction Selected")(entry);
154
+ const found = mappedIds.find((id) => id === entry.uid);
155
+ const newMap = (found)?
156
+ mappedIds.filter((id) => id !== found):
157
+ [...mappedIds, entry.uid];
158
+ setMappedIds(newMap);
159
+ editorRef.current.setMappedIds(newMap);
160
+ }, [mappedIds, setMappedIds, editorRef]);
161
+
142
162
  return (
143
163
  <DndContext sensors={sensors} onDragStart={onDragStart} onDragEnd={handleDragEnd}>
144
164
 
@@ -147,7 +167,7 @@ const Template = (args) => {
147
167
  <ToolBarEditor onSelectTool={onSelectTool} />
148
168
  </div>
149
169
  <div className="flow">
150
- <Editor ref={editorRef}{...args} />
170
+ <Editor ref={editorRef} onSelectAbstraction={onSelectAbstraction} {...args} />
151
171
  {dragging && (
152
172
  <div
153
173
  style={{