@linkdlab/funcnodes_react_flow 0.1.0 → 0.1.2
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/frontend/datarenderer/images.d.ts +11 -0
- package/dist/frontend/datarenderer/images.js +13 -0
- package/dist/frontend/datarenderer/images.js.map +1 -0
- package/dist/frontend/datarenderer/index.d.ts +16 -0
- package/dist/frontend/datarenderer/index.js +26 -0
- package/dist/frontend/datarenderer/index.js.map +1 -0
- package/dist/frontend/datarenderer/plotly.d.ts +14 -0
- package/dist/frontend/datarenderer/plotly.js +53 -0
- package/dist/frontend/datarenderer/plotly.js.map +1 -0
- package/dist/frontend/dialog.d.ts +17 -0
- package/dist/frontend/dialog.js +26 -0
- package/dist/frontend/dialog.js.map +1 -0
- package/dist/frontend/edge.d.ts +5 -0
- package/dist/frontend/edge.js +40 -0
- package/dist/frontend/edge.js.map +1 -0
- package/dist/frontend/funcnodesreactflow/index.d.ts +6 -0
- package/dist/frontend/funcnodesreactflow/index.js +94 -0
- package/dist/frontend/funcnodesreactflow/index.js.map +1 -0
- package/dist/frontend/funcnodesreactflow/react_flow_layer.d.ts +5 -0
- package/dist/frontend/funcnodesreactflow/react_flow_layer.js +149 -0
- package/dist/frontend/funcnodesreactflow/react_flow_layer.js.map +1 -0
- package/dist/frontend/header/index.d.ts +4 -0
- package/dist/frontend/header/index.js +227 -0
- package/dist/frontend/header/index.js.map +1 -0
- package/{src/frontend/index.tsx → dist/frontend/index.d.ts} +0 -1
- package/dist/frontend/index.js +4 -0
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/lib.d.ts +10 -0
- package/dist/frontend/lib.js +107 -0
- package/dist/frontend/lib.js.map +1 -0
- package/{src/frontend/node/index.tsx → dist/frontend/node/index.d.ts} +0 -1
- package/dist/frontend/node/index.js +3 -0
- package/dist/frontend/node/index.js.map +1 -0
- package/dist/frontend/node/io/default_input_renderer.d.ts +11 -0
- package/dist/frontend/node/io/default_input_renderer.js +235 -0
- package/dist/frontend/node/io/default_input_renderer.js.map +1 -0
- package/dist/frontend/node/io/default_output_render.d.ts +6 -0
- package/dist/frontend/node/io/default_output_render.js +23 -0
- package/dist/frontend/node/io/default_output_render.js.map +1 -0
- package/dist/frontend/node/io/handle_renderer.d.ts +6 -0
- package/dist/frontend/node/io/handle_renderer.js +70 -0
- package/dist/frontend/node/io/handle_renderer.js.map +1 -0
- package/{src/frontend/node/io/index.tsx → dist/frontend/node/io/index.d.ts} +0 -1
- package/dist/frontend/node/io/index.js +4 -0
- package/dist/frontend/node/io/index.js.map +1 -0
- package/dist/frontend/node/io/io.d.ts +16 -0
- package/dist/frontend/node/io/io.js +98 -0
- package/dist/frontend/node/io/io.js.map +1 -0
- package/dist/frontend/node/io/nodeinput.d.ts +6 -0
- package/dist/frontend/node/io/nodeinput.js +74 -0
- package/dist/frontend/node/io/nodeinput.js.map +1 -0
- package/dist/frontend/node/io/nodeoutput.d.ts +6 -0
- package/dist/frontend/node/io/nodeoutput.js +19 -0
- package/dist/frontend/node/io/nodeoutput.js.map +1 -0
- package/dist/frontend/node/node.d.ts +20 -0
- package/dist/frontend/node/node.js +118 -0
- package/dist/frontend/node/node.js.map +1 -0
- package/dist/frontend/utils/colorpicker.d.ts +19 -0
- package/dist/frontend/utils/colorpicker.js +209 -0
- package/dist/frontend/utils/colorpicker.js.map +1 -0
- package/dist/frontend/utils/jsondata.d.ts +6 -0
- package/dist/frontend/utils/jsondata.js +8 -0
- package/dist/frontend/utils/jsondata.js.map +1 -0
- package/dist/frontend/utils/table.d.ts +11 -0
- package/dist/frontend/utils/table.js +108 -0
- package/dist/frontend/utils/table.js.map +1 -0
- package/dist/funcnodes/funcnodesworker.d.ts +72 -0
- package/dist/funcnodes/funcnodesworker.js +532 -0
- package/dist/funcnodes/funcnodesworker.js.map +1 -0
- package/dist/funcnodes/index.js +5 -0
- package/dist/funcnodes/index.js.map +1 -0
- package/dist/funcnodes/websocketworker.d.ts +27 -0
- package/dist/funcnodes/websocketworker.js +224 -0
- package/dist/funcnodes/websocketworker.js.map +1 -0
- package/dist/funcnodes/workermanager.d.ts +32 -0
- package/dist/funcnodes/workermanager.js +241 -0
- package/dist/funcnodes/workermanager.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/states/edge.d.ts +7 -0
- package/dist/states/edge.js +6 -0
- package/dist/states/edge.js.map +1 -0
- package/dist/states/edge.t.d.ts +16 -0
- package/dist/states/edge.t.js +2 -0
- package/dist/states/edge.t.js.map +1 -0
- package/dist/states/fnrfzst.d.ts +10 -0
- package/dist/states/fnrfzst.js +378 -0
- package/dist/states/fnrfzst.js.map +1 -0
- package/dist/states/fnrfzst.t.d.ts +100 -0
- package/dist/states/fnrfzst.t.js +2 -0
- package/dist/states/fnrfzst.t.js.map +1 -0
- package/dist/states/index.d.ts +7 -0
- package/dist/states/index.js +6 -0
- package/dist/states/index.js.map +1 -0
- package/dist/states/lib.d.ts +3 -0
- package/dist/states/lib.js +14 -0
- package/dist/states/lib.js.map +1 -0
- package/dist/states/lib.t.d.ts +24 -0
- package/dist/states/lib.t.js +2 -0
- package/dist/states/lib.t.js.map +1 -0
- package/dist/states/node.d.ts +4 -0
- package/dist/states/node.js +43 -0
- package/dist/states/node.js.map +1 -0
- package/dist/states/node.t.d.ts +73 -0
- package/dist/states/node.t.js +2 -0
- package/dist/states/node.t.js.map +1 -0
- package/dist/states/nodeio.t.d.ts +67 -0
- package/dist/states/nodeio.t.js +2 -0
- package/dist/states/nodeio.t.js.map +1 -0
- package/dist/states/nodespace.d.ts +3 -0
- package/dist/states/nodespace.js +77 -0
- package/dist/states/nodespace.js.map +1 -0
- package/dist/states/nodespace.t.d.ts +16 -0
- package/dist/states/nodespace.t.js +2 -0
- package/dist/states/nodespace.t.js.map +1 -0
- package/dist/states/reactflow.d.ts +8 -0
- package/dist/states/reactflow.js +33 -0
- package/dist/states/reactflow.js.map +1 -0
- package/dist/states/reactflow.t.d.ts +11 -0
- package/dist/states/reactflow.t.js +2 -0
- package/dist/states/reactflow.t.js.map +1 -0
- package/dist/types/rendering.t.d.ts +10 -0
- package/dist/types/rendering.t.js +2 -0
- package/dist/types/rendering.t.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/objects.d.ts +19 -0
- package/dist/utils/objects.js +118 -0
- package/dist/utils/objects.js.map +1 -0
- package/package.json +52 -21
- package/package copy.json +0 -63
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/public/worker_manager +0 -1
- package/src/App.css +0 -38
- package/src/App.test.tsx +0 -9
- package/src/App.tsx +0 -22
- package/src/frontend/datarenderer/images.tsx +0 -28
- package/src/frontend/datarenderer/index.tsx +0 -53
- package/src/frontend/datarenderer/plotly.tsx +0 -82
- package/src/frontend/dialog.scss +0 -88
- package/src/frontend/dialog.tsx +0 -70
- package/src/frontend/edge.scss +0 -15
- package/src/frontend/edge.tsx +0 -31
- package/src/frontend/funcnodesreactflow.scss +0 -63
- package/src/frontend/funcnodesreactflow.tsx +0 -283
- package/src/frontend/header/header.scss +0 -48
- package/src/frontend/header/index.tsx +0 -268
- package/src/frontend/layout/htmlelements.scss +0 -63
- package/src/frontend/lib.scss +0 -157
- package/src/frontend/lib.tsx +0 -198
- package/src/frontend/node/io/default_input_renderer.tsx +0 -327
- package/src/frontend/node/io/default_output_render.tsx +0 -26
- package/src/frontend/node/io/handle_renderer.tsx +0 -89
- package/src/frontend/node/io/io.scss +0 -91
- package/src/frontend/node/io/io.tsx +0 -114
- package/src/frontend/node/io/nodeinput.tsx +0 -125
- package/src/frontend/node/io/nodeoutput.tsx +0 -37
- package/src/frontend/node/node.scss +0 -265
- package/src/frontend/node/node.tsx +0 -208
- package/src/frontend/nodecontextmenu.scss +0 -18
- package/src/frontend/utils/colorpicker.scss +0 -37
- package/src/frontend/utils/colorpicker.tsx +0 -342
- package/src/frontend/utils/jsondata.tsx +0 -19
- package/src/frontend/utils/table.scss +0 -22
- package/src/frontend/utils/table.tsx +0 -159
- package/src/funcnodes/funcnodesworker.ts +0 -455
- package/src/funcnodes/websocketworker.ts +0 -153
- package/src/funcnodes/workermanager.ts +0 -229
- package/src/index.css +0 -13
- package/src/index.tsx +0 -19
- package/src/logo.svg +0 -1
- package/src/react-app-env.d.ts +0 -1
- package/src/reportWebVitals.ts +0 -15
- package/src/setupTests.ts +0 -5
- package/src/state/edge.ts +0 -35
- package/src/state/fnrfzst.ts +0 -440
- package/src/state/index.ts +0 -139
- package/src/state/lib.ts +0 -26
- package/src/state/node.ts +0 -118
- package/src/state/nodespace.ts +0 -151
- package/src/state/reactflow.ts +0 -65
- package/src/types/lib.d.ts +0 -16
- package/src/types/node.d.ts +0 -29
- package/src/types/nodeio.d.ts +0 -82
- package/src/types/worker.d.ts +0 -56
- package/tsconfig.json +0 -20
- /package/{src/funcnodes/index.ts → dist/funcnodes/index.d.ts} +0 -0
package/src/frontend/lib.scss
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--expandtime: 0.3s;
|
|
3
|
-
--libnodebgcolor: #48465f;
|
|
4
|
-
--libnodebgcolor_hover: #6a6698;
|
|
5
|
-
}
|
|
6
|
-
.libcontainer {
|
|
7
|
-
top: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
|
|
10
|
-
height: 100%;
|
|
11
|
-
padding: 0.5rem;
|
|
12
|
-
box-sizing: border-box;
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
|
|
16
|
-
border-radius: 0.5rem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.library {
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-direction: column;
|
|
22
|
-
flex-grow: 1;
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
width: 15rem;
|
|
25
|
-
background-color: var(--funcnodesbackground2);
|
|
26
|
-
border-radius: var(--containerboarderradius);
|
|
27
|
-
padding: 0.5rem;
|
|
28
|
-
|
|
29
|
-
& .libtitle {
|
|
30
|
-
font-size: 1rem;
|
|
31
|
-
font-weight: bold;
|
|
32
|
-
color: var(--funheadercolor);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
& hr {
|
|
36
|
-
&.hr_prominent {
|
|
37
|
-
border: 0.5px solid var(--funheadercolor);
|
|
38
|
-
}
|
|
39
|
-
width: 100%;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.addlib {
|
|
44
|
-
background-color: var(--funcnodesbackground2);
|
|
45
|
-
border-radius: var(--containerboarderradius);
|
|
46
|
-
padding: 0.5rem;
|
|
47
|
-
|
|
48
|
-
& button {
|
|
49
|
-
background-color: var(--funcnodesbackground1);
|
|
50
|
-
color: var(--funheadercolor);
|
|
51
|
-
border: 0;
|
|
52
|
-
border-radius: 0.5rem;
|
|
53
|
-
padding: 0.5rem;
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
font-size: 1rem;
|
|
56
|
-
width: 100%;
|
|
57
|
-
&:hover {
|
|
58
|
-
background-color: var(--funheadercolor);
|
|
59
|
-
color: var(--funcnodesbackground1);
|
|
60
|
-
}
|
|
61
|
-
&:active {
|
|
62
|
-
background-color: var(--funcnodesbackground1);
|
|
63
|
-
color: var(--funcnodestextcolor1);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
& button[disabled] {
|
|
67
|
-
background-color: var(--funcnodesbackground1);
|
|
68
|
-
color: var(--funcnodestextcolor1);
|
|
69
|
-
cursor: not-allowed;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
.libfilter {
|
|
73
|
-
display: flex;
|
|
74
|
-
width: 100%;
|
|
75
|
-
flex-direction: row;
|
|
76
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
77
|
-
padding: 0.2rem;
|
|
78
|
-
&:focus-within {
|
|
79
|
-
border: 1px solid var(--funheadercolor);
|
|
80
|
-
}
|
|
81
|
-
& input {
|
|
82
|
-
flex-grow: 1;
|
|
83
|
-
background-color: transparent;
|
|
84
|
-
color: var(--funcnodestextcolor1);
|
|
85
|
-
border: 0;
|
|
86
|
-
|
|
87
|
-
&:focus {
|
|
88
|
-
outline: none;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
.libnodecontainer {
|
|
93
|
-
display: grid;
|
|
94
|
-
|
|
95
|
-
transition: grid-template-rows var(--expandtime) ease-out;
|
|
96
|
-
&.close {
|
|
97
|
-
grid-template-rows: 0fr;
|
|
98
|
-
}
|
|
99
|
-
&.open {
|
|
100
|
-
grid-template-rows: 1fr;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
&_inner {
|
|
104
|
-
transition: opacity var(--expandtime) ease-out;
|
|
105
|
-
overflow: hidden;
|
|
106
|
-
padding-left: 10px;
|
|
107
|
-
}
|
|
108
|
-
&.close &_inner {
|
|
109
|
-
opacity: 0.2;
|
|
110
|
-
}
|
|
111
|
-
&.open &_inner {
|
|
112
|
-
opacity: 1;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
.shelfcontainer {
|
|
116
|
-
padding-top: 0.2rem;
|
|
117
|
-
padding-bottom: 0.2rem;
|
|
118
|
-
display: flex;
|
|
119
|
-
flex-direction: column;
|
|
120
|
-
& .shelftitle {
|
|
121
|
-
font-size: 0.8rem;
|
|
122
|
-
|
|
123
|
-
color: var(--funheadercolor);
|
|
124
|
-
opacity: 0.8;
|
|
125
|
-
display: flex;
|
|
126
|
-
|
|
127
|
-
&_text {
|
|
128
|
-
flex-grow: 1;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.libnodeentry {
|
|
134
|
-
border-radius: 10px;
|
|
135
|
-
box-sizing: border-box;
|
|
136
|
-
background-color: var(--libnodebgcolor);
|
|
137
|
-
margin-bottom: 0.2rem;
|
|
138
|
-
// border-radius: 0.2rem;
|
|
139
|
-
padding: 0.1rem;
|
|
140
|
-
cursor: pointer;
|
|
141
|
-
border: 1px solid var(--libnodebgcolor);
|
|
142
|
-
transition: border 0.2s ease-in-out;
|
|
143
|
-
font-size: 0.8rem;
|
|
144
|
-
box-shadow: -0.2rem 0px rgba(0, 76, 255);
|
|
145
|
-
&:hover {
|
|
146
|
-
background-color: var(--libnodebgcolor_hover);
|
|
147
|
-
border: 1px solid rgba(0, 76, 255);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.expandicon {
|
|
152
|
-
transform: rotate(0deg);
|
|
153
|
-
&.close {
|
|
154
|
-
transform: rotate(180deg);
|
|
155
|
-
}
|
|
156
|
-
transition: transform var(--expandtime) ease-out;
|
|
157
|
-
}
|
package/src/frontend/lib.tsx
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import React, { useState, useContext } from "react";
|
|
2
|
-
import "./lib.scss";
|
|
3
|
-
|
|
4
|
-
import { FuncNodesReactFlowZustandInterface } from "../state";
|
|
5
|
-
import { UseBoundStore } from "zustand";
|
|
6
|
-
import { MouseEvent } from "react";
|
|
7
|
-
import { FuncNodesContext } from "./index";
|
|
8
|
-
import SearchIcon from "@mui/icons-material/Search";
|
|
9
|
-
import CloseIcon from "@mui/icons-material/Close";
|
|
10
|
-
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
|
11
|
-
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
12
|
-
import CustomDialog from "./dialog";
|
|
13
|
-
|
|
14
|
-
const LibraryNode = ({ item }: { item: LibNode }) => {
|
|
15
|
-
const zustand: FuncNodesReactFlowZustandInterface =
|
|
16
|
-
useContext(FuncNodesContext);
|
|
17
|
-
|
|
18
|
-
const add_to_flow = () => {
|
|
19
|
-
zustand.worker?.add_node(item.node_id);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const nodeclick = (event: MouseEvent<HTMLDivElement>) => {
|
|
23
|
-
// if double click, add node to graph
|
|
24
|
-
if (event.detail === 2) {
|
|
25
|
-
add_to_flow();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
return (
|
|
29
|
-
<div className="libnodeentry" onClick={nodeclick} title={item.description}>
|
|
30
|
-
{item.node_name || item.node_id}
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const filterShelf = (shelf: Shelf, filter: string): boolean => {
|
|
36
|
-
const hasFilteredNodes =
|
|
37
|
-
shelf.nodes?.some((node) =>
|
|
38
|
-
node.node_id.toLowerCase().includes(filter.toLowerCase())
|
|
39
|
-
) ?? false;
|
|
40
|
-
|
|
41
|
-
const hasFilteredSubShelves =
|
|
42
|
-
shelf.subshelves?.some((subShelf) => filterShelf(subShelf, filter)) ??
|
|
43
|
-
false;
|
|
44
|
-
|
|
45
|
-
return hasFilteredNodes || hasFilteredSubShelves;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const LibraryShelf = ({ item, filter }: { item: Shelf; filter: string }) => {
|
|
49
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
50
|
-
|
|
51
|
-
const handleToggle = () => setIsOpen(!isOpen);
|
|
52
|
-
|
|
53
|
-
const filterednodes = item.nodes?.filter((node) =>
|
|
54
|
-
node.node_id.toLowerCase().includes(filter.toLowerCase())
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const _isopen = isOpen || filter.length > 0;
|
|
58
|
-
if (!filterShelf(item, filter)) {
|
|
59
|
-
return <></>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<div className="shelfcontainer">
|
|
64
|
-
<div
|
|
65
|
-
className="shelftitle"
|
|
66
|
-
onClick={handleToggle}
|
|
67
|
-
style={{ cursor: "pointer" }}
|
|
68
|
-
title={item.description}
|
|
69
|
-
>
|
|
70
|
-
<div className="shelftitle_text">{item.name}</div>
|
|
71
|
-
<div className={"expandicon " + (_isopen ? "open" : "close")}>
|
|
72
|
-
<ExpandLessIcon />
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
<div className={"libnodecontainer " + (_isopen ? "open" : "close")}>
|
|
76
|
-
<div className="libnodecontainer_inner">
|
|
77
|
-
{filterednodes && (
|
|
78
|
-
<>
|
|
79
|
-
{filterednodes.map((subItem, idx) => (
|
|
80
|
-
<LibraryNode key={idx} item={subItem} />
|
|
81
|
-
))}
|
|
82
|
-
</>
|
|
83
|
-
)}
|
|
84
|
-
{item.subshelves && (
|
|
85
|
-
<>
|
|
86
|
-
{item.subshelves.map((subItem, idx) => (
|
|
87
|
-
<LibraryShelf key={idx} item={subItem} filter={filter} />
|
|
88
|
-
))}
|
|
89
|
-
</>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
<hr />
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const LibFilter = ({
|
|
99
|
-
filter,
|
|
100
|
-
setFilter,
|
|
101
|
-
}: {
|
|
102
|
-
filter: string;
|
|
103
|
-
setFilter: (filter: string) => void;
|
|
104
|
-
}) => {
|
|
105
|
-
// input with left icon
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<div className="libfilter">
|
|
109
|
-
<SearchIcon fontSize="inherit" />
|
|
110
|
-
<input
|
|
111
|
-
type="text"
|
|
112
|
-
placeholder="Filter"
|
|
113
|
-
value={filter}
|
|
114
|
-
onChange={(e) => {
|
|
115
|
-
setFilter(e.target.value);
|
|
116
|
-
}}
|
|
117
|
-
/>
|
|
118
|
-
{filter && (
|
|
119
|
-
<CloseIcon
|
|
120
|
-
fontSize="inherit"
|
|
121
|
-
onClick={() => {
|
|
122
|
-
setFilter("");
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
</div>
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const AddLibraryOverLay = ({ children }: { children: React.ReactNode }) => {
|
|
131
|
-
const [newlib, setNewLib] = useState("");
|
|
132
|
-
const zustand: FuncNodesReactFlowZustandInterface =
|
|
133
|
-
useContext(FuncNodesContext);
|
|
134
|
-
if (!zustand.worker) {
|
|
135
|
-
return <></>;
|
|
136
|
-
}
|
|
137
|
-
const add_new_lib = () => {
|
|
138
|
-
if (zustand.worker === undefined) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
zustand.worker.add_lib(newlib);
|
|
142
|
-
setNewLib("");
|
|
143
|
-
};
|
|
144
|
-
return (
|
|
145
|
-
<CustomDialog
|
|
146
|
-
title="Add Library"
|
|
147
|
-
trigger={children}
|
|
148
|
-
description="Add a new library to the current worker."
|
|
149
|
-
buttons={[
|
|
150
|
-
{
|
|
151
|
-
text: "add",
|
|
152
|
-
onClick: add_new_lib,
|
|
153
|
-
},
|
|
154
|
-
]}
|
|
155
|
-
>
|
|
156
|
-
<input
|
|
157
|
-
className="styledinput"
|
|
158
|
-
type="text"
|
|
159
|
-
value={newlib}
|
|
160
|
-
onChange={(e) => {
|
|
161
|
-
setNewLib(e.target.value);
|
|
162
|
-
}}
|
|
163
|
-
/>
|
|
164
|
-
</CustomDialog>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const Library = () => {
|
|
169
|
-
const zustand: FuncNodesReactFlowZustandInterface =
|
|
170
|
-
useContext(FuncNodesContext);
|
|
171
|
-
const libstate = zustand.lib.libstate((state) => state.state);
|
|
172
|
-
|
|
173
|
-
const [filter, setFilter] = useState("");
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<div className="libcontainer">
|
|
177
|
-
<div className="library">
|
|
178
|
-
<div className="libtitle">Lib</div>
|
|
179
|
-
<hr className="hr_prominent" />
|
|
180
|
-
<LibFilter filter={filter} setFilter={setFilter} />
|
|
181
|
-
<div className="vscrollcontainer">
|
|
182
|
-
{libstate.shelves.map((item, idx) => (
|
|
183
|
-
<LibraryShelf key={idx} item={item} filter={filter} />
|
|
184
|
-
))}
|
|
185
|
-
</div>
|
|
186
|
-
<hr />
|
|
187
|
-
</div>
|
|
188
|
-
<div className="addlib">
|
|
189
|
-
<AddLibraryOverLay>
|
|
190
|
-
<button disabled={zustand.worker === undefined}>Add Library</button>
|
|
191
|
-
</AddLibraryOverLay>
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export default Library;
|
|
198
|
-
export { LibraryShelf as LibraryItem };
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { FuncNodesReactFlowZustandInterface } from "../../../state";
|
|
3
|
-
|
|
4
|
-
import { FuncNodesContext } from "../../funcnodesreactflow";
|
|
5
|
-
import CustomColorPicker from "../../utils/colorpicker";
|
|
6
|
-
|
|
7
|
-
const BooleanInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
8
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
9
|
-
useContext(FuncNodesContext);
|
|
10
|
-
|
|
11
|
-
const indeterminate = io.value === undefined;
|
|
12
|
-
const cRef = useRef<HTMLInputElement>(null);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!cRef.current) return;
|
|
16
|
-
cRef.current.indeterminate = indeterminate;
|
|
17
|
-
}, [cRef, indeterminate]);
|
|
18
|
-
|
|
19
|
-
const on_change = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
20
|
-
let new_value: boolean = e.target.checked;
|
|
21
|
-
try {
|
|
22
|
-
new_value = inputconverter(e.target.checked);
|
|
23
|
-
} catch (e) {}
|
|
24
|
-
fnrf_zst.worker?.set_io_value({
|
|
25
|
-
nid: io.node,
|
|
26
|
-
ioid: io.id,
|
|
27
|
-
value: new_value,
|
|
28
|
-
set_default: io.render_options?.set_default || false,
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
return (
|
|
32
|
-
<input
|
|
33
|
-
ref={cRef}
|
|
34
|
-
type="checkbox"
|
|
35
|
-
className="styledcheckbox"
|
|
36
|
-
checked={!!io.value}
|
|
37
|
-
onChange={on_change}
|
|
38
|
-
disabled={io.connected}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
const NumberInput = ({
|
|
43
|
-
io,
|
|
44
|
-
inputconverter,
|
|
45
|
-
parser = (n: string) => parseFloat(n),
|
|
46
|
-
}: InputRendererProps & {
|
|
47
|
-
parser: (n: string) => number;
|
|
48
|
-
}) => {
|
|
49
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
50
|
-
useContext(FuncNodesContext);
|
|
51
|
-
|
|
52
|
-
const [tempvalue, setTempValue] = useState(io.value);
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
setTempValue(io.value);
|
|
56
|
-
}, [io.value]);
|
|
57
|
-
|
|
58
|
-
const set_new_value = (new_value: number | string) => {
|
|
59
|
-
new_value = parser(
|
|
60
|
-
parseFloat(new_value.toString()).toString() // parse float for e notation
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
if (isNaN(new_value)) {
|
|
64
|
-
new_value = "<NoValue>";
|
|
65
|
-
setTempValue("");
|
|
66
|
-
} else {
|
|
67
|
-
setTempValue(new_value.toString());
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
new_value = inputconverter(new_value);
|
|
71
|
-
} catch (e) {}
|
|
72
|
-
|
|
73
|
-
fnrf_zst.worker?.set_io_value({
|
|
74
|
-
nid: io.node,
|
|
75
|
-
ioid: io.id,
|
|
76
|
-
value: new_value,
|
|
77
|
-
set_default: io.render_options?.set_default || false,
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const on_change = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
82
|
-
set_new_value(e.target.value);
|
|
83
|
-
};
|
|
84
|
-
const v = io.connected ? io.value : tempvalue;
|
|
85
|
-
return (
|
|
86
|
-
<input
|
|
87
|
-
type="text"
|
|
88
|
-
className="nodedatainput styledinput"
|
|
89
|
-
value={v || ""}
|
|
90
|
-
onChange={(e) => setTempValue(e.target.value)}
|
|
91
|
-
onBlur={on_change}
|
|
92
|
-
onKeyDown={(e) => {
|
|
93
|
-
// on key up add step to value
|
|
94
|
-
|
|
95
|
-
if (e.key === "ArrowUp") {
|
|
96
|
-
let step = io.render_options?.step || 1;
|
|
97
|
-
if (e.shiftKey) step *= 10;
|
|
98
|
-
|
|
99
|
-
let new_value = (parseFloat(v) || 0) + step;
|
|
100
|
-
// setTempValue(new_value.toString());
|
|
101
|
-
set_new_value(new_value);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// on key down subtract step to value
|
|
106
|
-
if (e.key === "ArrowDown") {
|
|
107
|
-
let step = io.render_options?.step || 1;
|
|
108
|
-
if (e.shiftKey) step *= 10;
|
|
109
|
-
let new_value = (parseFloat(v) || 0) - step;
|
|
110
|
-
// setTempValue(new_value.toString());
|
|
111
|
-
set_new_value(new_value);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//accept only numbers
|
|
116
|
-
if (
|
|
117
|
-
!/^[0-9.eE+-]$/.test(e.key) &&
|
|
118
|
-
!["Backspace", "ArrowLeft", "ArrowRight", "Delete", "Tab"].includes(
|
|
119
|
-
e.key
|
|
120
|
-
)
|
|
121
|
-
) {
|
|
122
|
-
e.preventDefault();
|
|
123
|
-
}
|
|
124
|
-
}}
|
|
125
|
-
disabled={io.connected}
|
|
126
|
-
step={io.render_options?.step}
|
|
127
|
-
min={io.value_options?.min}
|
|
128
|
-
/>
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const FloatInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
133
|
-
return NumberInput({ io, inputconverter, parser: parseFloat });
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const IntegerInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
137
|
-
return NumberInput({ io, inputconverter, parser: parseInt });
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const StringInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
141
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
142
|
-
useContext(FuncNodesContext);
|
|
143
|
-
|
|
144
|
-
const [tempvalue, setTempValue] = useState(io.value);
|
|
145
|
-
|
|
146
|
-
const on_change = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
147
|
-
let new_value: string = e.target.value;
|
|
148
|
-
try {
|
|
149
|
-
new_value = inputconverter(new_value);
|
|
150
|
-
} catch (e) {}
|
|
151
|
-
|
|
152
|
-
if (!new_value) new_value = "<NoValue>";
|
|
153
|
-
|
|
154
|
-
fnrf_zst.worker?.set_io_value({
|
|
155
|
-
nid: io.node,
|
|
156
|
-
ioid: io.id,
|
|
157
|
-
value: new_value,
|
|
158
|
-
set_default: io.render_options?.set_default || false,
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<input
|
|
164
|
-
className="nodedatainput styledinput"
|
|
165
|
-
value={io.connected ? io.value : tempvalue}
|
|
166
|
-
onChange={(e) => setTempValue(e.target.value)}
|
|
167
|
-
onBlur={on_change}
|
|
168
|
-
disabled={io.connected}
|
|
169
|
-
/>
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const _parse_string = (s: string) => s;
|
|
174
|
-
const _parse_number = (s: string) => parseFloat(s);
|
|
175
|
-
const _parse_boolean = (s: string) => !!s;
|
|
176
|
-
const _parse_null = (s: string) => (s === "null" ? null : s);
|
|
177
|
-
|
|
178
|
-
const get_parser = (datatype: string | null) => {
|
|
179
|
-
if (datatype === "nuinputconvertermber") {
|
|
180
|
-
return _parse_number;
|
|
181
|
-
}
|
|
182
|
-
if (datatype === "boolean") {
|
|
183
|
-
return _parse_boolean;
|
|
184
|
-
}
|
|
185
|
-
if (datatype === "undefined") {
|
|
186
|
-
return _parse_null;
|
|
187
|
-
}
|
|
188
|
-
return _parse_string;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const SelectionInput = ({
|
|
192
|
-
io,
|
|
193
|
-
inputconverter,
|
|
194
|
-
parser,
|
|
195
|
-
}: InputRendererProps & {
|
|
196
|
-
parser?(s: string): any;
|
|
197
|
-
}) => {
|
|
198
|
-
let options: (string | number)[] | EnumOf = io.value_options?.options || [];
|
|
199
|
-
if (Array.isArray(options)) {
|
|
200
|
-
options = {
|
|
201
|
-
type: "enum",
|
|
202
|
-
values: options,
|
|
203
|
-
keys: options.map((x) => x.toString()),
|
|
204
|
-
nullable: false,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
options = options as EnumOf;
|
|
208
|
-
if (
|
|
209
|
-
options.nullable &&
|
|
210
|
-
!options.values.includes(null) &&
|
|
211
|
-
!options.keys.includes("None")
|
|
212
|
-
) {
|
|
213
|
-
options.values.unshift(null);
|
|
214
|
-
options.keys.unshift("None");
|
|
215
|
-
}
|
|
216
|
-
//make key value pairs
|
|
217
|
-
const optionsmap: [string, string, string][] = [];
|
|
218
|
-
for (let i = 0; i < options.values.length; i++) {
|
|
219
|
-
// set const t to "string", "number","boolean" "null" depenting on the type of options.values[i]
|
|
220
|
-
const t =
|
|
221
|
-
options.values[i] === null || options.values[i] === undefined
|
|
222
|
-
? "undefined"
|
|
223
|
-
: typeof options.values[i];
|
|
224
|
-
let v = options.values[i];
|
|
225
|
-
|
|
226
|
-
if (v === null) {
|
|
227
|
-
v = "null";
|
|
228
|
-
}
|
|
229
|
-
if (v === undefined) {
|
|
230
|
-
v = "undefined";
|
|
231
|
-
}
|
|
232
|
-
optionsmap.push([options.keys[i], v.toString(), t]);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
236
|
-
useContext(FuncNodesContext);
|
|
237
|
-
|
|
238
|
-
const on_change = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
239
|
-
// Find the selected option element
|
|
240
|
-
const selectedOption = e.target.options[e.target.selectedIndex];
|
|
241
|
-
// Retrieve the datatype attribute from the selected option
|
|
242
|
-
const datatype = selectedOption.getAttribute("datatype");
|
|
243
|
-
|
|
244
|
-
// Use the existing parser or get a new one based on the datatype
|
|
245
|
-
const p = parser || get_parser(datatype);
|
|
246
|
-
|
|
247
|
-
let new_value: string | number = p(e.target.value);
|
|
248
|
-
try {
|
|
249
|
-
new_value = inputconverter(e.target.value);
|
|
250
|
-
} catch (e) {}
|
|
251
|
-
|
|
252
|
-
fnrf_zst.worker?.set_io_value({
|
|
253
|
-
nid: io.node,
|
|
254
|
-
ioid: io.id,
|
|
255
|
-
value: p(e.target.value),
|
|
256
|
-
set_default: io.render_options?.set_default || false,
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
let v = io.value;
|
|
260
|
-
if (v === null) {
|
|
261
|
-
v = "null";
|
|
262
|
-
}
|
|
263
|
-
if (v === undefined) {
|
|
264
|
-
v = "undefined";
|
|
265
|
-
}
|
|
266
|
-
return (
|
|
267
|
-
<select
|
|
268
|
-
value={v}
|
|
269
|
-
onChange={on_change}
|
|
270
|
-
disabled={io.connected}
|
|
271
|
-
className="nodedatainput styleddropdown"
|
|
272
|
-
>
|
|
273
|
-
<option value="<NoValue>" disabled>
|
|
274
|
-
select
|
|
275
|
-
</option>
|
|
276
|
-
{optionsmap.map((option) => (
|
|
277
|
-
<option key={option[0]} value={option[1]} datatype={option[2]}>
|
|
278
|
-
{option[0]}
|
|
279
|
-
</option>
|
|
280
|
-
))}
|
|
281
|
-
</select>
|
|
282
|
-
);
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const ColorInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
286
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
287
|
-
useContext(FuncNodesContext);
|
|
288
|
-
|
|
289
|
-
const colorspace = io.value_options?.colorspace || "hex";
|
|
290
|
-
|
|
291
|
-
const on_change = (colorconverter?: {
|
|
292
|
-
[key: string]: () => number[] | string;
|
|
293
|
-
}) => {
|
|
294
|
-
let new_value: string | number[] = "<NoValue>";
|
|
295
|
-
if (colorconverter) {
|
|
296
|
-
if (colorconverter[colorspace]) new_value = colorconverter[colorspace]();
|
|
297
|
-
else new_value = colorconverter.hex();
|
|
298
|
-
}
|
|
299
|
-
try {
|
|
300
|
-
new_value = new_value;
|
|
301
|
-
} catch (e) {}
|
|
302
|
-
|
|
303
|
-
fnrf_zst.worker?.set_io_value({
|
|
304
|
-
nid: io.node,
|
|
305
|
-
ioid: io.id,
|
|
306
|
-
value: new_value,
|
|
307
|
-
set_default: io.render_options?.set_default || false,
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
return (
|
|
312
|
-
<CustomColorPicker
|
|
313
|
-
onChange={on_change}
|
|
314
|
-
inicolordata={io.value}
|
|
315
|
-
inicolorspace={colorspace}
|
|
316
|
-
/>
|
|
317
|
-
);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
export {
|
|
321
|
-
FloatInput,
|
|
322
|
-
IntegerInput,
|
|
323
|
-
BooleanInput,
|
|
324
|
-
StringInput,
|
|
325
|
-
SelectionInput,
|
|
326
|
-
ColorInput,
|
|
327
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { FuncNodesReactFlowZustandInterface } from "../../../state";
|
|
3
|
-
import { FuncNodesContext } from "../../funcnodesreactflow";
|
|
4
|
-
import { SortableTable } from "../../utils/table";
|
|
5
|
-
import JSONDataDisplay from "../../utils/jsondata";
|
|
6
|
-
import { Base64ImageRenderer } from "../../datarenderer/images";
|
|
7
|
-
|
|
8
|
-
const InLineOutput = ({ io }: { io: IOType }) => {
|
|
9
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
10
|
-
useContext(FuncNodesContext);
|
|
11
|
-
let value = io.fullvalue;
|
|
12
|
-
if (value == undefined) value = io.value;
|
|
13
|
-
if (value === undefined) {
|
|
14
|
-
value = "";
|
|
15
|
-
} else {
|
|
16
|
-
value = JSON.stringify(io.value).replace(/\\n/g, "\n"); //respect "\n" in strings
|
|
17
|
-
}
|
|
18
|
-
//truncate the string if it is too long
|
|
19
|
-
if (value.length > 63) {
|
|
20
|
-
value = value.slice(0, 60) + "...";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return <div>{value}</div>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { InLineOutput };
|