Skip to content

Commit dfd1bd1

Browse files
committed
add removeWidget() to node
1 parent 3b62021 commit dfd1bd1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@elicdavis/node-flow",
33
"description": "build node graphs",
44
"author": "Eli C Davis",
5-
"version": "0.1.10",
5+
"version": "0.1.11",
66
"license": "MIT",
77
"keywords": [
88
"nodes",

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ export { FlowNote };
1414
import { NumberWidget } from './widgets/number';
1515
import { ColorWidget } from './widgets/color';
1616
import { StringWidget } from './widgets/string';
17+
import { TextWidget } from './widgets/text';
1718
import { ButtonWidget } from './widgets/button';
1819
import { ToggleWidget } from './widgets/toggle';
1920
import { SliderWidget } from './widgets/slider';
2021
import { ImageWidget } from './widgets/image';
2122
export {
22-
NumberWidget, ColorWidget, StringWidget, ButtonWidget, ToggleWidget, SliderWidget, ImageWidget
23+
NumberWidget, ColorWidget, StringWidget, TextWidget,
24+
ButtonWidget, ToggleWidget, SliderWidget, ImageWidget
2325
};
2426

2527
import { GlobalWidgetFactory } from './widgets/factory';

src/node.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,14 @@ export class FlowNode {
856856
this.#widgets.push(widget);
857857
}
858858

859+
removeWidget(widget: Widget): void {
860+
const index = this.#widgets.indexOf(widget, 0);
861+
if (index === -1) {
862+
throw new Error("node does not contain widget");
863+
}
864+
this.#widgets.splice(index, 1);
865+
}
866+
859867
getWidget(index: number): Widget {
860868
return this.#widgets[index];
861869
}

0 commit comments

Comments
 (0)