sample-ui-component-library 0.0.0 → 0.0.1-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/README.md +2 -2
- package/dist/LibraryManager-V1.svg +3 -0
- package/dist/cjs/index.js +31 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +31 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +13 -6
- package/rollup.config.mjs +2 -0
- package/src/components/Editor/Editor.jsx +59 -0
- package/src/components/Editor/Editor.scss +16 -0
- package/src/components/Editor/EditorTabs/EditorTabs.jsx +76 -0
- package/src/components/Editor/EditorTabs/EditorTabs.scss +22 -0
- package/src/components/Editor/MonacoInstance/MonacoInstance.jsx +66 -0
- package/src/components/Editor/MonacoInstance/MonacoInstance.scss +0 -0
- package/src/components/Editor/index.js +1 -0
- package/src/components/FileBrowser/FileBrowser.jsx +127 -0
- package/src/components/FileBrowser/FileBrowser.scss +40 -0
- package/src/components/FileBrowser/helper.js +70 -0
- package/src/components/FileBrowser/index.js +1 -0
- package/src/components/FlowDiagram/DagreLayout.js +33 -0
- package/src/components/FlowDiagram/FlowDiagram.jsx +64 -0
- package/src/components/FlowDiagram/FlowDiagram.scss +0 -0
- package/src/components/FlowDiagram/helper.js +60 -0
- package/src/components/FlowDiagram/index.js +1 -0
- package/src/components/Viewer/MonacoInstance/MonacoInstance.jsx +4 -1
- package/src/components/Viewer/Tabs/Tabs.jsx +6 -3
- package/src/components/Viewer/Viewer.jsx +3 -3
- package/src/components/Viewer/Viewer.scss +23 -3
- package/src/index.js +3 -1
- package/src/stories/Editor.stories.js +38 -0
- package/src/stories/EditorStories.scss +7 -0
- package/src/stories/FileBrowser.stories.js +48 -0
- package/src/stories/FileBrowserStories.scss +19 -0
- package/src/stories/FlowDiagram.scss +7 -0
- package/src/stories/FlowDiagram.stories.js +29 -0
- package/src/stories/data/FileBrowser/Tree1.json +57 -0
- package/src/stories/data/FileBrowser/Tree2.json +60 -0
- package/src/stories/data/flow/SampleTree.json +8 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MarkerType } from "@xyflow/react";
|
|
2
|
+
|
|
3
|
+
const marker = {
|
|
4
|
+
type: MarkerType.ArrowClosed,
|
|
5
|
+
width: 20,
|
|
6
|
+
height: 20,
|
|
7
|
+
color: '#FF0072',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const arrowStyle = {
|
|
11
|
+
strokeWidth: 2,
|
|
12
|
+
stroke: '#FF0072',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns react flow nodes and edges from the given tree.
|
|
17
|
+
* @param {Object} tree Layout tree object.
|
|
18
|
+
* @param {boolean} animated Indicates if the edges should be animated.
|
|
19
|
+
* @returns {Array} An object containing nodes and edges arrays.
|
|
20
|
+
*/
|
|
21
|
+
export const getLayoutInfoFromTree = (tree, animated) => {
|
|
22
|
+
const edges = [];
|
|
23
|
+
const nodes = [];
|
|
24
|
+
Object.keys(tree).forEach((branchName, index1) => {
|
|
25
|
+
tree[branchName].forEach((node, index) => {
|
|
26
|
+
|
|
27
|
+
// Position doesn't matter, it will be set by layout algorithm
|
|
28
|
+
const flowNode = {
|
|
29
|
+
id: node,
|
|
30
|
+
flowId: node,
|
|
31
|
+
position: { x: 250, y: index * 200 },
|
|
32
|
+
data: { label: String(node) }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (index == 0) {
|
|
36
|
+
flowNode.type = "input"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (index > 0) {
|
|
40
|
+
const prevNode = nodes[nodes.length-1]
|
|
41
|
+
const edge = {
|
|
42
|
+
id: prevNode.flowId + "-" + branchName + "-" + index + "-" + flowNode.flowId,
|
|
43
|
+
source: prevNode.flowId,
|
|
44
|
+
target: flowNode.flowId,
|
|
45
|
+
animated: animated,
|
|
46
|
+
markerEnd: marker,
|
|
47
|
+
style: arrowStyle
|
|
48
|
+
}
|
|
49
|
+
edges.push(edge);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
nodes.push(flowNode);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
nodes: nodes,
|
|
58
|
+
edges: edges
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FlowDiagram.jsx"
|
|
@@ -109,9 +109,12 @@ export const Tabs = ({files, selectFile, systemTree}) => {
|
|
|
109
109
|
|
|
110
110
|
useEffect(() => {
|
|
111
111
|
if (files && files.length > 0) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
const numFiles = Math.floor(Math.random() * files.length) + 1;
|
|
113
|
+
const newFiles = files.slice(0, numFiles);
|
|
114
|
+
setTabsList(newFiles);
|
|
115
|
+
const randomFileIndex = Math.floor(Math.random() * newFiles.length);
|
|
116
|
+
setActiveTab(newFiles[randomFileIndex].key);
|
|
117
|
+
selectFile(newFiles[randomFileIndex].key);
|
|
115
118
|
}
|
|
116
119
|
}, [files]);
|
|
117
120
|
|
|
@@ -67,11 +67,11 @@ export const Viewer = ({systemTree, onFileSelect}) => {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
|
-
<div className="viewerContainer
|
|
71
|
-
<div>
|
|
70
|
+
<div className="viewerContainer">
|
|
71
|
+
<div className="tabContainer">
|
|
72
72
|
<Tabs files={files} selectFile={selectFile} systemTree={systemTree}/>
|
|
73
73
|
</div>
|
|
74
|
-
<div className="
|
|
74
|
+
<div className="monacoContainer">
|
|
75
75
|
<MonacoInstance editorContent={editorContent}/>
|
|
76
76
|
</div>
|
|
77
77
|
</div>
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
.viewerContainer {
|
|
2
|
-
position:
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
position: absolute;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
bottom: 0;
|
|
6
|
+
right:0;
|
|
7
|
+
overflow:hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.tabContainer{
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
bottom: 40px;
|
|
15
|
+
right:0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.monacoContainer{
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 40px;
|
|
21
|
+
left: 0;
|
|
22
|
+
bottom: 0;
|
|
23
|
+
right:0;
|
|
24
|
+
|
|
5
25
|
}
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { Editor } from "../components/Editor";
|
|
3
|
+
import { useArgs } from "@storybook/preview-api";
|
|
4
|
+
import { action } from "@storybook/addon-actions";
|
|
5
|
+
|
|
6
|
+
import fileTrees from "./data/filetree.json";
|
|
7
|
+
|
|
8
|
+
import "./EditorStories.scss"
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Editor',
|
|
12
|
+
component: Editor,
|
|
13
|
+
argTypes: {}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = (args) => {
|
|
17
|
+
const [, updateArgs] = useArgs();
|
|
18
|
+
|
|
19
|
+
const onFileSelect = (selectedFile) => {
|
|
20
|
+
action('Selected Stack Position:')(selectedFile);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
updateArgs({onFileSelect : onFileSelect});
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="editorStoryWrapper">
|
|
29
|
+
<Editor {...args} />
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Default = Template.bind({});
|
|
35
|
+
|
|
36
|
+
Default.args = {
|
|
37
|
+
systemTree: fileTrees.fileTrees
|
|
38
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { FileBrowser } from "../components/FileBrowser";
|
|
3
|
+
import { useArgs } from "@storybook/preview-api";
|
|
4
|
+
import { action } from "@storybook/addon-actions";
|
|
5
|
+
|
|
6
|
+
import FileTree1 from "./data/FileBrowser/Tree1.json"
|
|
7
|
+
import FileTree2 from "./data/FileBrowser/Tree2.json"
|
|
8
|
+
|
|
9
|
+
import "./FileBrowserStories.scss"
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'FileBrowser',
|
|
13
|
+
component: FileBrowser,
|
|
14
|
+
argTypes: {}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const Template = (args) => {
|
|
19
|
+
const [, updateArgs] = useArgs();
|
|
20
|
+
|
|
21
|
+
const onNodeSelect = (selectedFile) => {
|
|
22
|
+
action('Selected Node:')(selectedFile);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
updateArgs({onNodeSelect : onNodeSelect});
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="viewerStoryWrapper">
|
|
31
|
+
<div className="file-browser">
|
|
32
|
+
<FileBrowser {...args} />
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const Default = Template.bind({});
|
|
39
|
+
|
|
40
|
+
Default.args = {
|
|
41
|
+
tree: FileTree1.tree
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Tree2 = Template.bind({});
|
|
45
|
+
|
|
46
|
+
Tree2.args = {
|
|
47
|
+
tree: FileTree2.tree
|
|
48
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.viewerStoryWrapper{
|
|
2
|
+
position: absolute;
|
|
3
|
+
top:0;
|
|
4
|
+
bottom:0;
|
|
5
|
+
left:0;
|
|
6
|
+
right:0;
|
|
7
|
+
display:flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.viewerStoryWrapper > .file-browser{
|
|
13
|
+
height: 300px;
|
|
14
|
+
background-color: #333;
|
|
15
|
+
overflow: auto;
|
|
16
|
+
scrollbar-gutter: stable;
|
|
17
|
+
scrollbar-color: #47474766 #252526;
|
|
18
|
+
scrollbar-width: thin;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FlowDiagram } from "../components/FlowDiagram";
|
|
2
|
+
import "./FlowDiagram.scss"
|
|
3
|
+
|
|
4
|
+
import sampleTree from "./data/flow/SampleTree.json";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'FlowDiagram',
|
|
8
|
+
component: FlowDiagram,
|
|
9
|
+
argTypes: {
|
|
10
|
+
treeInfo: {
|
|
11
|
+
type: 'array'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Template = (args) => {
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="rootTraceContainer">
|
|
20
|
+
<FlowDiagram {...args}/>
|
|
21
|
+
</div>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Default = Template.bind({})
|
|
26
|
+
|
|
27
|
+
Default.args = {
|
|
28
|
+
treeInfo: sampleTree
|
|
29
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tree": [
|
|
3
|
+
{
|
|
4
|
+
"id": 1,
|
|
5
|
+
"name": "root",
|
|
6
|
+
"type": "folder",
|
|
7
|
+
"children": [
|
|
8
|
+
{
|
|
9
|
+
"id": 2,
|
|
10
|
+
"name": "TraceViewer",
|
|
11
|
+
"type": "folder",
|
|
12
|
+
"children": [
|
|
13
|
+
{
|
|
14
|
+
"id": 3,
|
|
15
|
+
"name": "file1.js",
|
|
16
|
+
"type": "file"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 4,
|
|
20
|
+
"name": "fileTree.json",
|
|
21
|
+
"type": "file"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": 5,
|
|
27
|
+
"name": "LogInjector",
|
|
28
|
+
"type": "folder",
|
|
29
|
+
"children": [
|
|
30
|
+
{
|
|
31
|
+
"id": 6,
|
|
32
|
+
"name": "injector.py",
|
|
33
|
+
"type": "file"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": 7,
|
|
41
|
+
"name": "sample.py",
|
|
42
|
+
"type": "file"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": 8,
|
|
46
|
+
"name": "DesignViewer",
|
|
47
|
+
"type": "folder",
|
|
48
|
+
"children": [
|
|
49
|
+
{
|
|
50
|
+
"id": 9,
|
|
51
|
+
"name": "test.js",
|
|
52
|
+
"type": "file"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tree": [
|
|
3
|
+
{
|
|
4
|
+
"id": 1,
|
|
5
|
+
"name": "TraceViewer",
|
|
6
|
+
"type": "folder",
|
|
7
|
+
"children": [
|
|
8
|
+
{
|
|
9
|
+
"id": 2,
|
|
10
|
+
"name": "FileBrowser.stories.js",
|
|
11
|
+
"type": "file"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": 3,
|
|
15
|
+
"name": "FileBrowserStories.scss",
|
|
16
|
+
"type": "file"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": 4,
|
|
20
|
+
"name": "FlowDiagram.stories.js",
|
|
21
|
+
"type": "file"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": 5,
|
|
25
|
+
"name": "FlowDiagram.scss",
|
|
26
|
+
"type": "file"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": 6,
|
|
32
|
+
"name": "Data",
|
|
33
|
+
"type": "folder",
|
|
34
|
+
"children": [
|
|
35
|
+
{
|
|
36
|
+
"id": 7,
|
|
37
|
+
"name": "fileTree.json",
|
|
38
|
+
"type": "file"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": 8,
|
|
42
|
+
"name": "FileBrowser",
|
|
43
|
+
"type": "folder",
|
|
44
|
+
"children": [
|
|
45
|
+
{
|
|
46
|
+
"id": 9,
|
|
47
|
+
"name": "fileTree.json",
|
|
48
|
+
"type": "file"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": 10,
|
|
52
|
+
"name": "Tree2.json",
|
|
53
|
+
"type": "file"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|