@floegence/floe-webapp-core 0.36.52 → 0.36.54

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,18 +1,19 @@
1
- import { use as X, spread as q, mergeProps as Y, insert as w, createComponent as s, Portal as z, addEventListener as V, template as D, delegateEvents as P } from "solid-js/web";
2
- import { createSignal as L, createMemo as f, untrack as p, createEffect as v, onCleanup as y, Show as H } from "solid-js";
3
- import { clientToCanvasWorld as $ } from "../ui/canvasGeometry.js";
4
- import { WorkbenchCanvas as U } from "./WorkbenchCanvas.js";
5
- import { WorkbenchContextMenu as K } from "./WorkbenchContextMenu.js";
6
- import { WorkbenchDock as j } from "./WorkbenchFilterBar.js";
7
- import { WorkbenchHud as Z } from "./WorkbenchHud.js";
8
- import { WorkbenchLockButton as G } from "./WorkbenchLockButton.js";
9
- import { installWorkbenchContextMenuDismissListeners as J } from "./workbenchContextMenuDismiss.js";
10
- import { createContextMenuPosition as Q, WORKBENCH_CONTEXT_MENU_WIDTH_PX as ee, estimateContextMenuHeight as te } from "./workbenchHelpers.js";
11
- import { useWorkbenchModel as ne } from "./useWorkbenchModel.js";
12
- import { resolveWorkbenchInteractionAdapter as oe } from "./workbenchInteractionAdapter.js";
13
- var re = /* @__PURE__ */ D("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), ie = /* @__PURE__ */ D("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
14
- const ae = "F1";
15
- function B(i) {
1
+ import { use as q, spread as z, mergeProps as V, insert as f, createComponent as s, Portal as H, addEventListener as $, template as B, delegateEvents as U } from "solid-js/web";
2
+ import { createSignal as A, createMemo as g, untrack as h, createEffect as v, onCleanup as y, Show as K } from "solid-js";
3
+ import { clientToCanvasWorld as j } from "../ui/canvasGeometry.js";
4
+ import { WorkbenchCanvas as Z } from "./WorkbenchCanvas.js";
5
+ import { WorkbenchContextMenu as G } from "./WorkbenchContextMenu.js";
6
+ import { WorkbenchDock as J } from "./WorkbenchFilterBar.js";
7
+ import { WorkbenchHud as Q } from "./WorkbenchHud.js";
8
+ import { WorkbenchLockButton as ee } from "./WorkbenchLockButton.js";
9
+ import { installWorkbenchContextMenuDismissListeners as te } from "./workbenchContextMenuDismiss.js";
10
+ import { createContextMenuPosition as ne, WORKBENCH_CONTEXT_MENU_WIDTH_PX as oe, estimateContextMenuHeight as re } from "./workbenchHelpers.js";
11
+ import { resolveWorkbenchWidgetPlacementPreview as ie, resolveWorkbenchToolPlacementPreview as ae } from "./workbenchPlacement.js";
12
+ import { useWorkbenchModel as ce } from "./useWorkbenchModel.js";
13
+ import { resolveWorkbenchInteractionAdapter as de } from "./workbenchInteractionAdapter.js";
14
+ var ue = /* @__PURE__ */ B("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), se = /* @__PURE__ */ B("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
15
+ const le = "F1";
16
+ function L(i) {
16
17
  if (i)
17
18
  try {
18
19
  i.focus({
@@ -22,8 +23,8 @@ function B(i) {
22
23
  i.focus();
23
24
  }
24
25
  }
25
- function Ae(i) {
26
- const t = ne({
26
+ function xe(i) {
27
+ const t = ce({
27
28
  state: () => i.state(),
28
29
  setState: (e) => i.setState(e),
29
30
  widgetDefinitions: () => i.widgetDefinitions,
@@ -31,18 +32,18 @@ function Ae(i) {
31
32
  backgroundLayerDefaults: () => i.backgroundLayerDefaults,
32
33
  onClose: () => {
33
34
  }
34
- }), [u, T] = L(null), d = f(() => oe(i.interactionAdapter)), [A, l] = L(p(() => d().createInitialInputOwner())), C = f(() => {
35
+ }), [u, T] = A(null), [N, R] = A(null), d = g(() => de(i.interactionAdapter)), [C, l] = A(h(() => d().createInitialInputOwner())), W = g(() => {
35
36
  const e = i.launcherWidgetTypes;
36
37
  return !e || e.length <= 0 ? null : new Set(e);
37
- }), N = f(() => {
38
- const e = t.widgetDefinitions(), n = C();
38
+ }), O = g(() => {
39
+ const e = t.widgetDefinitions(), n = W();
39
40
  return n ? e.filter((o) => n.has(o.type)) : e;
40
- }), h = f(() => {
41
- const e = t.contextMenu.state(), n = t.contextMenu.items(), o = C(), r = o ? n.filter((m) => {
41
+ }), S = g(() => {
42
+ const e = t.contextMenu.state(), n = t.contextMenu.items(), o = W(), r = o ? n.filter((m) => {
42
43
  if (m.kind !== "action")
43
44
  return !0;
44
- const M = /^add-(.+)$/.exec(String(m.id ?? ""));
45
- return M ? o.has(M[1]) : !0;
45
+ const D = /^add-(.+)$/.exec(String(m.id ?? ""));
46
+ return D ? o.has(D[1]) : !0;
46
47
  }) : n;
47
48
  if (!e || !i.resolveContextMenuItems)
48
49
  return r;
@@ -54,17 +55,17 @@ function Ae(i) {
54
55
  widget: c,
55
56
  closeMenu: t.contextMenu.close
56
57
  });
57
- }), W = f(() => {
58
+ }), b = g(() => {
58
59
  const e = t.contextMenu.state();
59
60
  if (!e) return;
60
- const n = h(), o = n.filter((a) => a.kind === "action").length, r = n.filter((a) => a.kind === "separator").length;
61
- return Q({
61
+ const n = S(), o = n.filter((a) => a.kind === "action").length, r = n.filter((a) => a.kind === "separator").length;
62
+ return ne({
62
63
  clientX: e.clientX,
63
64
  clientY: e.clientY,
64
- menuWidth: ee,
65
- menuHeight: te(o, r)
65
+ menuWidth: oe,
66
+ menuHeight: re(o, r)
66
67
  });
67
- }), S = (e, n, o) => {
68
+ }), x = (e, n, o) => {
68
69
  const r = d(), a = r.findWidgetRoot(e), c = r.readWidgetId(a);
69
70
  if (c) {
70
71
  if (t.queries.findStickyNoteById(c)) {
@@ -76,17 +77,17 @@ function Ae(i) {
76
77
  }
77
78
  const m = u();
78
79
  m && e instanceof Node && m.contains(e) && l(r.createCanvasInputOwner(o));
79
- }, b = (e = "selection_cleared") => {
80
+ }, I = (e = "selection_cleared") => {
80
81
  const n = d(), o = u();
81
82
  t.selection.clear(), l(n.createCanvasInputOwner(e)), queueMicrotask(() => {
82
83
  if (!o || typeof document > "u") return;
83
84
  const r = document.activeElement;
84
85
  if (!(r instanceof HTMLElement) || !o.contains(r)) {
85
- B(o);
86
+ L(o);
86
87
  return;
87
88
  }
88
89
  const a = n.findWidgetRoot(r);
89
- B(o), a && document.activeElement === r && r.isConnected && r.blur();
90
+ L(o), a && document.activeElement === r && r.isConnected && r.blur();
90
91
  });
91
92
  }, k = () => {
92
93
  const e = u()?.querySelector('[data-floe-workbench-canvas-frame="true"]'), n = t.viewport(), o = e?.getBoundingClientRect(), r = o?.width ?? 0, a = o?.height ?? 0;
@@ -94,17 +95,17 @@ function Ae(i) {
94
95
  worldX: r > 0 ? (r / 2 - n.x) / n.scale : 240,
95
96
  worldY: a > 0 ? (a / 2 - n.y) / n.scale : 180
96
97
  };
97
- }, g = (e) => {
98
- const n = p(d), o = p(u);
98
+ }, w = (e) => {
99
+ const n = h(d), o = h(u);
99
100
  queueMicrotask(() => {
100
101
  n.focusWidgetElement(o, e), l(n.createWidgetInputOwner(e, "activation"));
101
102
  });
102
- }, R = (e) => {
103
+ }, E = (e) => {
103
104
  const n = t.navigation.fitWidget(e);
104
- g(n.id);
105
- }, O = (e) => {
105
+ w(n.id);
106
+ }, F = (e) => {
106
107
  const n = t.navigation.overviewWidget(e);
107
- g(n.id);
108
+ w(n.id);
108
109
  };
109
110
  v(() => {
110
111
  i.onApiReady?.({
@@ -125,18 +126,18 @@ function Ae(i) {
125
126
  const n = k();
126
127
  return t.widgetActions.addBackgroundLayerAtCursor(e?.worldX ?? n.worldX, e?.worldY ?? n.worldY) ?? null;
127
128
  },
128
- clearSelection: () => b("selection_cleared"),
129
+ clearSelection: () => I("selection_cleared"),
129
130
  focusWidget: (e, n) => {
130
131
  const o = t.navigation.focusWidget(e, n);
131
- return g(o.id), o;
132
+ return w(o.id), o;
132
133
  },
133
134
  fitWidget: (e) => {
134
135
  const n = t.navigation.fitWidget(e);
135
- return g(n.id), n;
136
+ return w(n.id), n;
136
137
  },
137
138
  overviewWidget: (e) => {
138
139
  const n = t.navigation.overviewWidget(e);
139
- return g(n.id), n;
140
+ return w(n.id), n;
140
141
  },
141
142
  findWidgetByType: (e) => t.queries.findWidgetByType(e),
142
143
  findWidgetById: (e) => t.queries.findWidgetById(e),
@@ -163,32 +164,32 @@ function Ae(i) {
163
164
  i.onApiReady?.(null);
164
165
  });
165
166
  });
166
- const I = () => i.lockShortcut === void 0 ? ae : i.lockShortcut;
167
+ const M = () => i.lockShortcut === void 0 ? le : i.lockShortcut;
167
168
  v(() => {
168
169
  if (typeof window > "u" || !t.contextMenu.state()) return;
169
- const e = J({
170
+ const e = te({
170
171
  ownerWindow: window,
171
172
  onDismiss: t.contextMenu.close
172
173
  });
173
174
  y(() => e());
174
175
  }), v(() => {
175
- const e = A();
176
+ const e = C();
176
177
  if (e.kind !== "widget") return;
177
178
  t.widgets().some((o) => o.id === e.widgetId) || l(d().createCanvasInputOwner("widget_removed"));
178
179
  }), v(() => {
179
180
  const e = u();
180
181
  if (!e) return;
181
182
  const n = (r) => {
182
- S(r.target, "pointer", "background_pointer");
183
+ x(r.target, "pointer", "background_pointer");
183
184
  }, o = (r) => {
184
- S(r.target, "focus", "background_focus");
185
+ x(r.target, "focus", "background_focus");
185
186
  };
186
187
  e.addEventListener("pointerdown", n, !0), e.addEventListener("focusin", o), y(() => {
187
188
  e.removeEventListener("pointerdown", n, !0), e.removeEventListener("focusin", o);
188
189
  });
189
190
  }), v(() => {
190
191
  if (i.enableKeyboard === !1 || typeof document > "u") return;
191
- const e = I(), n = (o) => {
192
+ const e = M(), n = (o) => {
192
193
  if (!(o.defaultPrevented || o.isComposing)) {
193
194
  if (e !== null && o.key === e) {
194
195
  o.preventDefault(), t.lock.toggle();
@@ -197,7 +198,7 @@ function Ae(i) {
197
198
  if (!d().shouldBypassGlobalHotkeys({
198
199
  root: u(),
199
200
  target: o.target,
200
- owner: A(),
201
+ owner: C(),
201
202
  interactiveSelector: d().interactiveSelector
202
203
  }))
203
204
  switch (o.key) {
@@ -222,19 +223,19 @@ function Ae(i) {
222
223
  };
223
224
  document.addEventListener("keydown", n, !0), y(() => document.removeEventListener("keydown", n, !0));
224
225
  });
225
- const x = (e, n) => {
226
+ const p = (e, n) => {
226
227
  const o = u()?.querySelector('[data-floe-workbench-canvas-frame="true"]');
227
228
  if (!o) return null;
228
229
  const r = o.getBoundingClientRect();
229
- return $(r, t.viewport(), {
230
+ return j(r, t.viewport(), {
230
231
  clientX: e,
231
232
  clientY: n
232
233
  });
233
- }, E = (e, n, o) => {
234
- const r = x(n, o);
234
+ }, X = (e, n, o) => {
235
+ const r = p(n, o);
235
236
  r && t.widgetActions.addWidgetAtWorldCenter(e, r.worldX, r.worldY);
236
- }, F = (e, n, o) => {
237
- const r = x(n, o);
237
+ }, _ = (e, n, o) => {
238
+ const r = p(n, o);
238
239
  if (r) {
239
240
  if (e === "sticky-note") {
240
241
  t.widgetActions.addStickyNoteAtCursor(r.worldX, r.worldY);
@@ -246,12 +247,29 @@ function Ae(i) {
246
247
  }
247
248
  e === "background-region" && t.widgetActions.addBackgroundLayerAtCursor(r.worldX, r.worldY);
248
249
  }
249
- }, _ = (e) => {
250
- e.button === 0 && b("background_pointer");
251
- };
250
+ }, Y = (e) => {
251
+ e.button === 0 && I("background_pointer");
252
+ }, P = g(() => {
253
+ const e = N();
254
+ if (!e) return null;
255
+ const n = p(e.clientX, e.clientY);
256
+ return n ? e.kind === "widget" ? ie({
257
+ type: e.id,
258
+ widgetDefinitions: t.widgetDefinitions(),
259
+ worldX: n.worldX,
260
+ worldY: n.worldY
261
+ }) : ae({
262
+ tool: e.id,
263
+ label: e.label,
264
+ worldX: n.worldX,
265
+ worldY: n.worldY,
266
+ textDefaults: i.textAnnotationDefaults,
267
+ backgroundDefaults: i.backgroundLayerDefaults
268
+ }) : null;
269
+ });
252
270
  return (() => {
253
- var e = ie(), n = e.firstChild;
254
- return X(T, e), q(e, Y({
271
+ var e = se(), n = e.firstChild;
272
+ return q(T, e), z(e, V({
255
273
  get class() {
256
274
  return `workbench-surface${i.class ? ` ${i.class}` : ""}`;
257
275
  }
@@ -265,7 +283,7 @@ function Ae(i) {
265
283
  return t.mode();
266
284
  },
267
285
  tabIndex: -1
268
- }), !1, !0), w(n, s(U, {
286
+ }), !1, !0), f(n, s(Z, {
269
287
  get widgetDefinitions() {
270
288
  return t.widgetDefinitions();
271
289
  },
@@ -281,6 +299,9 @@ function Ae(i) {
281
299
  get backgroundLayers() {
282
300
  return t.backgroundLayers();
283
301
  },
302
+ get placementPreview() {
303
+ return P();
304
+ },
284
305
  get viewport() {
285
306
  return t.viewport();
286
307
  },
@@ -320,7 +341,7 @@ function Ae(i) {
320
341
  get onCanvasContextMenu() {
321
342
  return t.canvas.openCanvasContextMenu;
322
343
  },
323
- onCanvasPointerDown: _,
344
+ onCanvasPointerDown: Y,
324
345
  get onSelectWidget() {
325
346
  return t.canvas.selectWidget;
326
347
  },
@@ -399,8 +420,8 @@ function Ae(i) {
399
420
  get onDeleteBackgroundLayer() {
400
421
  return t.widgetActions.deleteBackgroundLayer;
401
422
  },
402
- onRequestOverview: O,
403
- onRequestFit: R,
423
+ onRequestOverview: F,
424
+ onRequestFit: E,
404
425
  get onRequestDelete() {
405
426
  return i.onRequestDelete ?? t.widgetActions.deleteWidget;
406
427
  },
@@ -410,7 +431,7 @@ function Ae(i) {
410
431
  get onLayoutInteractionEnd() {
411
432
  return i.onLayoutInteractionEnd;
412
433
  }
413
- })), w(e, s(G, {
434
+ })), f(e, s(ee, {
414
435
  get locked() {
415
436
  return t.locked();
416
437
  },
@@ -418,11 +439,11 @@ function Ae(i) {
418
439
  return t.lock.toggle;
419
440
  },
420
441
  get shortcutLabel() {
421
- return I() ?? void 0;
442
+ return M() ?? void 0;
422
443
  }
423
- }), null), w(e, s(j, {
444
+ }), null), f(e, s(J, {
424
445
  get widgetDefinitions() {
425
- return N();
446
+ return O();
426
447
  },
427
448
  get widgets() {
428
449
  return t.widgets();
@@ -446,9 +467,10 @@ function Ae(i) {
446
467
  return t.canvas.commitViewport;
447
468
  },
448
469
  onViewportInteractionStart: () => t.canvas.cancelViewportNavigation(),
449
- onCreateAt: E,
450
- onCreateToolAt: F
451
- }), null), w(e, s(Z, {
470
+ onCreateAt: X,
471
+ onCreateToolAt: _,
472
+ onDragPreviewChange: R
473
+ }), null), f(e, s(Q, {
452
474
  get scaleLabel() {
453
475
  return t.scaleLabel();
454
476
  },
@@ -462,25 +484,25 @@ function Ae(i) {
462
484
  return t.theme();
463
485
  },
464
486
  onSelectTheme: (o) => t.appearance.setTheme(o)
465
- }), null), w(e, s(H, {
487
+ }), null), f(e, s(K, {
466
488
  get when() {
467
489
  return t.contextMenu.state();
468
490
  },
469
491
  get children() {
470
- return s(z, {
492
+ return s(H, {
471
493
  get children() {
472
494
  return [(() => {
473
- var o = re();
474
- return V(o, "contextmenu", t.contextMenu.retarget, !0), o;
475
- })(), s(K, {
495
+ var o = ue();
496
+ return $(o, "contextmenu", t.contextMenu.retarget, !0), o;
497
+ })(), s(G, {
476
498
  get x() {
477
- return W()?.left ?? 0;
499
+ return b()?.left ?? 0;
478
500
  },
479
501
  get y() {
480
- return W()?.top ?? 0;
502
+ return b()?.top ?? 0;
481
503
  },
482
504
  get items() {
483
- return h();
505
+ return S();
484
506
  }
485
507
  })];
486
508
  }
@@ -489,7 +511,7 @@ function Ae(i) {
489
511
  }), null), e;
490
512
  })();
491
513
  }
492
- P(["contextmenu"]);
514
+ U(["contextmenu"]);
493
515
  export {
494
- Ae as WorkbenchSurface
516
+ xe as WorkbenchSurface
495
517
  };