@floegence/floe-webapp-core 0.36.38 → 0.36.40
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/components/workbench/WorkbenchCanvas.js +38 -20
- package/dist/components/workbench/WorkbenchCanvasField.d.ts +4 -1
- package/dist/components/workbench/WorkbenchCanvasField.js +34 -16
- package/dist/components/workbench/WorkbenchFilterBar.d.ts +4 -1
- package/dist/components/workbench/WorkbenchFilterBar.js +171 -125
- package/dist/components/workbench/WorkbenchSurface.js +25 -18
- package/dist/components/workbench/WorkbenchWidget.d.ts +3 -0
- package/dist/components/workbench/WorkbenchWidget.js +229 -201
- package/dist/components/workbench/workbenchEdgeAutoPan.d.ts +56 -0
- package/dist/components/workbench/workbenchEdgeAutoPan.js +127 -0
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { WorkbenchViewport } from './types';
|
|
2
|
+
export declare const WORKBENCH_EDGE_AUTO_PAN_FRAME_SELECTOR = "[data-floe-workbench-canvas-frame=\"true\"]";
|
|
3
|
+
export interface WorkbenchEdgeAutoPanFrame {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface WorkbenchEdgeAutoPanVelocityOptions {
|
|
12
|
+
frame: WorkbenchEdgeAutoPanFrame;
|
|
13
|
+
clientX: number;
|
|
14
|
+
clientY: number;
|
|
15
|
+
thresholdPx?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Deprecated: edge auto-pan intentionally keeps moving after the pointer leaves
|
|
18
|
+
* the frame during an active drag.
|
|
19
|
+
*/
|
|
20
|
+
outsideTolerancePx?: number;
|
|
21
|
+
maxSpeedPxPerSecond?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkbenchEdgeAutoPanVelocity {
|
|
24
|
+
viewportVelocityX: number;
|
|
25
|
+
viewportVelocityY: number;
|
|
26
|
+
}
|
|
27
|
+
export interface WorkbenchEdgeAutoPanStep {
|
|
28
|
+
viewportDeltaX: number;
|
|
29
|
+
viewportDeltaY: number;
|
|
30
|
+
worldDeltaX: number;
|
|
31
|
+
worldDeltaY: number;
|
|
32
|
+
viewport: WorkbenchViewport;
|
|
33
|
+
}
|
|
34
|
+
export interface WorkbenchEdgeAutoPanControllerOptions {
|
|
35
|
+
readFrame: () => WorkbenchEdgeAutoPanFrame | null;
|
|
36
|
+
readViewport: () => WorkbenchViewport | null;
|
|
37
|
+
commitViewport: (viewport: WorkbenchViewport) => void;
|
|
38
|
+
onPan?: (step: WorkbenchEdgeAutoPanStep) => void;
|
|
39
|
+
onPanStart?: () => void;
|
|
40
|
+
shouldPan?: () => boolean;
|
|
41
|
+
thresholdPx?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Deprecated: edge auto-pan intentionally keeps moving after the pointer leaves
|
|
44
|
+
* the frame during an active drag.
|
|
45
|
+
*/
|
|
46
|
+
outsideTolerancePx?: number;
|
|
47
|
+
activationDelayMs?: number;
|
|
48
|
+
maxSpeedPxPerSecond?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface WorkbenchEdgeAutoPanController {
|
|
51
|
+
updatePointer: (clientX: number, clientY: number) => void;
|
|
52
|
+
stop: () => void;
|
|
53
|
+
}
|
|
54
|
+
export declare function resolveWorkbenchEdgeAutoPanVelocity(options: WorkbenchEdgeAutoPanVelocityOptions): WorkbenchEdgeAutoPanVelocity;
|
|
55
|
+
export declare function frameFromElement(element: HTMLElement | null | undefined): WorkbenchEdgeAutoPanFrame | null;
|
|
56
|
+
export declare function createWorkbenchEdgeAutoPanController(options: WorkbenchEdgeAutoPanControllerOptions): WorkbenchEdgeAutoPanController;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const x = '[data-floe-workbench-canvas-frame="true"]';
|
|
2
|
+
function u(e, t) {
|
|
3
|
+
return Number.isFinite(e) && Number(e) > 0 ? Number(e) : t;
|
|
4
|
+
}
|
|
5
|
+
function w(e) {
|
|
6
|
+
const t = Math.max(0, Math.min(1, e));
|
|
7
|
+
return t * t * (3 - 2 * t);
|
|
8
|
+
}
|
|
9
|
+
function h(e, t) {
|
|
10
|
+
if (e >= t) return 0;
|
|
11
|
+
if (e >= 0) {
|
|
12
|
+
const i = (t - e) / t * 0.78;
|
|
13
|
+
return w(i);
|
|
14
|
+
}
|
|
15
|
+
const r = Math.max(96, t), n = Math.min(1, Math.abs(e) / r);
|
|
16
|
+
return w(0.78 + n * 0.22);
|
|
17
|
+
}
|
|
18
|
+
function p(e) {
|
|
19
|
+
const t = u(e.thresholdPx, 72), r = u(
|
|
20
|
+
e.maxSpeedPxPerSecond,
|
|
21
|
+
680
|
|
22
|
+
), n = e.frame;
|
|
23
|
+
if (!Number.isFinite(n.width) || n.width <= 0 || !Number.isFinite(n.height) || n.height <= 0)
|
|
24
|
+
return { viewportVelocityX: 0, viewportVelocityY: 0 };
|
|
25
|
+
const i = r / 1e3, l = h(e.clientX - n.left, t), s = h(n.right - e.clientX, t), A = h(e.clientY - n.top, t), D = h(n.bottom - e.clientY, t);
|
|
26
|
+
return {
|
|
27
|
+
viewportVelocityX: (l - s) * i,
|
|
28
|
+
viewportVelocityY: (A - D) * i
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function y(e) {
|
|
32
|
+
const t = e?.getBoundingClientRect();
|
|
33
|
+
return t ? {
|
|
34
|
+
left: t.left,
|
|
35
|
+
top: t.top,
|
|
36
|
+
right: t.right,
|
|
37
|
+
bottom: t.bottom,
|
|
38
|
+
width: t.width,
|
|
39
|
+
height: t.height
|
|
40
|
+
} : null;
|
|
41
|
+
}
|
|
42
|
+
function X(e) {
|
|
43
|
+
return typeof window > "u" || typeof window.requestAnimationFrame != "function" ? null : window.requestAnimationFrame(e);
|
|
44
|
+
}
|
|
45
|
+
function L(e) {
|
|
46
|
+
e === null || typeof window > "u" || typeof window.cancelAnimationFrame != "function" || window.cancelAnimationFrame(e);
|
|
47
|
+
}
|
|
48
|
+
function b(e) {
|
|
49
|
+
let t = null, r = null, n = null, i = null, l = !1, s = !1;
|
|
50
|
+
const A = () => u(e.thresholdPx, 72), D = () => Math.max(0, u(
|
|
51
|
+
e.activationDelayMs,
|
|
52
|
+
45
|
|
53
|
+
)), F = () => u(
|
|
54
|
+
e.maxSpeedPxPerSecond,
|
|
55
|
+
680
|
|
56
|
+
), E = () => {
|
|
57
|
+
i = null, n = null;
|
|
58
|
+
}, c = () => {
|
|
59
|
+
l || r !== null || !t || (r = X(T));
|
|
60
|
+
}, T = (o) => {
|
|
61
|
+
if (r = null, l || !t) return;
|
|
62
|
+
if (e.shouldPan && !e.shouldPan()) {
|
|
63
|
+
E();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const _ = e.readFrame(), a = e.readViewport();
|
|
67
|
+
if (!_ || !a) {
|
|
68
|
+
E();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const m = p({
|
|
72
|
+
frame: _,
|
|
73
|
+
clientX: t.clientX,
|
|
74
|
+
clientY: t.clientY,
|
|
75
|
+
thresholdPx: A(),
|
|
76
|
+
maxSpeedPxPerSecond: F()
|
|
77
|
+
});
|
|
78
|
+
if (m.viewportVelocityX === 0 && m.viewportVelocityY === 0) {
|
|
79
|
+
E();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (i === null) {
|
|
83
|
+
i = o, n = o, c();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (o - i < D()) {
|
|
87
|
+
n = o, c();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const P = Math.max(0, Math.min(48, o - (n ?? o)));
|
|
91
|
+
if (n = o, P <= 0) {
|
|
92
|
+
c();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const d = m.viewportVelocityX * P, f = m.viewportVelocityY * P;
|
|
96
|
+
if (Math.abs(d) < 0.01 && Math.abs(f) < 0.01) {
|
|
97
|
+
c();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const S = Math.max(Math.abs(Number(a.scale)), 1e-3), M = {
|
|
101
|
+
...a,
|
|
102
|
+
x: a.x + d,
|
|
103
|
+
y: a.y + f
|
|
104
|
+
};
|
|
105
|
+
s || (s = !0, e.onPanStart?.()), e.commitViewport(M), e.onPan?.({
|
|
106
|
+
viewportDeltaX: d,
|
|
107
|
+
viewportDeltaY: f,
|
|
108
|
+
worldDeltaX: -d / S,
|
|
109
|
+
worldDeltaY: -f / S,
|
|
110
|
+
viewport: M
|
|
111
|
+
}), c();
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
updatePointer: (o, _) => {
|
|
115
|
+
t = { clientX: o, clientY: _ }, c();
|
|
116
|
+
},
|
|
117
|
+
stop: () => {
|
|
118
|
+
l = !0, L(r), r = null, t = null, E();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
x as WORKBENCH_EDGE_AUTO_PAN_FRAME_SELECTOR,
|
|
124
|
+
b as createWorkbenchEdgeAutoPanController,
|
|
125
|
+
y as frameFromElement,
|
|
126
|
+
p as resolveWorkbenchEdgeAutoPanVelocity
|
|
127
|
+
};
|