@floegence/floe-webapp-core 0.36.18 → 0.36.19

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,51 +1,62 @@
1
- import { spread as L, mergeProps as at, insert as l, createComponent as c, memo as rt, template as q, use as dt, delegateEvents as lt } from "solid-js/web";
2
- import { createSignal as C, onCleanup as ct, untrack as S, createMemo as f } from "solid-js";
3
- import { startHotInteraction as A } from "../../utils/hotInteraction.js";
4
- import { X as O, Minus as F, Maximize as N, GripVertical as st } from "../icons/index.js";
5
- import { CANVAS_WHEEL_INTERACTIVE_ATTR as wt, WORKBENCH_WIDGET_SHELL_ATTR as gt, shouldActivateWorkbenchWidgetLocalTarget as ht, resolveWorkbenchWidgetEventOwnership as ut } from "../ui/localInteractionSurface.js";
6
- import { startPointerSession as j } from "../ui/pointerSession.js";
7
- import { createWorkbenchWidgetSurfaceMetrics as ft } from "./workbenchHelpers.js";
8
- var _t = /* @__PURE__ */ q('<article class=workbench-widget data-floe-dialog-surface-host=true><header class=workbench-widget__header><span class=workbench-widget__traffic role=group aria-label="Window controls"><button type=button class="workbench-widget__traffic-dot workbench-widget__traffic-dot--close"aria-label="Close widget"title="Close widget"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__traffic-dot workbench-widget__traffic-dot--min"aria-label="Minimize widget to overview"title="Minimize widget to overview"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__traffic-dot workbench-widget__traffic-dot--max"aria-label="Zoom widget to fit viewport"title="Zoom widget to fit viewport"data-floe-canvas-interactive=true></button></span><span class=workbench-widget__badge aria-hidden=true></span><button type=button class=workbench-widget__drag aria-label="Drag widget"data-floe-canvas-interactive=true></button><div class=workbench-widget__title-area><span class=workbench-widget__title-dot aria-hidden=true></span><span class=workbench-widget__title></span></div><span class=workbench-widget__window-controls role=group aria-label="Window controls"><button type=button class="workbench-widget__window-control workbench-widget__window-control--min"aria-label="Minimize widget to overview"title="Minimize widget to overview"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__window-control workbench-widget__window-control--max"aria-label="Zoom widget to fit viewport"title="Zoom widget to fit viewport"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__window-control workbench-widget__window-control--close"aria-label="Remove widget"title="Remove widget"data-floe-canvas-interactive=true></button></span></header><div class=workbench-widget__body data-floe-canvas-interactive=true>'), bt = /* @__PURE__ */ q('<div class=workbench-widget__resize aria-label="Resize widget"data-floe-canvas-interactive=true><svg class=workbench-widget__resize-glyph viewBox="0 0 12 12"aria-hidden=true><path d="M12 0 L0 12"></path><path d="M12 4 L4 12"></path><path d="M12 8 L8 12">');
9
- const mt = 220, vt = 160, B = '[data-floe-canvas-interactive="true"]', V = '[data-floe-canvas-pan-surface="true"]';
10
- function Ct(t) {
11
- const [_, I] = C(null), [b, x] = C(null), [G, Z] = C();
12
- let h, u, g;
13
- ct(() => {
14
- h?.stop({
1
+ import { spread as F, mergeProps as nt, insert as l, createComponent as c, memo as at, template as B, use as rt, delegateEvents as dt } from "solid-js/web";
2
+ import { createMemo as u, createSignal as W, onCleanup as lt, untrack as f } from "solid-js";
3
+ import { startHotInteraction as ct } from "../../utils/hotInteraction.js";
4
+ import { X as j, Minus as O, Maximize as N, GripVertical as st } from "../icons/index.js";
5
+ import { CANVAS_WHEEL_INTERACTIVE_ATTR as wt, WORKBENCH_WIDGET_SHELL_ATTR as gt, shouldActivateWorkbenchWidgetLocalTarget as ht } from "../ui/localInteractionSurface.js";
6
+ import { startPointerSession as q } from "../ui/pointerSession.js";
7
+ import { createWorkbenchWidgetSurfaceMetrics as ut } from "./workbenchHelpers.js";
8
+ import { resolveWorkbenchInteractionAdapter as ft } from "./workbenchInteractionAdapter.js";
9
+ var _t = /* @__PURE__ */ B('<article class=workbench-widget><header class=workbench-widget__header><span class=workbench-widget__traffic role=group aria-label="Window controls"><button type=button class="workbench-widget__traffic-dot workbench-widget__traffic-dot--close"aria-label="Close widget"title="Close widget"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__traffic-dot workbench-widget__traffic-dot--min"aria-label="Minimize widget to overview"title="Minimize widget to overview"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__traffic-dot workbench-widget__traffic-dot--max"aria-label="Zoom widget to fit viewport"title="Zoom widget to fit viewport"data-floe-canvas-interactive=true></button></span><span class=workbench-widget__badge aria-hidden=true></span><button type=button class=workbench-widget__drag aria-label="Drag widget"data-floe-canvas-interactive=true></button><div class=workbench-widget__title-area><span class=workbench-widget__title-dot aria-hidden=true></span><span class=workbench-widget__title></span></div><span class=workbench-widget__window-controls role=group aria-label="Window controls"><button type=button class="workbench-widget__window-control workbench-widget__window-control--min"aria-label="Minimize widget to overview"title="Minimize widget to overview"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__window-control workbench-widget__window-control--max"aria-label="Zoom widget to fit viewport"title="Zoom widget to fit viewport"data-floe-canvas-interactive=true></button><button type=button class="workbench-widget__window-control workbench-widget__window-control--close"aria-label="Remove widget"title="Remove widget"data-floe-canvas-interactive=true></button></span></header><div class=workbench-widget__body data-floe-canvas-interactive=true>'), bt = /* @__PURE__ */ B('<div class=workbench-widget__resize aria-label="Resize widget"data-floe-canvas-interactive=true><svg class=workbench-widget__resize-glyph viewBox="0 0 12 12"aria-hidden=true><path d="M12 0 L0 12"></path><path d="M12 4 L4 12"></path><path d="M12 8 L8 12">');
10
+ const mt = 220, vt = 160;
11
+ function Wt(t) {
12
+ const s = u(() => ft(t.interactionAdapter)), [m, y] = W(null), [v, x] = W(null), [V, Z] = W();
13
+ let _, b, h;
14
+ const p = (e, i) => {
15
+ const r = ct({
16
+ kind: e,
17
+ cursor: i
18
+ });
19
+ let d = !1;
20
+ return f(() => t.onLayoutInteractionStart?.()), () => {
21
+ d || (d = !0, r(), f(() => t.onLayoutInteractionEnd?.()));
22
+ };
23
+ };
24
+ lt(() => {
25
+ _?.stop({
15
26
  reason: "manual_stop",
16
27
  commit: !1
17
- }), h = void 0, u?.stop({
28
+ }), _ = void 0, b?.stop({
18
29
  reason: "manual_stop",
19
30
  commit: !1
20
- }), u = void 0, S(_)?.stopInteraction(), S(b)?.stopInteraction();
31
+ }), b = void 0, f(m)?.stopInteraction(), f(v)?.stopInteraction();
21
32
  });
22
- const W = () => _() !== null, R = () => b() !== null, p = (e) => ut({
33
+ const z = () => m() !== null, R = () => v() !== null, T = (e) => s().resolveWidgetEventOwnership({
23
34
  target: e,
24
- widgetRoot: g ?? null,
25
- interactiveSelector: B,
26
- panSurfaceSelector: V
27
- }), K = (e) => {
35
+ widgetRoot: h ?? null,
36
+ interactiveSelector: s().interactiveSelector,
37
+ panSurfaceSelector: s().panSurfaceSelector
38
+ }), G = (e) => {
28
39
  if (e.button !== 0) return;
29
40
  t.onSelect(t.widgetId), t.onCommitFront(t.widgetId);
30
- const i = p(e.target);
41
+ const i = T(e.target);
31
42
  if (i === "widget_shell") {
32
- g?.focus({
43
+ h?.focus({
33
44
  preventScroll: !0
34
45
  });
35
46
  return;
36
47
  }
37
48
  i === "widget_local" && ht({
38
49
  target: e.target,
39
- widgetRoot: g ?? null,
40
- interactiveSelector: B,
41
- panSurfaceSelector: V
50
+ widgetRoot: h ?? null,
51
+ interactiveSelector: s().interactiveSelector,
52
+ panSurfaceSelector: s().panSurfaceSelector
42
53
  }) && Z((r) => ({
43
54
  seq: (r?.seq ?? 0) + 1,
44
55
  source: "local_pointer",
45
56
  pointerType: e.pointerType || void 0
46
57
  }));
47
- }, m = f(() => {
48
- const e = _();
58
+ }, $ = u(() => {
59
+ const e = m();
49
60
  return e ? {
50
61
  x: e.worldX,
51
62
  y: e.worldY
@@ -53,8 +64,8 @@ function Ct(t) {
53
64
  x: t.x,
54
65
  y: t.y
55
66
  };
56
- }), v = f(() => {
57
- const e = b();
67
+ }), S = u(() => {
68
+ const e = v();
58
69
  return e ? {
59
70
  width: e.width,
60
71
  height: e.height
@@ -62,34 +73,34 @@ function Ct(t) {
62
73
  width: t.width,
63
74
  height: t.height
64
75
  };
65
- }), E = f(() => {
76
+ }), X = u(() => {
66
77
  if (!(t.layoutMode !== "projected_surface" || !t.projectedViewport))
67
- return ft({
78
+ return ut({
68
79
  widgetId: t.widgetId,
69
- worldX: m().x,
70
- worldY: m().y,
71
- worldWidth: v().width,
72
- worldHeight: v().height,
80
+ worldX: $().x,
81
+ worldY: $().y,
82
+ worldWidth: S().width,
83
+ worldHeight: S().height,
73
84
  viewport: t.projectedViewport,
74
85
  ready: t.surfaceReady ?? !0
75
86
  });
76
- }), U = f(() => {
87
+ }), K = u(() => {
77
88
  const e = t.itemSnapshot().z_index, i = Number.isFinite(e) ? Math.max(1, Math.min(99, Math.round(e))) : 1;
78
89
  return String(i).padStart(2, "0");
79
- }), T = (e) => {
90
+ }), Y = (e) => {
80
91
  e.preventDefault(), e.stopPropagation(), t.onRequestOverview(t.itemSnapshot());
81
- }, z = (e) => {
82
- e.preventDefault(), e.stopPropagation(), t.onRequestFit(t.itemSnapshot());
83
92
  }, D = (e) => {
93
+ e.preventDefault(), e.stopPropagation(), t.onRequestFit(t.itemSnapshot());
94
+ }, P = (e) => {
84
95
  e.preventDefault(), e.stopPropagation(), t.onRequestDelete(t.widgetId);
85
- }, J = f(() => {
96
+ }, J = u(() => {
86
97
  const e = {
87
- width: `${v().width}px`,
88
- height: `${v().height}px`,
89
- "z-index": W() || R() || t.optimisticFront ? `${t.topRenderLayer + 1}` : `${t.renderLayer}`
98
+ width: `${S().width}px`,
99
+ height: `${S().height}px`,
100
+ "z-index": z() || R() || t.optimisticFront ? `${t.topRenderLayer + 1}` : `${t.renderLayer}`
90
101
  };
91
102
  if (t.layoutMode === "projected_surface") {
92
- const i = E()?.rect;
103
+ const i = X()?.rect;
93
104
  return {
94
105
  ...e,
95
106
  left: `${i?.screenX ?? 0}px`,
@@ -99,10 +110,10 @@ function Ct(t) {
99
110
  }
100
111
  return {
101
112
  ...e,
102
- transform: `translate(${m().x}px, ${m().y}px)`
113
+ transform: `translate(${$().x}px, ${$().y}px)`
103
114
  };
104
115
  }), Q = (e) => {
105
- const i = S(_);
116
+ const i = f(m);
106
117
  if (!i) return;
107
118
  const r = {
108
119
  x: i.worldX,
@@ -111,20 +122,17 @@ function Ct(t) {
111
122
  x: i.startWorldX,
112
123
  y: i.startWorldY
113
124
  }, a = e && (Math.abs(r.x - d.x) > 1 || Math.abs(r.y - d.y) > 1);
114
- t.onCommitFront(t.widgetId), a && t.onCommitMove(t.widgetId, r), i.stopInteraction(), I(null), h = void 0;
115
- }, X = (e) => {
125
+ t.onCommitFront(t.widgetId), a && t.onCommitMove(t.widgetId, r), i.stopInteraction(), y(null), _ = void 0;
126
+ }, E = (e) => {
116
127
  if (e.button !== 0 || t.locked) return;
117
- e.preventDefault(), e.stopPropagation(), h?.stop({
128
+ e.preventDefault(), e.stopPropagation(), _?.stop({
118
129
  reason: "manual_stop",
119
130
  commit: !1
120
- }), t.onSelect(t.widgetId), g?.focus({
131
+ }), t.onSelect(t.widgetId), h?.focus({
121
132
  preventScroll: !0
122
133
  }), t.onStartOptimisticFront(t.widgetId);
123
- const i = A({
124
- kind: "drag",
125
- cursor: "grabbing"
126
- }), r = Math.max(t.viewportScale, 1e-3);
127
- I({
134
+ const i = p("drag", "grabbing"), r = Math.max(t.viewportScale, 1e-3);
135
+ y({
128
136
  pointerId: e.pointerId,
129
137
  startClientX: e.clientX,
130
138
  startClientY: e.clientY,
@@ -137,18 +145,18 @@ function Ct(t) {
137
145
  stopInteraction: i
138
146
  });
139
147
  const d = (a) => {
140
- I((o) => {
148
+ y((o) => {
141
149
  if (!o || o.pointerId !== a.pointerId) return o;
142
- const w = o.startWorldX + (a.clientX - o.startClientX) / o.scale, s = o.startWorldY + (a.clientY - o.startClientY) / o.scale;
150
+ const g = o.startWorldX + (a.clientX - o.startClientX) / o.scale, w = o.startWorldY + (a.clientY - o.startClientY) / o.scale;
143
151
  return {
144
152
  ...o,
145
- worldX: w,
146
- worldY: s,
147
- moved: o.moved || Math.abs(w - o.startWorldX) > 2 || Math.abs(s - o.startWorldY) > 2
153
+ worldX: g,
154
+ worldY: w,
155
+ moved: o.moved || Math.abs(g - o.startWorldX) > 2 || Math.abs(w - o.startWorldY) > 2
148
156
  };
149
157
  });
150
158
  };
151
- h = j({
159
+ _ = q({
152
160
  pointerEvent: e,
153
161
  captureEl: e.currentTarget,
154
162
  onMove: d,
@@ -156,24 +164,21 @@ function Ct(t) {
156
164
  commit: a
157
165
  }) => Q(a)
158
166
  });
159
- }, tt = (e) => {
160
- const i = S(b);
167
+ }, U = (e) => {
168
+ const i = f(v);
161
169
  if (!i) return;
162
170
  const r = {
163
171
  width: i.width,
164
172
  height: i.height
165
173
  }, d = Math.abs(i.width - i.startWidth) > 1 || Math.abs(i.height - i.startHeight) > 1;
166
- e && d && t.onCommitResize(t.widgetId, r), i.stopInteraction(), x(null), u = void 0;
167
- }, et = (e) => {
174
+ e && d && t.onCommitResize(t.widgetId, r), i.stopInteraction(), x(null), b = void 0;
175
+ }, tt = (e) => {
168
176
  if (e.button !== 0 || t.locked) return;
169
- e.preventDefault(), e.stopPropagation(), u?.stop({
177
+ e.preventDefault(), e.stopPropagation(), b?.stop({
170
178
  reason: "manual_stop",
171
179
  commit: !1
172
180
  }), t.onStartOptimisticFront(t.widgetId);
173
- const i = A({
174
- kind: "drag",
175
- cursor: "nwse-resize"
176
- }), r = Math.max(t.viewportScale, 1e-3);
181
+ const i = p("resize", "nwse-resize"), r = Math.max(t.viewportScale, 1e-3);
177
182
  x({
178
183
  pointerId: e.pointerId,
179
184
  startClientX: e.clientX,
@@ -188,39 +193,47 @@ function Ct(t) {
188
193
  const d = (a) => {
189
194
  x((o) => {
190
195
  if (!o || o.pointerId !== a.pointerId) return o;
191
- const w = Math.max(mt, o.startWidth + (a.clientX - o.startClientX) / o.scale), s = Math.max(vt, o.startHeight + (a.clientY - o.startClientY) / o.scale);
196
+ const g = Math.max(mt, o.startWidth + (a.clientX - o.startClientX) / o.scale), w = Math.max(vt, o.startHeight + (a.clientY - o.startClientY) / o.scale);
192
197
  return {
193
198
  ...o,
194
- width: w,
195
- height: s
199
+ width: g,
200
+ height: w
196
201
  };
197
202
  });
198
203
  };
199
- u = j({
204
+ b = q({
200
205
  pointerEvent: e,
201
206
  captureEl: e.currentTarget,
202
207
  onMove: d,
203
208
  onEnd: ({
204
209
  commit: a
205
- }) => tt(a)
210
+ }) => U(a)
206
211
  });
207
212
  };
208
213
  return (() => {
209
- var e = _t(), i = e.firstChild, r = i.firstChild, d = r.firstChild, a = d.nextSibling, o = a.nextSibling, w = r.nextSibling, s = w.nextSibling, y = s.nextSibling, it = y.firstChild, P = it.nextSibling, ot = y.nextSibling, $ = ot.firstChild, k = $.nextSibling, M = k.nextSibling, nt = i.nextSibling, Y = g;
210
- return typeof Y == "function" ? dt(Y, e) : g = e, L(e, at({
214
+ var e = _t(), i = e.firstChild, r = i.firstChild, d = r.firstChild, a = d.nextSibling, o = a.nextSibling, g = r.nextSibling, w = g.nextSibling, M = w.nextSibling, et = M.firstChild, A = et.nextSibling, it = M.nextSibling, k = it.firstChild, I = k.nextSibling, C = I.nextSibling, ot = i.nextSibling, L = h;
215
+ return typeof L == "function" ? rt(L, e) : h = e, F(e, nt({
211
216
  get classList() {
212
217
  return {
213
218
  "is-selected": t.selected,
214
- "is-dragging": W(),
219
+ "is-dragging": z(),
215
220
  "is-resizing": R(),
216
221
  "is-filtered-out": t.filtered,
217
222
  "is-projected-surface": t.layoutMode === "projected_surface",
218
223
  "is-locked": t.locked
219
224
  };
220
- },
225
+ }
226
+ }, () => ({
227
+ [s().dialogSurfaceHostAttr]: "true"
228
+ }), {
221
229
  get "data-floe-workbench-widget-id"() {
222
230
  return t.widgetId;
223
- },
231
+ }
232
+ }, () => ({
233
+ [s().widgetRootAttr]: "true"
234
+ }), () => ({
235
+ [s().widgetIdAttr]: t.widgetId
236
+ }), {
224
237
  get "data-workbench-widget-type"() {
225
238
  return t.widgetType;
226
239
  },
@@ -231,44 +244,44 @@ function Ct(t) {
231
244
  [wt]: t.selected ? "true" : void 0
232
245
  }), {
233
246
  tabIndex: 0,
234
- onPointerDown: K,
247
+ onPointerDown: G,
235
248
  onFocus: () => {
236
249
  t.onSelect(t.widgetId);
237
250
  },
238
251
  onContextMenu: (n) => {
239
- p(n.target) === "widget_shell" && (n.preventDefault(), n.stopPropagation(), t.onContextMenu(n, t.itemSnapshot()));
252
+ T(n.target) === "widget_shell" && (n.preventDefault(), n.stopPropagation(), t.onContextMenu(n, t.itemSnapshot()));
240
253
  },
241
254
  get style() {
242
255
  return J();
243
256
  }
244
- }), !1, !0), i.$$pointerdown = X, L(i, {
257
+ }), !1, !0), i.$$pointerdown = E, F(i, {
245
258
  [gt]: "true"
246
- }, !1, !0), d.$$click = D, d.$$pointerdown = (n) => n.stopPropagation(), l(d, c(O, {
259
+ }, !1, !0), d.$$click = P, d.$$pointerdown = (n) => n.stopPropagation(), l(d, c(j, {
247
260
  class: "workbench-widget__traffic-icon",
248
261
  "aria-hidden": "true"
249
- })), a.$$click = T, a.$$pointerdown = (n) => n.stopPropagation(), l(a, c(F, {
262
+ })), a.$$click = Y, a.$$pointerdown = (n) => n.stopPropagation(), l(a, c(O, {
250
263
  class: "workbench-widget__traffic-icon",
251
264
  "aria-hidden": "true"
252
- })), o.$$click = z, o.$$pointerdown = (n) => n.stopPropagation(), l(o, c(N, {
265
+ })), o.$$click = D, o.$$pointerdown = (n) => n.stopPropagation(), l(o, c(N, {
253
266
  class: "workbench-widget__traffic-icon",
254
267
  "aria-hidden": "true"
255
- })), l(w, U), s.$$pointerdown = X, l(s, c(st, {
268
+ })), l(g, K), w.$$pointerdown = E, l(w, c(st, {
256
269
  class: "w-3.5 h-3.5"
257
- })), l(y, () => {
270
+ })), l(M, () => {
258
271
  const n = t.definition.icon;
259
272
  return c(n, {
260
273
  class: "w-3.5 h-3.5"
261
274
  });
262
- }, P), l(P, () => t.widgetTitle), $.$$click = T, $.$$pointerdown = (n) => n.stopPropagation(), l($, c(F, {
275
+ }, A), l(A, () => t.widgetTitle), k.$$click = Y, k.$$pointerdown = (n) => n.stopPropagation(), l(k, c(O, {
263
276
  class: "workbench-widget__window-control-icon",
264
277
  "aria-hidden": "true"
265
- })), k.$$click = z, k.$$pointerdown = (n) => n.stopPropagation(), l(k, c(N, {
278
+ })), I.$$click = D, I.$$pointerdown = (n) => n.stopPropagation(), l(I, c(N, {
266
279
  class: "workbench-widget__window-control-icon",
267
280
  "aria-hidden": "true"
268
- })), M.$$click = D, M.$$pointerdown = (n) => n.stopPropagation(), l(M, c(O, {
281
+ })), C.$$click = P, C.$$pointerdown = (n) => n.stopPropagation(), l(C, c(j, {
269
282
  class: "workbench-widget__window-control-icon",
270
283
  "aria-hidden": "true"
271
- })), l(nt, () => {
284
+ })), l(ot, () => {
272
285
  const n = t.definition.body;
273
286
  return c(n, {
274
287
  get widgetId() {
@@ -281,22 +294,22 @@ function Ct(t) {
281
294
  return t.widgetType;
282
295
  },
283
296
  get surfaceMetrics() {
284
- return E();
297
+ return X();
285
298
  },
286
299
  get activation() {
287
- return G();
300
+ return V();
288
301
  }
289
302
  });
290
303
  }), l(e, (() => {
291
- var n = rt(() => !!t.locked);
304
+ var n = at(() => !!t.locked);
292
305
  return () => n() ? null : (() => {
293
306
  var H = bt();
294
- return H.$$pointerdown = et, H;
307
+ return H.$$pointerdown = tt, H;
295
308
  })();
296
309
  })(), null), e;
297
310
  })();
298
311
  }
299
- lt(["pointerdown", "click"]);
312
+ dt(["pointerdown", "click"]);
300
313
  export {
301
- Ct as WorkbenchWidget
314
+ Wt as WorkbenchWidget
302
315
  };
@@ -1,9 +1,68 @@
1
1
  import type { Component } from 'solid-js';
2
2
  import type { WorkbenchThemeId } from './workbenchThemes';
3
+ import type { SurfaceInteractionTargetRole, SurfaceWheelLocalReason, WorkbenchWidgetEventOwnership } from '../ui/localInteractionSurface';
3
4
  export type BuiltinWorkbenchWidgetType = 'terminal' | 'file-browser' | 'system-monitor' | 'log-viewer' | 'code-editor';
4
5
  export type WorkbenchWidgetType = BuiltinWorkbenchWidgetType | (string & {});
5
6
  export declare const WORKBENCH_WIDGET_TYPES: readonly WorkbenchWidgetType[];
6
7
  export type WorkbenchWidgetRenderMode = 'canvas_scaled' | 'projected_surface';
8
+ export type WorkbenchCanvasOwnerReason = 'initial' | 'background_pointer' | 'background_focus' | (string & {});
9
+ export type WorkbenchWidgetOwnerReason = 'pointer' | 'focus' | 'activation' | (string & {});
10
+ export type WorkbenchInputOwner = {
11
+ kind: 'canvas';
12
+ reason: WorkbenchCanvasOwnerReason;
13
+ } | {
14
+ kind: 'widget';
15
+ widgetId: string;
16
+ reason: WorkbenchWidgetOwnerReason;
17
+ };
18
+ export type WorkbenchWheelLocalReason = SurfaceWheelLocalReason | 'selected_widget' | (string & {});
19
+ export type WorkbenchWheelRoutingDecision = {
20
+ kind: 'canvas_zoom';
21
+ } | {
22
+ kind: 'local_surface';
23
+ reason: WorkbenchWheelLocalReason;
24
+ } | {
25
+ kind: 'ignore';
26
+ reason: 'pan_zoom_disabled' | (string & {});
27
+ };
28
+ export interface WorkbenchInteractionAdapter {
29
+ surfaceRootAttr?: string;
30
+ widgetRootAttr?: string;
31
+ widgetIdAttr?: string;
32
+ dialogSurfaceHostAttr?: string;
33
+ interactiveSelector?: string;
34
+ panSurfaceSelector?: string;
35
+ wheelInteractiveSelector?: string;
36
+ createInitialInputOwner?: () => WorkbenchInputOwner;
37
+ createCanvasInputOwner?: (reason: WorkbenchCanvasOwnerReason) => WorkbenchInputOwner;
38
+ createWidgetInputOwner?: (widgetId: string, reason: WorkbenchWidgetOwnerReason) => WorkbenchInputOwner;
39
+ findWidgetRoot?: (target: EventTarget | null) => HTMLElement | null;
40
+ readWidgetId?: (element: Element | null) => string | null;
41
+ focusWidgetElement?: (root: ParentNode | null | undefined, widgetId: string) => boolean;
42
+ resolveSurfaceTargetRole?: (args: {
43
+ target: EventTarget | null;
44
+ interactiveSelector: string;
45
+ panSurfaceSelector: string;
46
+ }) => SurfaceInteractionTargetRole;
47
+ resolveWidgetEventOwnership?: (args: {
48
+ target: EventTarget | null;
49
+ widgetRoot: Element | EventTarget | null;
50
+ interactiveSelector: string;
51
+ panSurfaceSelector: string;
52
+ }) => WorkbenchWidgetEventOwnership;
53
+ resolveWheelRouting?: (args: {
54
+ target: EventTarget | null;
55
+ disablePanZoom: boolean;
56
+ selectedWidgetId: string | null;
57
+ wheelInteractiveSelector: string;
58
+ }) => WorkbenchWheelRoutingDecision;
59
+ shouldBypassGlobalHotkeys?: (args: {
60
+ root: HTMLElement | null | undefined;
61
+ target: EventTarget | null;
62
+ owner: WorkbenchInputOwner;
63
+ interactiveSelector: string;
64
+ }) => boolean;
65
+ }
7
66
  export interface WorkbenchProjectedRect {
8
67
  widgetId: string;
9
68
  worldX: number;
@@ -0,0 +1,39 @@
1
+ import type { WorkbenchCanvasOwnerReason, WorkbenchInputOwner, WorkbenchInteractionAdapter, WorkbenchWidgetOwnerReason } from './types';
2
+ export declare const DEFAULT_WORKBENCH_SURFACE_ROOT_ATTR = "data-floe-workbench-surface-root";
3
+ export declare const DEFAULT_WORKBENCH_WIDGET_ROOT_ATTR = "data-floe-workbench-widget-root";
4
+ export declare const DEFAULT_WORKBENCH_WIDGET_ID_ATTR = "data-floe-workbench-widget-id";
5
+ export declare const DEFAULT_WORKBENCH_DIALOG_SURFACE_HOST_ATTR = "data-floe-dialog-surface-host";
6
+ export interface ResolvedWorkbenchInteractionAdapter extends WorkbenchInteractionAdapter {
7
+ surfaceRootAttr: string;
8
+ widgetRootAttr: string;
9
+ widgetIdAttr: string;
10
+ dialogSurfaceHostAttr: string;
11
+ interactiveSelector: string;
12
+ panSurfaceSelector: string;
13
+ wheelInteractiveSelector: string;
14
+ createInitialInputOwner: () => WorkbenchInputOwner;
15
+ createCanvasInputOwner: (reason: WorkbenchCanvasOwnerReason) => WorkbenchInputOwner;
16
+ createWidgetInputOwner: (widgetId: string, reason: WorkbenchWidgetOwnerReason) => WorkbenchInputOwner;
17
+ findWidgetRoot: (target: EventTarget | null) => HTMLElement | null;
18
+ readWidgetId: (element: Element | null) => string | null;
19
+ focusWidgetElement: (root: ParentNode | null | undefined, widgetId: string) => boolean;
20
+ resolveSurfaceTargetRole: NonNullable<WorkbenchInteractionAdapter['resolveSurfaceTargetRole']>;
21
+ resolveWidgetEventOwnership: NonNullable<WorkbenchInteractionAdapter['resolveWidgetEventOwnership']>;
22
+ resolveWheelRouting: NonNullable<WorkbenchInteractionAdapter['resolveWheelRouting']>;
23
+ shouldBypassGlobalHotkeys: NonNullable<WorkbenchInteractionAdapter['shouldBypassGlobalHotkeys']>;
24
+ }
25
+ export declare function readWorkbenchWidgetId(element: Element | null, widgetIdAttr?: string): string | null;
26
+ export declare function findWorkbenchWidgetRoot(target: EventTarget | null, widgetRootAttr?: string): HTMLElement | null;
27
+ export declare function findWorkbenchWidgetElement(args: {
28
+ root: ParentNode | null | undefined;
29
+ widgetId: string;
30
+ widgetRootAttr?: string;
31
+ readWidgetId?: (element: Element | null) => string | null;
32
+ }): HTMLElement | null;
33
+ export declare function focusWorkbenchWidgetElement(args: {
34
+ root: ParentNode | null | undefined;
35
+ widgetId: string;
36
+ widgetRootAttr?: string;
37
+ readWidgetId?: (element: Element | null) => string | null;
38
+ }): boolean;
39
+ export declare function resolveWorkbenchInteractionAdapter(adapter?: WorkbenchInteractionAdapter): ResolvedWorkbenchInteractionAdapter;
@@ -0,0 +1,103 @@
1
+ import { isTypingElement as R } from "../../utils/dom.js";
2
+ import { DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR as v, resolveWorkbenchWidgetEventOwnership as W, DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR as I, resolveSurfaceInteractionTargetRole as T, resolveSurfaceWheelRouting as A } from "../ui/localInteractionSurface.js";
3
+ const _ = "data-floe-workbench-surface-root", a = "data-floe-workbench-widget-root", s = "data-floe-workbench-widget-id", h = "data-floe-dialog-surface-host";
4
+ function m(e) {
5
+ return typeof Element < "u" && e instanceof Element ? e : typeof Node < "u" && e instanceof Node ? e.parentElement : null;
6
+ }
7
+ function g(e, t = s) {
8
+ const r = (e?.getAttribute(t) ?? "").trim();
9
+ return r.length > 0 ? r : null;
10
+ }
11
+ function O(e, t = a) {
12
+ if (!(e instanceof Element)) return null;
13
+ const o = e.closest(`[${t}="true"]`);
14
+ return o instanceof HTMLElement ? o : null;
15
+ }
16
+ function k(e) {
17
+ const {
18
+ root: t,
19
+ widgetId: o,
20
+ widgetRootAttr: r = a,
21
+ readWidgetId: c = (i) => g(i, s)
22
+ } = e;
23
+ if (!t || typeof t.querySelectorAll != "function") return null;
24
+ const l = t.querySelectorAll(`[${r}="true"]`);
25
+ for (const i of l)
26
+ if (i instanceof HTMLElement && c(i) === o)
27
+ return i;
28
+ return null;
29
+ }
30
+ function b(e) {
31
+ const t = k(e);
32
+ return t ? (t.focus({ preventScroll: !0 }), !0) : !1;
33
+ }
34
+ function d(e) {
35
+ return { kind: "canvas", reason: e };
36
+ }
37
+ function C(e, t) {
38
+ return { kind: "widget", widgetId: e, reason: t };
39
+ }
40
+ function H(e) {
41
+ const t = A({
42
+ target: e.target,
43
+ disablePanZoom: e.disablePanZoom,
44
+ wheelInteractiveSelector: e.wheelInteractiveSelector
45
+ });
46
+ return t.kind === "canvas_zoom" ? t : t.kind === "local_surface" ? { kind: "local_surface", reason: t.reason } : { kind: "ignore", reason: t.reason };
47
+ }
48
+ function D(e) {
49
+ const t = e?.surfaceRootAttr ?? _, o = e?.widgetRootAttr ?? a, r = e?.widgetIdAttr ?? s, c = e?.dialogSurfaceHostAttr ?? h, l = e?.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', i = e?.panSurfaceSelector ?? '[data-floe-canvas-pan-surface="true"]', S = e?.wheelInteractiveSelector ?? v, f = e?.readWidgetId ?? ((n) => g(n, r)), E = e?.findWidgetRoot ?? ((n) => O(n, o)), w = e?.focusWidgetElement ?? ((n, u) => b({
50
+ root: n,
51
+ widgetId: u,
52
+ widgetRootAttr: o,
53
+ readWidgetId: f
54
+ }));
55
+ return {
56
+ ...e,
57
+ surfaceRootAttr: t,
58
+ widgetRootAttr: o,
59
+ widgetIdAttr: r,
60
+ dialogSurfaceHostAttr: c,
61
+ interactiveSelector: l,
62
+ panSurfaceSelector: i,
63
+ wheelInteractiveSelector: S,
64
+ createInitialInputOwner: e?.createInitialInputOwner ?? (() => d("initial")),
65
+ createCanvasInputOwner: e?.createCanvasInputOwner ?? d,
66
+ createWidgetInputOwner: e?.createWidgetInputOwner ?? C,
67
+ readWidgetId: f,
68
+ findWidgetRoot: E,
69
+ focusWidgetElement: w,
70
+ resolveSurfaceTargetRole: e?.resolveSurfaceTargetRole ?? ((n) => T({
71
+ target: n.target,
72
+ interactiveSelector: n.interactiveSelector,
73
+ panSurfaceSelector: n.panSurfaceSelector
74
+ })),
75
+ resolveWidgetEventOwnership: e?.resolveWidgetEventOwnership ?? ((n) => W({
76
+ target: n.target,
77
+ widgetRoot: n.widgetRoot,
78
+ interactiveSelector: n.interactiveSelector,
79
+ panSurfaceSelector: n.panSurfaceSelector,
80
+ shellSelector: I
81
+ })),
82
+ resolveWheelRouting: e?.resolveWheelRouting ?? ((n) => H({
83
+ target: n.target,
84
+ disablePanZoom: n.disablePanZoom,
85
+ wheelInteractiveSelector: n.wheelInteractiveSelector
86
+ })),
87
+ shouldBypassGlobalHotkeys: e?.shouldBypassGlobalHotkeys ?? ((n) => {
88
+ const u = m(n.target);
89
+ return R(u);
90
+ })
91
+ };
92
+ }
93
+ export {
94
+ h as DEFAULT_WORKBENCH_DIALOG_SURFACE_HOST_ATTR,
95
+ _ as DEFAULT_WORKBENCH_SURFACE_ROOT_ATTR,
96
+ s as DEFAULT_WORKBENCH_WIDGET_ID_ATTR,
97
+ a as DEFAULT_WORKBENCH_WIDGET_ROOT_ATTR,
98
+ k as findWorkbenchWidgetElement,
99
+ O as findWorkbenchWidgetRoot,
100
+ b as focusWorkbenchWidgetElement,
101
+ g as readWorkbenchWidgetId,
102
+ D as resolveWorkbenchInteractionAdapter
103
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.18",
3
+ "version": "0.36.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",