@floegence/floe-webapp-core 0.36.12 → 0.36.15

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.
@@ -1,163 +1,181 @@
1
- import { insert as x, effect as G, className as T, setAttribute as J, setStyleProperty as K, template as Q, use as ee, delegateEvents as te } from "solid-js/web";
2
- import { createSignal as _, untrack as L, createEffect as b, onCleanup as A } from "solid-js";
3
- import { cn as D } from "../../utils/cn.js";
4
- import { startHotInteraction as y } from "../../utils/hotInteraction.js";
5
- import { resolveSurfaceInteractionTargetRole as ne, resolveSurfaceWheelRouting as re, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR as oe } from "./localInteractionSurface.js";
6
- var ae = /* @__PURE__ */ Q('<div><div style="transform-origin:0 0">');
7
- const ie = 1, ce = 0.45, le = 2.2, se = 14e-4, ue = '[data-floe-canvas-pan-surface="true"]', Y = 3;
8
- function de(n, a, d) {
9
- return Math.max(a, Math.min(d, n));
1
+ import { spread as B, mergeProps as j, insert as T, effect as q, className as G, setStyleProperty as J, template as K, use as Q } from "solid-js/web";
2
+ import { createSignal as _, untrack as I, createEffect as L, onCleanup as A } from "solid-js";
3
+ import { cn as x } from "../../utils/cn.js";
4
+ import { startHotInteraction as D } from "../../utils/hotInteraction.js";
5
+ import { resolveSurfaceInteractionTargetRole as ee, resolveSurfaceWheelRouting as te, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR as ne } from "./localInteractionSurface.js";
6
+ import { clientToCanvasLocal as Y, localToCanvasWorld as re, createViewportFromZoomAnchor as oe } from "./canvasGeometry.js";
7
+ import { SURFACE_PORTAL_LAYER_ATTR as ie } from "./dialogSurfaceScope.js";
8
+ var ae = /* @__PURE__ */ K('<div><div style="transform-origin:0 0">');
9
+ const ce = 1, le = 0.45, se = 2.2, ue = 14e-4, de = '[data-floe-canvas-pan-surface="true"]', R = 3;
10
+ function fe(t, i, u) {
11
+ return Math.max(i, Math.min(u, t));
10
12
  }
11
- function M(n) {
13
+ function b(t) {
12
14
  return {
13
- x: Number.isFinite(n.x) ? n.x : 0,
14
- y: Number.isFinite(n.y) ? n.y : 0,
15
- scale: Number.isFinite(n.scale) && n.scale > 0 ? n.scale : ie
15
+ x: Number.isFinite(t.x) ? t.x : 0,
16
+ y: Number.isFinite(t.y) ? t.y : 0,
17
+ scale: Number.isFinite(t.scale) && t.scale > 0 ? t.scale : ce
16
18
  };
17
19
  }
18
- function fe(n, a) {
19
- return n.deltaMode === 1 ? n.deltaY * 16 : n.deltaMode === 2 ? n.deltaY * (a?.clientHeight ?? window.innerHeight) : n.deltaY;
20
+ function me(t, i) {
21
+ return t.deltaMode === 1 ? t.deltaY * 16 : t.deltaMode === 2 ? t.deltaY * (i?.clientHeight ?? window.innerHeight) : t.deltaY;
20
22
  }
21
- function Ce(n) {
22
- const [a, d] = _(L(() => M(n.viewport))), [v, w] = _(null);
23
- let i, f, m = !1, l;
24
- const R = () => n.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', X = () => n.panSurfaceSelector ?? ue, F = () => n.wheelInteractiveSelector ?? oe, k = () => n.minScale ?? ce, V = () => n.maxScale ?? le, $ = () => n.wheelZoomSpeed ?? se, N = () => {
25
- const e = v();
23
+ function Pe(t) {
24
+ const [i, u] = _(I(() => b(t.viewport))), [m, S] = _(null);
25
+ let a, d, f = !1, l;
26
+ const M = () => t.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', X = () => t.panSurfaceSelector ?? de, F = () => t.wheelInteractiveSelector ?? ne, V = () => t.minScale ?? le, y = () => t.maxScale ?? se, k = () => t.wheelZoomSpeed ?? ue, U = () => {
27
+ const e = m();
26
28
  return e ? e.startedFromPanSurface ? e.moved : !0 : !1;
27
- }, p = () => {
28
- f !== void 0 && (window.clearTimeout(f), f = void 0);
29
+ }, w = () => {
30
+ d !== void 0 && (window.clearTimeout(d), d = void 0);
29
31
  }, C = () => {
30
- m = !1, l !== void 0 && (window.clearTimeout(l), l = void 0);
31
- }, U = () => {
32
+ f = !1, l !== void 0 && (window.clearTimeout(l), l = void 0);
33
+ }, N = () => {
32
34
  if (typeof window > "u") {
33
- m = !1;
35
+ f = !1;
34
36
  return;
35
37
  }
36
38
  l !== void 0 && window.clearTimeout(l), l = window.setTimeout(() => {
37
- l = void 0, m = !1;
39
+ l = void 0, f = !1;
38
40
  }, 0);
39
- }, h = (e) => {
40
- L(() => n.onViewportChange?.(e));
41
- }, H = (e) => {
41
+ }, v = (e) => {
42
+ I(() => t.onViewportChange?.(e));
43
+ }, Z = (e) => {
42
44
  if (typeof window > "u") {
43
- h(e);
45
+ v(e);
44
46
  return;
45
47
  }
46
- p(), f = window.setTimeout(() => {
47
- f = void 0, h(e);
48
+ w(), d = window.setTimeout(() => {
49
+ d = void 0, v(e);
48
50
  }, 90);
49
- }, g = (e) => ne({
51
+ }, p = (e) => ee({
50
52
  target: e,
51
- interactiveSelector: R(),
53
+ interactiveSelector: M(),
52
54
  panSurfaceSelector: X()
53
- }), E = (e) => {
54
- const t = v();
55
- if (!t || e !== void 0 && t.pointerId !== e) return;
56
- t.stopInteraction?.();
57
- const o = a();
58
- w(null), i && i.hasPointerCapture(t.pointerId) && i.releasePointerCapture(t.pointerId), t.startedFromPanSurface && t.moved && (m = !0, U()), h(o);
55
+ }), h = (e) => {
56
+ const n = m();
57
+ if (!n || e !== void 0 && n.pointerId !== e) return;
58
+ n.stopInteraction?.();
59
+ const r = i();
60
+ S(null), a && a.hasPointerCapture(n.pointerId) && a.releasePointerCapture(n.pointerId), n.startedFromPanSurface && n.moved && (f = !0, N()), v(r);
59
61
  };
60
- b(() => {
61
- v() || d(M(n.viewport));
62
- }), b(() => {
63
- const e = i;
62
+ L(() => {
63
+ m() || u(b(t.viewport));
64
+ }), L(() => {
65
+ const e = a;
64
66
  if (!e) return;
65
- const t = (o) => {
66
- !m || g(o.target) !== "pan_surface" || (C(), o.preventDefault(), o.stopPropagation());
67
+ const n = (r) => {
68
+ !f || p(r.target) !== "pan_surface" || (C(), r.preventDefault(), r.stopPropagation());
67
69
  };
68
- e.addEventListener("click", t, !0), e.addEventListener("wheel", P, {
70
+ e.addEventListener("click", n, !0), e.addEventListener("wheel", g, {
69
71
  passive: !1
70
72
  }), A(() => {
71
- e.removeEventListener("click", t, !0), e.removeEventListener("wheel", P);
73
+ e.removeEventListener("click", n, !0), e.removeEventListener("wheel", g);
72
74
  });
73
75
  }), A(() => {
74
- p(), E(), C();
76
+ w(), h(), C();
75
77
  });
76
- const Z = (e) => {
77
- if (e.button !== 0 || n.disablePanZoom) return;
78
- const t = g(e.target), o = t === "pan_surface";
79
- t !== "local_surface" && (p(), C(), o || (e.preventDefault(), i?.setPointerCapture(e.pointerId)), w({
78
+ const H = (e) => {
79
+ if (e.button !== 0 || t.disablePanZoom) return;
80
+ const n = p(e.target), r = n === "pan_surface";
81
+ n !== "local_surface" && (w(), C(), r || (t.onViewportInteractionStart?.("pan"), e.preventDefault(), a?.setPointerCapture(e.pointerId)), S({
80
82
  pointerId: e.pointerId,
81
83
  startClientX: e.clientX,
82
84
  startClientY: e.clientY,
83
- startViewport: a(),
85
+ startViewport: i(),
84
86
  moved: !1,
85
- startedFromPanSurface: o,
86
- stopInteraction: o ? void 0 : y({
87
+ startedFromPanSurface: r,
88
+ stopInteraction: r ? void 0 : D({
87
89
  kind: "drag",
88
90
  cursor: "grabbing"
89
91
  })
90
92
  }));
91
93
  }, W = (e) => {
92
- const t = v();
93
- if (!t || t.pointerId !== e.pointerId) return;
94
- const o = e.clientX - t.startClientX, r = e.clientY - t.startClientY;
95
- if (!(t.moved || Math.abs(o) > Y || Math.abs(r) > Y)) return;
96
- t.moved || (e.preventDefault(), i?.hasPointerCapture(e.pointerId) || i?.setPointerCapture(e.pointerId));
94
+ const n = m();
95
+ if (!n || n.pointerId !== e.pointerId) return;
96
+ const r = e.clientX - n.startClientX, o = e.clientY - n.startClientY;
97
+ if (!(n.moved || Math.abs(r) > R || Math.abs(o) > R)) return;
98
+ n.moved || (e.preventDefault(), a?.hasPointerCapture(e.pointerId) || a?.setPointerCapture(e.pointerId));
97
99
  const s = {
98
- ...t.startViewport,
99
- x: t.startViewport.x + o,
100
- y: t.startViewport.y + r
100
+ ...n.startViewport,
101
+ x: n.startViewport.x + r,
102
+ y: n.startViewport.y + o
101
103
  };
102
- t.moved || w({
103
- ...t,
104
+ n.moved || S({
105
+ ...n,
104
106
  moved: !0,
105
- stopInteraction: t.stopInteraction ?? y({
107
+ stopInteraction: n.stopInteraction ?? D({
106
108
  kind: "drag",
107
109
  cursor: "grabbing"
108
110
  })
109
- }), d(s);
111
+ }), u(s);
110
112
  }, O = (e) => {
111
- E(e.pointerId);
112
- }, z = (e) => {
113
- E(e.pointerId);
114
- }, P = (e) => {
115
- const t = i?.getBoundingClientRect();
116
- if (!t || re({
113
+ h(e.pointerId);
114
+ }, $ = (e) => {
115
+ h(e.pointerId);
116
+ }, g = (e) => {
117
+ const n = a?.getBoundingClientRect();
118
+ if (!n || te({
117
119
  target: e.target,
118
- disablePanZoom: !!n.disablePanZoom,
120
+ disablePanZoom: !!t.disablePanZoom,
119
121
  wheelInteractiveSelector: F()
120
122
  }).kind !== "canvas_zoom") return;
123
+ e.preventDefault(), t.onViewportInteractionStart?.("wheel");
124
+ const o = i(), c = Y(n, {
125
+ clientX: e.clientX,
126
+ clientY: e.clientY
127
+ }), s = me(e, a), P = fe(o.scale * Math.exp(-s * k()), V(), y());
128
+ if (Math.abs(P - o.scale) < 1e-4) return;
129
+ const E = oe({
130
+ viewport: o,
131
+ localPoint: c,
132
+ nextScale: P
133
+ });
134
+ u(E), Z(E);
135
+ }, z = (e) => {
136
+ if (p(e.target) !== "canvas") return;
137
+ const n = a?.getBoundingClientRect();
138
+ if (!n) return;
121
139
  e.preventDefault();
122
- const r = a(), c = e.clientX - t.left, s = e.clientY - t.top, S = fe(e, i), u = de(r.scale * Math.exp(-S * $()), k(), V());
123
- if (Math.abs(u - r.scale) < 1e-4) return;
124
- const j = (c - r.x) / r.scale, q = (s - r.y) / r.scale, I = {
125
- x: c - j * u,
126
- y: s - q * u,
127
- scale: u
128
- };
129
- d(I), H(I);
130
- }, B = (e) => {
131
- if (g(e.target) !== "canvas") return;
132
- const t = i?.getBoundingClientRect();
133
- if (!t) return;
134
- e.preventDefault();
135
- const o = e.clientX - t.left, r = e.clientY - t.top, c = a();
136
- n.onCanvasContextMenu?.({
140
+ const r = Y(n, {
141
+ clientX: e.clientX,
142
+ clientY: e.clientY
143
+ }), o = i(), c = re(o, r);
144
+ t.onCanvasContextMenu?.({
137
145
  clientX: e.clientX,
138
146
  clientY: e.clientY,
139
- localX: o,
140
- localY: r,
141
- worldX: (o - c.x) / c.scale,
142
- worldY: (r - c.y) / c.scale
147
+ localX: r.localX,
148
+ localY: r.localY,
149
+ worldX: c.worldX,
150
+ worldY: c.worldY
143
151
  });
144
152
  };
145
153
  return (() => {
146
- var e = ae(), t = e.firstChild;
147
- e.$$contextmenu = B, e.addEventListener("pointercancel", z), e.$$pointerup = O, e.$$pointermove = W, e.$$pointerdown = Z;
148
- var o = i;
149
- return typeof o == "function" ? ee(o, e) : i = e, x(t, () => n.children), x(e, () => n.overlay?.(a()), null), G((r) => {
150
- var c = D("floe-infinite-canvas", N() && "is-panning", n.disablePanZoom && "is-locked", n.class), s = n.ariaLabel ?? "Infinite canvas", S = D("floe-infinite-canvas__viewport", n.contentClass), u = `translate(${a().x}px, ${a().y}px) scale(${a().scale})`;
151
- return c !== r.e && T(e, r.e = c), s !== r.t && J(e, "aria-label", r.t = s), S !== r.a && T(t, r.a = S), u !== r.o && K(t, "transform", r.o = u), r;
154
+ var e = ae(), n = e.firstChild, r = a;
155
+ return typeof r == "function" ? Q(r, e) : a = e, B(e, j({
156
+ get class() {
157
+ return x("floe-infinite-canvas", U() && "is-panning", t.disablePanZoom && "is-locked", t.class);
158
+ }
159
+ }, {
160
+ [ie]: "true"
161
+ }, {
162
+ onPointerDown: H,
163
+ onPointerMove: W,
164
+ onPointerUp: O,
165
+ onPointerCancel: $,
166
+ onContextMenu: z,
167
+ get "aria-label"() {
168
+ return t.ariaLabel ?? "Infinite canvas";
169
+ }
170
+ }), !1, !0), T(n, () => t.children), T(e, () => t.overlay?.(i()), null), q((o) => {
171
+ var c = x("floe-infinite-canvas__viewport", t.contentClass), s = `translate(${i().x}px, ${i().y}px) scale(${i().scale})`;
172
+ return c !== o.e && G(n, o.e = c), s !== o.t && J(n, "transform", o.t = s), o;
152
173
  }, {
153
174
  e: void 0,
154
- t: void 0,
155
- a: void 0,
156
- o: void 0
175
+ t: void 0
157
176
  }), e;
158
177
  })();
159
178
  }
160
- te(["pointerdown", "pointermove", "pointerup", "contextmenu"]);
161
179
  export {
162
- Ce as InfiniteCanvas
180
+ Pe as InfiniteCanvas
163
181
  };
@@ -0,0 +1,32 @@
1
+ export interface CanvasViewportLike {
2
+ x: number;
3
+ y: number;
4
+ scale: number;
5
+ }
6
+ export interface CanvasClientPoint {
7
+ clientX: number;
8
+ clientY: number;
9
+ }
10
+ export interface CanvasLocalPoint {
11
+ localX: number;
12
+ localY: number;
13
+ }
14
+ export interface CanvasWorldPoint {
15
+ worldX: number;
16
+ worldY: number;
17
+ }
18
+ export interface CanvasViewportRectLike {
19
+ left: number;
20
+ top: number;
21
+ right: number;
22
+ bottom: number;
23
+ }
24
+ export declare function isPointInsideCanvasRect(rect: CanvasViewportRectLike, point: CanvasClientPoint): boolean;
25
+ export declare function clientToCanvasLocal(rect: Pick<CanvasViewportRectLike, 'left' | 'top'>, point: CanvasClientPoint): CanvasLocalPoint;
26
+ export declare function localToCanvasWorld(viewport: CanvasViewportLike, point: CanvasLocalPoint): CanvasWorldPoint;
27
+ export declare function clientToCanvasWorld(rect: CanvasViewportRectLike, viewport: CanvasViewportLike, point: CanvasClientPoint): CanvasWorldPoint | null;
28
+ export declare function createViewportFromZoomAnchor(options: {
29
+ viewport: CanvasViewportLike;
30
+ localPoint: CanvasLocalPoint;
31
+ nextScale: number;
32
+ }): CanvasViewportLike;
@@ -0,0 +1,33 @@
1
+ function e(l, c) {
2
+ return c.clientX >= l.left && c.clientX <= l.right && c.clientY >= l.top && c.clientY <= l.bottom;
3
+ }
4
+ function o(l, c) {
5
+ return {
6
+ localX: c.clientX - l.left,
7
+ localY: c.clientY - l.top
8
+ };
9
+ }
10
+ function a(l, c) {
11
+ return {
12
+ worldX: (c.localX - l.x) / l.scale,
13
+ worldY: (c.localY - l.y) / l.scale
14
+ };
15
+ }
16
+ function t(l, c, n) {
17
+ return e(l, n) ? a(c, o(l, n)) : null;
18
+ }
19
+ function r(l) {
20
+ const c = a(l.viewport, l.localPoint);
21
+ return {
22
+ x: l.localPoint.localX - c.worldX * l.nextScale,
23
+ y: l.localPoint.localY - c.worldY * l.nextScale,
24
+ scale: l.nextScale
25
+ };
26
+ }
27
+ export {
28
+ o as clientToCanvasLocal,
29
+ t as clientToCanvasWorld,
30
+ r as createViewportFromZoomAnchor,
31
+ e as isPointInsideCanvasRect,
32
+ a as localToCanvasWorld
33
+ };
@@ -1,14 +1,39 @@
1
+ import type { SurfacePortalRect } from './surfacePortalTypes';
1
2
  export declare const DIALOG_SURFACE_HOST_ATTR = "data-floe-dialog-surface-host";
3
+ export declare const SURFACE_PORTAL_HOST_ATTR = "data-floe-dialog-surface-host";
4
+ export declare const SURFACE_PORTAL_LAYER_ATTR = "data-floe-surface-portal-layer";
2
5
  export declare const DIALOG_SURFACE_BOUNDARY_ATTR = "data-floe-dialog-surface-boundary";
3
6
  export type DialogSurfaceInteractionSnapshot = Readonly<{
4
7
  target: Element | null;
5
8
  activeElement: Element | null;
6
9
  recordedAt: number;
7
10
  }>;
11
+ export type SurfacePortalInteractionSnapshot = DialogSurfaceInteractionSnapshot;
12
+ export type SurfacePortalMode = 'global' | 'surface';
8
13
  export type ResolvedDialogSurfaceHost = Readonly<{
9
14
  host: HTMLElement | null;
10
- mode: 'global' | 'surface';
15
+ boundaryHost: HTMLElement | null;
16
+ mountHost: HTMLElement | null;
17
+ mode: SurfacePortalMode;
11
18
  }>;
19
+ export type ResolvedSurfacePortalHost = ResolvedDialogSurfaceHost;
20
+ export type SurfacePortalBoundaryRect = SurfacePortalRect;
21
+ export type { SurfacePortalRect };
12
22
  export declare function ensureDialogSurfaceInteractionTracking(): void;
23
+ export declare function ensureSurfacePortalInteractionTracking(): void;
13
24
  export declare function resolveDialogSurfaceHost(): ResolvedDialogSurfaceHost;
25
+ export declare function resolveSurfacePortalHost(): ResolvedSurfacePortalHost;
26
+ export declare function isSurfacePortalMode(surfaceHost: ResolvedSurfacePortalHost): boolean;
27
+ export declare function resolveSurfacePortalMount(surfaceHost: ResolvedSurfacePortalHost): HTMLElement | undefined;
28
+ export declare function resolveSurfacePortalBoundaryRect(surfaceHost: ResolvedSurfacePortalHost): SurfacePortalBoundaryRect;
29
+ export declare function resolveSurfacePortalMountRect(surfaceHost: ResolvedSurfacePortalHost): SurfacePortalBoundaryRect;
30
+ export declare function projectSurfacePortalPosition(position: Readonly<{
31
+ x: number;
32
+ y: number;
33
+ }>, surfaceHost: ResolvedSurfacePortalHost): Readonly<{
34
+ x: number;
35
+ y: number;
36
+ }>;
37
+ export declare function projectSurfacePortalRect(rect: SurfacePortalBoundaryRect, surfaceHost: ResolvedSurfacePortalHost): SurfacePortalBoundaryRect;
14
38
  export declare function __resetDialogSurfaceScopeForTests(): void;
39
+ export declare function __resetSurfacePortalScopeForTests(): void;
@@ -1,45 +1,144 @@
1
- const a = "data-floe-dialog-surface-host", m = "data-floe-dialog-surface-boundary";
2
- let o = null, t = null;
3
- function d(e) {
4
- return typeof Element < "u" && e instanceof Element ? e : typeof Node < "u" && e instanceof Node ? e.parentElement : null;
5
- }
6
- function f(e) {
7
- const n = e?.activeElement;
8
- return n instanceof Element ? n : null;
9
- }
10
- function i(e) {
11
- const n = typeof document < "u" ? document : null;
12
- o = {
13
- target: d(e),
14
- activeElement: f(n),
1
+ const f = "data-floe-dialog-surface-host", y = f, m = "data-floe-surface-portal-layer", A = "data-floe-dialog-surface-boundary", p = 1600;
2
+ let r = null, o = null;
3
+ function g(t) {
4
+ return typeof Element < "u" && t instanceof Element ? t : typeof Node < "u" && t instanceof Node ? t.parentElement : null;
5
+ }
6
+ function E(t) {
7
+ const e = t?.activeElement;
8
+ return e instanceof Element ? e : null;
9
+ }
10
+ function d(t) {
11
+ const e = typeof document < "u" ? document : null;
12
+ r = {
13
+ target: g(t),
14
+ activeElement: E(e),
15
15
  recordedAt: Date.now()
16
16
  };
17
17
  }
18
- function r(e) {
19
- i(e.target);
18
+ function i(t) {
19
+ d(t.target);
20
+ }
21
+ function l(t) {
22
+ d(t.target);
23
+ }
24
+ function a() {
25
+ T();
26
+ }
27
+ function T() {
28
+ typeof document > "u" || o !== document && (o && (o.removeEventListener("pointerdown", i, !0), o.removeEventListener("focusin", l, !0)), document.addEventListener("pointerdown", i, !0), document.addEventListener("focusin", l, !0), o = document);
29
+ }
30
+ function w() {
31
+ return !r || Date.now() - r.recordedAt > p ? null : r;
32
+ }
33
+ function c(t) {
34
+ const e = t?.closest(`[${f}="true"]`);
35
+ return typeof HTMLElement > "u" ? null : e instanceof HTMLElement && e.isConnected ? e : null;
36
+ }
37
+ function R(t) {
38
+ if (!t) return null;
39
+ const e = t.closest(`[${m}="true"]`);
40
+ return typeof HTMLElement > "u" ? null : e instanceof HTMLElement && e.isConnected ? e : null;
41
+ }
42
+ function v() {
43
+ a();
44
+ const t = w(), e = c(t?.target ?? null) ?? c(t?.activeElement ?? null);
45
+ return e ? {
46
+ host: e,
47
+ boundaryHost: e,
48
+ mountHost: R(e) ?? e,
49
+ mode: "surface"
50
+ } : { host: null, boundaryHost: null, mountHost: null, mode: "global" };
20
51
  }
21
- function u(e) {
22
- i(e.target);
52
+ function u(t) {
53
+ return t.mode === "surface" && !!t.boundaryHost?.isConnected;
23
54
  }
24
- function l() {
25
- typeof document > "u" || t !== document && (t && (t.removeEventListener("pointerdown", r, !0), t.removeEventListener("focusin", u, !0)), document.addEventListener("pointerdown", r, !0), document.addEventListener("focusin", u, !0), t = document);
55
+ function S(t) {
56
+ if (u(t))
57
+ return t.mountHost ?? t.boundaryHost ?? void 0;
26
58
  }
27
59
  function s() {
28
- return !o || Date.now() - o.recordedAt > 1600 ? null : o;
60
+ return typeof window > "u" ? {
61
+ left: 0,
62
+ top: 0,
63
+ right: 0,
64
+ bottom: 0,
65
+ width: 0,
66
+ height: 0
67
+ } : {
68
+ left: 0,
69
+ top: 0,
70
+ right: window.innerWidth,
71
+ bottom: window.innerHeight,
72
+ width: window.innerWidth,
73
+ height: window.innerHeight
74
+ };
75
+ }
76
+ function _(t) {
77
+ if (!u(t) || !t.boundaryHost)
78
+ return s();
79
+ const e = t.boundaryHost.getBoundingClientRect();
80
+ return {
81
+ left: e.left,
82
+ top: e.top,
83
+ right: e.right,
84
+ bottom: e.bottom,
85
+ width: e.width,
86
+ height: e.height
87
+ };
88
+ }
89
+ function h(t) {
90
+ const e = S(t);
91
+ if (!e)
92
+ return s();
93
+ const n = e.getBoundingClientRect();
94
+ return {
95
+ left: n.left,
96
+ top: n.top,
97
+ right: n.right,
98
+ bottom: n.bottom,
99
+ width: n.width,
100
+ height: n.height
101
+ };
102
+ }
103
+ function b(t, e) {
104
+ if (!u(e))
105
+ return t;
106
+ const n = h(e);
107
+ return {
108
+ x: t.x - n.left,
109
+ y: t.y - n.top
110
+ };
29
111
  }
30
- function c(e) {
31
- const n = e?.closest(`[${a}="true"]`);
32
- return n instanceof HTMLElement && n.isConnected ? n : null;
112
+ function L(t, e) {
113
+ if (!u(e))
114
+ return t;
115
+ const n = h(e);
116
+ return {
117
+ left: t.left - n.left,
118
+ top: t.top - n.top,
119
+ right: t.right - n.left,
120
+ bottom: t.bottom - n.top,
121
+ width: t.width,
122
+ height: t.height
123
+ };
33
124
  }
34
- function E() {
35
- l();
36
- const e = s(), n = c(e?.target ?? null) ?? c(e?.activeElement ?? null);
37
- return n ? { host: n, mode: "surface" } : { host: null, mode: "global" };
125
+ function P() {
126
+ r = null;
38
127
  }
39
- typeof document < "u" && l();
128
+ typeof document < "u" && a();
40
129
  export {
41
- m as DIALOG_SURFACE_BOUNDARY_ATTR,
42
- a as DIALOG_SURFACE_HOST_ATTR,
43
- l as ensureDialogSurfaceInteractionTracking,
44
- E as resolveDialogSurfaceHost
130
+ A as DIALOG_SURFACE_BOUNDARY_ATTR,
131
+ f as DIALOG_SURFACE_HOST_ATTR,
132
+ y as SURFACE_PORTAL_HOST_ATTR,
133
+ m as SURFACE_PORTAL_LAYER_ATTR,
134
+ P as __resetSurfacePortalScopeForTests,
135
+ a as ensureDialogSurfaceInteractionTracking,
136
+ T as ensureSurfacePortalInteractionTracking,
137
+ u as isSurfacePortalMode,
138
+ b as projectSurfacePortalPosition,
139
+ L as projectSurfacePortalRect,
140
+ _ as resolveSurfacePortalBoundaryRect,
141
+ v as resolveSurfacePortalHost,
142
+ S as resolveSurfacePortalMount,
143
+ h as resolveSurfacePortalMountRect
45
144
  };
@@ -7,7 +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 { clientToCanvasLocal, clientToCanvasWorld, createViewportFromZoomAnchor, isPointInsideCanvasRect, localToCanvasWorld, type CanvasClientPoint, type CanvasLocalPoint, type CanvasViewportLike, type CanvasViewportRectLike, type CanvasWorldPoint, } from './canvasGeometry';
10
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 { 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';
11
13
  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';
12
14
  export { Tabs, TabPanel, type TabsProps, type TabPanelProps, type TabItem, type TabsFeatures, type TabsSlotClassNames, type TabsIndicatorMode, type TabsIndicatorColorToken, } from './Tabs';
13
15
  export { DirectoryPicker, type DirectoryPickerProps } from './DirectoryPicker';
@@ -1,11 +1,30 @@
1
1
  export declare const VIEWPORT_MARGIN = 8;
2
2
  export declare const MENU_ITEM_SELECTOR = "[role=\"menuitem\"]:not([disabled]):not([aria-disabled=\"true\"])";
3
+ export type MenuBoundaryRect = Readonly<{
4
+ left: number;
5
+ top: number;
6
+ right: number;
7
+ bottom: number;
8
+ width: number;
9
+ height: number;
10
+ }>;
3
11
  export type MenuFocusMode = 'first' | 'last' | 'selected';
4
- export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: DOMRect, align: 'start' | 'center' | 'end'): {
12
+ export declare function resolveViewportMenuBoundaryRect(): MenuBoundaryRect;
13
+ export declare function clampMenuPosition(anchor: Readonly<{
14
+ x: number;
15
+ y: number;
16
+ }>, menuRect: Readonly<{
17
+ width: number;
18
+ height: number;
19
+ }>, boundaryRect?: MenuBoundaryRect): {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ export declare function calculateMenuPosition(triggerRect: DOMRect, menuRect: DOMRect, align: 'start' | 'center' | 'end', boundaryRect?: MenuBoundaryRect): {
5
24
  x: number;
6
25
  y: number;
7
26
  };
8
- export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: DOMRect): {
27
+ export declare function calculateSubmenuPosition(parentRect: DOMRect, submenuRect: DOMRect, boundaryRect?: MenuBoundaryRect): {
9
28
  x: number;
10
29
  y: number;
11
30
  };