@floegence/floe-webapp-core 0.41.4 → 0.42.1

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 h, createComponent as c, effect as Y, setAttribute as y, memo as Z, className as Xe, template as X, addEventListener as ke, Portal as Ae, setStyleProperty as Ye, use as $e, delegateEvents as Fe } from "solid-js/web";
2
+ import { createSignal as ee, onCleanup as U, createEffect as q, createMemo as H, Show as W, For as z } from "solid-js";
3
+ import { Motion as $ } 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 R } from "../../utils/animations.js";
5
+ import { Plus as Re } from "../icons/index.js";
6
+ import { startHotInteraction as pe } 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 Ne } from "./widgets/widgetRegistry.js";
11
+ import { WORKBENCH_EDGE_AUTO_PAN_FRAME_SELECTOR as be, frameFromElement as _e, createWorkbenchEdgeAutoPanController as Ke } from "./workbenchEdgeAutoPan.js";
12
+ import { DockLayoutDashboard as Ve, DockLayers as Ge, DockRegion as Ue, DockText as qe, DockMessageSquare as ze } from "../icons/DockIcons.js";
13
+ var je = /* @__PURE__ */ X("<button type=button class=workbench-dock__item>"), Je = /* @__PURE__ */ X('<button type=button class="workbench-dock__item workbench-dock__action">'), Qe = /* @__PURE__ */ X('<div class=workbench-dock__mode-popover role=menu aria-label="Canvas mode">'), Ze = /* @__PURE__ */ X("<span class=workbench-dock__external-placeholder aria-hidden=true>"), et = /* @__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>'), tt = /* @__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>"), nt = /* @__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 fe = 5, ot = 1e3, rt = ".workbench-dock", te = [{
12
15
  mode: "work",
13
16
  label: "Work Mode",
14
17
  description: "Operate windows and sticky notes",
15
- icon: Xe
18
+ icon: Ve
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: Ge
24
+ }], it = [{
22
25
  tool: "sticky-note",
23
26
  label: "Sticky",
24
- icon: Ae
25
- }], Ge = [{
27
+ icon: ze
28
+ }], at = [{
26
29
  tool: "background-region",
27
30
  label: "Region",
28
- icon: Ye
31
+ icon: Ue
29
32
  }, {
30
33
  tool: "text",
31
34
  label: "Text",
32
- icon: Fe
35
+ icon: qe
33
36
  }];
34
- function Ue() {
35
- const e = document.querySelector(ke);
36
- return e instanceof HTMLElement ? fe(e) : null;
37
+ function lt(e) {
38
+ const a = e?.closest(".workbench-surface")?.querySelector(be);
39
+ return a instanceof HTMLElement ? _e(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 ne(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 ct(e, s, a) {
45
+ return a ? ne(e, s, a) : !1;
43
46
  }
44
- function ge(e, u, l) {
45
- return Math.min(l, Math.max(u, e));
47
+ function me(e, s, a) {
48
+ return Math.min(a, Math.max(s, e));
46
49
  }
47
- function ze(e, u, l, c, i) {
50
+ function st(e, s, a, l, r) {
48
51
  if (!e) return !1;
49
- if (Q(u, l, e) || Q(c, i, e))
52
+ if (ne(s, a, e) || ne(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 g = (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 g(-i, s - e.left) && g(i, e.right - s) && g(-D, a - e.top) && g(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 we(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(rt) === a;
64
67
  }
65
- function ve(e) {
66
- const u = () => e.hoverOffset === -1 ? {
68
+ function he(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 = je();
90
+ return r.$$pointerdown = l, r.addEventListener("pointerleave", () => e.onLeave()), r.addEventListener("pointerenter", () => e.onEnter()), h(r, c($.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,
97
+ duration: R.fast,
95
98
  easing: F.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), h(r, c($.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,
119
+ duration: R.fast,
117
120
  easing: F.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), Y((i) => {
127
+ var D = e.kind === "host" ? e.id : void 0, v = !!e.active, E = !!(e.filterable && !e.visible), g = !!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 && y(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), g !== i.o && r.classList.toggle("is-hovered", i.o = g), b !== i.i && r.classList.toggle("is-source-dragging", i.i = b), C !== i.n && y(r, "aria-label", i.n = C), k !== i.s && y(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 dt(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 = Je();
148
+ return r.$$click = (i) => e.action.onActivate(i.currentTarget), r.addEventListener("dragstart", (i) => i.preventDefault()), ke(r, "pointerleave", e.onLeave), ke(r, "pointerenter", e.onEnter), y(r, "draggable", !1), h(r, c($.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,
155
+ duration: R.fast,
153
156
  easing: F.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), h(r, c($.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,
174
+ duration: R.fast,
172
175
  easing: F.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), Y((i) => {
182
+ var D = e.action.id, v = !!e.action.active, E = !!s(), g = e.action.label, b = e.action.active;
183
+ return D !== i.e && y(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), g !== i.o && y(r, "aria-label", i.o = g), b !== i.i && y(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 Pt(e) {
194
+ const [s, a] = ee(null), [l, r] = ee(null), [i, D] = ee(!1);
195
+ let v, E, g, b, C = null;
196
+ U(() => {
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, g?.clear(), g = void 0, l()?.stopInteraction(), e.onDragPreviewChange?.(null), e.registerExternalDockDragController?.(null);
201
+ }), q(() => {
202
+ e.onDragPreviewChange?.(l()?.preview ?? null);
203
+ }), q(() => {
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), U(() => window.removeEventListener("keydown", t, !0));
211
+ }), q(() => {
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), U(() => {
216
219
  window.removeEventListener("pointerdown", t, !0), window.removeEventListener("keydown", n, !0);
217
220
  });
218
221
  });
219
- const f = (t) => {
220
- const n = u();
221
- 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({
222
+ const k = (t) => {
223
+ const n = s();
224
+ return n === null || n <= K().length ? 0 : n === t ? -1 : n === t + 1 ? -2 : n === t - 1 ? 1 : 0;
225
+ }, A = () => {
226
+ b?.stop(), b = void 0, C = null;
227
+ }, N = () => {
228
+ !e.viewport || !e.onViewportCommit || (C = e.viewport, b?.stop(), b = Ke({
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(be);
231
+ return n instanceof HTMLElement ? _e(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 && !we(t.clientX, t.clientY, v));
238
241
  }
239
242
  }));
240
- }, Z = (t) => {
241
- const n = c();
243
+ }, Ee = (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(), A(), r(null), E = void 0, n.kind === "external" && n.moved && g?.expire(), 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
+ O() !== "background" && e.onSoloFilter(String(n.id), le());
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
+ }, j = (t, n, f, P, S, o, _, w) => {
280
+ t.preventDefault(), E?.stop({
286
281
  reason: "manual_stop",
287
282
  commit: !1
288
- }), H();
289
- const v = Ue();
290
- i({
283
+ }), N();
284
+ const u = lt(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,106 @@ function lt(e) {
300
295
  moved: !1,
301
296
  overCanvas: !1,
302
297
  hasEnteredCanvas: !1,
303
- canvasFrame: v,
298
+ canvasFrame: u,
304
299
  preview: null,
305
- stopInteraction: de({
300
+ canvasPlacement: _,
301
+ dockDrop: w,
302
+ stopInteraction: pe({
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 M = d.clientX - m.startClientX, V = d.clientY - m.startClientY, x = m.moved || Math.abs(M) > fe || Math.abs(V) > fe;
314
+ if (m.kind === "external" && x && !m.moved) {
315
+ let p;
316
+ const B = () => {
317
+ p !== void 0 && window.clearTimeout(p), m.trigger.removeEventListener("click", ue, !0), window.removeEventListener("pointerdown", ge, !0), g?.clear === B && (g = void 0);
318
+ }, ue = (ve) => {
319
+ ve.preventDefault(), ve.stopImmediatePropagation(), B();
320
+ }, ge = () => B(), Me = () => {
321
+ p !== void 0 && window.clearTimeout(p), p = window.setTimeout(B, ot);
322
+ };
323
+ m.trigger.addEventListener("click", ue, !0), window.addEventListener("pointerdown", ge, !0), g = {
324
+ clear: B,
325
+ expire: Me
326
+ };
327
+ }
328
+ const G = we(d.clientX, d.clientY, v), I = m.canvasFrame, ce = x && ct(d.clientX, d.clientY, I), se = ce && !G, Te = x && !G && st(I, m.clientX, m.clientY, d.clientX, d.clientY), de = m.hasEnteredCanvas || ce || Te;
329
+ T = x && de && !G;
330
+ const xe = I ? me(d.clientX, I.left, I.right) : d.clientX, ye = I ? me(d.clientY, I.top, I.bottom) : d.clientY;
319
331
  return {
320
332
  ...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,
333
+ clientX: d.clientX,
334
+ clientY: d.clientY,
335
+ moved: x,
336
+ overDock: G,
337
+ overCanvas: se,
338
+ hasEnteredCanvas: de,
339
+ preview: x && I && m.canvasPlacement?.preview ? {
340
+ kind: m.canvasPlacement.preview.kind,
341
+ id: m.canvasPlacement.preview.id,
329
342
  label: m.label,
330
- clientX: Le,
331
- clientY: Ie,
332
- dropAllowed: ae,
343
+ clientX: xe,
344
+ clientY: ye,
345
+ dropAllowed: se,
333
346
  canvasFrame: I
334
347
  } : null
335
348
  };
336
- }), S && w?.updatePointer(a.clientX, a.clientY);
349
+ }), T && b?.updatePointer(d.clientX, d.clientY);
337
350
  };
338
- h = ue({
351
+ E = Be({
339
352
  pointerEvent: t,
340
353
  captureEl: t.currentTarget,
341
- onMove: k,
342
- 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
- },
354
+ onMove: L,
403
355
  onEnd: ({
404
- commit: _
405
- }) => Z(_)
356
+ commit: d,
357
+ snapshot: T
358
+ }) => {
359
+ L({
360
+ pointerId: T.pointerId,
361
+ clientX: T.latestClientX,
362
+ clientY: T.latestClientY
363
+ }), Ee(d);
364
+ }
406
365
  });
366
+ }, oe = (t) => t ? {
367
+ preview: {
368
+ kind: "widget",
369
+ id: t.widgetType
370
+ },
371
+ onDrop: (n, f, P) => {
372
+ if (!P?.worldPoint) return;
373
+ const S = Ne(t.widgetType, e.widgetDefinitions);
374
+ t.onDrop({
375
+ widgetType: t.widgetType,
376
+ centerWorld: P.worldPoint,
377
+ frame: We(S, {
378
+ anchor: "center",
379
+ worldX: P.worldPoint.worldX,
380
+ worldY: P.worldPoint.worldY
381
+ })
382
+ });
383
+ }
384
+ } : null, De = (t, n) => {
385
+ t.button !== 0 || !(t.currentTarget instanceof HTMLElement) || (g?.clear(), g = void 0, j(t, "external", n.id, n.label, n.icon, t.currentTarget, oe(n.canvasPlacement), n.onDropToDock ?? null));
407
386
  };
408
- p(() => {
387
+ q(() => {
409
388
  e.registerExternalDockDragController?.({
410
- begin: me
411
- }), K(() => e.registerExternalDockDragController?.(null));
389
+ begin: De
390
+ }), U(() => e.registerExternalDockDragController?.(null));
412
391
  });
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) => ({
392
+ const Ce = () => l()?.kind === "widget" ? l().id : null, Pe = () => l()?.kind === "tool" ? l().id : null, Le = () => l()?.kind === "external" ? l()?.icon : void 0, O = () => e.mode === "background" || e.mode === "annotation" ? "background" : "work", re = H(() => te.find((t) => t.mode === O()) ?? te[0]), ie = H(() => O() === "background" ? at.map((t) => ({
414
393
  id: t.tool,
415
394
  kind: "tool",
416
395
  label: t.label,
417
396
  icon: t.icon
418
- })) : [...Ve.map((t) => ({
397
+ })) : [...it.map((t) => ({
419
398
  id: t.tool,
420
399
  kind: "tool",
421
400
  label: t.label,
@@ -425,123 +404,123 @@ function lt(e) {
425
404
  kind: "widget",
426
405
  label: t.label,
427
406
  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())
407
+ }))]), ae = H(() => O() === "background" ? [] : [...e.dockItems ?? []]), K = H(() => O() === "background" ? [] : [...e.dockActions ?? []]), le = H(() => ie().map((t) => String(t.id))), J = () => O() !== "background", Se = (t) => !J() || e.filters[t] !== !1, Ie = (t) => {
408
+ if (!J())
430
409
  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 = () => ({
410
+ const n = le();
411
+ return n.length > 1 && n.every((f) => e.filters[f] !== !1 == (f === t));
412
+ }, Q = () => s() === 0, Oe = () => ({
434
413
  scale: 1,
435
414
  y: 0,
436
415
  x: 0
437
416
  });
438
417
  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, {
418
+ var t = et(), n = t.firstChild, f = n.firstChild, P = n.nextSibling;
419
+ t.addEventListener("pointerleave", () => a(null));
420
+ var S = v;
421
+ 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)), h(f, c($.span, {
443
422
  class: "workbench-dock__tile",
444
423
  get animate() {
445
- return De();
424
+ return Oe();
446
425
  },
447
426
  get transition() {
448
427
  return {
449
- duration: A.fast,
428
+ duration: R.fast,
450
429
  easing: F.easeOut
451
430
  };
452
431
  },
453
432
  get children() {
454
433
  return (() => {
455
- const o = te().icon;
456
- return s(o, {
434
+ const o = re().icon;
435
+ return c(o, {
457
436
  class: "workbench-dock__icon"
458
437
  });
459
438
  })();
460
439
  }
461
- }), null), b(d, s(Y.span, {
440
+ }), null), h(f, c($.span, {
462
441
  class: "workbench-dock__tooltip",
463
442
  get animate() {
464
443
  return {
465
- opacity: U() && !r() ? 1 : 0,
466
- y: U() && !r() ? -6 : 0
444
+ opacity: Q() && !i() ? 1 : 0,
445
+ y: Q() && !i() ? -6 : 0
467
446
  };
468
447
  },
469
448
  get transition() {
470
449
  return {
471
- duration: A.fast,
450
+ duration: R.fast,
472
451
  easing: F.easeOut
473
452
  };
474
453
  },
475
454
  get children() {
476
- return te().label;
455
+ return re().label;
477
456
  }
478
- }), null), b(n, s(B, {
457
+ }), null), h(n, c(W, {
479
458
  get when() {
480
- return r();
459
+ return i();
481
460
  },
482
461
  get children() {
483
- var o = He();
484
- return b(o, s(N, {
485
- each: j,
486
- children: (v) => {
487
- const k = v.icon;
462
+ var o = Qe();
463
+ return h(o, c(z, {
464
+ each: te,
465
+ children: (_) => {
466
+ const w = _.icon;
488
467
  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, {
468
+ var u = tt(), L = u.firstChild, d = L.nextSibling, T = d.firstChild, m = T.nextSibling;
469
+ return u.$$click = () => {
470
+ e.onSelectMode?.(_.mode), D(!1);
471
+ }, h(L, c(w, {
493
472
  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;
473
+ })), h(T, () => _.label), h(m, () => _.description), Y((M) => {
474
+ var V = O() === _.mode, x = O() === _.mode;
475
+ return V !== M.e && u.classList.toggle("is-active", M.e = V), x !== M.t && y(u, "aria-checked", M.t = x), M;
497
476
  }, {
498
477
  e: void 0,
499
478
  t: void 0
500
- }), a;
479
+ }), u;
501
480
  })();
502
481
  }
503
482
  })), o;
504
483
  }
505
- }), null), b(t, s(N, {
484
+ }), null), h(t, c(z, {
506
485
  get each() {
507
- return R();
486
+ return K();
508
487
  },
509
- children: (o, v) => {
510
- const k = () => v() + 1;
511
- return s(je, {
488
+ children: (o, _) => {
489
+ const w = () => _() + 1;
490
+ return c(dt, {
512
491
  action: o,
513
492
  get hoverOffset() {
514
- return f(k());
493
+ return k(w());
515
494
  },
516
- onEnter: () => l(k()),
517
- onLeave: () => l((a) => a === k() ? null : a)
495
+ onEnter: () => a(w()),
496
+ onLeave: () => a((u) => u === w() ? null : u)
518
497
  });
519
498
  }
520
- }), _), b(t, s(B, {
499
+ }), P), h(t, c(W, {
521
500
  get when() {
522
- return !!(c()?.kind === "external" && c()?.moved);
501
+ return !!(l()?.kind === "external" && l()?.moved);
523
502
  },
524
503
  get children() {
525
- var o = Re();
526
- return b(o, s(B, {
504
+ var o = Ze();
505
+ return h(o, c(W, {
527
506
  get when() {
528
- return we();
507
+ return Le();
529
508
  },
530
- children: (v) => {
531
- const k = v();
532
- return s(k, {
509
+ children: (_) => {
510
+ const w = _();
511
+ return c(w, {
533
512
  class: "workbench-dock__icon"
534
513
  });
535
514
  }
536
- })), P(() => o.classList.toggle("is-drop-allowed", !!c()?.overDock)), o;
515
+ })), Y(() => o.classList.toggle("is-drop-allowed", !!l()?.overDock)), o;
537
516
  }
538
- }), _), b(t, s(N, {
517
+ }), P), h(t, c(z, {
539
518
  get each() {
540
- return oe();
519
+ return ae();
541
520
  },
542
- children: (o, v) => {
543
- const k = () => v() + R().length + 1;
544
- return s(ve, {
521
+ children: (o, _) => {
522
+ const w = () => _() + K().length + 1;
523
+ return c(he, {
545
524
  get id() {
546
525
  return o.id;
547
526
  },
@@ -558,23 +537,26 @@ function lt(e) {
558
537
  visible: !0,
559
538
  filterable: !1,
560
539
  get hoverOffset() {
561
- return f(k());
540
+ return k(w());
562
541
  },
563
542
  get isDragging() {
564
- return ce(() => c()?.kind === "host")() && c()?.id === o.id;
543
+ return Z(() => l()?.kind === "host")() && l()?.id === o.id;
565
544
  },
566
- onEnter: () => l(k()),
567
- onLeave: () => l((a) => a === k() ? null : a),
568
- onDragBegin: ee
545
+ get canvasPlacement() {
546
+ return oe(o.canvasPlacement);
547
+ },
548
+ onEnter: () => a(w()),
549
+ onLeave: () => a((u) => u === w() ? null : u),
550
+ onDragBegin: j
569
551
  });
570
552
  }
571
- }), _), b(t, s(N, {
553
+ }), P), h(t, c(z, {
572
554
  get each() {
573
- return ne();
555
+ return ie();
574
556
  },
575
- children: (o, v) => {
576
- const k = () => v() + R().length + oe().length + 1;
577
- return s(ve, {
557
+ children: (o, _) => {
558
+ const w = () => _() + K().length + ae().length + 1;
559
+ return c(he, {
578
560
  get id() {
579
561
  return String(o.id);
580
562
  },
@@ -588,77 +570,91 @@ function lt(e) {
588
570
  return o.icon;
589
571
  },
590
572
  get active() {
591
- return Ee(String(o.id));
573
+ return Ie(String(o.id));
592
574
  },
593
575
  get visible() {
594
- return _e(String(o.id));
576
+ return Se(String(o.id));
595
577
  },
596
578
  get filterable() {
597
- return G();
579
+ return J();
598
580
  },
599
581
  get hoverOffset() {
600
- return f(k());
582
+ return k(w());
601
583
  },
602
584
  get isDragging() {
603
- return ce(() => o.kind === "widget")() ? he() === o.id : be() === o.id;
585
+ return Z(() => o.kind === "widget")() ? Ce() === o.id : Pe() === o.id;
586
+ },
587
+ get canvasPlacement() {
588
+ return Z(() => o.kind === "widget")() ? {
589
+ preview: {
590
+ kind: "widget",
591
+ id: o.id
592
+ },
593
+ onDrop: (u, L, d) => e.onCreateAt?.(o.id, u, L, d)
594
+ } : {
595
+ preview: {
596
+ kind: "tool",
597
+ id: o.id
598
+ },
599
+ onDrop: (u, L, d) => e.onCreateToolAt?.(o.id, u, L, d)
600
+ };
604
601
  },
605
- onEnter: () => l(k()),
606
- onLeave: () => l((a) => a === k() ? null : a),
607
- onDragBegin: ee
602
+ onEnter: () => a(w()),
603
+ onLeave: () => a((u) => u === w() ? null : u),
604
+ onDragBegin: j
608
605
  });
609
606
  }
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;
607
+ }), null), Y((o) => {
608
+ var _ = `workbench-dock workbench-dock-material${l()?.kind === "external" && l()?.moved ? " is-external-drop-target" : ""}${l()?.kind === "external" && l()?.overDock ? " is-external-drop-allowed" : ""}`, w = O() === "background", u = !!(Q() || i()), L = i();
609
+ return _ !== o.e && Xe(t, o.e = _), w !== o.t && f.classList.toggle("is-active", o.t = w), u !== o.a && f.classList.toggle("is-hovered", o.a = u), L !== o.o && y(f, "aria-expanded", o.o = L), o;
613
610
  }, {
614
611
  e: void 0,
615
612
  t: void 0,
616
613
  a: void 0,
617
- o: void 0,
618
- i: void 0
614
+ o: void 0
619
615
  }), t;
620
- })(), s(B, {
616
+ })(), c(W, {
621
617
  get when() {
622
- return !!(c()?.moved && !c()?.preview);
618
+ return !!(l()?.moved && !l()?.preview);
623
619
  },
624
620
  get children() {
625
- return s(Je, {
626
- state: c
621
+ return c(ut, {
622
+ state: l
627
623
  });
628
624
  }
629
625
  })];
630
626
  }
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, {
627
+ function ut(e) {
628
+ const s = () => {
629
+ const r = e.state();
630
+ return r ? `translate3d(${r.clientX + 14}px, ${r.clientY - 56}px, 0)` : "translate3d(0px, 0px, 0)";
631
+ }, a = () => e.state()?.label ?? "", l = () => e.state()?.icon;
632
+ return c(Ae, {
637
633
  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, {
634
+ var r = nt(), i = r.firstChild, D = i.nextSibling, v = D.firstChild, E = v.nextSibling, g = E.firstChild, b = g.nextSibling, C = b.firstChild;
635
+ return h(v, c(W, {
640
636
  get when() {
641
- return c();
637
+ return l();
642
638
  },
643
- children: (f) => {
644
- const T = f();
645
- return s(T, {
639
+ children: (k) => {
640
+ const A = k();
641
+ return c(A, {
646
642
  class: "w-4 h-4"
647
643
  });
648
644
  }
649
- })), b(g, l), b(w, s(xe, {
645
+ })), h(g, a), h(b, c(Re, {
650
646
  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;
647
+ }), C), h(C, () => e.state()?.kind === "external" ? "Pin to Dock" : "Drag onto canvas"), Y((k) => {
648
+ var A = !!(e.state()?.kind === "external" && e.state()?.overDock), N = s();
649
+ return A !== k.e && r.classList.toggle("is-over-dock", k.e = A), N !== k.t && Ye(r, "transform", k.t = N), k;
654
650
  }, {
655
651
  e: void 0,
656
652
  t: void 0
657
- }), i;
653
+ }), r;
658
654
  }
659
655
  });
660
656
  }
661
- ye(["pointerdown", "click"]);
657
+ Fe(["pointerdown", "click"]);
662
658
  export {
663
- lt as WorkbenchDock
659
+ Pt as WorkbenchDock
664
660
  };