@floegence/floe-webapp-core 0.36.16 → 0.36.18
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/ui/InfiniteCanvas.js +79 -71
- package/dist/components/ui/index.d.ts +2 -1
- package/dist/components/ui/localInteractionSurface.d.ts +2 -0
- package/dist/components/ui/localInteractionSurface.js +51 -26
- package/dist/components/ui/pointerSession.d.ts +35 -0
- package/dist/components/ui/pointerSession.js +85 -0
- package/dist/components/workbench/WorkbenchFilterBar.js +119 -117
- package/dist/components/workbench/WorkbenchWidget.js +157 -135
- package/dist/components/workbench/types.d.ts +7 -0
- package/dist/full.js +461 -458
- package/dist/ui.js +106 -103
- package/package.json +1 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { spread as
|
|
2
|
-
import { createSignal as
|
|
1
|
+
import { spread as z, mergeProps as B, insert as _, effect as j, className as q, setStyleProperty as G, template as J, use as K } from "solid-js/web";
|
|
2
|
+
import { createSignal as T, untrack as L, createEffect as A, onCleanup as I } from "solid-js";
|
|
3
3
|
import { cn as D } from "../../utils/cn.js";
|
|
4
4
|
import { startHotInteraction as x } from "../../utils/hotInteraction.js";
|
|
5
|
-
import { resolveSurfaceInteractionTargetRole as
|
|
5
|
+
import { resolveSurfaceInteractionTargetRole as Q, resolveSurfaceWheelRouting as ee, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR as te } from "./localInteractionSurface.js";
|
|
6
|
+
import { startPointerSession as ne } from "./pointerSession.js";
|
|
6
7
|
import { clientToCanvasLocal as Y, localToCanvasWorld as re, createViewportFromZoomAnchor as oe } from "./canvasGeometry.js";
|
|
7
8
|
import { SURFACE_PORTAL_LAYER_ATTR as ae } from "./dialogSurfaceScope.js";
|
|
8
|
-
var ie = /* @__PURE__ */
|
|
9
|
-
const ce = 1, le = 0.45, se = 2.2, ue = 14e-4,
|
|
10
|
-
function
|
|
11
|
-
return Math.max(a, Math.min(
|
|
9
|
+
var ie = /* @__PURE__ */ J('<div><div style="transform-origin:0 0">');
|
|
10
|
+
const ce = 1, le = 0.45, se = 2.2, ue = 14e-4, fe = '[data-floe-canvas-pan-surface="true"]', R = 3;
|
|
11
|
+
function de(t, a, f) {
|
|
12
|
+
return Math.max(a, Math.min(f, t));
|
|
12
13
|
}
|
|
13
14
|
function b(t) {
|
|
14
15
|
return {
|
|
@@ -20,67 +21,73 @@ function b(t) {
|
|
|
20
21
|
function me(t, a) {
|
|
21
22
|
return t.deltaMode === 1 ? t.deltaY * 16 : t.deltaMode === 2 ? t.deltaY * (a?.clientHeight ?? window.innerHeight) : t.deltaY;
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
const [a,
|
|
25
|
-
let i, d,
|
|
26
|
-
const M = () => t.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', X = () => t.panSurfaceSelector ??
|
|
27
|
-
const e =
|
|
24
|
+
function Pe(t) {
|
|
25
|
+
const [a, f] = T(L(() => b(t.viewport))), [S, w] = T(null);
|
|
26
|
+
let i, s, d, m = !1, l;
|
|
27
|
+
const M = () => t.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', X = () => t.panSurfaceSelector ?? fe, F = () => t.wheelInteractiveSelector ?? te, V = () => t.minScale ?? le, y = () => t.maxScale ?? se, k = () => t.wheelZoomSpeed ?? ue, N = () => {
|
|
28
|
+
const e = S();
|
|
28
29
|
return e ? e.startedFromPanSurface ? e.moved : !0 : !1;
|
|
29
|
-
},
|
|
30
|
+
}, v = () => {
|
|
30
31
|
d !== void 0 && (window.clearTimeout(d), d = void 0);
|
|
31
32
|
}, C = () => {
|
|
32
|
-
|
|
33
|
-
},
|
|
33
|
+
m = !1, l !== void 0 && (window.clearTimeout(l), l = void 0);
|
|
34
|
+
}, U = () => {
|
|
34
35
|
if (typeof window > "u") {
|
|
35
|
-
|
|
36
|
+
m = !1;
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
l !== void 0 && window.clearTimeout(l), l = window.setTimeout(() => {
|
|
39
|
-
l = void 0,
|
|
40
|
+
l = void 0, m = !1;
|
|
40
41
|
}, 0);
|
|
41
|
-
},
|
|
42
|
-
|
|
42
|
+
}, g = (e) => {
|
|
43
|
+
L(() => t.onViewportChange?.(e));
|
|
43
44
|
}, Z = (e) => {
|
|
44
45
|
if (typeof window > "u") {
|
|
45
|
-
|
|
46
|
+
g(e);
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
d = void 0,
|
|
49
|
+
v(), d = window.setTimeout(() => {
|
|
50
|
+
d = void 0, g(e);
|
|
50
51
|
}, 90);
|
|
51
|
-
},
|
|
52
|
+
}, p = (e) => Q({
|
|
52
53
|
target: e,
|
|
53
54
|
interactiveSelector: M(),
|
|
54
55
|
panSurfaceSelector: X()
|
|
55
|
-
}),
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
56
|
+
}), H = () => {
|
|
57
|
+
const e = S();
|
|
58
|
+
if (!e) return;
|
|
59
|
+
e.stopInteraction?.();
|
|
60
|
+
const n = a();
|
|
61
|
+
w(null), s = void 0, e.startedFromPanSurface && e.moved && (m = !0, U()), g(n);
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}),
|
|
63
|
+
A(() => {
|
|
64
|
+
S() || f(b(t.viewport));
|
|
65
|
+
}), A(() => {
|
|
65
66
|
const e = i;
|
|
66
67
|
if (!e) return;
|
|
67
68
|
const n = (r) => {
|
|
68
|
-
!
|
|
69
|
+
!m || p(r.target) !== "pan_surface" || (C(), r.preventDefault(), r.stopPropagation());
|
|
69
70
|
};
|
|
70
|
-
e.addEventListener("click", n, !0), e.addEventListener("wheel",
|
|
71
|
+
e.addEventListener("click", n, !0), e.addEventListener("wheel", h, {
|
|
71
72
|
passive: !1
|
|
72
|
-
}),
|
|
73
|
-
e.removeEventListener("click", n, !0), e.removeEventListener("wheel",
|
|
73
|
+
}), I(() => {
|
|
74
|
+
e.removeEventListener("click", n, !0), e.removeEventListener("wheel", h);
|
|
74
75
|
});
|
|
75
|
-
}),
|
|
76
|
-
|
|
76
|
+
}), I(() => {
|
|
77
|
+
v(), s?.stop({
|
|
78
|
+
reason: "manual_stop",
|
|
79
|
+
commit: !0
|
|
80
|
+
}), s = void 0, C();
|
|
77
81
|
});
|
|
78
|
-
const
|
|
82
|
+
const W = (e) => {
|
|
79
83
|
if (e.button !== 0) return;
|
|
80
|
-
const n =
|
|
84
|
+
const n = p(e.target);
|
|
81
85
|
if (n === "canvas" && t.onCanvasPointerDown?.(e), t.disablePanZoom) return;
|
|
82
86
|
const r = n === "pan_surface";
|
|
83
|
-
n !== "local_surface" && (
|
|
87
|
+
n !== "local_surface" && (v(), C(), r || (t.onViewportInteractionStart?.("pan"), e.preventDefault()), s?.stop({
|
|
88
|
+
reason: "manual_stop",
|
|
89
|
+
commit: !0
|
|
90
|
+
}), w({
|
|
84
91
|
pointerId: e.pointerId,
|
|
85
92
|
startClientX: e.clientX,
|
|
86
93
|
startClientY: e.clientY,
|
|
@@ -91,33 +98,37 @@ function ge(t) {
|
|
|
91
98
|
kind: "drag",
|
|
92
99
|
cursor: "grabbing"
|
|
93
100
|
})
|
|
101
|
+
}), s = ne({
|
|
102
|
+
pointerEvent: e,
|
|
103
|
+
captureEl: i ?? null,
|
|
104
|
+
capturePointer: !r,
|
|
105
|
+
onMove: O,
|
|
106
|
+
onEnd: () => {
|
|
107
|
+
H();
|
|
108
|
+
}
|
|
94
109
|
}));
|
|
95
|
-
},
|
|
96
|
-
const n =
|
|
110
|
+
}, O = (e) => {
|
|
111
|
+
const n = S();
|
|
97
112
|
if (!n || n.pointerId !== e.pointerId) return;
|
|
98
113
|
const r = e.clientX - n.startClientX, o = e.clientY - n.startClientY;
|
|
99
114
|
if (!(n.moved || Math.abs(r) > R || Math.abs(o) > R)) return;
|
|
100
|
-
n.moved || (e.preventDefault(), i
|
|
101
|
-
const
|
|
115
|
+
n.moved || (e.preventDefault(), (!i || typeof i.hasPointerCapture != "function" || !i.hasPointerCapture(e.pointerId)) && s?.capturePointer());
|
|
116
|
+
const u = {
|
|
102
117
|
...n.startViewport,
|
|
103
118
|
x: n.startViewport.x + r,
|
|
104
119
|
y: n.startViewport.y + o
|
|
105
120
|
};
|
|
106
|
-
n.moved ||
|
|
121
|
+
n.moved || w({
|
|
107
122
|
...n,
|
|
108
123
|
moved: !0,
|
|
109
124
|
stopInteraction: n.stopInteraction ?? x({
|
|
110
125
|
kind: "drag",
|
|
111
126
|
cursor: "grabbing"
|
|
112
127
|
})
|
|
113
|
-
}), u
|
|
114
|
-
},
|
|
115
|
-
p(e.pointerId);
|
|
116
|
-
}, $ = (e) => {
|
|
117
|
-
p(e.pointerId);
|
|
118
|
-
}, P = (e) => {
|
|
128
|
+
}), f(u);
|
|
129
|
+
}, h = (e) => {
|
|
119
130
|
const n = i?.getBoundingClientRect();
|
|
120
|
-
if (!n ||
|
|
131
|
+
if (!n || ee({
|
|
121
132
|
target: e.target,
|
|
122
133
|
disablePanZoom: !!t.disablePanZoom,
|
|
123
134
|
wheelInteractiveSelector: F()
|
|
@@ -126,16 +137,16 @@ function ge(t) {
|
|
|
126
137
|
const o = a(), c = Y(n, {
|
|
127
138
|
clientX: e.clientX,
|
|
128
139
|
clientY: e.clientY
|
|
129
|
-
}),
|
|
130
|
-
if (Math.abs(
|
|
131
|
-
const
|
|
140
|
+
}), u = me(e, i), E = de(o.scale * Math.exp(-u * k()), V(), y());
|
|
141
|
+
if (Math.abs(E - o.scale) < 1e-4) return;
|
|
142
|
+
const P = oe({
|
|
132
143
|
viewport: o,
|
|
133
144
|
localPoint: c,
|
|
134
|
-
nextScale:
|
|
145
|
+
nextScale: E
|
|
135
146
|
});
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
if (
|
|
147
|
+
f(P), Z(P);
|
|
148
|
+
}, $ = (e) => {
|
|
149
|
+
if (p(e.target) !== "canvas") return;
|
|
139
150
|
const n = i?.getBoundingClientRect();
|
|
140
151
|
if (!n) return;
|
|
141
152
|
e.preventDefault();
|
|
@@ -154,24 +165,21 @@ function ge(t) {
|
|
|
154
165
|
};
|
|
155
166
|
return (() => {
|
|
156
167
|
var e = ie(), n = e.firstChild, r = i;
|
|
157
|
-
return typeof r == "function" ?
|
|
168
|
+
return typeof r == "function" ? K(r, e) : i = e, z(e, B({
|
|
158
169
|
get class() {
|
|
159
|
-
return D("floe-infinite-canvas",
|
|
170
|
+
return D("floe-infinite-canvas", N() && "is-panning", t.disablePanZoom && "is-locked", t.class);
|
|
160
171
|
}
|
|
161
172
|
}, {
|
|
162
173
|
[ae]: "true"
|
|
163
174
|
}, {
|
|
164
|
-
onPointerDown:
|
|
165
|
-
|
|
166
|
-
onPointerUp: O,
|
|
167
|
-
onPointerCancel: $,
|
|
168
|
-
onContextMenu: z,
|
|
175
|
+
onPointerDown: W,
|
|
176
|
+
onContextMenu: $,
|
|
169
177
|
get "aria-label"() {
|
|
170
178
|
return t.ariaLabel ?? "Infinite canvas";
|
|
171
179
|
}
|
|
172
|
-
}), !1, !0),
|
|
173
|
-
var c = D("floe-infinite-canvas__viewport", t.contentClass),
|
|
174
|
-
return c !== o.e &&
|
|
180
|
+
}), !1, !0), _(n, () => t.children), _(e, () => t.overlay?.(a()), null), j((o) => {
|
|
181
|
+
var c = D("floe-infinite-canvas__viewport", t.contentClass), u = `translate(${a().x}px, ${a().y}px) scale(${a().scale})`;
|
|
182
|
+
return c !== o.e && q(n, o.e = c), u !== o.t && G(n, "transform", o.t = u), o;
|
|
175
183
|
}, {
|
|
176
184
|
e: void 0,
|
|
177
185
|
t: void 0
|
|
@@ -179,5 +187,5 @@ function ge(t) {
|
|
|
179
187
|
})();
|
|
180
188
|
}
|
|
181
189
|
export {
|
|
182
|
-
|
|
190
|
+
Pe as InfiniteCanvas
|
|
183
191
|
};
|
|
@@ -7,8 +7,9 @@ export { Dropdown, Select, type DropdownProps, type DropdownItem, type SelectPro
|
|
|
7
7
|
export { Tooltip, type TooltipProps } from './Tooltip';
|
|
8
8
|
export { CommandPalette } from './CommandPalette';
|
|
9
9
|
export { InfiniteCanvas, type InfiniteCanvasProps, type InfiniteCanvasPoint, type InfiniteCanvasContextMenuEvent, } from './InfiniteCanvas';
|
|
10
|
+
export { startPointerSession, type PointerSessionController, type PointerSessionEndEvent, type PointerSessionEndReason, type PointerSessionSnapshot, type StartPointerSessionOptions, } from './pointerSession';
|
|
10
11
|
export { clientToCanvasLocal, clientToCanvasWorld, createViewportFromZoomAnchor, isPointInsideCanvasRect, localToCanvasWorld, type CanvasClientPoint, type CanvasLocalPoint, type CanvasViewportLike, type CanvasViewportRectLike, type CanvasWorldPoint, } from './canvasGeometry';
|
|
11
|
-
export { CANVAS_WHEEL_INTERACTIVE_ATTR, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR, LOCAL_INTERACTION_SURFACE_ATTR, DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR, WORKBENCH_WIDGET_SHELL_ATTR, DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR, isLocalInteractionSurfaceTarget, resolveSurfaceInteractionTargetRole, resolveSurfaceWheelRouting, resolveWorkbenchWidgetEventOwnership, type SurfaceInteractionRoutingOptions, type SurfaceInteractionTargetRole, type SurfaceWheelLocalReason, type SurfaceWheelRoutingDecision, type SurfaceWheelRoutingOptions, type WorkbenchWidgetEventOwnership, type WorkbenchWidgetEventOwnershipOptions, } from './localInteractionSurface';
|
|
12
|
+
export { CANVAS_WHEEL_INTERACTIVE_ATTR, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR, LOCAL_INTERACTION_SURFACE_ATTR, DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR, WORKBENCH_WIDGET_SHELL_ATTR, DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR, isLocalInteractionSurfaceTarget, resolveSurfaceInteractionTargetRole, resolveSurfaceWheelRouting, resolveWorkbenchWidgetEventOwnership, shouldActivateWorkbenchWidgetLocalTarget, type SurfaceInteractionRoutingOptions, type SurfaceInteractionTargetRole, type SurfaceWheelLocalReason, type SurfaceWheelRoutingDecision, type SurfaceWheelRoutingOptions, type WorkbenchWidgetEventOwnership, type WorkbenchWidgetEventOwnershipOptions, type WorkbenchWidgetLocalActivationTargetOptions, } from './localInteractionSurface';
|
|
12
13
|
export { DIALOG_SURFACE_HOST_ATTR, SURFACE_PORTAL_HOST_ATTR, SURFACE_PORTAL_LAYER_ATTR, DIALOG_SURFACE_BOUNDARY_ATTR, ensureSurfacePortalInteractionTracking, isSurfacePortalMode, projectSurfacePortalPosition, projectSurfacePortalRect, resolveSurfacePortalBoundaryRect, resolveSurfacePortalHost, resolveSurfacePortalMount, resolveSurfacePortalMountRect, __resetSurfacePortalScopeForTests, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, type SurfacePortalInteractionSnapshot, type SurfacePortalMode, type SurfacePortalRect, } from './surfacePortalScope';
|
|
13
14
|
export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Interactive3DCard, AnimatedBorderCard, NeonCard, MorphCard, type CardProps, type CardVariant, type CardHeaderProps, type CardTitleProps, type CardDescriptionProps, type CardContentProps, type CardFooterProps, type Interactive3DCardProps, type AnimatedBorderCardProps, type NeonCardProps, type MorphCardProps, } from './Card';
|
|
14
15
|
export { Tabs, TabPanel, type TabsProps, type TabPanelProps, type TabItem, type TabsFeatures, type TabsSlotClassNames, type TabsIndicatorMode, type TabsIndicatorColorToken, } from './Tabs';
|
|
@@ -26,6 +26,7 @@ export interface WorkbenchWidgetEventOwnershipOptions extends SurfaceInteraction
|
|
|
26
26
|
widgetRoot: Element | EventTarget | null;
|
|
27
27
|
shellSelector?: string;
|
|
28
28
|
}
|
|
29
|
+
export type WorkbenchWidgetLocalActivationTargetOptions = WorkbenchWidgetEventOwnershipOptions;
|
|
29
30
|
export interface SurfaceWheelRoutingOptions {
|
|
30
31
|
target: EventTarget | null;
|
|
31
32
|
disablePanZoom: boolean;
|
|
@@ -36,3 +37,4 @@ export declare function resolveSurfaceInteractionTargetRole(options: SurfaceInte
|
|
|
36
37
|
export declare function resolveSurfaceWheelRouting(options: SurfaceWheelRoutingOptions): SurfaceWheelRoutingDecision;
|
|
37
38
|
export declare function isLocalInteractionSurfaceTarget(options: SurfaceInteractionRoutingOptions): boolean;
|
|
38
39
|
export declare function resolveWorkbenchWidgetEventOwnership(options: WorkbenchWidgetEventOwnershipOptions): WorkbenchWidgetEventOwnership;
|
|
40
|
+
export declare function shouldActivateWorkbenchWidgetLocalTarget(options: WorkbenchWidgetLocalActivationTargetOptions): boolean;
|
|
@@ -1,48 +1,73 @@
|
|
|
1
|
-
import { isTypingElement as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { isTypingElement as o } from "../../utils/dom.js";
|
|
2
|
+
const f = "data-floe-local-interaction-surface", u = `[${f}="true"]`, E = "data-floe-canvas-wheel-interactive", d = `[${E}="true"]`, _ = "data-floe-workbench-widget-shell", i = `[${_}="true"]`;
|
|
3
|
+
function a(e) {
|
|
4
4
|
return typeof Element < "u" && e instanceof Element ? e : typeof Node < "u" && e instanceof Node ? e.parentElement : null;
|
|
5
5
|
}
|
|
6
|
+
function T(e) {
|
|
7
|
+
if (!e || typeof HTMLElement > "u" || !(e instanceof HTMLElement))
|
|
8
|
+
return !1;
|
|
9
|
+
if (e.matches("button, input, select, textarea, summary") || e.matches("a[href], area[href]") || e.matches('iframe, [contenteditable="true"]')) return !0;
|
|
10
|
+
const t = e.getAttribute("tabindex");
|
|
11
|
+
return t !== null && t !== "-1";
|
|
12
|
+
}
|
|
13
|
+
function S(e, t) {
|
|
14
|
+
let r = e;
|
|
15
|
+
for (; r && r !== t; ) {
|
|
16
|
+
if (o(r) || T(r))
|
|
17
|
+
return !0;
|
|
18
|
+
r = r.parentElement;
|
|
19
|
+
}
|
|
20
|
+
return !1;
|
|
21
|
+
}
|
|
6
22
|
function s(e) {
|
|
7
23
|
const {
|
|
8
24
|
target: t,
|
|
9
|
-
interactiveSelector:
|
|
10
|
-
panSurfaceSelector:
|
|
11
|
-
localInteractionSurfaceSelector: n =
|
|
12
|
-
} = e,
|
|
13
|
-
return
|
|
25
|
+
interactiveSelector: r,
|
|
26
|
+
panSurfaceSelector: c,
|
|
27
|
+
localInteractionSurfaceSelector: n = u
|
|
28
|
+
} = e, l = t instanceof Element ? t : null;
|
|
29
|
+
return l ? l.closest(c) !== null ? "pan_surface" : o(l) || l.closest(r) !== null || l.closest(n) !== null ? "local_surface" : "canvas" : "canvas";
|
|
14
30
|
}
|
|
15
|
-
function
|
|
31
|
+
function g(e) {
|
|
16
32
|
const {
|
|
17
33
|
target: t,
|
|
18
|
-
localInteractionSurfaceSelector:
|
|
19
|
-
wheelInteractiveSelector:
|
|
20
|
-
} = e, n =
|
|
21
|
-
return n ?
|
|
34
|
+
localInteractionSurfaceSelector: r = u,
|
|
35
|
+
wheelInteractiveSelector: c = d
|
|
36
|
+
} = e, n = a(t);
|
|
37
|
+
return n ? o(n) ? "typing_element" : n.closest(r) !== null ? "local_interaction_surface" : n.closest(c) !== null ? "wheel_interactive" : null : null;
|
|
22
38
|
}
|
|
23
|
-
function
|
|
24
|
-
const t =
|
|
39
|
+
function L(e) {
|
|
40
|
+
const t = g(e);
|
|
25
41
|
return t ? { kind: "local_surface", reason: t } : e.disablePanZoom ? { kind: "ignore", reason: "pan_zoom_disabled" } : { kind: "canvas_zoom" };
|
|
26
42
|
}
|
|
27
43
|
function A(e) {
|
|
28
44
|
return s(e) !== "canvas";
|
|
29
45
|
}
|
|
30
|
-
function
|
|
46
|
+
function m(e) {
|
|
47
|
+
const {
|
|
48
|
+
widgetRoot: t,
|
|
49
|
+
shellSelector: r = i
|
|
50
|
+
} = e, c = a(t), n = a(e.target);
|
|
51
|
+
return !c || !n || !c.contains(n) ? "outside_widget" : s(e) !== "canvas" ? "widget_local" : n === c || n.closest(r) !== null ? "widget_shell" : "widget_local";
|
|
52
|
+
}
|
|
53
|
+
function R(e) {
|
|
31
54
|
const {
|
|
32
55
|
widgetRoot: t,
|
|
33
|
-
shellSelector:
|
|
34
|
-
|
|
35
|
-
|
|
56
|
+
shellSelector: r = i,
|
|
57
|
+
localInteractionSurfaceSelector: c = u
|
|
58
|
+
} = e, n = a(t), l = a(e.target);
|
|
59
|
+
return !n || !l || !n.contains(l) || l === n || l.closest(r) !== null || l.closest(e.panSurfaceSelector) !== null || l.closest(c) !== null || S(l, n) ? !1 : m(e) === "widget_local";
|
|
36
60
|
}
|
|
37
61
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
E as CANVAS_WHEEL_INTERACTIVE_ATTR,
|
|
63
|
+
d as DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR,
|
|
64
|
+
u as DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR,
|
|
65
|
+
i as DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR,
|
|
66
|
+
f as LOCAL_INTERACTION_SURFACE_ATTR,
|
|
43
67
|
_ as WORKBENCH_WIDGET_SHELL_ATTR,
|
|
44
68
|
A as isLocalInteractionSurfaceTarget,
|
|
45
69
|
s as resolveSurfaceInteractionTargetRole,
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
L as resolveSurfaceWheelRouting,
|
|
71
|
+
m as resolveWorkbenchWidgetEventOwnership,
|
|
72
|
+
R as shouldActivateWorkbenchWidgetLocalTarget
|
|
48
73
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type PointerSessionEndReason = 'pointer_up' | 'pointer_cancel' | 'buttons_released' | 'lost_pointer_capture' | 'window_blur' | 'document_hidden' | 'manual_stop';
|
|
2
|
+
export interface PointerSessionSnapshot {
|
|
3
|
+
pointerId: number;
|
|
4
|
+
latestClientX: number;
|
|
5
|
+
latestClientY: number;
|
|
6
|
+
latestButtons: number;
|
|
7
|
+
active: boolean;
|
|
8
|
+
captureActive: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface PointerSessionEndEvent {
|
|
11
|
+
reason: PointerSessionEndReason;
|
|
12
|
+
commit: boolean;
|
|
13
|
+
snapshot: PointerSessionSnapshot;
|
|
14
|
+
event?: Pick<PointerEvent, 'pointerId' | 'clientX' | 'clientY' | 'buttons'>;
|
|
15
|
+
}
|
|
16
|
+
export interface StartPointerSessionOptions {
|
|
17
|
+
pointerEvent: PointerEvent;
|
|
18
|
+
captureEl?: HTMLElement | null;
|
|
19
|
+
ownerDocument?: Document;
|
|
20
|
+
buttonMask?: number;
|
|
21
|
+
capturePointer?: boolean;
|
|
22
|
+
onMove?: (event: PointerEvent, snapshot: PointerSessionSnapshot) => void;
|
|
23
|
+
onEnd: (event: PointerSessionEndEvent) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface PointerSessionController {
|
|
26
|
+
snapshot: () => PointerSessionSnapshot;
|
|
27
|
+
updatePointer: (event: Pick<PointerEvent, 'pointerId' | 'clientX' | 'clientY' | 'buttons'>) => void;
|
|
28
|
+
capturePointer: () => void;
|
|
29
|
+
stop: (options?: {
|
|
30
|
+
reason?: PointerSessionEndReason;
|
|
31
|
+
commit?: boolean;
|
|
32
|
+
event?: Pick<PointerEvent, 'pointerId' | 'clientX' | 'clientY' | 'buttons'>;
|
|
33
|
+
}) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare function startPointerSession(options: StartPointerSessionOptions): PointerSessionController;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function C(e) {
|
|
2
|
+
if (e.ownerDocument) return e.ownerDocument;
|
|
3
|
+
if (e.captureEl?.ownerDocument) return e.captureEl.ownerDocument;
|
|
4
|
+
const n = e.pointerEvent.target;
|
|
5
|
+
return n && typeof n == "object" && "ownerDocument" in n && n.ownerDocument instanceof Document ? n.ownerDocument : document;
|
|
6
|
+
}
|
|
7
|
+
function c(e, n) {
|
|
8
|
+
return typeof e.buttons == "number" ? e.buttons : n;
|
|
9
|
+
}
|
|
10
|
+
function L(e, n) {
|
|
11
|
+
return !e || e.pointerId === n;
|
|
12
|
+
}
|
|
13
|
+
function b(e) {
|
|
14
|
+
const n = C(e), l = n.defaultView ?? window, a = e.buttonMask ?? 1, h = c(e.pointerEvent, a), t = {
|
|
15
|
+
pointerId: e.pointerEvent.pointerId,
|
|
16
|
+
latestClientX: e.pointerEvent.clientX,
|
|
17
|
+
latestClientY: e.pointerEvent.clientY,
|
|
18
|
+
latestButtons: h,
|
|
19
|
+
active: !0,
|
|
20
|
+
captureActive: !1
|
|
21
|
+
}, o = (r) => {
|
|
22
|
+
!t.active || r.pointerId !== t.pointerId || (t.latestClientX = r.clientX, t.latestClientY = r.clientY, t.latestButtons = c(r, t.latestButtons));
|
|
23
|
+
}, s = () => {
|
|
24
|
+
if (t.active && !(!e.captureEl || typeof e.captureEl.setPointerCapture != "function"))
|
|
25
|
+
try {
|
|
26
|
+
e.captureEl.setPointerCapture(t.pointerId), t.captureActive = !0;
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}, w = () => {
|
|
30
|
+
if (!e.captureEl || typeof e.captureEl.releasePointerCapture != "function") {
|
|
31
|
+
t.captureActive = !1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
(typeof e.captureEl.hasPointerCapture != "function" || e.captureEl.hasPointerCapture(t.pointerId)) && e.captureEl.releasePointerCapture(t.pointerId);
|
|
36
|
+
} catch {
|
|
37
|
+
} finally {
|
|
38
|
+
t.captureActive = !1;
|
|
39
|
+
}
|
|
40
|
+
}, P = () => {
|
|
41
|
+
n.removeEventListener("pointermove", p, !0), n.removeEventListener("pointerup", d, !0), n.removeEventListener("pointercancel", f, !0), n.removeEventListener("visibilitychange", E), l.removeEventListener("blur", v), e.captureEl?.removeEventListener("lostpointercapture", m);
|
|
42
|
+
}, i = (r = {}) => {
|
|
43
|
+
if (!t.active) return;
|
|
44
|
+
const u = r.event;
|
|
45
|
+
L(u, t.pointerId) && (u && o(u), t.active = !1, P(), w(), e.onEnd({
|
|
46
|
+
reason: r.reason ?? "manual_stop",
|
|
47
|
+
commit: r.commit ?? !1,
|
|
48
|
+
snapshot: t,
|
|
49
|
+
...u ? { event: u } : {}
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
function p(r) {
|
|
53
|
+
if (!(!t.active || r.pointerId !== t.pointerId)) {
|
|
54
|
+
if (o(r), a > 0 && (c(r, t.latestButtons) & a) !== a) {
|
|
55
|
+
i({ reason: "buttons_released", commit: !0, event: r });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
e.onMove?.(r, t);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function d(r) {
|
|
62
|
+
i({ reason: "pointer_up", commit: !0, event: r });
|
|
63
|
+
}
|
|
64
|
+
function f(r) {
|
|
65
|
+
i({ reason: "pointer_cancel", commit: !1, event: r });
|
|
66
|
+
}
|
|
67
|
+
function m() {
|
|
68
|
+
i({ reason: "lost_pointer_capture", commit: !0 });
|
|
69
|
+
}
|
|
70
|
+
function v() {
|
|
71
|
+
i({ reason: "window_blur", commit: !0 });
|
|
72
|
+
}
|
|
73
|
+
function E() {
|
|
74
|
+
n.hidden && i({ reason: "document_hidden", commit: !0 });
|
|
75
|
+
}
|
|
76
|
+
return n.addEventListener("pointermove", p, !0), n.addEventListener("pointerup", d, !0), n.addEventListener("pointercancel", f, !0), n.addEventListener("visibilitychange", E), l.addEventListener("blur", v), e.captureEl?.addEventListener("lostpointercapture", m), e.capturePointer !== !1 && s(), {
|
|
77
|
+
snapshot: () => t,
|
|
78
|
+
updatePointer: o,
|
|
79
|
+
capturePointer: s,
|
|
80
|
+
stop: i
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
b as startPointerSession
|
|
85
|
+
};
|