@floegence/floe-webapp-core 0.40.14 → 0.40.16

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