@floegence/floe-webapp-core 0.40.14 → 0.40.15

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