tp-flow-nodes/demo-node.js

58 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-12-18 21:27:29 +01:00
/**
@license
Copyright (c) 2024 trading_peter
This program is available under Apache License Version 2.0
*/
import { html, css } from 'lit';
import { TpFlowNode } from './tp-flow-node';
2024-12-20 10:29:39 +01:00
import { TpFlowNodes } from './tp-flow-nodes.js';
2024-12-18 21:27:29 +01:00
class DemoNode extends TpFlowNode {
static get styles() {
return [
...super.styles,
css`
:host {
display: block;
}
`
];
}
renderNodeContent() {
return html`
<select @change="${this._handleOperationChange}">
<option value="add">Add</option>
<option value="subtract">Subtract</option>
</select>
`;
}
static get properties() {
return { };
}
constructor() {
super();
this.flowNodeType = 'MathNode';
this.inputs = [
{ name: 'value1' },
{ name: 'value2' }
];
this.outputs = [
{ name: 'result' }
];
this.data = {
operation: 'add'
};
}
_handleOperationChange(e) {
this.data.operation = e.target.value;
}
}
2024-12-20 10:29:39 +01:00
window.customElements.define('demo-node', DemoNode);
TpFlowNodes.registerNode('MathNode', DemoNode);