@floegence/floe-webapp-core 0.41.4 → 0.42.0

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,69 +1,72 @@
1
- import { insert as b, createComponent as s, effect as P, setAttribute as y, memo as ce, template as x, addEventListener as se, Portal as Se, setStyleProperty as Oe, use as Me, delegateEvents as ye } from "solid-js/web";
2
- import { createSignal as z, onCleanup as K, createEffect as p, createMemo as $, Show as B, For as N } from "solid-js";
3
- import { Motion as Y } from "../../node_modules/.pnpm/solid-motionone@1.0.4_solid-js@1.9.11/node_modules/solid-motionone/dist/index.js";
4
- import { easing as F, duration as A } from "../../utils/animations.js";
5
- import { Plus as xe } from "../icons/index.js";
6
- import { startHotInteraction as de } from "../../utils/hotInteraction.js";
7
- import { startPointerSession as ue } from "../ui/pointerSession.js";
8
- import { createWorkbenchEdgeAutoPanController as Te, WORKBENCH_EDGE_AUTO_PAN_FRAME_SELECTOR as ke, frameFromElement as fe } from "./workbenchEdgeAutoPan.js";
9
- import { DockLayoutDashboard as Xe, DockLayers as Pe, DockRegion as Ye, DockText as Fe, DockMessageSquare as Ae } from "../icons/DockIcons.js";
10
- var $e = /* @__PURE__ */ x("<button type=button class=workbench-dock__item>"), Be = /* @__PURE__ */ x('<button type=button class="workbench-dock__item workbench-dock__action">'), He = /* @__PURE__ */ x('<div class=workbench-dock__mode-popover role=menu aria-label="Canvas mode">'), Re = /* @__PURE__ */ x("<span class=workbench-dock__external-placeholder aria-hidden=true>"), We = /* @__PURE__ */ x('<div class=workbench-dock data-floe-canvas-interactive=true><div class=workbench-dock__mode-switcher><button type=button class="workbench-dock__item workbench-dock__mode-trigger"aria-label="Switch canvas mode"aria-haspopup=menu></button></div><span class=workbench-dock__divider aria-hidden=true>'), Ke = /* @__PURE__ */ x("<button type=button class=workbench-dock__mode-option role=menuitemradio><span class=workbench-dock__mode-option-icon></span><span class=workbench-dock__mode-option-copy><span class=workbench-dock__mode-option-label></span><span class=workbench-dock__mode-option-description>"), pe = /* @__PURE__ */ x("<div class=workbench-dock-ghost aria-hidden=true><div class=workbench-dock-ghost__halo></div><div class=workbench-dock-ghost__card><div class=workbench-dock-ghost__icon></div><div class=workbench-dock-ghost__copy><div class=workbench-dock-ghost__title></div><div class=workbench-dock-ghost__hint><span>");
11
- const V = 5, Ne = ".workbench-dock", j = [{
1
+ import { insert as w, createComponent as c, effect as A, setAttribute as M, memo as Q, className as Me, template as X, addEventListener as ge, Portal as xe, setStyleProperty as Xe, use as $e, delegateEvents as Ae } from "solid-js/web";
2
+ import { createSignal as Z, onCleanup as G, createEffect as U, createMemo as H, Show as W, For as q } from "solid-js";
3
+ import { Motion as F } from "../../node_modules/.pnpm/solid-motionone@1.0.4_solid-js@1.9.11/node_modules/solid-motionone/dist/index.js";
4
+ import { easing as Y, duration as B } from "../../utils/animations.js";
5
+ import { Plus as Fe } from "../icons/index.js";
6
+ import { startHotInteraction as Ye } from "../../utils/hotInteraction.js";
7
+ import { startPointerSession as Be } from "../ui/pointerSession.js";
8
+ import { clientToCanvasWorld as He } from "../ui/canvasGeometry.js";
9
+ import { createWorkbenchWidgetFrame as We } from "./workbenchHelpers.js";
10
+ import { getWidgetEntry as pe } from "./widgets/widgetRegistry.js";
11
+ import { WORKBENCH_EDGE_AUTO_PAN_FRAME_SELECTOR as he, frameFromElement as we, createWorkbenchEdgeAutoPanController as Re } from "./workbenchEdgeAutoPan.js";
12
+ import { DockLayoutDashboard as Ke, DockLayers as Ne, DockRegion as Ve, DockText as Ge, DockMessageSquare as Ue } from "../icons/DockIcons.js";
13
+ var qe = /* @__PURE__ */ X("<button type=button class=workbench-dock__item>"), ze = /* @__PURE__ */ X('<button type=button class="workbench-dock__item workbench-dock__action">'), je = /* @__PURE__ */ X('<div class=workbench-dock__mode-popover role=menu aria-label="Canvas mode">'), Je = /* @__PURE__ */ X("<span class=workbench-dock__external-placeholder aria-hidden=true>"), Qe = /* @__PURE__ */ X('<div data-floe-canvas-interactive=true><div class=workbench-dock__mode-switcher><button type=button class="workbench-dock__item workbench-dock__mode-trigger"aria-label="Switch canvas mode"aria-haspopup=menu></button></div><span class=workbench-dock__divider aria-hidden=true>'), Ze = /* @__PURE__ */ X("<button type=button class=workbench-dock__mode-option role=menuitemradio><span class=workbench-dock__mode-option-icon></span><span class=workbench-dock__mode-option-copy><span class=workbench-dock__mode-option-label></span><span class=workbench-dock__mode-option-description>"), et = /* @__PURE__ */ X("<div class=workbench-dock-ghost aria-hidden=true><div class=workbench-dock-ghost__halo></div><div class=workbench-dock-ghost__card><div class=workbench-dock-ghost__icon></div><div class=workbench-dock-ghost__copy><div class=workbench-dock-ghost__title></div><div class=workbench-dock-ghost__hint><span>");
14
+ const ve = 5, tt = ".workbench-dock", ee = [{
12
15
  mode: "work",
13
16
  label: "Work Mode",
14
17
  description: "Operate windows and sticky notes",
15
- icon: Xe
18
+ icon: Ke
16
19
  }, {
17
20
  mode: "background",
18
21
  label: "Composition Mode",
19
22
  description: "Arrange regions and canvas text",
20
- icon: Pe
21
- }], Ve = [{
23
+ icon: Ne
24
+ }], nt = [{
22
25
  tool: "sticky-note",
23
26
  label: "Sticky",
24
- icon: Ae
25
- }], Ge = [{
27
+ icon: Ue
28
+ }], ot = [{
26
29
  tool: "background-region",
27
30
  label: "Region",
28
- icon: Ye
31
+ icon: Ve
29
32
  }, {
30
33
  tool: "text",
31
34
  label: "Text",
32
- icon: Fe
35
+ icon: Ge
33
36
  }];
34
- function Ue() {
35
- const e = document.querySelector(ke);
36
- return e instanceof HTMLElement ? fe(e) : null;
37
+ function rt(e) {
38
+ const a = e?.closest(".workbench-surface")?.querySelector(he);
39
+ return a instanceof HTMLElement ? we(a) : null;
37
40
  }
38
- function Q(e, u, l) {
39
- return e >= l.left && e <= l.right && u >= l.top && u <= l.bottom;
41
+ function te(e, s, a) {
42
+ return e >= a.left && e <= a.right && s >= a.top && s <= a.bottom;
40
43
  }
41
- function qe(e, u, l) {
42
- return l ? Q(e, u, l) : !1;
44
+ function it(e, s, a) {
45
+ return a ? te(e, s, a) : !1;
43
46
  }
44
- function ge(e, u, l) {
45
- return Math.min(l, Math.max(u, e));
47
+ function ke(e, s, a) {
48
+ return Math.min(a, Math.max(s, e));
46
49
  }
47
- function ze(e, u, l, c, i) {
50
+ function at(e, s, a, l, r) {
48
51
  if (!e) return !1;
49
- if (Q(u, l, e) || Q(c, i, e))
52
+ if (te(s, a, e) || te(l, r, e))
50
53
  return !0;
51
- const r = c - u, C = i - l;
52
- let D = 0, h = 1;
53
- const g = (w, L) => {
54
- if (w === 0) return L >= 0;
55
- const f = L / w;
56
- return w < 0 ? f > h ? !1 : (f > D && (D = f), !0) : f < D ? !1 : (f < h && (h = f), !0);
54
+ const i = l - s, D = r - a;
55
+ let v = 0, E = 1;
56
+ const u = (b, C) => {
57
+ if (b === 0) return C >= 0;
58
+ const k = C / b;
59
+ return b < 0 ? k > E ? !1 : (k > v && (v = k), !0) : k < v ? !1 : (k < E && (E = k), !0);
57
60
  };
58
- return g(-r, u - e.left) && g(r, e.right - u) && g(-C, l - e.top) && g(C, e.bottom - l);
61
+ return u(-i, s - e.left) && u(i, e.right - s) && u(-D, a - e.top) && u(D, e.bottom - a);
59
62
  }
60
- function J(e, u) {
61
- if (typeof document.elementFromPoint != "function") return !1;
62
- const l = document.elementFromPoint(e, u);
63
- return l instanceof Element && l.closest(Ne) !== null;
63
+ function fe(e, s, a) {
64
+ if (!a || typeof document.elementFromPoint != "function") return !1;
65
+ const l = document.elementFromPoint(e, s);
66
+ return l instanceof Element && l.closest(tt) === a;
64
67
  }
65
- function ve(e) {
66
- const u = () => e.hoverOffset === -1 ? {
68
+ function me(e) {
69
+ const s = () => e.hoverOffset === -1 ? {
67
70
  scale: 1.26,
68
71
  y: -6,
69
72
  x: 0
@@ -79,50 +82,50 @@ function ve(e) {
79
82
  scale: 1,
80
83
  y: 0,
81
84
  x: 0
82
- }, l = () => e.hoverOffset === -1, c = (i) => {
83
- i.button === 0 && e.onDragBegin(i, e.kind, e.id, e.label, e.icon, i.currentTarget);
85
+ }, a = () => e.hoverOffset === -1, l = (r) => {
86
+ r.button === 0 && e.onDragBegin(r, e.kind, e.id, e.label, e.icon, r.currentTarget, e.canvasPlacement, null);
84
87
  };
85
88
  return (() => {
86
- var i = $e();
87
- return i.$$pointerdown = c, i.addEventListener("pointerleave", () => e.onLeave()), i.addEventListener("pointerenter", () => e.onEnter()), b(i, s(Y.span, {
89
+ var r = qe();
90
+ return r.$$pointerdown = l, r.addEventListener("pointerleave", () => e.onLeave()), r.addEventListener("pointerenter", () => e.onEnter()), w(r, c(F.span, {
88
91
  class: "workbench-dock__tile",
89
92
  get animate() {
90
- return u();
93
+ return s();
91
94
  },
92
95
  get transition() {
93
96
  return {
94
- duration: A.fast,
95
- easing: F.easeOut
97
+ duration: B.fast,
98
+ easing: Y.easeOut
96
99
  };
97
100
  },
98
101
  get children() {
99
102
  return (() => {
100
- const r = e.icon;
101
- return s(r, {
103
+ const i = e.icon;
104
+ return c(i, {
102
105
  class: "workbench-dock__icon"
103
106
  });
104
107
  })();
105
108
  }
106
- }), null), b(i, s(Y.span, {
109
+ }), null), w(r, c(F.span, {
107
110
  class: "workbench-dock__tooltip",
108
111
  get animate() {
109
112
  return {
110
- opacity: l() ? 1 : 0,
111
- y: l() ? -6 : 0
113
+ opacity: a() ? 1 : 0,
114
+ y: a() ? -6 : 0
112
115
  };
113
116
  },
114
117
  get transition() {
115
118
  return {
116
- duration: A.fast,
117
- easing: F.easeOut
119
+ duration: B.fast,
120
+ easing: Y.easeOut
118
121
  };
119
122
  },
120
123
  get children() {
121
124
  return e.label;
122
125
  }
123
- }), null), P((r) => {
124
- var C = e.kind === "host" ? e.id : void 0, D = !!e.active, h = !!(e.filterable && !e.visible), g = !!l(), w = !!e.isDragging, L = e.filterable ? `${e.label} — click to solo, drag to canvas to create` : `${e.label} — drag to canvas to create`, f = e.active;
125
- return C !== r.e && y(i, "data-workbench-dock-item", r.e = C), D !== r.t && i.classList.toggle("is-active", r.t = D), h !== r.a && i.classList.toggle("is-filter-muted", r.a = h), g !== r.o && i.classList.toggle("is-hovered", r.o = g), w !== r.i && i.classList.toggle("is-source-dragging", r.i = w), L !== r.n && y(i, "aria-label", r.n = L), f !== r.s && y(i, "aria-pressed", r.s = f), r;
126
+ }), null), A((i) => {
127
+ var D = e.kind === "host" ? e.id : void 0, v = !!e.active, E = !!(e.filterable && !e.visible), u = !!a(), b = !!e.isDragging, C = e.filterable ? `${e.label} — click to solo, drag to canvas to create` : `${e.label} — drag to canvas to create`, k = e.active;
128
+ return D !== i.e && M(r, "data-workbench-dock-item", i.e = D), v !== i.t && r.classList.toggle("is-active", i.t = v), E !== i.a && r.classList.toggle("is-filter-muted", i.a = E), u !== i.o && r.classList.toggle("is-hovered", i.o = u), b !== i.i && r.classList.toggle("is-source-dragging", i.i = b), C !== i.n && M(r, "aria-label", i.n = C), k !== i.s && M(r, "aria-pressed", i.s = k), i;
126
129
  }, {
127
130
  e: void 0,
128
131
  t: void 0,
@@ -131,120 +134,120 @@ function ve(e) {
131
134
  i: void 0,
132
135
  n: void 0,
133
136
  s: void 0
134
- }), i;
137
+ }), r;
135
138
  })();
136
139
  }
137
- function je(e) {
138
- const u = () => e.hoverOffset === -1, l = () => ({
140
+ function lt(e) {
141
+ const s = () => e.hoverOffset === -1, a = () => ({
139
142
  scale: 1,
140
143
  y: 0,
141
144
  x: 0
142
- }), c = e.action.icon;
145
+ }), l = e.action.icon;
143
146
  return (() => {
144
- var i = Be();
145
- return i.$$click = (r) => e.action.onActivate(r.currentTarget), i.addEventListener("dragstart", (r) => r.preventDefault()), se(i, "pointerleave", e.onLeave), se(i, "pointerenter", e.onEnter), y(i, "draggable", !1), b(i, s(Y.span, {
147
+ var r = ze();
148
+ return r.$$click = (i) => e.action.onActivate(i.currentTarget), r.addEventListener("dragstart", (i) => i.preventDefault()), ge(r, "pointerleave", e.onLeave), ge(r, "pointerenter", e.onEnter), M(r, "draggable", !1), w(r, c(F.span, {
146
149
  class: "workbench-dock__tile",
147
150
  get animate() {
148
- return l();
151
+ return a();
149
152
  },
150
153
  get transition() {
151
154
  return {
152
- duration: A.fast,
153
- easing: F.easeOut
155
+ duration: B.fast,
156
+ easing: Y.easeOut
154
157
  };
155
158
  },
156
159
  get children() {
157
- return s(c, {
160
+ return c(l, {
158
161
  class: "workbench-dock__icon"
159
162
  });
160
163
  }
161
- }), null), b(i, s(Y.span, {
164
+ }), null), w(r, c(F.span, {
162
165
  class: "workbench-dock__tooltip",
163
166
  get animate() {
164
167
  return {
165
- opacity: u() ? 1 : 0,
166
- y: u() ? -6 : 0
168
+ opacity: s() ? 1 : 0,
169
+ y: s() ? -6 : 0
167
170
  };
168
171
  },
169
172
  get transition() {
170
173
  return {
171
- duration: A.fast,
172
- easing: F.easeOut
174
+ duration: B.fast,
175
+ easing: Y.easeOut
173
176
  };
174
177
  },
175
178
  get children() {
176
179
  return e.action.label;
177
180
  }
178
- }), null), P((r) => {
179
- var C = e.action.id, D = !!e.action.active, h = !!u(), g = e.action.label, w = e.action.active;
180
- return C !== r.e && y(i, "data-workbench-dock-action", r.e = C), D !== r.t && i.classList.toggle("is-active", r.t = D), h !== r.a && i.classList.toggle("is-hovered", r.a = h), g !== r.o && y(i, "aria-label", r.o = g), w !== r.i && y(i, "aria-pressed", r.i = w), r;
181
+ }), null), A((i) => {
182
+ var D = e.action.id, v = !!e.action.active, E = !!s(), u = e.action.label, b = e.action.active;
183
+ return D !== i.e && M(r, "data-workbench-dock-action", i.e = D), v !== i.t && r.classList.toggle("is-active", i.t = v), E !== i.a && r.classList.toggle("is-hovered", i.a = E), u !== i.o && M(r, "aria-label", i.o = u), b !== i.i && M(r, "aria-pressed", i.i = b), i;
181
184
  }, {
182
185
  e: void 0,
183
186
  t: void 0,
184
187
  a: void 0,
185
188
  o: void 0,
186
189
  i: void 0
187
- }), i;
190
+ }), r;
188
191
  })();
189
192
  }
190
- function lt(e) {
191
- const [u, l] = z(null), [c, i] = z(null), [r, C] = z(!1);
192
- let D, h, g, w, L = null;
193
- K(() => {
194
- w?.stop(), h?.stop({
193
+ function Et(e) {
194
+ const [s, a] = Z(null), [l, r] = Z(null), [i, D] = Z(!1);
195
+ let v, E, u, b, C = null;
196
+ G(() => {
197
+ b?.stop(), E?.stop({
195
198
  reason: "manual_stop",
196
199
  commit: !1
197
- }), h = void 0, g?.(), g = void 0, c()?.stopInteraction(), e.onDragPreviewChange?.(null), e.registerExternalDockDragController?.(null);
198
- }), p(() => {
199
- e.onDragPreviewChange?.(c()?.preview ?? null);
200
- }), p(() => {
200
+ }), E = void 0, u?.(), u = void 0, l()?.stopInteraction(), e.onDragPreviewChange?.(null), e.registerExternalDockDragController?.(null);
201
+ }), U(() => {
202
+ e.onDragPreviewChange?.(l()?.preview ?? null);
203
+ }), U(() => {
201
204
  const t = (n) => {
202
- n.key !== "Escape" || !c() || (n.preventDefault(), h?.stop({
205
+ n.key !== "Escape" || !l() || (n.preventDefault(), E?.stop({
203
206
  reason: "manual_stop",
204
207
  commit: !1
205
208
  }));
206
209
  };
207
- window.addEventListener("keydown", t, !0), K(() => window.removeEventListener("keydown", t, !0));
208
- }), p(() => {
209
- if (!r() || typeof window > "u") return;
210
- const t = (d) => {
211
- D && d.target instanceof Node && D.contains(d.target) || C(!1);
212
- }, n = (d) => {
213
- d.key === "Escape" && C(!1);
210
+ window.addEventListener("keydown", t, !0), G(() => window.removeEventListener("keydown", t, !0));
211
+ }), U(() => {
212
+ if (!i() || typeof window > "u") return;
213
+ const t = (f) => {
214
+ v && f.target instanceof Node && v.contains(f.target) || D(!1);
215
+ }, n = (f) => {
216
+ f.key === "Escape" && D(!1);
214
217
  };
215
- window.addEventListener("pointerdown", t, !0), window.addEventListener("keydown", n, !0), K(() => {
218
+ window.addEventListener("pointerdown", t, !0), window.addEventListener("keydown", n, !0), G(() => {
216
219
  window.removeEventListener("pointerdown", t, !0), window.removeEventListener("keydown", n, !0);
217
220
  });
218
221
  });
219
- const f = (t) => {
220
- const n = u();
222
+ const k = (t) => {
223
+ const n = s();
221
224
  return n === null || n <= R().length ? 0 : n === t ? -1 : n === t + 1 ? -2 : n === t - 1 ? 1 : 0;
222
- }, T = () => {
223
- w?.stop(), w = void 0, L = null;
224
- }, H = () => {
225
- !e.viewport || !e.onViewportCommit || (L = e.viewport, w?.stop(), w = Te({
225
+ }, $ = () => {
226
+ b?.stop(), b = void 0, C = null;
227
+ }, p = () => {
228
+ !e.viewport || !e.onViewportCommit || (C = e.viewport, b?.stop(), b = Re({
226
229
  readFrame: () => {
227
- const t = document.querySelector(ke);
228
- return t instanceof HTMLElement ? fe(t) : null;
230
+ const n = v?.closest(".workbench-surface")?.querySelector(he);
231
+ return n instanceof HTMLElement ? we(n) : null;
229
232
  },
230
- readViewport: () => L ?? e.viewport ?? null,
233
+ readViewport: () => C ?? e.viewport ?? null,
231
234
  commitViewport: (t) => {
232
- L = t, e.onViewportCommit?.(t);
235
+ C = t, e.onViewportCommit?.(t);
233
236
  },
234
237
  onPanStart: () => e.onViewportInteractionStart?.("pan"),
235
238
  shouldPan: () => {
236
- const t = c();
237
- return !!(t?.moved && t.hasEnteredCanvas && !J(t.clientX, t.clientY));
239
+ const t = l();
240
+ return !!(t?.moved && t.hasEnteredCanvas && !fe(t.clientX, t.clientY, v));
238
241
  }
239
242
  }));
240
- }, Z = (t) => {
241
- const n = c();
243
+ }, be = (t) => {
244
+ const n = l();
242
245
  if (!n) return;
243
- const d = !n.moved;
244
- if (n.stopInteraction(), T(), i(null), h = void 0, d) {
245
- if (n.kind === "external") return;
246
+ const f = !n.moved, P = C ?? e.viewport;
247
+ if (n.stopInteraction(), $(), r(null), E = void 0, f) {
248
+ if (n.kind === "external" || !(n.trigger instanceof HTMLButtonElement)) return;
246
249
  if (n.kind === "host") {
247
- e.dockItems?.find((E) => E.id === n.id)?.onActivate?.(n.trigger);
250
+ e.dockItems?.find((o) => o.id === n.id)?.onActivate?.(n.trigger);
248
251
  return;
249
252
  }
250
253
  if (e.onItemClick?.({
@@ -253,45 +256,37 @@ function lt(e) {
253
256
  label: n.label,
254
257
  trigger: n.trigger
255
258
  })) return;
256
- M() !== "background" && e.onSoloFilter(String(n.id), ie());
259
+ I() !== "background" && e.onSoloFilter(String(n.id), ae());
257
260
  return;
258
261
  }
259
- if (t && n.kind === "external" && n.overDock) {
260
- e.onExternalDockDrop?.({
261
- id: n.id,
262
- label: n.label,
263
- icon: n.icon
264
- });
262
+ if (t && n.overDock && n.dockDrop) {
263
+ n.dockDrop();
265
264
  return;
266
265
  }
267
- if (t && n.overCanvas) {
268
- const _ = n.canvasFrame ? {
266
+ if (t && n.overCanvas && n.canvasPlacement) {
267
+ const S = n.canvasFrame && P ? He(n.canvasFrame, P, {
268
+ clientX: n.clientX,
269
+ clientY: n.clientY
270
+ }) : null, o = n.canvasFrame ? {
269
271
  dropAllowed: n.overCanvas,
270
- canvasFrame: n.canvasFrame
272
+ canvasFrame: n.canvasFrame,
273
+ ...S ? {
274
+ worldPoint: S
275
+ } : {}
271
276
  } : void 0;
272
- if (n.kind === "widget")
273
- e.onCreateAt?.(n.id, n.clientX, n.clientY, _);
274
- else if (n.kind === "tool")
275
- e.onCreateToolAt?.(n.id, n.clientX, n.clientY, _);
276
- else {
277
- const E = n.canvasFrame ? {
278
- dropAllowed: n.overCanvas,
279
- canvasFrame: n.canvasFrame
280
- } : void 0;
281
- e.dockItems?.find((o) => o.id === n.id)?.onDropToCanvas?.(n.clientX, n.clientY, E);
282
- }
277
+ n.canvasPlacement.onDrop(n.clientX, n.clientY, o);
283
278
  }
284
- }, ee = (t, n, d, _, E, o) => {
285
- t.preventDefault(), h?.stop({
279
+ }, z = (t, n, f, P, S, o, _, h) => {
280
+ t.preventDefault(), E?.stop({
286
281
  reason: "manual_stop",
287
282
  commit: !1
288
- }), H();
289
- const v = Ue();
290
- i({
283
+ }), p();
284
+ const g = rt(v);
285
+ r({
291
286
  kind: n,
292
- id: d,
293
- label: _,
294
- icon: E,
287
+ id: f,
288
+ label: P,
289
+ icon: S,
295
290
  pointerId: t.pointerId,
296
291
  startClientX: t.clientX,
297
292
  startClientY: t.clientY,
@@ -300,122 +295,105 @@ function lt(e) {
300
295
  moved: !1,
301
296
  overCanvas: !1,
302
297
  hasEnteredCanvas: !1,
303
- canvasFrame: v,
298
+ canvasFrame: g,
304
299
  preview: null,
305
- stopInteraction: de({
300
+ canvasPlacement: _,
301
+ dockDrop: h,
302
+ stopInteraction: Ye({
306
303
  kind: "drag",
307
304
  cursor: "grabbing"
308
305
  }),
309
306
  trigger: o,
310
307
  overDock: !1
311
308
  });
312
- const k = (a) => {
313
- let S = !1;
314
- i((m) => {
315
- if (!m || m.pointerId !== a.pointerId) return m;
316
- const W = a.clientX - m.startClientX, q = a.clientY - m.startClientY, O = m.moved || Math.abs(W) > V || Math.abs(q) > V, X = J(a.clientX, a.clientY), I = m.canvasFrame, re = O && qe(a.clientX, a.clientY, I), ae = re && !X, Ce = O && !X && ze(I, m.clientX, m.clientY, a.clientX, a.clientY), le = m.hasEnteredCanvas || re || Ce;
317
- S = O && le && !X;
318
- const Le = I ? ge(a.clientX, I.left, I.right) : a.clientX, Ie = I ? ge(a.clientY, I.top, I.bottom) : a.clientY;
309
+ const L = (d) => {
310
+ let T = !1;
311
+ r((m) => {
312
+ if (!m || m.pointerId !== d.pointerId) return m;
313
+ const x = d.clientX - m.startClientX, K = d.clientY - m.startClientY, y = m.moved || Math.abs(x) > ve || Math.abs(K) > ve;
314
+ if (m.kind === "external" && y && !m.moved) {
315
+ const de = (ue) => {
316
+ ue.preventDefault(), ue.stopImmediatePropagation(), u?.();
317
+ }, ye = window.setTimeout(() => {
318
+ u === V && V();
319
+ }, 0), V = () => {
320
+ window.clearTimeout(ye), m.trigger.removeEventListener("click", de, !0), u === V && (u = void 0);
321
+ };
322
+ m.trigger.addEventListener("click", de, {
323
+ capture: !0,
324
+ once: !0
325
+ }), u = V;
326
+ }
327
+ const N = fe(d.clientX, d.clientY, v), O = m.canvasFrame, le = y && it(d.clientX, d.clientY, O), ce = le && !N, Oe = y && !N && at(O, m.clientX, m.clientY, d.clientX, d.clientY), se = m.hasEnteredCanvas || le || Oe;
328
+ T = y && se && !N;
329
+ const Ie = O ? ke(d.clientX, O.left, O.right) : d.clientX, Te = O ? ke(d.clientY, O.top, O.bottom) : d.clientY;
319
330
  return {
320
331
  ...m,
321
- clientX: a.clientX,
322
- clientY: a.clientY,
323
- moved: O,
324
- overCanvas: ae,
325
- hasEnteredCanvas: le,
326
- preview: O && I && (m.kind === "widget" || m.kind === "tool") ? {
327
- kind: m.kind,
328
- id: m.id,
332
+ clientX: d.clientX,
333
+ clientY: d.clientY,
334
+ moved: y,
335
+ overDock: N,
336
+ overCanvas: ce,
337
+ hasEnteredCanvas: se,
338
+ preview: y && O && m.canvasPlacement?.preview ? {
339
+ kind: m.canvasPlacement.preview.kind,
340
+ id: m.canvasPlacement.preview.id,
329
341
  label: m.label,
330
- clientX: Le,
331
- clientY: Ie,
332
- dropAllowed: ae,
333
- canvasFrame: I
342
+ clientX: Ie,
343
+ clientY: Te,
344
+ dropAllowed: ce,
345
+ canvasFrame: O
334
346
  } : null
335
347
  };
336
- }), S && w?.updatePointer(a.clientX, a.clientY);
348
+ }), T && b?.updatePointer(d.clientX, d.clientY);
337
349
  };
338
- h = ue({
350
+ E = Be({
339
351
  pointerEvent: t,
340
352
  captureEl: t.currentTarget,
341
- onMove: k,
353
+ onMove: L,
342
354
  onEnd: ({
343
- commit: a
344
- }) => Z(a)
345
- });
346
- }, me = (t, n) => {
347
- if (t.button !== 0 || !(t.currentTarget instanceof HTMLElement)) return;
348
- t.preventDefault(), h?.stop({
349
- reason: "manual_stop",
350
- commit: !1
351
- }), g?.(), g = void 0;
352
- const d = t.currentTarget;
353
- i({
354
- kind: "external",
355
- id: n.id,
356
- label: n.label,
357
- icon: n.icon,
358
- pointerId: t.pointerId,
359
- startClientX: t.clientX,
360
- startClientY: t.clientY,
361
- clientX: t.clientX,
362
- clientY: t.clientY,
363
- moved: !1,
364
- overCanvas: !1,
365
- overDock: !1,
366
- hasEnteredCanvas: !1,
367
- canvasFrame: null,
368
- preview: null,
369
- stopInteraction: de({
370
- kind: "drag",
371
- cursor: "grabbing"
372
- }),
373
- trigger: d
374
- }), h = ue({
375
- pointerEvent: t,
376
- captureEl: d,
377
- onMove: (_) => {
378
- i((E) => {
379
- if (!E || E.kind !== "external" || E.pointerId !== _.pointerId) return E;
380
- const o = E.moved || Math.abs(_.clientX - E.startClientX) > V || Math.abs(_.clientY - E.startClientY) > V;
381
- if (o && !E.moved) {
382
- const v = (S) => {
383
- S.preventDefault(), S.stopImmediatePropagation(), g?.();
384
- }, k = window.setTimeout(() => {
385
- g === a && a();
386
- }, 0), a = () => {
387
- window.clearTimeout(k), d.removeEventListener("click", v, !0), g === a && (g = void 0);
388
- };
389
- d.addEventListener("click", v, {
390
- capture: !0,
391
- once: !0
392
- }), g = a;
393
- }
394
- return {
395
- ...E,
396
- clientX: _.clientX,
397
- clientY: _.clientY,
398
- moved: o,
399
- overDock: o && J(_.clientX, _.clientY)
400
- };
401
- });
402
- },
403
- onEnd: ({
404
- commit: _
405
- }) => Z(_)
355
+ commit: d,
356
+ snapshot: T
357
+ }) => {
358
+ L({
359
+ pointerId: T.pointerId,
360
+ clientX: T.latestClientX,
361
+ clientY: T.latestClientY
362
+ }), be(d);
363
+ }
406
364
  });
365
+ }, ne = (t) => t ? {
366
+ preview: {
367
+ kind: "widget",
368
+ id: t.widgetType
369
+ },
370
+ onDrop: (n, f, P) => {
371
+ if (!P?.worldPoint) return;
372
+ const S = pe(t.widgetType, e.widgetDefinitions);
373
+ t.onDrop({
374
+ widgetType: t.widgetType,
375
+ centerWorld: P.worldPoint,
376
+ frame: We(S, {
377
+ anchor: "center",
378
+ worldX: P.worldPoint.worldX,
379
+ worldY: P.worldPoint.worldY
380
+ })
381
+ });
382
+ }
383
+ } : null, _e = (t, n) => {
384
+ t.button !== 0 || !(t.currentTarget instanceof HTMLElement) || (u?.(), u = void 0, z(t, "external", n.id, n.label, n.icon, t.currentTarget, ne(n.canvasPlacement), n.onDropToDock ?? null));
407
385
  };
408
- p(() => {
386
+ U(() => {
409
387
  e.registerExternalDockDragController?.({
410
- begin: me
411
- }), K(() => e.registerExternalDockDragController?.(null));
388
+ begin: _e
389
+ }), G(() => e.registerExternalDockDragController?.(null));
412
390
  });
413
- const he = () => c()?.kind === "widget" ? c().id : null, be = () => c()?.kind === "tool" ? c().id : null, we = () => c()?.kind === "external" ? c()?.icon : void 0, M = () => e.mode === "background" || e.mode === "annotation" ? "background" : "work", te = $(() => j.find((t) => t.mode === M()) ?? j[0]), ne = $(() => M() === "background" ? Ge.map((t) => ({
391
+ const Ee = () => l()?.kind === "widget" ? l().id : null, De = () => l()?.kind === "tool" ? l().id : null, Ce = () => l()?.kind === "external" ? l()?.icon : void 0, I = () => e.mode === "background" || e.mode === "annotation" ? "background" : "work", oe = H(() => ee.find((t) => t.mode === I()) ?? ee[0]), re = H(() => I() === "background" ? ot.map((t) => ({
414
392
  id: t.tool,
415
393
  kind: "tool",
416
394
  label: t.label,
417
395
  icon: t.icon
418
- })) : [...Ve.map((t) => ({
396
+ })) : [...nt.map((t) => ({
419
397
  id: t.tool,
420
398
  kind: "tool",
421
399
  label: t.label,
@@ -425,123 +403,123 @@ function lt(e) {
425
403
  kind: "widget",
426
404
  label: t.label,
427
405
  icon: t.icon
428
- }))]), oe = $(() => M() === "background" ? [] : [...e.dockItems ?? []]), R = $(() => M() === "background" ? [] : [...e.dockActions ?? []]), ie = $(() => ne().map((t) => String(t.id))), G = () => M() !== "background", _e = (t) => !G() || e.filters[t] !== !1, Ee = (t) => {
429
- if (!G())
406
+ }))]), ie = H(() => I() === "background" ? [] : [...e.dockItems ?? []]), R = H(() => I() === "background" ? [] : [...e.dockActions ?? []]), ae = H(() => re().map((t) => String(t.id))), j = () => I() !== "background", Pe = (t) => !j() || e.filters[t] !== !1, Le = (t) => {
407
+ if (!j())
430
408
  return !1;
431
- const n = ie();
432
- return n.length > 1 && n.every((d) => e.filters[d] !== !1 == (d === t));
433
- }, U = () => u() === 0, De = () => ({
409
+ const n = ae();
410
+ return n.length > 1 && n.every((f) => e.filters[f] !== !1 == (f === t));
411
+ }, J = () => s() === 0, Se = () => ({
434
412
  scale: 1,
435
413
  y: 0,
436
414
  x: 0
437
415
  });
438
416
  return [(() => {
439
- var t = We(), n = t.firstChild, d = n.firstChild, _ = n.nextSibling;
440
- t.addEventListener("pointerleave", () => l(null));
441
- var E = D;
442
- return typeof E == "function" ? Me(E, t) : D = t, d.$$click = () => C((o) => !o), d.addEventListener("pointerleave", () => l((o) => o === 0 ? null : o)), d.addEventListener("pointerenter", () => l(0)), b(d, s(Y.span, {
417
+ var t = Qe(), n = t.firstChild, f = n.firstChild, P = n.nextSibling;
418
+ t.addEventListener("pointerleave", () => a(null));
419
+ var S = v;
420
+ return typeof S == "function" ? $e(S, t) : v = t, f.$$click = () => D((o) => !o), f.addEventListener("pointerleave", () => a((o) => o === 0 ? null : o)), f.addEventListener("pointerenter", () => a(0)), w(f, c(F.span, {
443
421
  class: "workbench-dock__tile",
444
422
  get animate() {
445
- return De();
423
+ return Se();
446
424
  },
447
425
  get transition() {
448
426
  return {
449
- duration: A.fast,
450
- easing: F.easeOut
427
+ duration: B.fast,
428
+ easing: Y.easeOut
451
429
  };
452
430
  },
453
431
  get children() {
454
432
  return (() => {
455
- const o = te().icon;
456
- return s(o, {
433
+ const o = oe().icon;
434
+ return c(o, {
457
435
  class: "workbench-dock__icon"
458
436
  });
459
437
  })();
460
438
  }
461
- }), null), b(d, s(Y.span, {
439
+ }), null), w(f, c(F.span, {
462
440
  class: "workbench-dock__tooltip",
463
441
  get animate() {
464
442
  return {
465
- opacity: U() && !r() ? 1 : 0,
466
- y: U() && !r() ? -6 : 0
443
+ opacity: J() && !i() ? 1 : 0,
444
+ y: J() && !i() ? -6 : 0
467
445
  };
468
446
  },
469
447
  get transition() {
470
448
  return {
471
- duration: A.fast,
472
- easing: F.easeOut
449
+ duration: B.fast,
450
+ easing: Y.easeOut
473
451
  };
474
452
  },
475
453
  get children() {
476
- return te().label;
454
+ return oe().label;
477
455
  }
478
- }), null), b(n, s(B, {
456
+ }), null), w(n, c(W, {
479
457
  get when() {
480
- return r();
458
+ return i();
481
459
  },
482
460
  get children() {
483
- var o = He();
484
- return b(o, s(N, {
485
- each: j,
486
- children: (v) => {
487
- const k = v.icon;
461
+ var o = je();
462
+ return w(o, c(q, {
463
+ each: ee,
464
+ children: (_) => {
465
+ const h = _.icon;
488
466
  return (() => {
489
- var a = Ke(), S = a.firstChild, m = S.nextSibling, W = m.firstChild, q = W.nextSibling;
490
- return a.$$click = () => {
491
- e.onSelectMode?.(v.mode), C(!1);
492
- }, b(S, s(k, {
467
+ var g = Ze(), L = g.firstChild, d = L.nextSibling, T = d.firstChild, m = T.nextSibling;
468
+ return g.$$click = () => {
469
+ e.onSelectMode?.(_.mode), D(!1);
470
+ }, w(L, c(h, {
493
471
  class: "workbench-dock__mode-icon"
494
- })), b(W, () => v.label), b(q, () => v.description), P((O) => {
495
- var X = M() === v.mode, I = M() === v.mode;
496
- return X !== O.e && a.classList.toggle("is-active", O.e = X), I !== O.t && y(a, "aria-checked", O.t = I), O;
472
+ })), w(T, () => _.label), w(m, () => _.description), A((x) => {
473
+ var K = I() === _.mode, y = I() === _.mode;
474
+ return K !== x.e && g.classList.toggle("is-active", x.e = K), y !== x.t && M(g, "aria-checked", x.t = y), x;
497
475
  }, {
498
476
  e: void 0,
499
477
  t: void 0
500
- }), a;
478
+ }), g;
501
479
  })();
502
480
  }
503
481
  })), o;
504
482
  }
505
- }), null), b(t, s(N, {
483
+ }), null), w(t, c(q, {
506
484
  get each() {
507
485
  return R();
508
486
  },
509
- children: (o, v) => {
510
- const k = () => v() + 1;
511
- return s(je, {
487
+ children: (o, _) => {
488
+ const h = () => _() + 1;
489
+ return c(lt, {
512
490
  action: o,
513
491
  get hoverOffset() {
514
- return f(k());
492
+ return k(h());
515
493
  },
516
- onEnter: () => l(k()),
517
- onLeave: () => l((a) => a === k() ? null : a)
494
+ onEnter: () => a(h()),
495
+ onLeave: () => a((g) => g === h() ? null : g)
518
496
  });
519
497
  }
520
- }), _), b(t, s(B, {
498
+ }), P), w(t, c(W, {
521
499
  get when() {
522
- return !!(c()?.kind === "external" && c()?.moved);
500
+ return !!(l()?.kind === "external" && l()?.moved);
523
501
  },
524
502
  get children() {
525
- var o = Re();
526
- return b(o, s(B, {
503
+ var o = Je();
504
+ return w(o, c(W, {
527
505
  get when() {
528
- return we();
506
+ return Ce();
529
507
  },
530
- children: (v) => {
531
- const k = v();
532
- return s(k, {
508
+ children: (_) => {
509
+ const h = _();
510
+ return c(h, {
533
511
  class: "workbench-dock__icon"
534
512
  });
535
513
  }
536
- })), P(() => o.classList.toggle("is-drop-allowed", !!c()?.overDock)), o;
514
+ })), A(() => o.classList.toggle("is-drop-allowed", !!l()?.overDock)), o;
537
515
  }
538
- }), _), b(t, s(N, {
516
+ }), P), w(t, c(q, {
539
517
  get each() {
540
- return oe();
518
+ return ie();
541
519
  },
542
- children: (o, v) => {
543
- const k = () => v() + R().length + 1;
544
- return s(ve, {
520
+ children: (o, _) => {
521
+ const h = () => _() + R().length + 1;
522
+ return c(me, {
545
523
  get id() {
546
524
  return o.id;
547
525
  },
@@ -558,23 +536,26 @@ function lt(e) {
558
536
  visible: !0,
559
537
  filterable: !1,
560
538
  get hoverOffset() {
561
- return f(k());
539
+ return k(h());
562
540
  },
563
541
  get isDragging() {
564
- return ce(() => c()?.kind === "host")() && c()?.id === o.id;
542
+ return Q(() => l()?.kind === "host")() && l()?.id === o.id;
543
+ },
544
+ get canvasPlacement() {
545
+ return ne(o.canvasPlacement);
565
546
  },
566
- onEnter: () => l(k()),
567
- onLeave: () => l((a) => a === k() ? null : a),
568
- onDragBegin: ee
547
+ onEnter: () => a(h()),
548
+ onLeave: () => a((g) => g === h() ? null : g),
549
+ onDragBegin: z
569
550
  });
570
551
  }
571
- }), _), b(t, s(N, {
552
+ }), P), w(t, c(q, {
572
553
  get each() {
573
- return ne();
554
+ return re();
574
555
  },
575
- children: (o, v) => {
576
- const k = () => v() + R().length + oe().length + 1;
577
- return s(ve, {
556
+ children: (o, _) => {
557
+ const h = () => _() + R().length + ie().length + 1;
558
+ return c(me, {
578
559
  get id() {
579
560
  return String(o.id);
580
561
  },
@@ -588,77 +569,91 @@ function lt(e) {
588
569
  return o.icon;
589
570
  },
590
571
  get active() {
591
- return Ee(String(o.id));
572
+ return Le(String(o.id));
592
573
  },
593
574
  get visible() {
594
- return _e(String(o.id));
575
+ return Pe(String(o.id));
595
576
  },
596
577
  get filterable() {
597
- return G();
578
+ return j();
598
579
  },
599
580
  get hoverOffset() {
600
- return f(k());
581
+ return k(h());
601
582
  },
602
583
  get isDragging() {
603
- return ce(() => o.kind === "widget")() ? he() === o.id : be() === o.id;
584
+ return Q(() => o.kind === "widget")() ? Ee() === o.id : De() === o.id;
604
585
  },
605
- onEnter: () => l(k()),
606
- onLeave: () => l((a) => a === k() ? null : a),
607
- onDragBegin: ee
586
+ get canvasPlacement() {
587
+ return Q(() => o.kind === "widget")() ? {
588
+ preview: {
589
+ kind: "widget",
590
+ id: o.id
591
+ },
592
+ onDrop: (g, L, d) => e.onCreateAt?.(o.id, g, L, d)
593
+ } : {
594
+ preview: {
595
+ kind: "tool",
596
+ id: o.id
597
+ },
598
+ onDrop: (g, L, d) => e.onCreateToolAt?.(o.id, g, L, d)
599
+ };
600
+ },
601
+ onEnter: () => a(h()),
602
+ onLeave: () => a((g) => g === h() ? null : g),
603
+ onDragBegin: z
608
604
  });
609
605
  }
610
- }), null), P((o) => {
611
- var v = !!(c()?.kind === "external" && c()?.moved), k = !!(c()?.kind === "external" && c()?.overDock), a = M() === "background", S = !!(U() || r()), m = r();
612
- return v !== o.e && t.classList.toggle("is-external-drop-target", o.e = v), k !== o.t && t.classList.toggle("is-external-drop-allowed", o.t = k), a !== o.a && d.classList.toggle("is-active", o.a = a), S !== o.o && d.classList.toggle("is-hovered", o.o = S), m !== o.i && y(d, "aria-expanded", o.i = m), o;
606
+ }), null), A((o) => {
607
+ var _ = `workbench-dock workbench-dock-material${l()?.kind === "external" && l()?.moved ? " is-external-drop-target" : ""}${l()?.kind === "external" && l()?.overDock ? " is-external-drop-allowed" : ""}`, h = I() === "background", g = !!(J() || i()), L = i();
608
+ return _ !== o.e && Me(t, o.e = _), h !== o.t && f.classList.toggle("is-active", o.t = h), g !== o.a && f.classList.toggle("is-hovered", o.a = g), L !== o.o && M(f, "aria-expanded", o.o = L), o;
613
609
  }, {
614
610
  e: void 0,
615
611
  t: void 0,
616
612
  a: void 0,
617
- o: void 0,
618
- i: void 0
613
+ o: void 0
619
614
  }), t;
620
- })(), s(B, {
615
+ })(), c(W, {
621
616
  get when() {
622
- return !!(c()?.moved && !c()?.preview);
617
+ return !!(l()?.moved && !l()?.preview);
623
618
  },
624
619
  get children() {
625
- return s(Je, {
626
- state: c
620
+ return c(ct, {
621
+ state: l
627
622
  });
628
623
  }
629
624
  })];
630
625
  }
631
- function Je(e) {
632
- const u = () => {
633
- const i = e.state();
634
- return i ? `translate3d(${i.clientX + 14}px, ${i.clientY - 56}px, 0)` : "translate3d(0px, 0px, 0)";
635
- }, l = () => e.state()?.label ?? "", c = () => e.state()?.icon;
636
- return s(Se, {
626
+ function ct(e) {
627
+ const s = () => {
628
+ const r = e.state();
629
+ return r ? `translate3d(${r.clientX + 14}px, ${r.clientY - 56}px, 0)` : "translate3d(0px, 0px, 0)";
630
+ }, a = () => e.state()?.label ?? "", l = () => e.state()?.icon;
631
+ return c(xe, {
637
632
  get children() {
638
- var i = pe(), r = i.firstChild, C = r.nextSibling, D = C.firstChild, h = D.nextSibling, g = h.firstChild, w = g.nextSibling, L = w.firstChild;
639
- return b(D, s(B, {
633
+ var r = et(), i = r.firstChild, D = i.nextSibling, v = D.firstChild, E = v.nextSibling, u = E.firstChild, b = u.nextSibling, C = b.firstChild;
634
+ return w(v, c(W, {
640
635
  get when() {
641
- return c();
636
+ return l();
642
637
  },
643
- children: (f) => {
644
- const T = f();
645
- return s(T, {
638
+ children: (k) => {
639
+ const $ = k();
640
+ return c($, {
646
641
  class: "w-4 h-4"
647
642
  });
648
643
  }
649
- })), b(g, l), b(w, s(xe, {
644
+ })), w(u, a), w(b, c(Fe, {
650
645
  class: "w-3 h-3"
651
- }), L), b(L, () => e.state()?.kind === "external" ? "Pin to Dock" : "Drag onto canvas"), P((f) => {
652
- var T = !!(e.state()?.kind === "external" && e.state()?.overDock), H = u();
653
- return T !== f.e && i.classList.toggle("is-over-dock", f.e = T), H !== f.t && Oe(i, "transform", f.t = H), f;
646
+ }), C), w(C, () => e.state()?.kind === "external" ? "Pin to Dock" : "Drag onto canvas"), A((k) => {
647
+ var $ = !!(e.state()?.kind === "external" && e.state()?.overDock), p = s();
648
+ return $ !== k.e && r.classList.toggle("is-over-dock", k.e = $), p !== k.t && Xe(r, "transform", k.t = p), k;
654
649
  }, {
655
650
  e: void 0,
656
651
  t: void 0
657
- }), i;
652
+ }), r;
658
653
  }
659
654
  });
660
655
  }
661
- ye(["pointerdown", "click"]);
656
+ Ae(["pointerdown", "click"]);
662
657
  export {
663
- lt as WorkbenchDock
658
+ Et as WorkbenchDock
664
659
  };