@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
37 lines (36 loc) • 1 kB
JavaScript
import { Port } from './port.svelte';
export class Input extends Port {
isRequired;
// showControl: boolean = $state(true);
/**
* Control instance
*/
control = null;
/**
* Whether the control is visible. Can be managed dynamically by extensions. Default is `true`
*/
showControl = $state(true);
alwaysShowLabel = $state(false);
hideLabel = $state(false);
constructor(params) {
super(params);
this.alwaysShowLabel = params.alwaysShowLabel ?? false;
this.hideLabel = params.hideLabel ?? false;
this.isRequired = params.isRequired ?? false;
}
/**
* Add control to the input port
* @param control Control instance
*/
addControl(control) {
if (this.control)
throw new Error('control already added for this input');
this.control = control;
}
/**
* Remove control from the input port
*/
removeControl() {
this.control = null;
}
}