@statelyai/flow-dom 3.3.0 → 3.4.3
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/esm/index.d.ts +1 -0
- package/dist/esm/index.js +34 -4
- package/package.json +2 -2
package/dist/esm/index.d.ts
CHANGED
|
@@ -215,6 +215,7 @@ type AttachInputOptions = {
|
|
|
215
215
|
runtime: {
|
|
216
216
|
send(event: FlowInputEvent): FlowInputEffects;
|
|
217
217
|
cancelSession(): void;
|
|
218
|
+
getActiveSession?(): string | null;
|
|
218
219
|
};
|
|
219
220
|
/**
|
|
220
221
|
* Where keyboard events are listened for. Defaults to the flow container so
|
package/dist/esm/index.js
CHANGED
|
@@ -648,6 +648,8 @@ function attachInput(options) {
|
|
|
648
648
|
const keyboardTarget = options.keyboardTarget ?? "container";
|
|
649
649
|
const keyboardElement = keyboardTarget === "window" ? win : keyboardTarget === "container" ? container : keyboardTarget;
|
|
650
650
|
let capturedPointerId = null;
|
|
651
|
+
let gestureContainerOffset = null;
|
|
652
|
+
let lastContainerOffset = null;
|
|
651
653
|
let lastClient = null;
|
|
652
654
|
let autoPanFrame = null;
|
|
653
655
|
const activeTouchPointers = /* @__PURE__ */ new Map();
|
|
@@ -666,7 +668,7 @@ function attachInput(options) {
|
|
|
666
668
|
function autoPanTick() {
|
|
667
669
|
autoPanFrame = null;
|
|
668
670
|
if (!options.autoPan || capturedPointerId === null || !lastClient) return;
|
|
669
|
-
const rect = container.getBoundingClientRect();
|
|
671
|
+
const rect = gestureContainerOffset ?? container.getBoundingClientRect();
|
|
670
672
|
const screenPoint = {
|
|
671
673
|
x: lastClient.x - rect.left,
|
|
672
674
|
y: lastClient.y - rect.top
|
|
@@ -715,7 +717,12 @@ function attachInput(options) {
|
|
|
715
717
|
return clickCount;
|
|
716
718
|
}
|
|
717
719
|
function toPoints(event) {
|
|
718
|
-
const rect = container.getBoundingClientRect();
|
|
720
|
+
const rect = gestureContainerOffset ?? container.getBoundingClientRect();
|
|
721
|
+
lastContainerOffset = {
|
|
722
|
+
left: rect.left,
|
|
723
|
+
top: rect.top
|
|
724
|
+
};
|
|
725
|
+
if (capturedPointerId !== null && gestureContainerOffset === null) gestureContainerOffset = lastContainerOffset;
|
|
719
726
|
const screenPoint = {
|
|
720
727
|
x: event.clientX - rect.left,
|
|
721
728
|
y: event.clientY - rect.top
|
|
@@ -740,7 +747,9 @@ function attachInput(options) {
|
|
|
740
747
|
if (portElement?.dataset.flowPortName) return {
|
|
741
748
|
kind: "port",
|
|
742
749
|
nodeId: portElement.dataset.flowNodeId ?? "",
|
|
743
|
-
portName: portElement.dataset.flowPortName
|
|
750
|
+
portName: portElement.dataset.flowPortName,
|
|
751
|
+
portId: portElement.dataset.flowPortId,
|
|
752
|
+
interaction: portElement.dataset.flowPortInteraction === "inspect" ? "inspect" : "connect"
|
|
744
753
|
};
|
|
745
754
|
if (element.closest("[data-flow-interactive], .nodrag, input, textarea, select, button, a[href], [contenteditable]:not([contenteditable=\"false\"])")) return { kind: "none" };
|
|
746
755
|
const entityElement = element.closest("[data-entity-id]");
|
|
@@ -771,6 +780,8 @@ function attachInput(options) {
|
|
|
771
780
|
clientX,
|
|
772
781
|
clientY
|
|
773
782
|
});
|
|
783
|
+
const activeSession = runtime.getActiveSession?.() ?? null;
|
|
784
|
+
const targetIndependentSession = activeSession === "entity-press" || activeSession === "pan" || activeSession === "pane-press" || activeSession === "box-select";
|
|
774
785
|
const effects = runtime.send({
|
|
775
786
|
kind,
|
|
776
787
|
pointerId: info.pointerId,
|
|
@@ -779,7 +790,7 @@ function attachInput(options) {
|
|
|
779
790
|
detail: info.detail,
|
|
780
791
|
point,
|
|
781
792
|
screenPoint,
|
|
782
|
-
target: resolveTarget({
|
|
793
|
+
target: kind === "pointer.move" && targetIndependentSession ? { kind: "none" } : resolveTarget({
|
|
783
794
|
clientX,
|
|
784
795
|
clientY,
|
|
785
796
|
target: info.target
|
|
@@ -791,6 +802,13 @@ function attachInput(options) {
|
|
|
791
802
|
container.setPointerCapture(info.pointerId);
|
|
792
803
|
} catch {}
|
|
793
804
|
capturedPointerId = info.pointerId;
|
|
805
|
+
gestureContainerOffset = lastContainerOffset ?? (() => {
|
|
806
|
+
const rect = container.getBoundingClientRect();
|
|
807
|
+
return {
|
|
808
|
+
left: rect.left,
|
|
809
|
+
top: rect.top
|
|
810
|
+
};
|
|
811
|
+
})();
|
|
794
812
|
scheduleAutoPan();
|
|
795
813
|
}
|
|
796
814
|
if (effects.sessionEnded && capturedPointerId !== null) {
|
|
@@ -798,6 +816,7 @@ function attachInput(options) {
|
|
|
798
816
|
if (container.hasPointerCapture(capturedPointerId)) container.releasePointerCapture(capturedPointerId);
|
|
799
817
|
} catch {}
|
|
800
818
|
capturedPointerId = null;
|
|
819
|
+
gestureContainerOffset = null;
|
|
801
820
|
lastClient = null;
|
|
802
821
|
stopAutoPan();
|
|
803
822
|
}
|
|
@@ -853,6 +872,7 @@ function attachInput(options) {
|
|
|
853
872
|
if (container.hasPointerCapture(capturedPointerId)) container.releasePointerCapture(capturedPointerId);
|
|
854
873
|
} catch {}
|
|
855
874
|
capturedPointerId = null;
|
|
875
|
+
gestureContainerOffset = null;
|
|
856
876
|
lastClient = null;
|
|
857
877
|
stopAutoPan();
|
|
858
878
|
}
|
|
@@ -976,6 +996,7 @@ function attachInput(options) {
|
|
|
976
996
|
stopAutoPan();
|
|
977
997
|
runtime.cancelSession();
|
|
978
998
|
capturedPointerId = null;
|
|
999
|
+
gestureContainerOffset = null;
|
|
979
1000
|
lastClient = null;
|
|
980
1001
|
};
|
|
981
1002
|
const onWindowBlur = () => {
|
|
@@ -983,8 +1004,13 @@ function attachInput(options) {
|
|
|
983
1004
|
runtime.cancelSession();
|
|
984
1005
|
activeTouchPointers.clear();
|
|
985
1006
|
capturedPointerId = null;
|
|
1007
|
+
gestureContainerOffset = null;
|
|
986
1008
|
lastClient = null;
|
|
987
1009
|
};
|
|
1010
|
+
const onContainerGeometryChange = () => {
|
|
1011
|
+
gestureContainerOffset = null;
|
|
1012
|
+
lastContainerOffset = null;
|
|
1013
|
+
};
|
|
988
1014
|
const onKeyDown = handleKey("key.down");
|
|
989
1015
|
const onKeyUp = handleKey("key.up");
|
|
990
1016
|
if (keyboardTarget === "container" && !container.hasAttribute("tabindex")) container.tabIndex = 0;
|
|
@@ -998,6 +1024,8 @@ function attachInput(options) {
|
|
|
998
1024
|
keyboardElement?.addEventListener("keydown", onKeyDown);
|
|
999
1025
|
keyboardElement?.addEventListener("keyup", onKeyUp);
|
|
1000
1026
|
win?.addEventListener("blur", onWindowBlur);
|
|
1027
|
+
win?.addEventListener("resize", onContainerGeometryChange);
|
|
1028
|
+
win?.addEventListener("scroll", onContainerGeometryChange, true);
|
|
1001
1029
|
return () => {
|
|
1002
1030
|
stopAutoPan();
|
|
1003
1031
|
runtime.cancelSession();
|
|
@@ -1014,6 +1042,8 @@ function attachInput(options) {
|
|
|
1014
1042
|
keyboardElement?.removeEventListener("keydown", onKeyDown);
|
|
1015
1043
|
keyboardElement?.removeEventListener("keyup", onKeyUp);
|
|
1016
1044
|
win?.removeEventListener("blur", onWindowBlur);
|
|
1045
|
+
win?.removeEventListener("resize", onContainerGeometryChange);
|
|
1046
|
+
win?.removeEventListener("scroll", onContainerGeometryChange, true);
|
|
1017
1047
|
};
|
|
1018
1048
|
}
|
|
1019
1049
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statelyai/flow-dom",
|
|
3
|
-
"version": "3.3
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "DOM-specific helpers for @statelyai/flow with core re-exports.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@statelyai/flow": "0.
|
|
30
|
+
"@statelyai/flow": "0.9.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@vitest/coverage-v8": "^4.1.0",
|