@linkdlab/funcnodes_react_flow 0.1.1 → 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/{module/src/frontend/index.tsx → dist/frontend/index.d.ts} +1 -2
- 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/{module/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/{module/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/{module/src/states/edge.t.ts → dist/states/edge.t.d.ts} +8 -12
- 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.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/{module/src/states/node.t.ts → dist/states/node.t.d.ts} +33 -58
- 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/{module/src/states/nodespace.ts → dist/states/nodespace.js} +17 -30
- 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/{module/src/types/rendering.t.ts → dist/types/rendering.t.d.ts} +4 -7
- package/dist/types/rendering.t.js +2 -0
- package/dist/types/rendering.t.js.map +1 -0
- package/{module/src/utils/index.ts → dist/utils/index.d.ts} +0 -1
- 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 +32 -23
- package/app/public/favicon.ico +0 -0
- package/app/public/index.html +0 -43
- package/app/public/logo192.png +0 -0
- package/app/public/logo512.png +0 -0
- package/app/public/manifest.json +0 -25
- package/app/public/robots.txt +0 -3
- package/app/public/worker_manager +0 -1
- package/app/src/App.css +0 -38
- package/app/src/App.test.tsx +0 -9
- package/app/src/App.tsx +0 -22
- package/app/src/index.css +0 -13
- package/app/src/index.tsx +0 -19
- package/app/src/react-app-env.d.ts +0 -1
- package/app/src/reportWebVitals.ts +0 -15
- package/app/src/setupTests.ts +0 -5
- package/app/tsconfig.app.json +0 -10
- package/app/webpack.config.js +0 -143
- package/module/src/frontend/datarenderer/images.tsx +0 -28
- package/module/src/frontend/datarenderer/index.tsx +0 -54
- package/module/src/frontend/datarenderer/plotly.tsx +0 -82
- package/module/src/frontend/dialog.scss +0 -88
- package/module/src/frontend/dialog.tsx +0 -71
- package/module/src/frontend/edge.scss +0 -15
- package/module/src/frontend/edge.tsx +0 -32
- package/module/src/frontend/funcnodesreactflow/funcnodesreactflow.scss +0 -63
- package/module/src/frontend/funcnodesreactflow/index.tsx +0 -68
- package/module/src/frontend/funcnodesreactflow/react_flow_layer.tsx +0 -212
- package/module/src/frontend/header/header.scss +0 -48
- package/module/src/frontend/header/index.tsx +0 -269
- package/module/src/frontend/layout/htmlelements.scss +0 -63
- package/module/src/frontend/lib.scss +0 -157
- package/module/src/frontend/lib.tsx +0 -199
- package/module/src/frontend/node/io/default_input_renderer.tsx +0 -329
- package/module/src/frontend/node/io/default_output_render.tsx +0 -25
- package/module/src/frontend/node/io/handle_renderer.tsx +0 -94
- package/module/src/frontend/node/io/io.scss +0 -91
- package/module/src/frontend/node/io/io.tsx +0 -115
- package/module/src/frontend/node/io/nodeinput.tsx +0 -127
- package/module/src/frontend/node/io/nodeoutput.tsx +0 -43
- package/module/src/frontend/node/node.scss +0 -265
- package/module/src/frontend/node/node.tsx +0 -209
- package/module/src/frontend/utils/colorpicker.scss +0 -37
- package/module/src/frontend/utils/colorpicker.tsx +0 -342
- package/module/src/frontend/utils/jsondata.tsx +0 -19
- package/module/src/frontend/utils/table.scss +0 -22
- package/module/src/frontend/utils/table.tsx +0 -160
- package/module/src/funcnodes/funcnodesworker.ts +0 -456
- package/module/src/funcnodes/websocketworker.ts +0 -152
- package/module/src/funcnodes/workermanager.ts +0 -233
- package/module/src/index.tsx +0 -4
- package/module/src/states/edge.ts +0 -15
- package/module/src/states/fnrfzst.t.ts +0 -117
- package/module/src/states/fnrfzst.ts +0 -415
- package/module/src/states/lib.t.ts +0 -30
- package/module/src/states/lib.ts +0 -16
- package/module/src/states/node.ts +0 -46
- package/module/src/states/nodeio.t.ts +0 -103
- package/module/src/states/nodespace.t.ts +0 -57
- package/module/src/states/reactflow.t.ts +0 -27
- package/module/src/states/reactflow.ts +0 -49
- package/module/src/types/funcnodesreactflow.d.ts +0 -1
- package/module/src/utils/objects.ts +0 -131
- package/module/tsconfig.module.json +0 -15
- package/module/webpack.config.js +0 -140
- package/tsconfig.json +0 -18
- /package/{module/src/funcnodes/index.ts → dist/funcnodes/index.d.ts} +0 -0
- /package/{module/src/states/index.ts → dist/states/index.d.ts} +0 -0
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { FuncNodesReactFlowZustandInterface } from "../../../states/fnrfzst.t";
|
|
3
|
-
|
|
4
|
-
import { FuncNodesContext } from "../../funcnodesreactflow";
|
|
5
|
-
import CustomColorPicker from "../../utils/colorpicker";
|
|
6
|
-
import { EnumOf, InputRendererProps } from "../../../states/nodeio.t";
|
|
7
|
-
import React from "react";
|
|
8
|
-
|
|
9
|
-
const BooleanInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
10
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
11
|
-
useContext(FuncNodesContext);
|
|
12
|
-
|
|
13
|
-
const indeterminate = io.value === undefined;
|
|
14
|
-
const cRef = useRef<HTMLInputElement>(null);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (!cRef.current) return;
|
|
18
|
-
cRef.current.indeterminate = indeterminate;
|
|
19
|
-
}, [cRef, indeterminate]);
|
|
20
|
-
|
|
21
|
-
const on_change = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
22
|
-
let new_value: boolean = e.target.checked;
|
|
23
|
-
try {
|
|
24
|
-
new_value = inputconverter(e.target.checked);
|
|
25
|
-
} catch (e) {}
|
|
26
|
-
fnrf_zst.worker?.set_io_value({
|
|
27
|
-
nid: io.node,
|
|
28
|
-
ioid: io.id,
|
|
29
|
-
value: new_value,
|
|
30
|
-
set_default: io.render_options?.set_default || false,
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
return (
|
|
34
|
-
<input
|
|
35
|
-
ref={cRef}
|
|
36
|
-
type="checkbox"
|
|
37
|
-
className="styledcheckbox"
|
|
38
|
-
checked={!!io.value}
|
|
39
|
-
onChange={on_change}
|
|
40
|
-
disabled={io.connected}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
const NumberInput = ({
|
|
45
|
-
io,
|
|
46
|
-
inputconverter,
|
|
47
|
-
parser = (n: string) => parseFloat(n),
|
|
48
|
-
}: InputRendererProps & {
|
|
49
|
-
parser: (n: string) => number;
|
|
50
|
-
}) => {
|
|
51
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
52
|
-
useContext(FuncNodesContext);
|
|
53
|
-
|
|
54
|
-
const [tempvalue, setTempValue] = useState(io.value);
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
setTempValue(io.value);
|
|
58
|
-
}, [io.value]);
|
|
59
|
-
|
|
60
|
-
const set_new_value = (new_value: number | string) => {
|
|
61
|
-
new_value = parser(
|
|
62
|
-
parseFloat(new_value.toString()).toString() // parse float for e notation
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
if (isNaN(new_value)) {
|
|
66
|
-
new_value = "<NoValue>";
|
|
67
|
-
setTempValue("");
|
|
68
|
-
} else {
|
|
69
|
-
setTempValue(new_value.toString());
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
new_value = inputconverter(new_value);
|
|
73
|
-
} catch (e) {}
|
|
74
|
-
|
|
75
|
-
fnrf_zst.worker?.set_io_value({
|
|
76
|
-
nid: io.node,
|
|
77
|
-
ioid: io.id,
|
|
78
|
-
value: new_value,
|
|
79
|
-
set_default: io.render_options?.set_default || false,
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const on_change = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
84
|
-
set_new_value(e.target.value);
|
|
85
|
-
};
|
|
86
|
-
const v = io.connected ? io.value : tempvalue;
|
|
87
|
-
return (
|
|
88
|
-
<input
|
|
89
|
-
type="text"
|
|
90
|
-
className="nodedatainput styledinput"
|
|
91
|
-
value={v || ""}
|
|
92
|
-
onChange={(e) => setTempValue(e.target.value)}
|
|
93
|
-
onBlur={on_change}
|
|
94
|
-
onKeyDown={(e) => {
|
|
95
|
-
// on key up add step to value
|
|
96
|
-
|
|
97
|
-
if (e.key === "ArrowUp") {
|
|
98
|
-
let step = io.render_options?.step || 1;
|
|
99
|
-
if (e.shiftKey) step *= 10;
|
|
100
|
-
|
|
101
|
-
let new_value = (parseFloat(v) || 0) + step;
|
|
102
|
-
// setTempValue(new_value.toString());
|
|
103
|
-
set_new_value(new_value);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// on key down subtract step to value
|
|
108
|
-
if (e.key === "ArrowDown") {
|
|
109
|
-
let step = io.render_options?.step || 1;
|
|
110
|
-
if (e.shiftKey) step *= 10;
|
|
111
|
-
let new_value = (parseFloat(v) || 0) - step;
|
|
112
|
-
// setTempValue(new_value.toString());
|
|
113
|
-
set_new_value(new_value);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
//accept only numbers
|
|
118
|
-
if (
|
|
119
|
-
!/^[0-9.eE+-]$/.test(e.key) &&
|
|
120
|
-
!["Backspace", "ArrowLeft", "ArrowRight", "Delete", "Tab"].includes(
|
|
121
|
-
e.key
|
|
122
|
-
)
|
|
123
|
-
) {
|
|
124
|
-
e.preventDefault();
|
|
125
|
-
}
|
|
126
|
-
}}
|
|
127
|
-
disabled={io.connected}
|
|
128
|
-
step={io.render_options?.step}
|
|
129
|
-
min={io.value_options?.min}
|
|
130
|
-
/>
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const FloatInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
135
|
-
return NumberInput({ io, inputconverter, parser: parseFloat });
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const IntegerInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
139
|
-
return NumberInput({ io, inputconverter, parser: parseInt });
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const StringInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
143
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
144
|
-
useContext(FuncNodesContext);
|
|
145
|
-
|
|
146
|
-
const [tempvalue, setTempValue] = useState(io.value);
|
|
147
|
-
|
|
148
|
-
const on_change = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
149
|
-
let new_value: string = e.target.value;
|
|
150
|
-
try {
|
|
151
|
-
new_value = inputconverter(new_value);
|
|
152
|
-
} catch (e) {}
|
|
153
|
-
|
|
154
|
-
if (!new_value) new_value = "<NoValue>";
|
|
155
|
-
|
|
156
|
-
fnrf_zst.worker?.set_io_value({
|
|
157
|
-
nid: io.node,
|
|
158
|
-
ioid: io.id,
|
|
159
|
-
value: new_value,
|
|
160
|
-
set_default: io.render_options?.set_default || false,
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<input
|
|
166
|
-
className="nodedatainput styledinput"
|
|
167
|
-
value={io.connected ? io.value : tempvalue}
|
|
168
|
-
onChange={(e) => setTempValue(e.target.value)}
|
|
169
|
-
onBlur={on_change}
|
|
170
|
-
disabled={io.connected}
|
|
171
|
-
/>
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const _parse_string = (s: string) => s;
|
|
176
|
-
const _parse_number = (s: string) => parseFloat(s);
|
|
177
|
-
const _parse_boolean = (s: string) => !!s;
|
|
178
|
-
const _parse_null = (s: string) => (s === "null" ? null : s);
|
|
179
|
-
|
|
180
|
-
const get_parser = (datatype: string | null) => {
|
|
181
|
-
if (datatype === "nuinputconvertermber") {
|
|
182
|
-
return _parse_number;
|
|
183
|
-
}
|
|
184
|
-
if (datatype === "boolean") {
|
|
185
|
-
return _parse_boolean;
|
|
186
|
-
}
|
|
187
|
-
if (datatype === "undefined") {
|
|
188
|
-
return _parse_null;
|
|
189
|
-
}
|
|
190
|
-
return _parse_string;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const SelectionInput = ({
|
|
194
|
-
io,
|
|
195
|
-
inputconverter,
|
|
196
|
-
parser,
|
|
197
|
-
}: InputRendererProps & {
|
|
198
|
-
parser?(s: string): any;
|
|
199
|
-
}) => {
|
|
200
|
-
let options: (string | number)[] | EnumOf = io.value_options?.options || [];
|
|
201
|
-
if (Array.isArray(options)) {
|
|
202
|
-
options = {
|
|
203
|
-
type: "enum",
|
|
204
|
-
values: options,
|
|
205
|
-
keys: options.map((x) => x.toString()),
|
|
206
|
-
nullable: false,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
options = options as EnumOf;
|
|
210
|
-
if (
|
|
211
|
-
options.nullable &&
|
|
212
|
-
!options.values.includes(null) &&
|
|
213
|
-
!options.keys.includes("None")
|
|
214
|
-
) {
|
|
215
|
-
options.values.unshift(null);
|
|
216
|
-
options.keys.unshift("None");
|
|
217
|
-
}
|
|
218
|
-
//make key value pairs
|
|
219
|
-
const optionsmap: [string, string, string][] = [];
|
|
220
|
-
for (let i = 0; i < options.values.length; i++) {
|
|
221
|
-
// set const t to "string", "number","boolean" "null" depenting on the type of options.values[i]
|
|
222
|
-
const t =
|
|
223
|
-
options.values[i] === null || options.values[i] === undefined
|
|
224
|
-
? "undefined"
|
|
225
|
-
: typeof options.values[i];
|
|
226
|
-
let v = options.values[i];
|
|
227
|
-
|
|
228
|
-
if (v === null) {
|
|
229
|
-
v = "null";
|
|
230
|
-
}
|
|
231
|
-
if (v === undefined) {
|
|
232
|
-
v = "undefined";
|
|
233
|
-
}
|
|
234
|
-
optionsmap.push([options.keys[i], v.toString(), t]);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
238
|
-
useContext(FuncNodesContext);
|
|
239
|
-
|
|
240
|
-
const on_change = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
241
|
-
// Find the selected option element
|
|
242
|
-
const selectedOption = e.target.options[e.target.selectedIndex];
|
|
243
|
-
// Retrieve the datatype attribute from the selected option
|
|
244
|
-
const datatype = selectedOption.getAttribute("datatype");
|
|
245
|
-
|
|
246
|
-
// Use the existing parser or get a new one based on the datatype
|
|
247
|
-
const p = parser || get_parser(datatype);
|
|
248
|
-
|
|
249
|
-
let new_value: string | number = p(e.target.value);
|
|
250
|
-
try {
|
|
251
|
-
new_value = inputconverter(e.target.value);
|
|
252
|
-
} catch (e) {}
|
|
253
|
-
|
|
254
|
-
fnrf_zst.worker?.set_io_value({
|
|
255
|
-
nid: io.node,
|
|
256
|
-
ioid: io.id,
|
|
257
|
-
value: p(e.target.value),
|
|
258
|
-
set_default: io.render_options?.set_default || false,
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
let v = io.value;
|
|
262
|
-
if (v === null) {
|
|
263
|
-
v = "null";
|
|
264
|
-
}
|
|
265
|
-
if (v === undefined) {
|
|
266
|
-
v = "undefined";
|
|
267
|
-
}
|
|
268
|
-
return (
|
|
269
|
-
<select
|
|
270
|
-
value={v}
|
|
271
|
-
onChange={on_change}
|
|
272
|
-
disabled={io.connected}
|
|
273
|
-
className="nodedatainput styleddropdown"
|
|
274
|
-
>
|
|
275
|
-
<option value="<NoValue>" disabled>
|
|
276
|
-
select
|
|
277
|
-
</option>
|
|
278
|
-
{optionsmap.map((option) => (
|
|
279
|
-
<option key={option[0]} value={option[1]} datatype={option[2]}>
|
|
280
|
-
{option[0]}
|
|
281
|
-
</option>
|
|
282
|
-
))}
|
|
283
|
-
</select>
|
|
284
|
-
);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
const ColorInput = ({ io, inputconverter }: InputRendererProps) => {
|
|
288
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
289
|
-
useContext(FuncNodesContext);
|
|
290
|
-
|
|
291
|
-
const colorspace = io.value_options?.colorspace || "hex";
|
|
292
|
-
|
|
293
|
-
const on_change = (colorconverter?: {
|
|
294
|
-
[key: string]: () => number[] | string;
|
|
295
|
-
}) => {
|
|
296
|
-
let new_value: string | number[] = "<NoValue>";
|
|
297
|
-
if (colorconverter) {
|
|
298
|
-
if (colorconverter[colorspace]) new_value = colorconverter[colorspace]();
|
|
299
|
-
else new_value = colorconverter.hex();
|
|
300
|
-
}
|
|
301
|
-
try {
|
|
302
|
-
new_value = new_value;
|
|
303
|
-
} catch (e) {}
|
|
304
|
-
|
|
305
|
-
fnrf_zst.worker?.set_io_value({
|
|
306
|
-
nid: io.node,
|
|
307
|
-
ioid: io.id,
|
|
308
|
-
value: new_value,
|
|
309
|
-
set_default: io.render_options?.set_default || false,
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
<CustomColorPicker
|
|
315
|
-
onChange={on_change}
|
|
316
|
-
inicolordata={io.value}
|
|
317
|
-
inicolorspace={colorspace}
|
|
318
|
-
/>
|
|
319
|
-
);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
export {
|
|
323
|
-
FloatInput,
|
|
324
|
-
IntegerInput,
|
|
325
|
-
BooleanInput,
|
|
326
|
-
StringInput,
|
|
327
|
-
SelectionInput,
|
|
328
|
-
ColorInput,
|
|
329
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { FuncNodesReactFlowZustandInterface } from "../../../states/fnrfzst.t";
|
|
3
|
-
import { FuncNodesContext } from "../../funcnodesreactflow";
|
|
4
|
-
import { IOType } from "../../../states/nodeio.t";
|
|
5
|
-
import React from "react";
|
|
6
|
-
|
|
7
|
-
const InLineOutput = ({ io }: { io: IOType }) => {
|
|
8
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
9
|
-
useContext(FuncNodesContext);
|
|
10
|
-
let value = io.fullvalue;
|
|
11
|
-
if (value == undefined) value = io.value;
|
|
12
|
-
if (value === undefined) {
|
|
13
|
-
value = "";
|
|
14
|
-
} else {
|
|
15
|
-
value = JSON.stringify(io.value).replace(/\\n/g, "\n"); //respect "\n" in strings
|
|
16
|
-
}
|
|
17
|
-
//truncate the string if it is too long
|
|
18
|
-
if (value.length > 63) {
|
|
19
|
-
value = value.slice(0, 60) + "...";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return <div>{value}</div>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export { InLineOutput };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import {
|
|
3
|
-
FuncNodesReactFlowZustandInterface,
|
|
4
|
-
RenderOptions,
|
|
5
|
-
} from "../../../states/fnrfzst.t";
|
|
6
|
-
import { FuncNodesContext } from "../../funcnodesreactflow";
|
|
7
|
-
import { pick_best_io_type } from "./io";
|
|
8
|
-
import { SortableTable } from "../../utils/table";
|
|
9
|
-
import JSONDataDisplay from "../../utils/jsondata";
|
|
10
|
-
import { Base64ImageRenderer } from "../../datarenderer/images";
|
|
11
|
-
import { IOType } from "../../../states/nodeio.t";
|
|
12
|
-
import React from "react";
|
|
13
|
-
|
|
14
|
-
const TableOutput = ({ io }: { io: IOType }) => {
|
|
15
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
16
|
-
useContext(FuncNodesContext);
|
|
17
|
-
|
|
18
|
-
let value = io.fullvalue;
|
|
19
|
-
if (value == undefined) value = io.value;
|
|
20
|
-
if (value === undefined) {
|
|
21
|
-
value = [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return <SortableTable tabledata={value} />;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const DictOutput = ({ io }: { io: IOType }) => {
|
|
28
|
-
let value = io.fullvalue;
|
|
29
|
-
|
|
30
|
-
if (value === undefined) value = io.value;
|
|
31
|
-
if (value === undefined) {
|
|
32
|
-
value = {};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return <JSONDataDisplay data={value} />;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const Base64ImageOutput = ({ io }: { io: IOType }) => {
|
|
39
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
40
|
-
useContext(FuncNodesContext);
|
|
41
|
-
|
|
42
|
-
let value = io.fullvalue;
|
|
43
|
-
if (value == undefined) value = io.value;
|
|
44
|
-
if (value === undefined) {
|
|
45
|
-
value = "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return <Base64ImageRenderer value={value} />;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const SingleValueOutput = ({ io }: { io: IOType }) => {
|
|
52
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
53
|
-
useContext(FuncNodesContext);
|
|
54
|
-
|
|
55
|
-
let value = io.fullvalue;
|
|
56
|
-
if (value == undefined) value = io.value;
|
|
57
|
-
if (value === undefined) {
|
|
58
|
-
value = "";
|
|
59
|
-
} else {
|
|
60
|
-
value = JSON.stringify(io.value).replace(/\\n/g, "\n"); //respect "\n" in strings
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div>
|
|
65
|
-
<pre>{value}</pre>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const HandlePreviouGenerators: {
|
|
71
|
-
[key: string]: ({ io }: { io: IOType }) => JSX.Element;
|
|
72
|
-
} = {
|
|
73
|
-
string: SingleValueOutput,
|
|
74
|
-
table: TableOutput,
|
|
75
|
-
image: Base64ImageOutput,
|
|
76
|
-
dict: DictOutput,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const PreviewHandleDataRendererForIo = (io: IOType) => {
|
|
80
|
-
const fnrf_zst: FuncNodesReactFlowZustandInterface =
|
|
81
|
-
useContext(FuncNodesContext);
|
|
82
|
-
const render: RenderOptions = fnrf_zst.render_options();
|
|
83
|
-
|
|
84
|
-
const [typestring, otypestring] = pick_best_io_type(
|
|
85
|
-
io.type,
|
|
86
|
-
render.typemap || {}
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
return typestring && HandlePreviouGenerators[typestring]
|
|
90
|
-
? HandlePreviouGenerators[typestring]
|
|
91
|
-
: DictOutput;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export { PreviewHandleDataRendererForIo };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
s slideUpAndFade {
|
|
2
|
-
from {
|
|
3
|
-
opacity: 0;
|
|
4
|
-
transform: translateY(2px);
|
|
5
|
-
}
|
|
6
|
-
to {
|
|
7
|
-
opacity: 1;
|
|
8
|
-
transform: translateY(0);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@keyframes slideRightAndFade {
|
|
13
|
-
from {
|
|
14
|
-
opacity: 0;
|
|
15
|
-
transform: translateX(-2px);
|
|
16
|
-
}
|
|
17
|
-
to {
|
|
18
|
-
opacity: 1;
|
|
19
|
-
transform: translateX(0);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@keyframes slideDownAndFade {
|
|
24
|
-
from {
|
|
25
|
-
opacity: 0;
|
|
26
|
-
transform: translateY(-2px);
|
|
27
|
-
}
|
|
28
|
-
to {
|
|
29
|
-
opacity: 1;
|
|
30
|
-
transform: translateY(0);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@keyframes slideLeftAndFade {
|
|
35
|
-
from {
|
|
36
|
-
opacity: 0;
|
|
37
|
-
transform: translateX(2px);
|
|
38
|
-
}
|
|
39
|
-
to {
|
|
40
|
-
opacity: 1;
|
|
41
|
-
transform: translateX(0);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.iotooltipcontent {
|
|
46
|
-
background-color: #f9f9f9;
|
|
47
|
-
border: 1px solid #ffffff;
|
|
48
|
-
border-radius: 5px;
|
|
49
|
-
padding: 10px;
|
|
50
|
-
box-shadow: hsl(206 22% 7% / 35%) 0px 10px 38px -10px,
|
|
51
|
-
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
|
|
52
|
-
font-size: 10px;
|
|
53
|
-
color: #333;
|
|
54
|
-
max-width: 30vw;
|
|
55
|
-
max-height: 30vh;
|
|
56
|
-
cursor: default;
|
|
57
|
-
|
|
58
|
-
&.fullsize {
|
|
59
|
-
max-width: 100vw;
|
|
60
|
-
max-height: 100vh;
|
|
61
|
-
position: fixed;
|
|
62
|
-
top: 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
overflow: auto;
|
|
66
|
-
display: flex;
|
|
67
|
-
flex-direction: column;
|
|
68
|
-
&[data-state="delayed-open"][data-side="top"] {
|
|
69
|
-
animation-name: slideDownAndFade;
|
|
70
|
-
}
|
|
71
|
-
&[data-state="delayed-open"][data-side="right"] {
|
|
72
|
-
animation-name: slideLeftAndFade;
|
|
73
|
-
}
|
|
74
|
-
&[data-state="delayed-open"][data-side="bottom"] {
|
|
75
|
-
animation-name: slideUpAndFade;
|
|
76
|
-
}
|
|
77
|
-
&[data-state="delayed-open"][data-side="left"] {
|
|
78
|
-
animation-name: slideRightAndFade;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.iotooltip_container {
|
|
83
|
-
display: flex;
|
|
84
|
-
flex-direction: column;
|
|
85
|
-
max-width: inherit;
|
|
86
|
-
max-height: inherit;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.iotooltipcontentarrow {
|
|
90
|
-
fill: white;
|
|
91
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import * as Tooltip from "@radix-ui/react-tooltip";
|
|
2
|
-
import LockOpenIcon from "@mui/icons-material/LockOpen";
|
|
3
|
-
import LockIcon from "@mui/icons-material/Lock";
|
|
4
|
-
import FullscreenIcon from "@mui/icons-material/Fullscreen";
|
|
5
|
-
|
|
6
|
-
import "./io.scss";
|
|
7
|
-
import { Handle, HandleProps } from "reactflow";
|
|
8
|
-
import { useMemo, useState } from "react";
|
|
9
|
-
import CustomDialog from "../../dialog";
|
|
10
|
-
import { PreviewHandleDataRendererForIo } from "./handle_renderer";
|
|
11
|
-
import { IOType, SerializedType } from "../../../states/nodeio.t";
|
|
12
|
-
const pick_best_io_type = (
|
|
13
|
-
iot: SerializedType,
|
|
14
|
-
typemap: { [key: string]: string }
|
|
15
|
-
): [string | undefined, string | undefined] => {
|
|
16
|
-
// check if iot is string
|
|
17
|
-
if (typeof iot === "string") {
|
|
18
|
-
if (iot in typemap) {
|
|
19
|
-
return [typemap[iot], iot];
|
|
20
|
-
}
|
|
21
|
-
return [iot, iot];
|
|
22
|
-
}
|
|
23
|
-
if ("allOf" in iot && iot.allOf !== undefined) {
|
|
24
|
-
return [undefined, undefined];
|
|
25
|
-
}
|
|
26
|
-
if ("anyOf" in iot && iot.anyOf !== undefined) {
|
|
27
|
-
const picks = iot.anyOf.map((x) => pick_best_io_type(x, typemap));
|
|
28
|
-
for (const pick of picks) {
|
|
29
|
-
switch (pick[0]) {
|
|
30
|
-
case "bool":
|
|
31
|
-
return ["bool", pick[1]];
|
|
32
|
-
case "enum":
|
|
33
|
-
return ["enum", pick[1]];
|
|
34
|
-
case "float":
|
|
35
|
-
return ["float", pick[1]];
|
|
36
|
-
case "int":
|
|
37
|
-
return ["int", pick[1]];
|
|
38
|
-
case "string":
|
|
39
|
-
return ["string", pick[1]];
|
|
40
|
-
case "str":
|
|
41
|
-
return ["string", pick[1]];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return [undefined, undefined];
|
|
46
|
-
}
|
|
47
|
-
if (!("type" in iot) || iot.type === undefined) {
|
|
48
|
-
return [undefined, undefined];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (iot.type === "enum") {
|
|
52
|
-
return ["enum", "enum"];
|
|
53
|
-
}
|
|
54
|
-
return [undefined, undefined];
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
type HandleWithPreviewProps = {
|
|
58
|
-
io: IOType;
|
|
59
|
-
typestring: string | undefined;
|
|
60
|
-
preview?: React.FC<{ io: IOType }>;
|
|
61
|
-
} & HandleProps;
|
|
62
|
-
|
|
63
|
-
const HandleWithPreview = ({
|
|
64
|
-
io,
|
|
65
|
-
typestring,
|
|
66
|
-
preview,
|
|
67
|
-
...props
|
|
68
|
-
}: HandleWithPreviewProps) => {
|
|
69
|
-
const [locked, setLocked] = useState(false);
|
|
70
|
-
const [opened, setOpened] = useState(false);
|
|
71
|
-
|
|
72
|
-
const pvhandle: React.FC<{ io: IOType }> =
|
|
73
|
-
preview || PreviewHandleDataRendererForIo(io);
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Tooltip.Provider>
|
|
77
|
-
<Tooltip.Root open={locked || opened} onOpenChange={setOpened}>
|
|
78
|
-
<Tooltip.Trigger asChild>
|
|
79
|
-
<Handle id={io.id} {...props} />
|
|
80
|
-
</Tooltip.Trigger>
|
|
81
|
-
<Tooltip.Portal>
|
|
82
|
-
<Tooltip.Content className={"iotooltipcontent"} sideOffset={5}>
|
|
83
|
-
<div className="iotooltip_container">
|
|
84
|
-
<div className="iotooltip_header">
|
|
85
|
-
{locked ? (
|
|
86
|
-
<LockIcon onClick={() => setLocked(false)} />
|
|
87
|
-
) : (
|
|
88
|
-
<LockOpenIcon onClick={() => setLocked(true)} />
|
|
89
|
-
)}
|
|
90
|
-
{pvhandle && (
|
|
91
|
-
<CustomDialog
|
|
92
|
-
trigger={<FullscreenIcon />}
|
|
93
|
-
onOpenChange={(open: boolean) => {
|
|
94
|
-
if (open) {
|
|
95
|
-
io.try_get_full_value();
|
|
96
|
-
}
|
|
97
|
-
setLocked(open);
|
|
98
|
-
}}
|
|
99
|
-
>
|
|
100
|
-
{pvhandle({ io })}
|
|
101
|
-
</CustomDialog>
|
|
102
|
-
)}
|
|
103
|
-
</div>
|
|
104
|
-
{pvhandle
|
|
105
|
-
? pvhandle({ io })
|
|
106
|
-
: `no preview available for "${typestring}"`}
|
|
107
|
-
</div>
|
|
108
|
-
<Tooltip.Arrow className="iotooltipcontentarrow" />
|
|
109
|
-
</Tooltip.Content>
|
|
110
|
-
</Tooltip.Portal>
|
|
111
|
-
</Tooltip.Root>
|
|
112
|
-
</Tooltip.Provider>
|
|
113
|
-
);
|
|
114
|
-
};
|
|
115
|
-
export { pick_best_io_type, HandleWithPreview };
|