@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,60 +1,90 @@
1
- const d = 8, r = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
2
- function M(e, t, n) {
3
- const o = window.innerWidth, f = window.innerHeight;
4
- let i;
5
- switch (n) {
1
+ const u = 8, M = '[role="menuitem"]:not([disabled]):not([aria-disabled="true"])';
2
+ function a() {
3
+ return typeof window > "u" ? {
4
+ left: 0,
5
+ top: 0,
6
+ right: 0,
7
+ bottom: 0,
8
+ width: 0,
9
+ height: 0
10
+ } : {
11
+ left: 0,
12
+ top: 0,
13
+ right: window.innerWidth,
14
+ bottom: window.innerHeight,
15
+ width: window.innerWidth,
16
+ height: window.innerHeight
17
+ };
18
+ }
19
+ function h(e) {
20
+ return e ?? a();
21
+ }
22
+ function E(e, t, f) {
23
+ const i = h(f);
24
+ let o = e.x, n = e.y;
25
+ return o + t.width > i.right - 8 && (o = i.right - t.width - 8), n + t.height > i.bottom - 8 && (n = i.bottom - t.height - 8), {
26
+ x: Math.max(i.left + 8, o),
27
+ y: Math.max(i.top + 8, n)
28
+ };
29
+ }
30
+ function A(e, t, f, i) {
31
+ const o = h(i);
32
+ let n;
33
+ switch (f) {
6
34
  case "center":
7
- i = e.left + e.width / 2 - t.width / 2;
35
+ n = e.left + e.width / 2 - t.width / 2;
8
36
  break;
9
37
  case "end":
10
- i = e.right - t.width;
38
+ n = e.right - t.width;
11
39
  break;
12
40
  default:
13
- i = e.left;
41
+ n = e.left;
14
42
  }
15
- let l = e.bottom + 4;
16
- if (i + t.width > o - 8 && (i = o - t.width - 8), i = Math.max(8, i), l + t.height > f - 8) {
17
- const I = e.top - 8, h = f - e.bottom - 8;
18
- I > h && I >= t.height ? l = e.top - t.height - 4 : l = f - t.height - 8;
43
+ let r = e.bottom + 4;
44
+ if (n + t.width > o.right - 8 && (n = o.right - t.width - 8), n = Math.max(o.left + 8, n), r + t.height > o.bottom - 8) {
45
+ const I = e.top - o.top - 8, d = o.bottom - e.bottom - 8;
46
+ I > d && I >= t.height ? r = e.top - t.height - 4 : r = o.bottom - t.height - 8;
19
47
  }
20
- return l = Math.max(8, l), { x: i, y: l };
21
- }
22
- function u(e, t) {
23
- const n = window.innerWidth, o = window.innerHeight;
24
- let f = e.right, i = e.top;
25
- if (f + t.width > n - 8) {
26
- const l = e.left - t.width;
27
- l >= 8 ? f = l : f = n - t.width - 8;
48
+ return r = Math.max(o.top + 8, r), { x: n, y: r };
49
+ }
50
+ function P(e, t, f) {
51
+ const i = h(f);
52
+ let o = e.right, n = e.top;
53
+ if (o + t.width > i.right - 8) {
54
+ const r = e.left - t.width;
55
+ r >= i.left + 8 ? o = r : o = i.right - t.width - 8;
28
56
  }
29
- return i + t.height > o - 8 && (i = o - t.height - 8), f = Math.max(8, f), i = Math.max(8, i), { x: f, y: i };
57
+ return n + t.height > i.bottom - 8 && (n = i.bottom - t.height - 8), o = Math.max(i.left + 8, o), n = Math.max(i.top + 8, n), { x: o, y: n };
30
58
  }
31
- function a(e, t, n) {
32
- return e <= 0 ? null : t < 0 ? n > 0 ? 0 : e - 1 : (t + n + e) % e;
59
+ function s(e, t, f) {
60
+ return e <= 0 ? null : t < 0 ? f > 0 ? 0 : e - 1 : (t + f + e) % e;
33
61
  }
34
- function s(e) {
35
- return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(r)).filter(
62
+ function l(e) {
63
+ return !e || typeof HTMLElement > "u" ? [] : Array.from(e.querySelectorAll(M)).filter(
36
64
  (t) => t instanceof HTMLElement
37
65
  );
38
66
  }
39
- function w(e, t = "first") {
40
- const n = s(e);
41
- if (!n.length) return !1;
42
- let o = n[0];
43
- return t === "last" ? o = n[n.length - 1] : t === "selected" && (o = n.find((f) => f.getAttribute("data-floe-selected") === "true") ?? n[0]), o.focus(), !0;
67
+ function T(e, t = "first") {
68
+ const f = l(e);
69
+ if (!f.length) return !1;
70
+ let i = f[0];
71
+ return t === "last" ? i = f[f.length - 1] : t === "selected" && (i = f.find((o) => o.getAttribute("data-floe-selected") === "true") ?? f[0]), i.focus(), !0;
44
72
  }
45
- function E(e, t, n) {
46
- const o = s(e);
47
- if (!o.length) return !1;
48
- const f = t ? o.indexOf(t) : -1, i = a(o.length, f, n);
49
- return i === null ? !1 : (o[i]?.focus(), !0);
73
+ function w(e, t, f) {
74
+ const i = l(e);
75
+ if (!i.length) return !1;
76
+ const o = t ? i.indexOf(t) : -1, n = s(i.length, o, f);
77
+ return n === null ? !1 : (i[n]?.focus(), !0);
50
78
  }
51
79
  export {
52
- r as MENU_ITEM_SELECTOR,
53
- d as VIEWPORT_MARGIN,
54
- M as calculateMenuPosition,
55
- u as calculateSubmenuPosition,
56
- w as focusMenuItem,
57
- s as getMenuItems,
58
- a as getWrappedMenuItemIndex,
59
- E as moveMenuFocus
80
+ M as MENU_ITEM_SELECTOR,
81
+ u as VIEWPORT_MARGIN,
82
+ A as calculateMenuPosition,
83
+ P as calculateSubmenuPosition,
84
+ E as clampMenuPosition,
85
+ T as focusMenuItem,
86
+ l as getMenuItems,
87
+ s as getWrappedMenuItemIndex,
88
+ w as moveMenuFocus,
89
+ a as resolveViewportMenuBoundaryRect
60
90
  };
@@ -0,0 +1 @@
1
+ export { DIALOG_SURFACE_HOST_ATTR, SURFACE_PORTAL_HOST_ATTR, SURFACE_PORTAL_LAYER_ATTR, DIALOG_SURFACE_BOUNDARY_ATTR, ensureSurfacePortalInteractionTracking, resolveSurfacePortalHost, isSurfacePortalMode, resolveSurfacePortalMount, resolveSurfacePortalBoundaryRect, resolveSurfacePortalMountRect, projectSurfacePortalPosition, projectSurfacePortalRect, __resetSurfacePortalScopeForTests, type SurfacePortalInteractionSnapshot, type SurfacePortalMode, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, type SurfacePortalRect, } from './dialogSurfaceScope';
@@ -0,0 +1,8 @@
1
+ export type SurfacePortalRect = Readonly<{
2
+ left: number;
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ width: number;
7
+ height: number;
8
+ }>;
@@ -14,6 +14,7 @@ export interface WorkbenchCanvasProps {
14
14
  filters: Record<WorkbenchWidgetType, boolean>;
15
15
  setCanvasFrameRef: (el: HTMLDivElement | undefined) => void;
16
16
  onViewportCommit: (viewport: WorkbenchViewport) => void;
17
+ onViewportInteractionStart?: (kind: 'wheel' | 'pan') => void;
17
18
  onCanvasContextMenu: (event: InfiniteCanvasContextMenuEvent) => void;
18
19
  onSelectWidget: (widgetId: string) => void;
19
20
  onWidgetContextMenu: (event: MouseEvent, item: WorkbenchWidgetItem) => void;
@@ -1,11 +1,11 @@
1
- import { use as v, insert as m, createComponent as i, effect as W, template as f } from "solid-js/web";
1
+ import { use as v, insert as m, createComponent as i, effect as W, template as w } from "solid-js/web";
2
2
  import { createMemo as o, Show as h, For as F } from "solid-js";
3
3
  import { WorkbenchCanvasField as y } from "./WorkbenchCanvasField.js";
4
- import { WorkbenchWidget as R } from "./WorkbenchWidget.js";
5
- import { createWorkbenchRenderLayerMap as I, resolveWorkbenchWidgetRenderMode as l } from "./workbenchHelpers.js";
4
+ import { WorkbenchWidget as I } from "./WorkbenchWidget.js";
5
+ import { createWorkbenchRenderLayerMap as R, resolveWorkbenchWidgetRenderMode as l } from "./workbenchHelpers.js";
6
6
  import { getWidgetEntry as c } from "./widgets/widgetRegistry.js";
7
7
  import { InfiniteCanvas as S } from "../ui/InfiniteCanvas.js";
8
- var M = /* @__PURE__ */ f("<div class=workbench-canvas>"), k = /* @__PURE__ */ f("<div class=workbench-canvas__projected-layer>");
8
+ var M = /* @__PURE__ */ w("<div class=workbench-canvas>"), k = /* @__PURE__ */ w("<div class=workbench-canvas__projected-layer>");
9
9
  function b(e) {
10
10
  const n = o((g) => {
11
11
  const d = e.widgetById().get(e.widgetId);
@@ -13,7 +13,7 @@ function b(e) {
13
13
  if (g) return g;
14
14
  throw new Error(`Workbench widget ${e.widgetId} is missing from the projected render map.`);
15
15
  }), a = o(() => c(n().type, e.widgetDefinitions));
16
- return i(R, {
16
+ return i(I, {
17
17
  get definition() {
18
18
  return a();
19
19
  },
@@ -91,13 +91,13 @@ function b(e) {
91
91
  });
92
92
  }
93
93
  function q(e) {
94
- const n = o(() => new Map(e.widgets.map((t) => [t.id, t]))), a = o(() => I(e.widgets)), g = o(() => e.widgets.filter((t) => {
94
+ const n = o(() => new Map(e.widgets.map((t) => [t.id, t]))), a = o(() => R(e.widgets)), g = o(() => e.widgets.filter((t) => {
95
95
  const r = c(t.type, e.widgetDefinitions);
96
96
  return l(r) === "canvas_scaled";
97
97
  })), d = o(() => e.widgets.filter((t) => {
98
98
  const r = c(t.type, e.widgetDefinitions);
99
99
  return l(r) === "projected_surface";
100
- }).map((t) => t.id)), w = () => e.canvasFrameSize.width > 0 && e.canvasFrameSize.height > 0;
100
+ }).map((t) => t.id)), f = () => e.canvasFrameSize.width > 0 && e.canvasFrameSize.height > 0;
101
101
  return (() => {
102
102
  var t = M(), r = e.setCanvasFrameRef;
103
103
  return typeof r == "function" ? v(r, t) : e.setCanvasFrameRef = t, m(t, i(S, {
@@ -109,6 +109,9 @@ function q(e) {
109
109
  get onViewportChange() {
110
110
  return e.onViewportCommit;
111
111
  },
112
+ get onViewportInteractionStart() {
113
+ return e.onViewportInteractionStart;
114
+ },
112
115
  get onCanvasContextMenu() {
113
116
  return e.onCanvasContextMenu;
114
117
  },
@@ -179,7 +182,7 @@ function q(e) {
179
182
  },
180
183
  projectedViewport: s,
181
184
  get surfaceReady() {
182
- return w();
185
+ return f();
183
186
  }
184
187
  })
185
188
  })), u;
@@ -1,53 +1,54 @@
1
- import { insert as c, createComponent as a, Portal as h, addEventListener as p, effect as k, className as W, template as g, delegateEvents as b } from "solid-js/web";
2
- import { createEffect as s, onCleanup as u, Show as C } from "solid-js";
3
- import { isTypingElement as y } from "../../utils/dom.js";
4
- import { WorkbenchCanvas as A } from "./WorkbenchCanvas.js";
5
- import { WorkbenchContextMenu as D } from "./WorkbenchContextMenu.js";
6
- import { WorkbenchFilterBar as x } from "./WorkbenchFilterBar.js";
7
- import { WorkbenchHud as S } from "./WorkbenchHud.js";
8
- import { WorkbenchLockButton as M } from "./WorkbenchLockButton.js";
9
- import { installWorkbenchContextMenuDismissListeners as F } from "./workbenchContextMenuDismiss.js";
10
- import { useWorkbenchModel as L } from "./useWorkbenchModel.js";
11
- var R = /* @__PURE__ */ g("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), E = /* @__PURE__ */ g("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
12
- const _ = "F1";
13
- function P(i) {
14
- const e = L({
15
- state: () => i.state(),
16
- setState: (t) => i.setState(t),
17
- widgetDefinitions: () => i.widgetDefinitions,
1
+ import { insert as c, createComponent as a, Portal as f, addEventListener as w, effect as v, className as h, template as d, delegateEvents as p } from "solid-js/web";
2
+ import { createEffect as s, onCleanup as l, Show as k } from "solid-js";
3
+ import { isTypingElement as W } from "../../utils/dom.js";
4
+ import { clientToCanvasWorld as C } from "../ui/canvasGeometry.js";
5
+ import { WorkbenchCanvas as b } from "./WorkbenchCanvas.js";
6
+ import { WorkbenchContextMenu as A } from "./WorkbenchContextMenu.js";
7
+ import { WorkbenchFilterBar as y } from "./WorkbenchFilterBar.js";
8
+ import { WorkbenchHud as D } from "./WorkbenchHud.js";
9
+ import { WorkbenchLockButton as S } from "./WorkbenchLockButton.js";
10
+ import { installWorkbenchContextMenuDismissListeners as x } from "./workbenchContextMenuDismiss.js";
11
+ import { useWorkbenchModel as M } from "./useWorkbenchModel.js";
12
+ var F = /* @__PURE__ */ d("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), L = /* @__PURE__ */ d("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
13
+ const R = "F1";
14
+ function U(o) {
15
+ const e = M({
16
+ state: () => o.state(),
17
+ setState: (t) => o.setState(t),
18
+ widgetDefinitions: () => o.widgetDefinitions,
18
19
  onClose: () => {
19
20
  }
20
21
  });
21
22
  s(() => {
22
- i.onApiReady?.({
23
+ o.onApiReady?.({
23
24
  ensureWidget: (t, r) => e.widgetActions.ensureWidget(t, r) ?? null,
24
25
  clearSelection: () => e.selection.clear(),
25
26
  focusWidget: (t, r) => e.navigation.focusWidget(t, r),
26
27
  fitWidget: (t) => e.navigation.fitWidget(t),
27
28
  overviewWidget: (t) => e.navigation.overviewWidget(t),
28
29
  findWidgetByType: (t) => e.queries.findWidgetByType(t)
29
- }), u(() => {
30
- i.onApiReady?.(null);
30
+ }), l(() => {
31
+ o.onApiReady?.(null);
31
32
  });
32
33
  });
33
- const d = () => i.lockShortcut === void 0 ? _ : i.lockShortcut;
34
+ const u = () => o.lockShortcut === void 0 ? R : o.lockShortcut;
34
35
  s(() => {
35
36
  if (typeof window > "u" || !e.contextMenu.state()) return;
36
- const t = F({
37
+ const t = x({
37
38
  ownerWindow: window,
38
39
  onDismiss: e.contextMenu.close
39
40
  });
40
- u(() => t());
41
+ l(() => t());
41
42
  }), s(() => {
42
- if (i.enableKeyboard === !1 || typeof document > "u") return;
43
- const t = d(), r = (n) => {
43
+ if (o.enableKeyboard === !1 || typeof document > "u") return;
44
+ const t = u(), r = (n) => {
44
45
  if (n.defaultPrevented || n.isComposing) return;
45
46
  if (t !== null && n.key === t) {
46
47
  n.preventDefault(), e.lock.toggle();
47
48
  return;
48
49
  }
49
- const o = n.target;
50
- if (!(o instanceof Element && y(o)))
50
+ const i = n.target;
51
+ if (!(i instanceof Element && W(i)))
51
52
  switch (n.key) {
52
53
  case "ArrowUp":
53
54
  n.preventDefault(), e.navigation.handleArrowNavigation("up");
@@ -67,26 +68,23 @@ function P(i) {
67
68
  break;
68
69
  }
69
70
  };
70
- document.addEventListener("keydown", r, !0), u(() => document.removeEventListener("keydown", r, !0));
71
+ document.addEventListener("keydown", r, !0), l(() => document.removeEventListener("keydown", r, !0));
71
72
  });
72
- const m = (t, r) => {
73
+ const g = (t, r) => {
73
74
  const n = document.querySelector('[data-floe-workbench-canvas-frame="true"]');
74
75
  if (!n) return null;
75
- const o = n.getBoundingClientRect();
76
- if (t < o.left || t > o.right || r < o.top || r > o.bottom)
77
- return null;
78
- const w = t - o.left, v = r - o.top, l = e.viewport();
79
- return {
80
- worldX: (w - l.x) / l.scale,
81
- worldY: (v - l.y) / l.scale
82
- };
83
- }, f = (t, r, n) => {
84
- const o = m(r, n);
85
- o && e.widgetActions.addWidgetAtCursor(t, o.worldX, o.worldY);
76
+ const i = n.getBoundingClientRect();
77
+ return C(i, e.viewport(), {
78
+ clientX: t,
79
+ clientY: r
80
+ });
81
+ }, m = (t, r, n) => {
82
+ const i = g(r, n);
83
+ i && e.widgetActions.addWidgetAtCursor(t, i.worldX, i.worldY);
86
84
  };
87
85
  return (() => {
88
- var t = E(), r = t.firstChild;
89
- return c(r, a(A, {
86
+ var t = L(), r = t.firstChild;
87
+ return c(r, a(b, {
90
88
  get widgetDefinitions() {
91
89
  return e.widgetDefinitions();
92
90
  },
@@ -117,6 +115,9 @@ function P(i) {
117
115
  get onViewportCommit() {
118
116
  return e.canvas.commitViewport;
119
117
  },
118
+ get onViewportInteractionStart() {
119
+ return e.canvas.cancelViewportNavigation;
120
+ },
120
121
  get onCanvasContextMenu() {
121
122
  return e.canvas.openCanvasContextMenu;
122
123
  },
@@ -141,7 +142,7 @@ function P(i) {
141
142
  get onRequestDelete() {
142
143
  return e.widgetActions.deleteWidget;
143
144
  }
144
- })), c(t, a(M, {
145
+ })), c(t, a(S, {
145
146
  get locked() {
146
147
  return e.locked();
147
148
  },
@@ -149,9 +150,9 @@ function P(i) {
149
150
  return e.lock.toggle;
150
151
  },
151
152
  get shortcutLabel() {
152
- return d() ?? void 0;
153
+ return u() ?? void 0;
153
154
  }
154
- }), null), c(t, a(x, {
155
+ }), null), c(t, a(y, {
155
156
  get widgetDefinitions() {
156
157
  return e.widgetDefinitions();
157
158
  },
@@ -167,8 +168,8 @@ function P(i) {
167
168
  get onShowAll() {
168
169
  return e.filter.showAll;
169
170
  },
170
- onCreateAt: f
171
- }), null), c(t, a(S, {
171
+ onCreateAt: m
172
+ }), null), c(t, a(D, {
172
173
  get scaleLabel() {
173
174
  return e.scaleLabel();
174
175
  },
@@ -178,17 +179,17 @@ function P(i) {
178
179
  get onZoomIn() {
179
180
  return e.hud.zoomIn;
180
181
  }
181
- }), null), c(t, a(C, {
182
+ }), null), c(t, a(k, {
182
183
  get when() {
183
184
  return e.contextMenu.state();
184
185
  },
185
186
  get children() {
186
- return a(h, {
187
+ return a(f, {
187
188
  get children() {
188
189
  return [(() => {
189
- var n = R();
190
- return p(n, "contextmenu", e.contextMenu.retarget, !0), n;
191
- })(), a(D, {
190
+ var n = F();
191
+ return w(n, "contextmenu", e.contextMenu.retarget, !0), n;
192
+ })(), a(A, {
192
193
  get x() {
193
194
  return e.contextMenu.position()?.left ?? 0;
194
195
  },
@@ -202,10 +203,10 @@ function P(i) {
202
203
  }
203
204
  });
204
205
  }
205
- }), null), k(() => W(t, `workbench-surface${i.class ? ` ${i.class}` : ""}`)), t;
206
+ }), null), v(() => h(t, `workbench-surface${o.class ? ` ${o.class}` : ""}`)), t;
206
207
  })();
207
208
  }
208
- b(["contextmenu"]);
209
+ p(["contextmenu"]);
209
210
  export {
210
- P as WorkbenchSurface
211
+ U as WorkbenchSurface
211
212
  };
@@ -48,6 +48,7 @@ export declare function useWorkbenchModel(options: UseWorkbenchModelOptions): {
48
48
  height: number;
49
49
  }) => void;
50
50
  commitViewport: (next: WorkbenchViewport) => void;
51
+ cancelViewportNavigation: () => void;
51
52
  };
52
53
  hud: {
53
54
  zoomIn: () => void;