sample-ui-component-library 0.0.19-dev → 0.0.24-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.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Editor/Tabs/Tabs.jsx +1 -1
- package/src/components/FileBrowser/FileBrowserReducer.js +18 -23
- package/src/components/FileBrowser/TreeNode/TreeNode.jsx +4 -3
package/package.json
CHANGED
|
@@ -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={tab.uid} parentId={tabGroupId} node={tab} />);
|
|
37
|
+
list.push(<Tab key={tab.uid} 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);
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setDefaultCollapsed,
|
|
3
|
-
collapseTree,
|
|
4
|
-
flattenTree,
|
|
5
|
-
} from "./helper";
|
|
1
|
+
import { setDefaultCollapsed, collapseTree, flattenTree } from "./helper";
|
|
6
2
|
|
|
7
3
|
//TODO: I should set a unique id for each reducer state and use it
|
|
8
4
|
// for all the ids of the components to make them unique. I could
|
|
@@ -15,9 +11,7 @@ export const initialState = {
|
|
|
15
11
|
};
|
|
16
12
|
|
|
17
13
|
export const fileBrowserReducer = (state, action) => {
|
|
18
|
-
|
|
19
14
|
switch (action.type) {
|
|
20
|
-
|
|
21
15
|
case "ADD_FILE_TREE": {
|
|
22
16
|
let flattenedTree = setDefaultCollapsed(flattenTree(action.payload));
|
|
23
17
|
const collapsedTree = collapseTree(flattenedTree);
|
|
@@ -25,33 +19,34 @@ export const fileBrowserReducer = (state, action) => {
|
|
|
25
19
|
...state,
|
|
26
20
|
tree: action.payload,
|
|
27
21
|
flattenedTree: flattenedTree,
|
|
28
|
-
collapsedTree: collapsedTree
|
|
29
|
-
}
|
|
22
|
+
collapsedTree: collapsedTree,
|
|
23
|
+
};
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
case "SELECT_NODE": {
|
|
33
|
-
const tree =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} else {
|
|
41
|
-
n.selected = false;
|
|
27
|
+
const tree = state.flattenedTree.map((n) => {
|
|
28
|
+
if (n.uid === action.payload.uid) {
|
|
29
|
+
return {
|
|
30
|
+
...n,
|
|
31
|
+
selected: true,
|
|
32
|
+
collapsed: !n.collapsed,
|
|
33
|
+
};
|
|
42
34
|
}
|
|
35
|
+
return {
|
|
36
|
+
...n,
|
|
37
|
+
selected: false,
|
|
38
|
+
};
|
|
43
39
|
});
|
|
44
|
-
const collapsedTree = collapseTree(tree);
|
|
45
40
|
return {
|
|
46
41
|
...state,
|
|
47
42
|
flattenedTree: tree,
|
|
48
|
-
collapsedTree:
|
|
49
|
-
selectedNode:
|
|
50
|
-
}
|
|
43
|
+
collapsedTree: collapseTree(tree),
|
|
44
|
+
selectedNode: action.payload,
|
|
45
|
+
};
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
case "RESET_STATE": {
|
|
54
49
|
return initialState;
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
|
-
}
|
|
52
|
+
};
|
|
@@ -10,6 +10,7 @@ const INDENT_WIDTH = 20;
|
|
|
10
10
|
const SELECTED_FILE_COLOR = "#00426b";
|
|
11
11
|
|
|
12
12
|
import "./TreeNode.scss";
|
|
13
|
+
import { useCallback } from "react";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Renders a single node in the file tree.
|
|
@@ -71,9 +72,9 @@ export const TreeNode = ({ id, node }) => {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const onSelectRow = () => {
|
|
75
|
-
selectNode(node
|
|
76
|
-
}
|
|
75
|
+
const onSelectRow = useCallback(() => {
|
|
76
|
+
selectNode(node);
|
|
77
|
+
}, [selectNode]);
|
|
77
78
|
|
|
78
79
|
return (
|
|
79
80
|
<div className="file-node-row" ref={setNodeRef} {...listeners} {...attributes}
|