-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannelSplitter.tsx
42 lines (39 loc) · 1.34 KB
/
ChannelSplitter.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";
import { NodeProps } from "react-flow-renderer";
import Node from "components/Node";
import useChannelSplitterNode from "hooks/nodes/useChannelSplitterNode";
import { channelCounts } from "utils/channels";
function ChannelSplitter({ data, id, selected, type }: NodeProps) {
const { onChange, outputs = 2 } = data;
const node = useChannelSplitterNode(id, { outputs });
return (
<Node
id={id}
inputs={["input"]}
outputs={Array(node.numberOfOutputs)
.fill(0)
.map((_, channel) => `output-${channel}`)}
type={type}
>
{selected && (
<div className="customNode_editor nodrag">
<div className="customNode_item" style={{ alignItems: "flex-start", flexDirection: "column" }}>
{Object.keys(channelCounts).map(channelCount => (
<label key={channelCount} title="Channel configuration">
<input
checked={outputs === +channelCount}
onChange={e => onChange({ outputs: +e.target.value })}
type="radio"
value={+channelCount}
/>{" "}
{/* @ts-ignore */}
{channelCounts[channelCount]}
</label>
))}
</div>
</div>
)}
</Node>
);
}
export default React.memo(ChannelSplitter);