@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
41 lines (40 loc) • 1.12 kB
JavaScript
import { Node } from '../Node.svelte';
export class SelectNode extends Node {
state = { ...this.state, pickA: '' };
constructor({ factory }) {
super({ factory, label: 'Select', height: 255 });
this.oldAddInData({
name: 'a',
displayName: 'A',
type: 'any'
});
this.oldAddInData({
name: 'b',
displayName: 'B',
type: 'any'
});
this.oldAddInData({
name: 'pickA',
socketLabel: 'Pick A',
displayName: 'Pick A',
type: 'boolean',
control: {
type: 'checkbox',
options: {
label: 'Pick A',
initial: true,
change: () => setTimeout(this.processDataflow)
}
}
});
this.oldAddOutData({
name: 'value',
type: 'any'
});
}
data(inputs) {
return {
value: this.getData('pickA', inputs) ? this.getData('a', inputs) : this.getData('b', inputs)
};
}
}