@elicdavis/node-flow 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +49 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/graph.ts +22 -17
- package/src/node.ts +3 -0
- package/src/nodes/subsystem.ts +3 -1
- package/src/popup.ts +27 -6
- package/src/theme.ts +1 -1
- package/src/widgets/number.ts +2 -1
- package/src/widgets/string.ts +3 -1
- package/src/widgets/toggle.ts +3 -1
- package/test/popup.test.ts +104 -0
- package/test/widget_click.test.ts +126 -0
- package/test/widget_construction.test.ts +48 -0
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,7 @@ var Theme = {
|
|
|
61
61
|
DisabledFontColor: "#4a585c"
|
|
62
62
|
},
|
|
63
63
|
Minimap: {
|
|
64
|
-
BackgroundColor: "rgba(
|
|
64
|
+
BackgroundColor: "rgba(10, 16, 18, 0.85)",
|
|
65
65
|
BorderColor: "#1c1c1c",
|
|
66
66
|
BorderRadius: 4,
|
|
67
67
|
Padding: 6,
|
|
@@ -1844,6 +1844,7 @@ var Popup = class {
|
|
|
1844
1844
|
#buttonCSS;
|
|
1845
1845
|
// Runtime ================================================================
|
|
1846
1846
|
#popup;
|
|
1847
|
+
#keyHandler;
|
|
1847
1848
|
constructor(config) {
|
|
1848
1849
|
this.#title = config.title;
|
|
1849
1850
|
this.#options = config.options;
|
|
@@ -1851,14 +1852,25 @@ var Popup = class {
|
|
|
1851
1852
|
this.#onClose = config.onClose;
|
|
1852
1853
|
this.#buttonCSS = config.buttonCSS === void 0 ? "flex-grow: 1; margin-right: 8px;" : config.buttonCSS;
|
|
1853
1854
|
this.#popup = null;
|
|
1855
|
+
this.#keyHandler = null;
|
|
1854
1856
|
}
|
|
1855
1857
|
Hide() {
|
|
1856
1858
|
if (this.#popup === null) {
|
|
1857
1859
|
return;
|
|
1858
1860
|
}
|
|
1861
|
+
if (this.#keyHandler !== null) {
|
|
1862
|
+
document.removeEventListener("keydown", this.#keyHandler, true);
|
|
1863
|
+
this.#keyHandler = null;
|
|
1864
|
+
}
|
|
1859
1865
|
document.body.removeChild(this.#popup);
|
|
1860
1866
|
this.#popup = null;
|
|
1861
1867
|
}
|
|
1868
|
+
#close(option) {
|
|
1869
|
+
this.Hide();
|
|
1870
|
+
if (this.#onClose !== void 0) {
|
|
1871
|
+
this.#onClose(option);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1862
1874
|
Show() {
|
|
1863
1875
|
this.#popup = document.createElement("div");
|
|
1864
1876
|
this.#popup.style.cssText = "position:absolute;top:0;width:100%;display:flex;height:100%;justify-content:center;align-items:center;background-color:#00000070;";
|
|
@@ -1880,14 +1892,20 @@ var Popup = class {
|
|
|
1880
1892
|
const button = document.createElement("button");
|
|
1881
1893
|
button.style.cssText = this.#buttonCSS;
|
|
1882
1894
|
button.textContent = this.#options[i];
|
|
1883
|
-
button.onclick = () =>
|
|
1884
|
-
this.Hide();
|
|
1885
|
-
if (this.#onClose !== void 0) {
|
|
1886
|
-
this.#onClose(this.#options[i]);
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1895
|
+
button.onclick = () => this.#close(this.#options[i]);
|
|
1889
1896
|
buttonContainer.appendChild(button);
|
|
1890
1897
|
}
|
|
1898
|
+
this.#keyHandler = (e) => {
|
|
1899
|
+
if (e.key === "Enter") {
|
|
1900
|
+
e.preventDefault();
|
|
1901
|
+
this.#close(this.#options.length > 0 ? this.#options[0] : null);
|
|
1902
|
+
} else if (e.key === "Escape") {
|
|
1903
|
+
e.preventDefault();
|
|
1904
|
+
this.#close(null);
|
|
1905
|
+
}
|
|
1906
|
+
e.stopPropagation();
|
|
1907
|
+
};
|
|
1908
|
+
document.addEventListener("keydown", this.#keyHandler, true);
|
|
1891
1909
|
}
|
|
1892
1910
|
};
|
|
1893
1911
|
|
|
@@ -1996,8 +2014,8 @@ var NumberWidget = class {
|
|
|
1996
2014
|
},
|
|
1997
2015
|
text: { color: Theme.Widget.FontColor }
|
|
1998
2016
|
}));
|
|
1999
|
-
this.#callback = config?.callback;
|
|
2000
2017
|
this.Set(startingWidgetValue(node, this.#nodeProperty, config?.value, 0));
|
|
2018
|
+
this.#callback = config?.callback;
|
|
2001
2019
|
if (this.#nodeProperty !== void 0) {
|
|
2002
2020
|
this.#node.addPropertyChangeListener(this.#nodeProperty, (oldVal, newVal) => {
|
|
2003
2021
|
this.Set(newVal);
|
|
@@ -2439,8 +2457,8 @@ var StringWidget = class {
|
|
|
2439
2457
|
},
|
|
2440
2458
|
text: { color: Theme.Widget.FontColor }
|
|
2441
2459
|
}));
|
|
2442
|
-
this.#callback = config?.callback;
|
|
2443
2460
|
this.Set(startingWidgetValue(node, this.#nodeProperty, config?.value, ""));
|
|
2461
|
+
this.#callback = config?.callback;
|
|
2444
2462
|
if (this.#nodeProperty !== void 0) {
|
|
2445
2463
|
this.#node.addPropertyChangeListener(this.#nodeProperty, (oldVal, newVal) => {
|
|
2446
2464
|
this.Set(newVal);
|
|
@@ -2605,8 +2623,8 @@ var ToggleWidget = class {
|
|
|
2605
2623
|
lightBorderColor: config?.disabledStyle?.lightBorderColor,
|
|
2606
2624
|
lightColor: config?.disabledStyle?.lightColor === void 0 ? "#004400" : config?.enabledStyle?.lightColor
|
|
2607
2625
|
});
|
|
2608
|
-
this.#callback = config?.callback;
|
|
2609
2626
|
this.Set(startingWidgetValue(node, this.#nodeProperty, config?.value, false));
|
|
2627
|
+
this.#callback = config?.callback;
|
|
2610
2628
|
if (this.#nodeProperty !== void 0) {
|
|
2611
2629
|
this.#node.addPropertyChangeListener(this.#nodeProperty, (oldVal, newVal) => {
|
|
2612
2630
|
this.Set(newVal);
|
|
@@ -3707,7 +3725,9 @@ var NodeSubsystem2 = class {
|
|
|
3707
3725
|
this.#boxSelect = false;
|
|
3708
3726
|
}
|
|
3709
3727
|
if (this.#widgetCurrentlyClicking !== null) {
|
|
3710
|
-
this.#widgetCurrentlyClicking
|
|
3728
|
+
if (this.#widgetHovering === this.#widgetCurrentlyClicking) {
|
|
3729
|
+
this.#widgetCurrentlyClicking.ClickEnd();
|
|
3730
|
+
}
|
|
3711
3731
|
this.#widgetCurrentlyClicking = null;
|
|
3712
3732
|
}
|
|
3713
3733
|
if (this.#connectionSelected === null) {
|
|
@@ -5193,6 +5213,7 @@ var FlowNode = class {
|
|
|
5193
5213
|
};
|
|
5194
5214
|
project(this.#portOffsets.input, this.#inputPortPositions);
|
|
5195
5215
|
project(this.#portOffsets.output, this.#outputPortPositions);
|
|
5216
|
+
this.#widgetPositions.Clear();
|
|
5196
5217
|
return true;
|
|
5197
5218
|
}
|
|
5198
5219
|
};
|
|
@@ -6853,12 +6874,25 @@ var NodeFlowGraph = class {
|
|
|
6853
6874
|
this.#pasteCallbacks.forEach((callback) => callback(position));
|
|
6854
6875
|
}
|
|
6855
6876
|
#deleteKey(e) {
|
|
6856
|
-
return e.code === "Delete" || e.
|
|
6877
|
+
return e.code === "Delete" || e.key === "Delete";
|
|
6857
6878
|
}
|
|
6858
6879
|
#keyDown(e) {
|
|
6859
6880
|
if (document.activeElement) {
|
|
6860
6881
|
if (["INPUT", "TEXTAREA"].includes(document.activeElement.tagName)) return;
|
|
6861
6882
|
}
|
|
6883
|
+
if (this.#openQuickMenu) {
|
|
6884
|
+
if (e.code === "Escape") {
|
|
6885
|
+
this.#openQuickMenu = null;
|
|
6886
|
+
return;
|
|
6887
|
+
}
|
|
6888
|
+
if (e.code === "Enter") {
|
|
6889
|
+
this.#openQuickMenu.Menu.execute();
|
|
6890
|
+
this.#openQuickMenu = null;
|
|
6891
|
+
return;
|
|
6892
|
+
}
|
|
6893
|
+
this.#openQuickMenu.Menu.keyboardEvent(e);
|
|
6894
|
+
return;
|
|
6895
|
+
}
|
|
6862
6896
|
if (this.#deleteKey(e)) {
|
|
6863
6897
|
if (this.#mainNodeSubsystem.getSelectedNodes().length > 0) {
|
|
6864
6898
|
e.preventDefault();
|
|
@@ -6883,19 +6917,6 @@ var NodeFlowGraph = class {
|
|
|
6883
6917
|
return;
|
|
6884
6918
|
}
|
|
6885
6919
|
}
|
|
6886
|
-
if (this.#openQuickMenu) {
|
|
6887
|
-
if (e.code === "Escape") {
|
|
6888
|
-
this.#openQuickMenu = null;
|
|
6889
|
-
return;
|
|
6890
|
-
}
|
|
6891
|
-
if (e.code === "Enter") {
|
|
6892
|
-
this.#openQuickMenu.Menu.execute();
|
|
6893
|
-
this.#openQuickMenu = null;
|
|
6894
|
-
return;
|
|
6895
|
-
}
|
|
6896
|
-
this.#openQuickMenu.Menu.keyboardEvent(e);
|
|
6897
|
-
return;
|
|
6898
|
-
}
|
|
6899
6920
|
const spacePressed = e.key == " " || e.code == "Space";
|
|
6900
6921
|
if (!spacePressed) {
|
|
6901
6922
|
return;
|
|
@@ -7094,6 +7115,9 @@ var NodeFlowGraph = class {
|
|
|
7094
7115
|
connectNodes(nodeOut, outPort, nodeIn, inPort) {
|
|
7095
7116
|
return this.#mainNodeSubsystem.connectNodes(nodeOut, outPort, nodeIn, inPort);
|
|
7096
7117
|
}
|
|
7118
|
+
clearNodeInputConnection(node, index) {
|
|
7119
|
+
this.#mainNodeSubsystem.clearNodeInputConnection(node, index);
|
|
7120
|
+
}
|
|
7097
7121
|
addNode(node) {
|
|
7098
7122
|
this.#mainNodeSubsystem.addNode(node);
|
|
7099
7123
|
}
|