@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,23 +1,23 @@
1
- import { createSignal as V, createMemo as d, onCleanup as xt } from "solid-js";
2
- import { ArrowUp as St, Copy as Ct, Trash as pt } from "../icons/index.js";
3
- import { getTopZIndex as kt, createContextMenuPosition as Ft, createWorkbenchId as bt, createWorkbenchViewportCenteredOnWidget as L, findNearestWidget as It, clampScale as Mt, WORKBENCH_CANVAS_ZOOM_STEP as $, WORKBENCH_MIN_SCALE as Xt, createWorkbenchViewportFitForWidget as yt, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Yt, estimateContextMenuHeight as vt } from "./workbenchHelpers.js";
4
- import { resolveWorkbenchWidgetDefinitions as Ot, getWidgetEntry as j, createWorkbenchFilterState as zt } from "./widgets/widgetRegistry.js";
5
- function qt(c) {
6
- const [W, x] = V(null), [U, D] = V(null), [H, G] = V({ width: 0, height: 0 });
1
+ import { createSignal as N, createMemo as d, onCleanup as St } from "solid-js";
2
+ import { ArrowUp as Ct, Copy as pt, Trash as kt } from "../icons/index.js";
3
+ import { getTopZIndex as Ft, createContextMenuPosition as bt, createWorkbenchId as It, createWorkbenchViewportCenteredOnWidget as L, findNearestWidget as Mt, clampScale as Xt, WORKBENCH_CANVAS_ZOOM_STEP as $, WORKBENCH_MIN_SCALE as vt, createWorkbenchViewportFitForWidget as yt, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Yt, estimateContextMenuHeight as Ot } from "./workbenchHelpers.js";
4
+ import { resolveWorkbenchWidgetDefinitions as zt, getWidgetEntry as j, createWorkbenchFilterState as _t } from "./widgets/widgetRegistry.js";
5
+ function Pt(c) {
6
+ const [W, x] = N(null), [U, D] = N(null), [H, G] = N({ width: 0, height: 0 });
7
7
  let r = null, S = null;
8
- const l = c.state, w = d(() => l().widgets), u = d(() => l().viewport), J = d(() => l().locked), N = d(() => l().filters), F = d(() => l().selectedWidgetId), b = d(() => kt(w())), Q = d(() => `${Math.round(u().scale * 100)}%`), tt = () => typeof c.widgetDefinitions == "function" ? c.widgetDefinitions() : c.widgetDefinitions, m = d(
9
- () => Ot(tt())
8
+ const l = c.state, w = d(() => l().widgets), u = d(() => l().viewport), J = d(() => l().locked), R = d(() => l().filters), F = d(() => l().selectedWidgetId), b = d(() => Ft(w())), Q = d(() => `${Math.round(u().scale * 100)}%`), tt = () => typeof c.widgetDefinitions == "function" ? c.widgetDefinitions() : c.widgetDefinitions, m = d(
9
+ () => zt(tt())
10
10
  ), I = (t, e) => {
11
11
  const n = Number.isFinite(t) && t > 0 ? t : 0, i = Number.isFinite(e) && e > 0 ? e : 0, o = { width: n, height: i }, s = H();
12
12
  return s.width === n && s.height === i ? s : (G(o), o);
13
- }, R = () => {
13
+ }, T = () => {
14
14
  S?.disconnect(), S = null;
15
15
  }, a = () => r ? I(r.clientWidth, r.clientHeight) : I(0, 0), et = (t) => {
16
16
  if (r === (t ?? null)) {
17
17
  a();
18
18
  return;
19
19
  }
20
- R(), r = t ?? null, a(), !(!r || typeof ResizeObserver > "u") && (S = new ResizeObserver((e) => {
20
+ T(), r = t ?? null, a(), !(!r || typeof ResizeObserver > "u") && (S = new ResizeObserver((e) => {
21
21
  const n = e[0];
22
22
  I(
23
23
  n?.contentRect.width ?? r?.clientWidth ?? 0,
@@ -25,8 +25,8 @@ function qt(c) {
25
25
  );
26
26
  }), S.observe(r));
27
27
  };
28
- xt(() => {
29
- R(), r = null;
28
+ St(() => {
29
+ T(), r = null;
30
30
  });
31
31
  const nt = (t) => {
32
32
  x({
@@ -43,7 +43,7 @@ function qt(c) {
43
43
  worldY: e.y,
44
44
  widgetId: e.id
45
45
  });
46
- }, h = () => x(null), ot = (t) => l().widgets.find((e) => e.id === t) ?? null, M = (t) => l().widgets.find((e) => e.type === t) ?? null, T = d(() => {
46
+ }, h = () => x(null), ot = (t) => l().widgets.find((e) => e.id === t) ?? null, M = (t) => l().widgets.find((e) => e.type === t) ?? null, E = d(() => {
47
47
  const t = W();
48
48
  if (!t) return [];
49
49
  if (t.widgetId) {
@@ -52,7 +52,7 @@ function qt(c) {
52
52
  id: "bring-to-front",
53
53
  kind: "action",
54
54
  label: "Bring to Front",
55
- icon: St,
55
+ icon: Ct,
56
56
  onSelect: () => {
57
57
  f(e.id), h();
58
58
  }
@@ -60,18 +60,18 @@ function qt(c) {
60
60
  id: "duplicate",
61
61
  kind: "action",
62
62
  label: "Duplicate",
63
- icon: Ct,
63
+ icon: pt,
64
64
  onSelect: () => {
65
- E(e.type, e.x + 32, e.y + 32), h();
65
+ B(e.type, e.x + 32, e.y + 32), h();
66
66
  }
67
67
  })), n.push({ id: "separator-delete", kind: "separator" }), n.push({
68
68
  id: "delete",
69
69
  kind: "action",
70
70
  label: "Delete",
71
- icon: pt,
71
+ icon: kt,
72
72
  destructive: !0,
73
73
  onSelect: () => {
74
- t.widgetId && Y(t.widgetId), h();
74
+ t.widgetId && y(t.widgetId), h();
75
75
  }
76
76
  }), n;
77
77
  }
@@ -81,25 +81,25 @@ function qt(c) {
81
81
  label: `Add ${e.label}`,
82
82
  icon: e.icon,
83
83
  onSelect: () => {
84
- y(e.type, t.worldX, t.worldY), h();
84
+ v(e.type, t.worldX, t.worldY), h();
85
85
  }
86
86
  }));
87
87
  }), ct = d(() => {
88
88
  const t = W();
89
89
  if (!t) return;
90
- const e = T(), n = e.filter((o) => o.kind === "action").length, i = e.filter((o) => o.kind === "separator").length;
91
- return Ft({
90
+ const e = E(), n = e.filter((o) => o.kind === "action").length, i = e.filter((o) => o.kind === "separator").length;
91
+ return bt({
92
92
  clientX: t.clientX,
93
93
  clientY: t.clientY,
94
94
  menuWidth: Yt,
95
- menuHeight: vt(n, i)
95
+ menuHeight: Ot(n, i)
96
96
  });
97
97
  }), X = (t, e, n) => {
98
98
  const i = j(t, m()), o = i.singleton ? M(t) : null;
99
99
  if (o)
100
100
  return p(o, { centerViewport: !0 });
101
101
  const s = i.defaultSize, g = {
102
- id: bt(),
102
+ id: It(),
103
103
  type: t,
104
104
  title: i.defaultTitle,
105
105
  x: e,
@@ -114,10 +114,10 @@ function qt(c) {
114
114
  widgets: [...k.widgets, g],
115
115
  selectedWidgetId: g.id
116
116
  })), g;
117
- }, y = (t, e, n) => {
117
+ }, v = (t, e, n) => {
118
118
  const i = j(t, m()).defaultSize;
119
119
  return X(t, e - i.width / 2, n - i.height / 2);
120
- }, E = (t, e, n) => X(t, e, n), Y = (t) => {
120
+ }, B = (t, e, n) => X(t, e, n), y = (t) => {
121
121
  c.setState((e) => ({
122
122
  ...e,
123
123
  widgets: e.widgets.filter((n) => n.id !== t),
@@ -148,17 +148,17 @@ function qt(c) {
148
148
  (i) => i.id === t ? { ...i, width: e.width, height: e.height } : i
149
149
  )
150
150
  }));
151
- }, v = (t) => {
151
+ }, Y = (t) => {
152
152
  c.setState((e) => ({ ...e, viewport: t }));
153
- }, B = (t) => {
154
- const e = u(), n = a(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, s = Mt(
153
+ }, q = (t) => {
154
+ const e = u(), n = a(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, s = Xt(
155
155
  t === "in" ? e.scale * $ : e.scale / $
156
156
  ), g = {
157
157
  x: n.width / 2 - i * s,
158
158
  y: n.height / 2 - o * s,
159
159
  scale: s
160
160
  };
161
- v(g);
161
+ Y(g);
162
162
  }, lt = () => {
163
163
  c.setState((t) => ({ ...t, locked: !t.locked }));
164
164
  }, at = (t) => {
@@ -174,14 +174,14 @@ function qt(c) {
174
174
  return { ...e, filters: n };
175
175
  });
176
176
  }, ut = () => {
177
- const t = zt(m());
177
+ const t = _t(m());
178
178
  c.setState((e) => ({
179
179
  ...e,
180
180
  filters: t
181
181
  }));
182
182
  }, C = (t) => {
183
183
  c.setState((e) => ({ ...e, selectedWidgetId: t }));
184
- }, q = () => {
184
+ }, P = () => {
185
185
  c.setState(
186
186
  (t) => t.selectedWidgetId === null ? t : { ...t, selectedWidgetId: null }
187
187
  );
@@ -192,48 +192,50 @@ function qt(c) {
192
192
  worldY: t.height > 0 ? (t.height / 2 - e.y) / e.scale : 180
193
193
  };
194
194
  };
195
- let P = 0;
196
- const O = (t) => {
197
- const e = u(), n = e.x, i = e.y, o = e.scale, s = performance.now(), g = 360, k = ++P, mt = (_) => 1 - Math.pow(1 - _, 3), Z = (_) => {
198
- if (k !== P) return;
199
- const Wt = _ - s, K = Math.min(Math.max(Wt / g, 0), 1), A = mt(K);
200
- v({
195
+ let O = 0;
196
+ const ft = () => {
197
+ O += 1;
198
+ }, z = (t) => {
199
+ const e = u(), n = e.x, i = e.y, o = e.scale, s = performance.now(), g = 360, k = ++O, Wt = (V) => 1 - Math.pow(1 - V, 3), Z = (V) => {
200
+ if (k !== O) return;
201
+ const xt = V - s, K = Math.min(Math.max(xt / g, 0), 1), A = Wt(K);
202
+ Y({
201
203
  x: n + (t.x - n) * A,
202
204
  y: i + (t.y - i) * A,
203
205
  scale: o + (t.scale - o) * A
204
206
  }), K < 1 && requestAnimationFrame(Z);
205
207
  };
206
208
  requestAnimationFrame(Z);
207
- }, z = (t) => {
209
+ }, _ = (t) => {
208
210
  const e = a();
209
- e.width === 0 || e.height === 0 || O(L({
211
+ e.width === 0 || e.height === 0 || z(L({
210
212
  widget: t,
211
213
  scale: u().scale,
212
214
  frameWidth: e.width,
213
215
  frameHeight: e.height
214
216
  }));
215
- }, ft = (t) => {
217
+ }, wt = (t) => {
216
218
  const e = a();
217
- e.width === 0 || e.height === 0 || O(yt({
219
+ e.width === 0 || e.height === 0 || z(yt({
218
220
  widget: t,
219
221
  frameWidth: e.width,
220
222
  frameHeight: e.height
221
223
  }));
222
- }, wt = (t) => {
224
+ }, mt = (t) => {
223
225
  const e = a();
224
- e.width === 0 || e.height === 0 || O(L({
226
+ e.width === 0 || e.height === 0 || z(L({
225
227
  widget: t,
226
- scale: Xt,
228
+ scale: vt,
227
229
  frameWidth: e.width,
228
230
  frameHeight: e.height
229
231
  }));
230
- }, p = (t, e = {}) => (C(t.id), f(t.id), e.centerViewport !== !1 && z(t), t);
232
+ }, p = (t, e = {}) => (C(t.id), f(t.id), e.centerViewport !== !1 && _(t), t);
231
233
  return {
232
234
  widgets: w,
233
235
  viewport: u,
234
236
  canvasFrameSize: H,
235
237
  locked: J,
236
- filters: N,
238
+ filters: R,
237
239
  selectedWidgetId: F,
238
240
  topZIndex: b,
239
241
  scaleLabel: Q,
@@ -242,7 +244,7 @@ function qt(c) {
242
244
  setCanvasFrameRef: et,
243
245
  contextMenu: {
244
246
  state: W,
245
- items: T,
247
+ items: E,
246
248
  position: ct,
247
249
  close: h,
248
250
  retarget: (t) => {
@@ -258,16 +260,17 @@ function qt(c) {
258
260
  openCanvasContextMenu: nt,
259
261
  openWidgetContextMenu: it,
260
262
  selectWidget: C,
261
- clearSelection: q,
263
+ clearSelection: P,
262
264
  startOptimisticFront: st,
263
265
  commitFront: f,
264
266
  commitMove: rt,
265
267
  commitResize: dt,
266
- commitViewport: v
268
+ commitViewport: Y,
269
+ cancelViewportNavigation: ft
267
270
  },
268
271
  hud: {
269
- zoomIn: () => B("in"),
270
- zoomOut: () => B("out")
272
+ zoomIn: () => q("in"),
273
+ zoomOut: () => q("out")
271
274
  },
272
275
  lock: {
273
276
  toggle: lt
@@ -279,41 +282,41 @@ function qt(c) {
279
282
  },
280
283
  navigation: {
281
284
  handleArrowNavigation: (t) => {
282
- const e = It(
285
+ const e = Mt(
283
286
  w(),
284
287
  F(),
285
288
  t,
286
- N()
289
+ R()
287
290
  );
288
291
  e && p(e);
289
292
  },
290
- centerOnWidget: z,
293
+ centerOnWidget: _,
291
294
  focusWidget: p,
292
- fitWidget: (t) => (C(t.id), f(t.id), ft(t), t),
293
- overviewWidget: (t) => (C(t.id), f(t.id), wt(t), t)
295
+ fitWidget: (t) => (C(t.id), f(t.id), wt(t), t),
296
+ overviewWidget: (t) => (C(t.id), f(t.id), mt(t), t)
294
297
  },
295
298
  selection: {
296
- clear: q
299
+ clear: P
297
300
  },
298
301
  widgetActions: {
299
302
  deleteSelected: () => {
300
303
  const t = F();
301
- t && Y(t);
304
+ t && y(t);
302
305
  },
303
- deleteWidget: Y,
306
+ deleteWidget: y,
304
307
  addWidget: X,
305
- addWidgetAtCursor: y,
306
- addWidgetCentered: E,
308
+ addWidgetAtCursor: v,
309
+ addWidgetCentered: B,
307
310
  ensureWidget: (t, e) => {
308
311
  const n = M(t);
309
312
  if (n)
310
313
  return p(n, { centerViewport: e?.centerViewport ?? !0 });
311
- const i = ht(), o = y(
314
+ const i = ht(), o = v(
312
315
  t,
313
316
  e?.worldX ?? i.worldX,
314
317
  e?.worldY ?? i.worldY
315
318
  );
316
- return (e?.centerViewport ?? !0) && o && z(o), o;
319
+ return (e?.centerViewport ?? !0) && o && _(o), o;
317
320
  }
318
321
  },
319
322
  queries: {
@@ -330,5 +333,5 @@ function qt(c) {
330
333
  };
331
334
  }
332
335
  export {
333
- qt as useWorkbenchModel
336
+ Pt as useWorkbenchModel
334
337
  };