@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
61 lines (60 loc) • 1.76 kB
JavaScript
import { Node } from '../Node.svelte';
export class AppendNode extends Node {
constructor({ a = '', sep = ' ', b = '', factory }) {
// super('Append', { height: 220, factory });
super({ label: 'Append', height: 220, factory, params: { a, b, sep } });
this.oldAddInData({
name: 'a',
displayName: 'A',
type: 'any',
control: {
type: 'text',
options: {
initial: a
}
}
});
this.oldAddInData({
name: 'sep',
displayName: 'Separator',
type: 'string',
control: {
type: 'text',
options: {
initial: sep,
label: 'Separator'
}
}
});
this.oldAddInData({
name: 'b',
displayName: 'B',
type: 'any',
control: {
type: 'text',
options: {
initial: sep
}
},
initial: b
});
this.oldAddOutData({
name: 'result',
type: 'string'
});
this.pythonComponent.setDataCodeGetter('result', () => '$(a) + $(sep) + $(b)');
}
data(inputs) {
const res = { result: '' };
if (!inputs)
return { ...super.data(inputs), res };
const a = this.getData('a', inputs);
const b = this.getData('b', inputs);
const sep = this.getData('sep', inputs);
// console.log("" + aValue + sepValue + bValue);
return {
...super.data(inputs),
result: '' + a + sep + b
};
}
}