@floegence/floe-webapp-core 0.35.49 → 0.35.50

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.
@@ -9,6 +9,7 @@ export type BuiltinContextMenuAction = Exclude<ContextMenuActionType, 'custom'>;
9
9
  * - Dynamic function: decide which action types to hide based on the target items.
10
10
  */
11
11
  export type HideItemsValue = BuiltinContextMenuAction[] | ((targetItems: FileItem[]) => BuiltinContextMenuAction[]);
12
+ type ContextMenuDismissWindow = Pick<Window, 'addEventListener' | 'removeEventListener'>;
12
13
  export interface FileContextMenuProps {
13
14
  /** Custom menu items to add (will be merged with defaults) */
14
15
  customItems?: ContextMenuItem[];
@@ -30,7 +31,13 @@ export interface FileContextMenuProps {
30
31
  }
31
32
  export declare function createDefaultContextMenuItems(callbacks?: ContextMenuCallbacks): ContextMenuItem[];
32
33
  export declare function dispatchContextMenuAction(item: ContextMenuItem, items: FileItem[], callbacks?: ContextMenuCallbacks, event?: ContextMenuEvent): void;
34
+ export declare function installContextMenuDismissListeners(options: {
35
+ ownerWindow: ContextMenuDismissWindow;
36
+ contextMenuId: string;
37
+ onDismiss: () => void;
38
+ }): () => void;
33
39
  /**
34
40
  * Context menu for file browser items
35
41
  */
36
42
  export declare function FileContextMenu(props: FileContextMenuProps): import("solid-js").JSX.Element;
43
+ export {};
@@ -1,44 +1,44 @@
1
- import { createComponent as c, Portal as z, setAttribute as g, insert as y, effect as w, className as R, setStyleProperty as _, template as h, Dynamic as J, memo as V, use as E, delegateEvents as Q } from "solid-js/web";
2
- import { createSignal as B, createEffect as q, onCleanup as O, Show as $, For as W } from "solid-js";
1
+ import { createComponent as c, Portal as W, setAttribute as x, insert as C, effect as b, className as R, setStyleProperty as P, template as p, Dynamic as J, memo as V, use as L, delegateEvents as Q } from "solid-js/web";
2
+ import { createSignal as B, createEffect as z, onCleanup as Z, Show as $, For as O } from "solid-js";
3
3
  import { cn as T } from "../../utils/cn.js";
4
4
  import { deferAfterPaint as X } from "../../utils/defer.js";
5
5
  import { ChevronRight as Y } from "../icons/index.js";
6
- import { focusMenuItem as P, moveMenuFocus as Z, calculateSubmenuPosition as ee } from "../ui/menuUtils.js";
6
+ import { focusMenuItem as _, moveMenuFocus as q, calculateSubmenuPosition as ee } from "../ui/menuUtils.js";
7
7
  import { useFileBrowser as te } from "./FileBrowserContext.js";
8
- var ne = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=14 x=8 y=8 rx=2 ry=2></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2">'), oe = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=16 x=5 y=4 rx=2></rect><path d="M9 4.5h6a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v.5a1 1 0 0 0 1 1Z">'), re = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3Z">'), ie = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"></path><path d="M8 10v4"></path><path d="M12 10v2"></path><path d="M16 10v6">'), ae = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M12 3v18"></path><path d="m8 7-4 4 4 4"></path><path d="m16 7 4 4-4 4">'), se = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2">'), ue = /* @__PURE__ */ h('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"></path><path d="m15 5 4 4">'), le = /* @__PURE__ */ h('<span class="text-[10px] text-muted-foreground opacity-60">'), ce = /* @__PURE__ */ h("<div role=menu>"), de = /* @__PURE__ */ h('<div class=relative><button type=button role=menuitem><span class="flex-1 text-left">'), K = /* @__PURE__ */ h('<div class="my-1 h-px bg-border"role=separator>'), me = /* @__PURE__ */ h("<div role=menu aria-orientation=vertical>");
8
+ var ne = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=14 x=8 y=8 rx=2 ry=2></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2">'), re = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=16 x=5 y=4 rx=2></rect><path d="M9 4.5h6a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v.5a1 1 0 0 0 1 1Z">'), oe = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3Z">'), ie = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"></path><path d="M8 10v4"></path><path d="M12 10v2"></path><path d="M16 10v6">'), se = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M12 3v18"></path><path d="m8 7-4 4 4 4"></path><path d="m16 7 4 4-4 4">'), ae = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2">'), ue = /* @__PURE__ */ p('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"></path><path d="m15 5 4 4">'), le = /* @__PURE__ */ p('<span class="text-[10px] text-muted-foreground opacity-60">'), ce = /* @__PURE__ */ p("<div role=menu>"), de = /* @__PURE__ */ p('<div class=relative><button type=button role=menuitem><span class="flex-1 text-left">'), K = /* @__PURE__ */ p('<div class="my-1 h-px bg-border"role=separator>'), me = /* @__PURE__ */ p("<div role=menu aria-orientation=vertical>");
9
9
  const he = (e) => (() => {
10
10
  var t = ne();
11
- return w(() => g(t, "class", e.class)), t;
11
+ return b(() => x(t, "class", e.class)), t;
12
12
  })(), fe = (e) => (() => {
13
- var t = oe();
14
- return w(() => g(t, "class", e.class)), t;
15
- })(), ve = (e) => (() => {
16
13
  var t = re();
17
- return w(() => g(t, "class", e.class)), t;
14
+ return b(() => x(t, "class", e.class)), t;
15
+ })(), ve = (e) => (() => {
16
+ var t = oe();
17
+ return b(() => x(t, "class", e.class)), t;
18
18
  })(), ge = (e) => (() => {
19
19
  var t = ie();
20
- return w(() => g(t, "class", e.class)), t;
21
- })(), we = (e) => (() => {
22
- var t = ae();
23
- return w(() => g(t, "class", e.class)), t;
20
+ return b(() => x(t, "class", e.class)), t;
24
21
  })(), pe = (e) => (() => {
25
22
  var t = se();
26
- return w(() => g(t, "class", e.class)), t;
23
+ return b(() => x(t, "class", e.class)), t;
24
+ })(), we = (e) => (() => {
25
+ var t = ae();
26
+ return b(() => x(t, "class", e.class)), t;
27
27
  })(), xe = (e) => (() => {
28
28
  var t = ue();
29
- return w(() => g(t, "class", e.class)), t;
29
+ return b(() => x(t, "class", e.class)), t;
30
30
  })();
31
31
  let ye = 0;
32
32
  function be(e) {
33
- const t = !!e?.onAskAgent, a = !!e?.onCopyName;
33
+ const t = !!e?.onAskAgent, o = !!e?.onCopyName;
34
34
  return [{
35
35
  id: "duplicate",
36
36
  label: "Duplicate",
37
37
  type: "duplicate",
38
38
  icon: he,
39
39
  shortcut: "Cmd+D",
40
- separator: !a && !t
41
- }, ...a ? [{
40
+ separator: !o && !t
41
+ }, ...o ? [{
42
42
  id: "copy-name",
43
43
  label: "Copy Name",
44
44
  type: "copy-name",
@@ -59,7 +59,7 @@ function be(e) {
59
59
  id: "move-to",
60
60
  label: "Move to...",
61
61
  type: "move-to",
62
- icon: we,
62
+ icon: pe,
63
63
  separator: !0
64
64
  }, {
65
65
  id: "rename",
@@ -71,52 +71,52 @@ function be(e) {
71
71
  id: "delete",
72
72
  label: "Delete",
73
73
  type: "delete",
74
- icon: pe,
74
+ icon: we,
75
75
  shortcut: "Del"
76
76
  }];
77
77
  }
78
- function ke(e, t, a, f) {
78
+ function ke(e, t, o, a) {
79
79
  switch (e.type) {
80
80
  case "duplicate":
81
- a?.onDuplicate?.(t);
81
+ o?.onDuplicate?.(t);
82
82
  break;
83
83
  case "copy-name":
84
- a?.onCopyName?.(t);
84
+ o?.onCopyName?.(t);
85
85
  break;
86
86
  case "ask-agent":
87
- a?.onAskAgent?.(t);
87
+ o?.onAskAgent?.(t);
88
88
  break;
89
89
  case "copy-to":
90
- a?.onCopyTo?.(t);
90
+ o?.onCopyTo?.(t);
91
91
  break;
92
92
  case "move-to":
93
- a?.onMoveTo?.(t);
93
+ o?.onMoveTo?.(t);
94
94
  break;
95
95
  case "delete":
96
- a?.onDelete?.(t);
96
+ o?.onDelete?.(t);
97
97
  break;
98
98
  case "rename":
99
- t.length === 1 && a?.onRename?.(t[0]);
99
+ t.length === 1 && o?.onRename?.(t[0]);
100
100
  break;
101
101
  case "custom":
102
- e.onAction?.(t, f);
102
+ e.onAction?.(t, a);
103
103
  break;
104
104
  }
105
105
  }
106
106
  function U(e, t) {
107
- const a = e.target, f = a?.closest('[role="menu"]'), x = a?.closest('[role="menuitem"]');
107
+ const o = e.target, a = o?.closest('[role="menu"]'), m = o?.closest('[role="menuitem"]');
108
108
  switch (e.key) {
109
109
  case "ArrowDown":
110
- e.preventDefault(), Z(f, x, 1);
110
+ e.preventDefault(), q(a, m, 1);
111
111
  return;
112
112
  case "ArrowUp":
113
- e.preventDefault(), Z(f, x, -1);
113
+ e.preventDefault(), q(a, m, -1);
114
114
  return;
115
115
  case "Home":
116
- e.preventDefault(), P(f, "first");
116
+ e.preventDefault(), _(a, "first");
117
117
  return;
118
118
  case "End":
119
- e.preventDefault(), P(f, "last");
119
+ e.preventDefault(), _(a, "last");
120
120
  return;
121
121
  case "ArrowLeft":
122
122
  if (!t.onCloseSubmenu) return;
@@ -136,92 +136,120 @@ function U(e, t) {
136
136
  return;
137
137
  }
138
138
  }
139
+ function Ce(e, t) {
140
+ return !e || typeof e != "object" ? !1 : ("dataset" in e ? e.dataset : void 0)?.floeContextMenu === t;
141
+ }
142
+ function Me(e, t) {
143
+ if (typeof e.composedPath == "function") {
144
+ const a = e.composedPath();
145
+ for (const m of a)
146
+ if (Ce(m, t)) return !0;
147
+ }
148
+ const o = e.target;
149
+ return typeof Element < "u" && o instanceof Element ? !!o.closest(`[data-floe-context-menu="${t}"]`) : !1;
150
+ }
151
+ function $e(e) {
152
+ const {
153
+ ownerWindow: t,
154
+ contextMenuId: o,
155
+ onDismiss: a
156
+ } = e, m = (w) => {
157
+ Me(w, o) || a();
158
+ }, y = (w) => {
159
+ w.key === "Escape" && a();
160
+ }, v = () => {
161
+ a();
162
+ };
163
+ return t.addEventListener("pointerdown", m, !0), t.addEventListener("keydown", y, !0), t.addEventListener("resize", v), t.addEventListener("scroll", v, !0), () => {
164
+ t.removeEventListener("pointerdown", m, !0), t.removeEventListener("keydown", y, !0), t.removeEventListener("resize", v), t.removeEventListener("scroll", v, !0);
165
+ };
166
+ }
139
167
  function G(e) {
140
- const [t, a] = B(!1), [f, x] = B({
168
+ const [t, o] = B(!1), [a, m] = B({
141
169
  x: -9999,
142
170
  y: -9999
143
171
  });
144
- let b, k, C, M;
145
- const d = () => (e.item.children?.length ?? 0) > 0, L = () => {
146
- if (!b || !C) return;
147
- const s = b.getBoundingClientRect(), u = C.getBoundingClientRect(), A = ee(s, u);
148
- x(A);
149
- }, p = () => {
172
+ let y, v, w, M;
173
+ const h = () => (e.item.children?.length ?? 0) > 0, S = () => {
174
+ if (!y || !w) return;
175
+ const u = y.getBoundingClientRect(), d = w.getBoundingClientRect(), A = ee(u, d);
176
+ m(A);
177
+ }, i = () => {
150
178
  M && (clearTimeout(M), M = void 0);
151
- }, r = (s = "first") => {
152
- !d() || e.item.disabled || (p(), a(!0), requestAnimationFrame(() => {
153
- L(), P(C, s);
179
+ }, n = (u = "first") => {
180
+ !h() || e.item.disabled || (i(), o(!0), requestAnimationFrame(() => {
181
+ S(), _(w, u);
154
182
  }));
155
- }, n = () => {
156
- p(), a(!1), requestAnimationFrame(() => k?.focus());
157
- }, m = () => {
158
- !d() || e.item.disabled || (p(), M = setTimeout(() => {
159
- r("first");
183
+ }, f = () => {
184
+ i(), o(!1), requestAnimationFrame(() => v?.focus());
185
+ }, s = () => {
186
+ !h() || e.item.disabled || (i(), M = setTimeout(() => {
187
+ n("first");
160
188
  }, 100));
161
- }, i = () => {
162
- d() && (p(), M = setTimeout(() => {
163
- a(!1);
189
+ }, g = () => {
190
+ h() && (i(), M = setTimeout(() => {
191
+ o(!1);
164
192
  }, 150));
165
- }, v = (s) => {
193
+ }, k = (u) => {
166
194
  if (!e.item.disabled) {
167
- if (d()) {
168
- s.preventDefault(), s.stopPropagation(), t() ? n() : r("first");
195
+ if (h()) {
196
+ u.preventDefault(), u.stopPropagation(), t() ? f() : n("first");
169
197
  return;
170
198
  }
171
199
  e.onSelect(e.item, e.menu);
172
200
  }
173
201
  };
174
- return O(() => {
175
- p();
202
+ return Z(() => {
203
+ i();
176
204
  }), (() => {
177
- var s = de(), u = s.firstChild, A = u.firstChild;
178
- s.addEventListener("mouseleave", i), s.addEventListener("mouseenter", m);
179
- var j = b;
180
- typeof j == "function" ? E(j, s) : b = s, u.$$keydown = (o) => {
181
- e.item.disabled || !d() || (o.key === "ArrowRight" || o.key === "Enter" || o.key === " ") && (o.preventDefault(), r("first"));
182
- }, u.$$click = v;
183
- var F = k;
184
- return typeof F == "function" ? E(F, u) : k = u, y(u, c($, {
205
+ var u = de(), d = u.firstChild, A = d.firstChild;
206
+ u.addEventListener("mouseleave", g), u.addEventListener("mouseenter", s);
207
+ var j = y;
208
+ typeof j == "function" ? L(j, u) : y = u, d.$$keydown = (r) => {
209
+ e.item.disabled || !h() || (r.key === "ArrowRight" || r.key === "Enter" || r.key === " ") && (r.preventDefault(), n("first"));
210
+ }, d.$$click = k;
211
+ var F = v;
212
+ return typeof F == "function" ? L(F, d) : v = d, C(d, c($, {
185
213
  get when() {
186
214
  return e.item.icon;
187
215
  },
188
- children: (o) => c(J, {
216
+ children: (r) => c(J, {
189
217
  get component() {
190
- return o();
218
+ return r();
191
219
  },
192
220
  class: "w-3.5 h-3.5 opacity-60"
193
221
  })
194
- }), A), y(A, () => e.item.label), y(u, c($, {
222
+ }), A), C(A, () => e.item.label), C(d, c($, {
195
223
  get when() {
196
- return V(() => !!e.item.shortcut)() && !d();
224
+ return V(() => !!e.item.shortcut)() && !h();
197
225
  },
198
226
  get children() {
199
- var o = le();
200
- return y(o, () => e.item.shortcut), o;
227
+ var r = le();
228
+ return C(r, () => e.item.shortcut), r;
201
229
  }
202
- }), null), y(u, c($, {
230
+ }), null), C(d, c($, {
203
231
  get when() {
204
- return d();
232
+ return h();
205
233
  },
206
234
  get children() {
207
235
  return c(Y, {
208
236
  class: "w-3 h-3 text-muted-foreground"
209
237
  });
210
238
  }
211
- }), null), y(s, c($, {
239
+ }), null), C(u, c($, {
212
240
  get when() {
213
- return V(() => !!t())() && d();
241
+ return V(() => !!t())() && h();
214
242
  },
215
243
  get children() {
216
- return c(z, {
244
+ return c(W, {
217
245
  get children() {
218
- var o = ce();
219
- o.$$keydown = (l) => U(l, {
246
+ var r = ce();
247
+ r.$$keydown = (l) => U(l, {
220
248
  onDismiss: e.onDismiss,
221
- onCloseSubmenu: n
222
- }), o.addEventListener("mouseleave", i), o.addEventListener("mouseenter", p);
223
- var D = C;
224
- return typeof D == "function" ? E(D, o) : C = o, y(o, c(W, {
249
+ onCloseSubmenu: f
250
+ }), r.addEventListener("mouseleave", g), r.addEventListener("mouseenter", i);
251
+ var D = w;
252
+ return typeof D == "function" ? L(D, r) : w = r, C(r, c(O, {
225
253
  get each() {
226
254
  return e.item.children;
227
255
  },
@@ -247,131 +275,130 @@ function G(e) {
247
275
  return K();
248
276
  }
249
277
  })]
250
- })), w((l) => {
251
- var I = T("fixed z-50 min-w-[180px] py-1", "bg-popover border border-border rounded-lg shadow-lg", "animate-in fade-in slide-in-from-left-1"), S = e.contextMenuId, H = `${f().x}px`, N = `${f().y}px`;
252
- return I !== l.e && R(o, l.e = I), S !== l.t && g(o, "data-floe-context-menu", l.t = S), H !== l.a && _(o, "left", l.a = H), N !== l.o && _(o, "top", l.o = N), l;
278
+ })), b((l) => {
279
+ var I = T("fixed z-50 min-w-[180px] py-1", "bg-popover border border-border rounded-lg shadow-lg", "animate-in fade-in slide-in-from-left-1"), E = e.contextMenuId, H = `${a().x}px`, N = `${a().y}px`;
280
+ return I !== l.e && R(r, l.e = I), E !== l.t && x(r, "data-floe-context-menu", l.t = E), H !== l.a && P(r, "left", l.a = H), N !== l.o && P(r, "top", l.o = N), l;
253
281
  }, {
254
282
  e: void 0,
255
283
  t: void 0,
256
284
  a: void 0,
257
285
  o: void 0
258
- }), o;
286
+ }), r;
259
287
  }
260
288
  });
261
289
  }
262
- }), null), w((o) => {
263
- var D = e.item.disabled || !d() && e.item.type === "rename" && e.menu.items.length > 1, l = T("w-full flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer", "transition-colors duration-75", "hover:bg-accent hover:text-accent-foreground", "focus:outline-none focus-visible:bg-accent focus-visible:text-accent-foreground", "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent", e.item.type === "delete" && "text-error hover:bg-error/10 hover:text-error"), I = d() ? "menu" : void 0, S = d() ? t() : void 0;
264
- return D !== o.e && (u.disabled = o.e = D), l !== o.t && R(u, o.t = l), I !== o.a && g(u, "aria-haspopup", o.a = I), S !== o.o && g(u, "aria-expanded", o.o = S), o;
290
+ }), null), b((r) => {
291
+ var D = e.item.disabled || !h() && e.item.type === "rename" && e.menu.items.length > 1, l = T("w-full flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer", "transition-colors duration-75", "hover:bg-accent hover:text-accent-foreground", "focus:outline-none focus-visible:bg-accent focus-visible:text-accent-foreground", "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent", e.item.type === "delete" && "text-error hover:bg-error/10 hover:text-error"), I = h() ? "menu" : void 0, E = h() ? t() : void 0;
292
+ return D !== r.e && (d.disabled = r.e = D), l !== r.t && R(d, r.t = l), I !== r.a && x(d, "aria-haspopup", r.a = I), E !== r.o && x(d, "aria-expanded", r.o = E), r;
265
293
  }, {
266
294
  e: void 0,
267
295
  t: void 0,
268
296
  a: void 0,
269
297
  o: void 0
270
- }), s;
298
+ }), u;
271
299
  })();
272
300
  }
273
- function Ee(e) {
301
+ function _e(e) {
274
302
  const t = te();
275
- let a;
276
- const f = typeof window > "u" || typeof document > "u", x = `floe-context-menu-${ye += 1}`, [b, k] = B({
303
+ let o;
304
+ const a = typeof window > "u" || typeof document > "u", m = `floe-context-menu-${ye += 1}`, [y, v] = B({
277
305
  x: -9999,
278
306
  y: -9999
279
- }), C = () => {
307
+ }), w = () => {
280
308
  if (e.overrideItems)
281
309
  return e.overrideItems;
282
- const r = () => {
283
- const i = e.hideItems;
284
- if (!i) return [];
285
- if (typeof i == "function") {
286
- const v = t.contextMenu()?.items ?? [];
287
- return i(v);
310
+ const i = () => {
311
+ const s = e.hideItems;
312
+ if (!s) return [];
313
+ if (typeof s == "function") {
314
+ const g = t.contextMenu()?.items ?? [];
315
+ return s(g);
288
316
  }
289
- return i;
317
+ return s;
290
318
  };
291
319
  let n = be(e.callbacks);
292
- const m = r();
293
- return m.length > 0 && (n = n.filter((i) => !m.includes(i.type))), e.customItems?.length && (n = [...n, ...e.customItems]), n;
294
- }, M = (r, n) => {
320
+ const f = i();
321
+ return f.length > 0 && (n = n.filter((s) => !f.includes(s.type))), e.customItems?.length && (n = [...n, ...e.customItems]), n;
322
+ }, M = (i, n) => {
295
323
  t.hideContextMenu();
296
- const m = [...n.items], i = e.callbacks;
324
+ const f = [...n.items], s = e.callbacks;
297
325
  X(() => {
298
- ke(r, m, i, n);
326
+ ke(i, f, s, n);
299
327
  });
300
- }, d = (r) => {
301
- const n = r.target;
302
- n && typeof n.closest == "function" && n.closest(`[data-floe-context-menu="${x}"]`) || t.hideContextMenu();
303
- }, L = () => {
304
- const r = t.contextMenu();
305
- if (!r || !a) return {
306
- x: r?.x ?? 0,
307
- y: r?.y ?? 0
328
+ }, h = () => {
329
+ const i = t.contextMenu();
330
+ if (!i || !o) return {
331
+ x: i?.x ?? 0,
332
+ y: i?.y ?? 0
308
333
  };
309
- const n = a.getBoundingClientRect(), m = window.innerWidth, i = window.innerHeight;
310
- let v = r.x, s = r.y;
334
+ const n = o.getBoundingClientRect(), f = window.innerWidth, s = window.innerHeight;
335
+ let g = i.x, k = i.y;
311
336
  return n.width === 0 || n.height === 0 ? {
312
- x: v,
313
- y: s
314
- } : (v + n.width > m && (v = m - n.width - 8), s + n.height > i && (s = i - n.height - 8), {
315
- x: Math.max(8, v),
316
- y: Math.max(8, s)
337
+ x: g,
338
+ y: k
339
+ } : (g + n.width > f && (g = f - n.width - 8), k + n.height > s && (k = s - n.height - 8), {
340
+ x: Math.max(8, g),
341
+ y: Math.max(8, k)
317
342
  });
318
343
  };
319
- q(() => {
320
- if (!t.contextMenu()) return;
321
- const r = (n) => {
322
- n.key === "Escape" && t.hideContextMenu();
323
- };
324
- document.addEventListener("mousedown", d), document.addEventListener("keydown", r), O(() => {
325
- document.removeEventListener("mousedown", d), document.removeEventListener("keydown", r);
344
+ z(() => {
345
+ if (a || !t.contextMenu()) return;
346
+ const i = $e({
347
+ ownerWindow: window,
348
+ contextMenuId: m,
349
+ onDismiss: t.hideContextMenu
350
+ });
351
+ Z(() => {
352
+ i();
326
353
  });
327
- }), q(() => {
328
- const r = t.contextMenu();
329
- if (!r) {
330
- k({
354
+ }), z(() => {
355
+ const i = t.contextMenu();
356
+ if (!i) {
357
+ v({
331
358
  x: -9999,
332
359
  y: -9999
333
360
  });
334
361
  return;
335
362
  }
336
- k({
337
- x: r.x,
338
- y: r.y
363
+ v({
364
+ x: i.x,
365
+ y: i.y
339
366
  }), requestAnimationFrame(() => {
340
- const n = L();
341
- k(n), P(a, "first");
367
+ const n = h();
368
+ v(n), _(o, "first");
342
369
  });
343
370
  });
344
- const p = (r) => (() => {
371
+ const S = (i) => (() => {
345
372
  var n = me();
346
- n.$$keydown = (i) => U(i, {
373
+ n.$$keydown = (s) => U(s, {
347
374
  onDismiss: t.hideContextMenu
348
375
  });
349
- var m = a;
350
- return typeof m == "function" ? E(m, n) : a = n, g(n, "data-floe-context-menu", x), y(n, c(W, {
376
+ var f = o;
377
+ return typeof f == "function" ? L(f, n) : o = n, x(n, "data-floe-context-menu", m), C(n, c(O, {
351
378
  get each() {
352
- return C();
379
+ return w();
353
380
  },
354
- children: (i) => [c(G, {
355
- item: i,
381
+ children: (s) => [c(G, {
382
+ item: s,
356
383
  get menu() {
357
- return r.menu();
384
+ return i.menu();
358
385
  },
359
- contextMenuId: x,
386
+ contextMenuId: m,
360
387
  onSelect: M,
361
388
  get onDismiss() {
362
389
  return t.hideContextMenu;
363
390
  }
364
391
  }), c($, {
365
392
  get when() {
366
- return i.separator;
393
+ return s.separator;
367
394
  },
368
395
  get children() {
369
396
  return K();
370
397
  }
371
398
  })]
372
- })), w((i) => {
373
- var v = T("fixed z-50 min-w-[180px] py-1", "bg-popover border border-border rounded-lg shadow-lg", "animate-in fade-in zoom-in-95 duration-100"), s = `${b().x}px`, u = `${b().y}px`;
374
- return v !== i.e && R(n, i.e = v), s !== i.t && _(n, "left", i.t = s), u !== i.a && _(n, "top", i.a = u), i;
399
+ })), b((s) => {
400
+ var g = T("fixed z-50 min-w-[180px] py-1", "bg-popover border border-border rounded-lg shadow-lg", "animate-in fade-in zoom-in-95 duration-100"), k = `${y().x}px`, u = `${y().y}px`;
401
+ return g !== s.e && R(n, s.e = g), k !== s.t && P(n, "left", s.t = k), u !== s.a && P(n, "top", s.a = u), s;
375
402
  }, {
376
403
  e: void 0,
377
404
  t: void 0,
@@ -382,12 +409,12 @@ function Ee(e) {
382
409
  get when() {
383
410
  return t.contextMenu();
384
411
  },
385
- children: (r) => f ? c(p, {
386
- menu: r
387
- }) : c(z, {
412
+ children: (i) => a ? c(S, {
413
+ menu: i
414
+ }) : c(W, {
388
415
  get children() {
389
- return c(p, {
390
- menu: r
416
+ return c(S, {
417
+ menu: i
391
418
  });
392
419
  }
393
420
  })
@@ -395,7 +422,8 @@ function Ee(e) {
395
422
  }
396
423
  Q(["click", "keydown"]);
397
424
  export {
398
- Ee as FileContextMenu,
425
+ _e as FileContextMenu,
399
426
  be as createDefaultContextMenuItems,
400
- ke as dispatchContextMenuAction
427
+ ke as dispatchContextMenuAction,
428
+ $e as installContextMenuDismissListeners
401
429
  };
@@ -1,6 +1,6 @@
1
- import { addEventListener as te, use as z, insert as y, createComponent as D, effect as N, setStyleProperty as Y, className as H, style as ue, template as S, spread as ge, mergeProps as me, memo as fe, delegateEvents as he } from "solid-js/web";
1
+ import { addEventListener as te, use as z, insert as S, createComponent as D, effect as N, setStyleProperty as Y, className as p, style as ue, template as y, spread as ge, mergeProps as me, memo as fe, delegateEvents as he } from "solid-js/web";
2
2
  import { createSignal as ie, createMemo as W, createEffect as ne, onCleanup as oe, Show as q, For as ae, untrack as ve } from "solid-js";
3
- import { cn as p } from "../../utils/cn.js";
3
+ import { cn as H } from "../../utils/cn.js";
4
4
  import { useResizeObserver as xe } from "../../hooks/useResizeObserver.js";
5
5
  import { useVirtualWindow as Ie } from "../../hooks/useVirtualWindow.js";
6
6
  import { useFileBrowser as le } from "./FileBrowserContext.js";
@@ -8,11 +8,11 @@ import { useFileBrowserDrag as we } from "../../context/FileBrowserDragContext.j
8
8
  import { FileItemIcon as be } from "./FileIcons.js";
9
9
  import { createLongPressContextMenuHandlers as Ce } from "./longPressContextMenu.js";
10
10
  import { fileBrowserTouchTargetAttrs as De } from "./touchInteractionGuard.js";
11
- import { createItemContextMenuEvent as Se } from "./contextMenuEvent.js";
12
- import { createFileBrowserMarqueeSelection as ye, FILE_BROWSER_MARQUEE_OVERLAY_CLASS as Me } from "./useFileBrowserMarqueeSelection.js";
11
+ import { createItemContextMenuEvent as ye } from "./contextMenuEvent.js";
12
+ import { createFileBrowserMarqueeSelection as Se, FILE_BROWSER_MARQUEE_OVERLAY_CLASS as Me } from "./useFileBrowserMarqueeSelection.js";
13
13
  import { isPrimaryModKeyPressed as re } from "../../utils/keybind.js";
14
- var Te = /* @__PURE__ */ S('<mark class="bg-warning/40 text-inherit rounded-sm">'), Pe = /* @__PURE__ */ S('<div class="grid gap-2">'), _e = /* @__PURE__ */ S('<div><div class=p-3><div class="w-full h-0"aria-hidden=true>'), Ee = /* @__PURE__ */ S('<span>No files matching "<!>"'), Fe = /* @__PURE__ */ S('<button type=button class="px-2 py-1 rounded bg-muted hover:bg-muted/80 transition-colors">Clear Filter'), Le = /* @__PURE__ */ S('<div class="flex flex-col items-center justify-center h-32 gap-2 text-xs text-muted-foreground">'), Re = /* @__PURE__ */ S("<span>This folder is empty"), $e = /* @__PURE__ */ S("<div>"), ke = /* @__PURE__ */ S('<div class="absolute top-1.5 right-1.5 w-4 h-4 rounded-full bg-primary flex items-center justify-center"><svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=3 stroke-linecap=round stroke-linejoin=round class="w-2.5 h-2.5 text-primary-foreground"><polyline points="20 6 9 17 4 12">'), Ae = /* @__PURE__ */ S("<button type=button><div></div><span></span><div>");
15
- function pe(e) {
14
+ var Te = /* @__PURE__ */ y('<mark class="bg-warning/40 text-inherit rounded-sm">'), Pe = /* @__PURE__ */ y('<div class="grid gap-2">'), _e = /* @__PURE__ */ y('<div><div class=p-3><div class="w-full h-0"aria-hidden=true>'), Ee = /* @__PURE__ */ y('<span>No files matching "<!>"'), Fe = /* @__PURE__ */ y('<button type=button class="px-2 py-1 rounded bg-muted hover:bg-muted/80 transition-colors">Clear Filter'), Le = /* @__PURE__ */ y('<div class="flex flex-col items-center justify-center h-32 gap-2 text-xs text-muted-foreground">'), Re = /* @__PURE__ */ y("<span>This folder is empty"), $e = /* @__PURE__ */ y("<div>"), ke = /* @__PURE__ */ y('<div class="absolute top-1.5 right-1.5 w-4 h-4 rounded-full bg-primary flex items-center justify-center"><svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=3 stroke-linecap=round stroke-linejoin=round class="w-2.5 h-2.5 text-primary-foreground"><polyline points="20 6 9 17 4 12">'), Ae = /* @__PURE__ */ y("<button type=button><div></div><span></span><div>");
15
+ function He(e) {
16
16
  const r = W(() => {
17
17
  if (!e.match || e.match.matchedIndices.length === 0)
18
18
  return [{
@@ -20,17 +20,17 @@ function pe(e) {
20
20
  highlight: !1
21
21
  }];
22
22
  const s = [], M = new Set(e.match.matchedIndices);
23
- let C = "", g = !1;
23
+ let C = "", m = !1;
24
24
  for (let d = 0; d < e.name.length; d++) {
25
25
  const v = M.has(d);
26
- d === 0 ? (g = v, C = e.name[d]) : v === g ? C += e.name[d] : (s.push({
26
+ d === 0 ? (m = v, C = e.name[d]) : v === m ? C += e.name[d] : (s.push({
27
27
  text: C,
28
- highlight: g
29
- }), C = e.name[d], g = v);
28
+ highlight: m
29
+ }), C = e.name[d], m = v);
30
30
  }
31
31
  return C && s.push({
32
32
  text: C,
33
- highlight: g
33
+ highlight: m
34
34
  }), s;
35
35
  });
36
36
  return D(ae, {
@@ -46,47 +46,47 @@ function pe(e) {
46
46
  },
47
47
  get children() {
48
48
  var M = Te();
49
- return y(M, () => s.text), M;
49
+ return S(M, () => s.text), M;
50
50
  }
51
51
  })
52
52
  });
53
53
  }
54
54
  function Ke(e) {
55
- const r = le(), s = we(), M = () => (e.enableDragDrop ?? !0) && !!s, C = () => e.instanceId ?? "default", g = 112, d = 8, v = 180, T = 2, R = 6, [m, V] = ie(null), U = xe(m), x = W(() => {
55
+ const r = le(), s = we(), M = () => (e.enableDragDrop ?? !0) && !!s, C = () => e.instanceId ?? "default", m = 112, d = 8, v = 180, T = 2, R = 6, [f, V] = ie(null), U = xe(f), x = W(() => {
56
56
  const n = U()?.width ?? 0;
57
57
  if (n <= 0) return T;
58
58
  const l = Math.floor((n + d) / (v + d));
59
59
  return Math.max(T, Math.min(R, l));
60
- }), F = () => g + d, c = Ie({
60
+ }), F = () => m + d, c = Ie({
61
61
  count: () => Math.ceil(r.currentFiles().length / Math.max(1, x())),
62
62
  itemSize: F,
63
63
  overscan: 2
64
- }), Q = () => c.range().start * x(), $ = () => Math.min(r.currentFiles().length, c.range().end * x()), k = W(() => r.currentFiles().slice(Q(), $())), P = /* @__PURE__ */ new Map(), B = (n, l) => {
64
+ }), Q = () => c.range().start * x(), $ = () => Math.min(r.currentFiles().length, c.range().end * x()), k = W(() => r.currentFiles().slice(Q(), $())), P = /* @__PURE__ */ new Map(), O = (n, l) => {
65
65
  if (l) {
66
66
  P.set(n, l);
67
67
  return;
68
68
  }
69
69
  P.delete(n);
70
70
  };
71
- let f = null, L = T, I = 0;
71
+ let g = null, L = T, I = 0;
72
72
  ne(() => {
73
73
  const n = x();
74
- if (!f) {
74
+ if (!g) {
75
75
  L = n;
76
76
  return;
77
77
  }
78
78
  if (n === L) return;
79
- const l = F(), o = Math.floor(f.scrollTop / Math.max(1, l)) * Math.max(1, L), i = Math.floor(o / Math.max(1, n));
80
- f.scrollTop = i * l, c.onScroll(), L = n;
79
+ const l = F(), o = Math.floor(g.scrollTop / Math.max(1, l)) * Math.max(1, L), i = Math.floor(o / Math.max(1, n));
80
+ g.scrollTop = i * l, c.onScroll(), L = n;
81
81
  });
82
- const O = (n) => {
83
- if (!f) return;
84
- const b = Math.floor(n / Math.max(1, x())) * F(), o = b + F(), i = f.scrollTop, w = i + f.clientHeight;
82
+ const B = (n) => {
83
+ if (!g) return;
84
+ const b = Math.floor(n / Math.max(1, x())) * F(), o = b + F(), i = g.scrollTop, w = i + g.clientHeight;
85
85
  if (b < i) {
86
- f.scrollTop = b, c.onScroll();
86
+ g.scrollTop = b, c.onScroll();
87
87
  return;
88
88
  }
89
- o > w && (f.scrollTop = Math.max(0, o - f.clientHeight), c.onScroll());
89
+ o > w && (g.scrollTop = Math.max(0, o - g.clientHeight), c.onScroll());
90
90
  };
91
91
  ne(() => {
92
92
  const n = r.revealRequest(), l = r.currentFiles();
@@ -94,7 +94,7 @@ function Ke(e) {
94
94
  const b = l.findIndex((w) => w.id === n.targetId);
95
95
  if (b < 0) return;
96
96
  if (!P.get(n.targetId)) {
97
- O(b);
97
+ B(b);
98
98
  return;
99
99
  }
100
100
  typeof cancelAnimationFrame == "function" && I && (cancelAnimationFrame(I), I = 0);
@@ -114,8 +114,9 @@ function Ke(e) {
114
114
  }), oe(() => {
115
115
  typeof cancelAnimationFrame == "function" && I && cancelAnimationFrame(I);
116
116
  });
117
- const A = ye({
118
- getContainer: () => f,
117
+ const A = Se({
118
+ getContainer: () => g,
119
+ getOverlayHost: () => g,
119
120
  getVisibleItemIdsInOrder: () => r.currentFiles().map((n) => n.id),
120
121
  getElementForId: (n) => P.get(n) ?? null,
121
122
  getSelectedIds: () => [...r.selectedItems()],
@@ -125,15 +126,15 @@ function Ke(e) {
125
126
  return (() => {
126
127
  var n = _e(), l = n.firstChild, b = l.firstChild;
127
128
  return te(n, "pointerdown", A.onPointerDown, !0), te(n, "scroll", c.onScroll), z((o) => {
128
- f = o, c.scrollRef(o), r.setScrollContainer(o);
129
- }, n), z((o) => V(o), b), y(l, D(q, {
129
+ g = o, c.scrollRef(o), r.setScrollContainer(o);
130
+ }, n), z((o) => V(o), b), S(l, D(q, {
130
131
  get when() {
131
132
  return r.currentFiles().length > 0;
132
133
  },
133
134
  get fallback() {
134
135
  return (() => {
135
136
  var o = Le();
136
- return y(o, D(q, {
137
+ return S(o, D(q, {
137
138
  get when() {
138
139
  return r.filterQueryApplied().trim();
139
140
  },
@@ -143,7 +144,7 @@ function Ke(e) {
143
144
  get children() {
144
145
  return [(() => {
145
146
  var i = Ee(), w = i.firstChild, _ = w.nextSibling;
146
- return _.nextSibling, y(i, () => r.filterQueryApplied(), _), i;
147
+ return _.nextSibling, S(i, () => r.filterQueryApplied(), _), i;
147
148
  })(), (() => {
148
149
  var i = Fe();
149
150
  return i.$$click = () => r.setFilterQuery(""), i;
@@ -154,11 +155,11 @@ function Ke(e) {
154
155
  },
155
156
  get children() {
156
157
  var o = Pe();
157
- return y(o, D(ae, {
158
+ return S(o, D(ae, {
158
159
  get each() {
159
160
  return k();
160
161
  },
161
- children: (i) => D(He, {
162
+ children: (i) => D(pe, {
162
163
  item: i,
163
164
  get instanceId() {
164
165
  return C();
@@ -167,7 +168,7 @@ function Ke(e) {
167
168
  return M();
168
169
  },
169
170
  dragContext: s,
170
- registerTile: B
171
+ registerTile: O
171
172
  })
172
173
  })), N((i) => {
173
174
  var w = `repeat(${x()}, minmax(0, 1fr))`, _ = `${c.paddingTop()}px`, X = `${c.paddingBottom()}px`;
@@ -178,22 +179,22 @@ function Ke(e) {
178
179
  a: void 0
179
180
  }), o;
180
181
  }
181
- }), null), y(n, D(q, {
182
+ }), null), S(l, D(q, {
182
183
  get when() {
183
184
  return A.overlayStyle();
184
185
  },
185
186
  children: (o) => (() => {
186
187
  var i = $e();
187
- return H(i, Me), N((w) => ue(i, o(), w)), i;
188
+ return p(i, Me), N((w) => ue(i, o(), w)), i;
188
189
  })()
189
- }), null), N(() => H(n, p("relative h-full min-h-0 overflow-auto", e.class))), n;
190
+ }), null), N(() => p(n, H("relative h-full min-h-0 overflow-auto", e.class))), n;
190
191
  })();
191
192
  }
192
- function He(e) {
193
- const r = le(), s = () => r.isSelected(e.item.id), M = () => r.getFilterMatchForId(e.item.id), C = ve(() => e.item), g = Ce(r, C, {
193
+ function pe(e) {
194
+ const r = le(), s = () => r.isSelected(e.item.id), M = () => r.getFilterMatchForId(e.item.id), C = ve(() => e.item), m = Ce(r, C, {
194
195
  source: "grid"
195
196
  });
196
- let d, v = null, T = 0, R = 0, m = !1;
197
+ let d, v = null, T = 0, R = 0, f = !1;
197
198
  const V = 5, U = 500;
198
199
  let x = null;
199
200
  const [F, j] = ie(!1), c = () => d === "touch" || d === "pen", Q = () => e.item.type === "folder", $ = () => Q() && e.enableDragDrop && e.dragContext, k = () => {
@@ -204,21 +205,21 @@ function He(e) {
204
205
  if (!e.dragContext) return !1;
205
206
  const t = e.dragContext.dragState();
206
207
  return t.isDragging ? t.draggedItems.some((a) => a.item.id === e.item.id) : !1;
207
- }, B = () => {
208
+ }, O = () => {
208
209
  x !== null && (clearTimeout(x), x = null);
209
- }, f = () => {
210
+ }, g = () => {
210
211
  typeof document > "u" || (document.removeEventListener("pointermove", A, !0), document.removeEventListener("pointerup", n, !0), document.removeEventListener("pointercancel", l, !0));
211
212
  }, L = () => {
212
213
  typeof document > "u" || (document.addEventListener("pointermove", A, !0), document.addEventListener("pointerup", n, !0), document.addEventListener("pointercancel", l, !0));
213
214
  }, I = (t) => {
214
- B(), f(), m && e.dragContext && e.dragContext.endDrag(t), v = null, m = !1;
215
+ O(), g(), f && e.dragContext && e.dragContext.endDrag(t), v = null, f = !1;
215
216
  };
216
217
  oe(() => {
217
218
  e.registerTile(e.item.id, null), I(!1);
218
219
  });
219
- const O = (t, a) => {
220
- if (!e.enableDragDrop || !e.dragContext || m) return;
221
- m = !0, s() || r.selectItem(e.item.id, !1);
220
+ const B = (t, a) => {
221
+ if (!e.enableDragDrop || !e.dragContext || f) return;
222
+ f = !0, s() || r.selectItem(e.item.id, !1);
222
223
  const h = r.getSelectedItemsList(), u = (h.length > 0 && s() ? h : [e.item]).map((G) => ({
223
224
  item: G,
224
225
  sourceInstanceId: e.instanceId,
@@ -233,21 +234,21 @@ function He(e) {
233
234
  }, A = (t) => {
234
235
  if (v !== t.pointerId) return;
235
236
  const a = t.clientX - T, h = t.clientY - R, E = Math.sqrt(a * a + h * h);
236
- if (c() && !m && E > 10) {
237
+ if (c() && !f && E > 10) {
237
238
  I(!1);
238
239
  return;
239
240
  }
240
- !c() && !m && E > V && O(t.clientX, t.clientY), m && e.dragContext && e.dragContext.updateDrag(t.clientX, t.clientY);
241
+ !c() && !f && E > V && B(t.clientX, t.clientY), f && e.dragContext && e.dragContext.updateDrag(t.clientX, t.clientY);
241
242
  }, n = (t) => {
242
- v === t.pointerId && (g.onPointerUp(), I(!0));
243
+ v === t.pointerId && (m.onPointerUp(), I(!0));
243
244
  }, l = (t) => {
244
- v === t.pointerId && (g.onPointerCancel(), I(!1));
245
+ v === t.pointerId && (m.onPointerCancel(), I(!1));
245
246
  }, b = (t) => {
246
- d = t.pointerType, g.onPointerDown(t), !(t.pointerType === "mouse" && t.button !== 0) && (!e.enableDragDrop || !e.dragContext || (v = t.pointerId, T = t.clientX, R = t.clientY, m = !1, L(), c() && (B(), x = setTimeout(() => {
247
- v !== null && !m && O(T, R);
247
+ d = t.pointerType, m.onPointerDown(t), !(t.pointerType === "mouse" && t.button !== 0) && (!e.enableDragDrop || !e.dragContext || (v = t.pointerId, T = t.clientX, R = t.clientY, f = !1, L(), c() && (O(), x = setTimeout(() => {
248
+ v !== null && !f && B(T, R);
248
249
  }, U))));
249
250
  }, o = (t) => {
250
- d = t.pointerType, g.onPointerMove(t);
251
+ d = t.pointerType, m.onPointerMove(t);
251
252
  }, i = (t) => {
252
253
  if (!$() || !e.dragContext) return;
253
254
  const a = e.dragContext.dragState();
@@ -265,11 +266,11 @@ function He(e) {
265
266
  const a = e.dragContext.dragState();
266
267
  a.isDragging && a.dropTarget?.targetPath === e.item.path && e.dragContext.setDropTarget(null, !1);
267
268
  }, _ = (t) => {
268
- if (m) {
269
- m = !1;
269
+ if (f) {
270
+ f = !1;
270
271
  return;
271
272
  }
272
- if (!g.consumeClickSuppression(t)) {
273
+ if (!m.consumeClickSuppression(t)) {
273
274
  if (c()) {
274
275
  r.openItem(e.item);
275
276
  return;
@@ -286,7 +287,7 @@ function He(e) {
286
287
  if (t.preventDefault(), t.stopPropagation(), c()) return;
287
288
  r.ensureContextMenuSelection(e.item.id);
288
289
  const a = r.getSelectedItemsList(), h = a.length > 0 ? a : [e.item];
289
- r.showContextMenu(Se({
290
+ r.showContextMenu(ye({
290
291
  x: t.clientX,
291
292
  y: t.clientY,
292
293
  triggerItem: e.item,
@@ -317,7 +318,7 @@ function He(e) {
317
318
  onPointerEnter: i,
318
319
  onPointerLeave: w,
319
320
  get class() {
320
- return p(
321
+ return H(
321
322
  "group relative flex flex-col items-center gap-2 p-3 rounded-lg cursor-pointer h-28",
322
323
  "transition-all duration-150 ease-out",
323
324
  "hover:bg-accent/50 hover:scale-[1.02]",
@@ -331,19 +332,19 @@ function He(e) {
331
332
  K() && !k() && ["bg-destructive/10 ring-2 ring-dashed ring-destructive/50"]
332
333
  );
333
334
  }
334
- }), !1, !0), y(t, D(q, {
335
+ }), !1, !0), S(t, D(q, {
335
336
  get when() {
336
337
  return s();
337
338
  },
338
339
  get children() {
339
340
  return ke();
340
341
  }
341
- }), a), y(a, D(be, {
342
+ }), a), S(a, D(be, {
342
343
  get item() {
343
344
  return e.item;
344
345
  },
345
346
  class: "w-8 h-8"
346
- })), y(h, D(pe, {
347
+ })), S(h, D(He, {
347
348
  get name() {
348
349
  return e.item.name;
349
350
  },
@@ -351,8 +352,8 @@ function He(e) {
351
352
  return M();
352
353
  }
353
354
  })), N((u) => {
354
- var G = p("w-12 h-12 flex items-center justify-center rounded-lg", "transition-transform duration-200", "group-hover:scale-110", e.item.type === "folder" ? "bg-warning/10" : "bg-muted/50"), J = p("block w-full min-w-0 truncate px-1 text-xs text-center", "transition-colors duration-150", s() && "font-medium"), Z = p("absolute inset-0 rounded-lg opacity-0 transition-opacity duration-300", "group-hover:opacity-100", "pointer-events-none"), ee = e.item.type === "folder" ? "radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--warning) 8%, transparent), transparent 70%)" : "radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 70%)";
355
- return G !== u.e && H(a, u.e = G), J !== u.t && H(h, u.t = J), Z !== u.a && H(E, u.a = Z), ee !== u.o && Y(E, "background", u.o = ee), u;
355
+ var G = H("w-12 h-12 flex items-center justify-center rounded-lg", "transition-transform duration-200", "group-hover:scale-110", e.item.type === "folder" ? "bg-warning/10" : "bg-muted/50"), J = H("block w-full min-w-0 truncate px-1 text-xs text-center", "transition-colors duration-150", s() && "font-medium"), Z = H("absolute inset-0 rounded-lg opacity-0 transition-opacity duration-300", "group-hover:opacity-100", "pointer-events-none"), ee = e.item.type === "folder" ? "radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--warning) 8%, transparent), transparent 70%)" : "radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 70%)";
356
+ return G !== u.e && p(a, u.e = G), J !== u.t && p(h, u.t = J), Z !== u.a && p(E, u.a = Z), ee !== u.o && Y(E, "background", u.o = ee), u;
356
357
  }, {
357
358
  e: void 0,
358
359
  t: void 0,
@@ -1,4 +1,4 @@
1
- import { use as ee, insert as f, createComponent as m, effect as p, className as N, setStyleProperty as L, addEventListener as ie, style as Ce, template as _, spread as be, mergeProps as Me, memo as ce, delegateEvents as De } from "solid-js/web";
1
+ import { use as ee, insert as f, createComponent as m, effect as p, className as N, setStyleProperty as L, addEventListener as ie, style as Ce, template as z, spread as be, mergeProps as Me, memo as ce, delegateEvents as De } from "solid-js/web";
2
2
  import { createMemo as te, createEffect as Ie, onCleanup as de, createSignal as ue, Show as P, For as me, untrack as $e } from "solid-js";
3
3
  import { cn as E } from "../../utils/cn.js";
4
4
  import { useMediaQuery as re } from "../../hooks/useMediaQuery.js";
@@ -14,7 +14,7 @@ import { fileBrowserTouchTargetAttrs as Fe } from "./touchInteractionGuard.js";
14
14
  import { createItemContextMenuEvent as ke } from "./contextMenuEvent.js";
15
15
  import { createFileBrowserMarqueeSelection as pe, FILE_BROWSER_MARQUEE_OVERLAY_CLASS as Ae } from "./useFileBrowserMarqueeSelection.js";
16
16
  import { isPrimaryModKeyPressed as ae } from "../../utils/keybind.js";
17
- var Ee = /* @__PURE__ */ _("<span class=truncate>"), Le = /* @__PURE__ */ _('<mark class="bg-warning/40 text-inherit rounded-sm">'), We = /* @__PURE__ */ _("<span>"), Be = /* @__PURE__ */ _('<div><button type=button class="group w-full flex items-center justify-start text-left px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors">Modified'), He = /* @__PURE__ */ _('<div class=shrink-0><button type=button class="group w-full flex items-center justify-start text-left px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors">Size'), le = /* @__PURE__ */ _("<div>"), qe = /* @__PURE__ */ _('<div><div class="flex items-center border-b border-border text-[11px] text-muted-foreground font-medium"><div><button type=button class="group w-full flex items-center min-w-0 px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors"><span class="flex items-center gap-2 min-w-0"><span class="flex-shrink-0 w-4 h-4"aria-hidden=true></span><span class="flex items-center min-w-0"><span class=truncate>Name</span></span></span></button></div></div><div class="relative flex-1 min-h-0 overflow-auto">'), Ne = /* @__PURE__ */ _('<span>No files matching "<!>"'), Oe = /* @__PURE__ */ _('<button type=button class="px-2 py-1 rounded bg-muted hover:bg-muted/80 transition-colors">Clear Filter'), Xe = /* @__PURE__ */ _('<div class="flex flex-col items-center justify-center h-32 gap-2 text-xs text-muted-foreground">'), Ye = /* @__PURE__ */ _("<span>This folder is empty"), se = /* @__PURE__ */ _('<div class="shrink-0 px-3 py-1.5 text-left text-muted-foreground truncate">'), Ge = /* @__PURE__ */ _('<button type=button><div class="flex items-center gap-2 flex-1 min-w-0 px-3 py-1.5"><span class="flex-shrink-0 w-4 h-4">');
17
+ var Ee = /* @__PURE__ */ z("<span class=truncate>"), Le = /* @__PURE__ */ z('<mark class="bg-warning/40 text-inherit rounded-sm">'), We = /* @__PURE__ */ z("<span>"), He = /* @__PURE__ */ z('<div><button type=button class="group w-full flex items-center justify-start text-left px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors">Modified'), Be = /* @__PURE__ */ z('<div class=shrink-0><button type=button class="group w-full flex items-center justify-start text-left px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors">Size'), le = /* @__PURE__ */ z("<div>"), qe = /* @__PURE__ */ z('<div><div class="flex items-center border-b border-border text-[11px] text-muted-foreground font-medium"><div><button type=button class="group w-full flex items-center min-w-0 px-3 py-2 cursor-pointer hover:bg-muted/50 transition-colors"><span class="flex items-center gap-2 min-w-0"><span class="flex-shrink-0 w-4 h-4"aria-hidden=true></span><span class="flex items-center min-w-0"><span class=truncate>Name</span></span></span></button></div></div><div class="relative flex-1 min-h-0 overflow-auto">'), Ne = /* @__PURE__ */ z('<span>No files matching "<!>"'), Oe = /* @__PURE__ */ z('<button type=button class="px-2 py-1 rounded bg-muted hover:bg-muted/80 transition-colors">Clear Filter'), Xe = /* @__PURE__ */ z('<div class="flex flex-col items-center justify-center h-32 gap-2 text-xs text-muted-foreground">'), Ye = /* @__PURE__ */ z("<span>This folder is empty"), se = /* @__PURE__ */ z('<div class="shrink-0 px-3 py-1.5 text-left text-muted-foreground truncate">'), Ge = /* @__PURE__ */ z('<button type=button><div class="flex items-center gap-2 flex-1 min-w-0 px-3 py-1.5"><span class="flex-shrink-0 w-4 h-4">');
18
18
  function Ve(t) {
19
19
  const o = te(() => {
20
20
  if (!t.match || t.match.matchedIndices.length === 0)
@@ -69,7 +69,7 @@ function ut(t) {
69
69
  } = g.range();
70
70
  return o.currentFiles().slice(n, i);
71
71
  }), T = /* @__PURE__ */ new Map();
72
- let z = null, x = 0;
72
+ let _ = null, x = 0;
73
73
  const U = (n, i) => {
74
74
  if (i) {
75
75
  T.set(n, i);
@@ -77,13 +77,13 @@ function ut(t) {
77
77
  }
78
78
  T.delete(n);
79
79
  }, Q = (n) => {
80
- if (!z) return;
81
- const i = n * C, l = i + C, c = z.scrollTop, h = c + z.clientHeight;
80
+ if (!_) return;
81
+ const i = n * C, l = i + C, c = _.scrollTop, h = c + _.clientHeight;
82
82
  if (i < c) {
83
- z.scrollTop = i, g.onScroll();
83
+ _.scrollTop = i, g.onScroll();
84
84
  return;
85
85
  }
86
- l > h && (z.scrollTop = Math.max(0, l - z.clientHeight), g.onScroll());
86
+ l > h && (_.scrollTop = Math.max(0, l - _.clientHeight), g.onScroll());
87
87
  };
88
88
  Ie(() => {
89
89
  const n = o.revealRequest(), i = o.currentFiles();
@@ -122,7 +122,8 @@ function ut(t) {
122
122
  day: "numeric",
123
123
  year: "numeric"
124
124
  }) : "-", y = pe({
125
- getContainer: () => z,
125
+ getContainer: () => _,
126
+ getOverlayHost: () => _,
126
127
  getVisibleItemIdsInOrder: () => o.currentFiles().map((n) => n.id),
127
128
  getElementForId: (n) => T.get(n) ?? null,
128
129
  getSelectedIds: () => [...o.selectedItems()],
@@ -138,8 +139,8 @@ function ut(t) {
138
139
  }
139
140
  })), p(() => N(c, E("ml-1 transition-all duration-150", l() ? "opacity-100" : "opacity-0 group-hover:opacity-40"))), c;
140
141
  })();
141
- }, B = re("(min-width: 640px)"), X = re("(min-width: 768px)"), [K, Y] = ue(null), J = _e(K), A = (n, i, l) => Math.max(i, Math.min(l, n)), S = te(() => {
142
- const n = J()?.width ?? 0, i = B(), l = X(), c = o.listColumnRatios(), h = 160, v = 120, b = 80, M = 128, a = 96;
142
+ }, H = re("(min-width: 640px)"), X = re("(min-width: 768px)"), [K, Y] = ue(null), J = _e(K), A = (n, i, l) => Math.max(i, Math.min(l, n)), S = te(() => {
143
+ const n = J()?.width ?? 0, i = H(), l = X(), c = o.listColumnRatios(), h = 160, v = 120, b = 80, M = 128, a = 96;
143
144
  if (!i || n <= 0)
144
145
  return {
145
146
  width: n,
@@ -181,7 +182,7 @@ function ut(t) {
181
182
  modifiedWidth: r,
182
183
  sizeWidth: e
183
184
  };
184
- }), H = () => S().modifiedWidth, q = () => S().sizeWidth, G = (n) => {
185
+ }), B = () => S().modifiedWidth, q = () => S().sizeWidth, G = (n) => {
185
186
  const i = S();
186
187
  if (!i.showModified || i.width <= 0) return;
187
188
  if (!i.showSize) {
@@ -238,7 +239,7 @@ function ut(t) {
238
239
  return S().showModified;
239
240
  },
240
241
  get children() {
241
- var a = Be(), r = a.firstChild;
242
+ var a = He(), r = a.firstChild;
242
243
  return r.firstChild, r.$$click = () => k("modifiedAt"), f(r, m(W, {
243
244
  field: "modifiedAt"
244
245
  }), null), f(a, m(P, {
@@ -252,7 +253,7 @@ function ut(t) {
252
253
  });
253
254
  }
254
255
  }), null), p((e) => {
255
- var s = E("relative shrink-0", S().showSize && "border-r border-border"), u = `${H()}px`;
256
+ var s = E("relative shrink-0", S().showSize && "border-r border-border"), u = `${B()}px`;
256
257
  return s !== e.e && N(a, e.e = s), u !== e.t && L(a, "width", e.t = u), e;
257
258
  }, {
258
259
  e: void 0,
@@ -264,13 +265,13 @@ function ut(t) {
264
265
  return S().showSize;
265
266
  },
266
267
  get children() {
267
- var a = He(), r = a.firstChild;
268
+ var a = Be(), r = a.firstChild;
268
269
  return r.firstChild, r.$$click = () => k("size"), f(r, m(W, {
269
270
  field: "size"
270
271
  }), null), p((e) => L(a, "width", `${q()}px`)), a;
271
272
  }
272
273
  }), null), ie(M, "pointerdown", y.onPointerDown, !0), ie(M, "scroll", g.onScroll), ee((a) => {
273
- z = a, g.scrollRef(a), o.setScrollContainer(a);
274
+ _ = a, g.scrollRef(a), o.setScrollContainer(a);
274
275
  }, M), f(M, m(P, {
275
276
  get when() {
276
277
  return o.currentFiles().length > 0;
@@ -314,7 +315,7 @@ function ut(t) {
314
315
  return S().showSize;
315
316
  },
316
317
  get modifiedWidthPx() {
317
- return H();
318
+ return B();
318
319
  },
319
320
  get sizeWidthPx() {
320
321
  return q();
@@ -357,11 +358,11 @@ function Ue(t) {
357
358
  const o = fe(), D = () => o.isSelected(t.item.id), R = () => o.getFilterMatchForId(t.item.id), I = $e(() => t.item), C = Te(o, I, {
358
359
  source: "list"
359
360
  });
360
- let g, $ = null, T = 0, z = 0, x = !1;
361
+ let g, $ = null, T = 0, _ = 0, x = !1;
361
362
  const U = 5, Q = 500;
362
363
  let k = null;
363
- const [j, O] = ue(!1), y = () => g === "touch" || g === "pen", W = () => t.item.type === "folder", B = () => W() && t.enableDragDrop && t.dragContext, X = () => {
364
- if (!B() || !t.dragContext) return !1;
364
+ const [j, O] = ue(!1), y = () => g === "touch" || g === "pen", W = () => t.item.type === "folder", H = () => W() && t.enableDragDrop && t.dragContext, X = () => {
365
+ if (!H() || !t.dragContext) return !1;
365
366
  const e = t.dragContext.dragState();
366
367
  return e.isDragging ? t.dragContext.canDropOn(e.draggedItems, t.item.path, t.item, t.instanceId) : !1;
367
368
  }, K = () => {
@@ -380,7 +381,7 @@ function Ue(t) {
380
381
  de(() => {
381
382
  t.registerRow(t.item.id, null), S(!1);
382
383
  });
383
- const H = (e, s) => {
384
+ const B = (e, s) => {
384
385
  if (!t.enableDragDrop || !t.dragContext || x) return;
385
386
  x = !0, D() || o.selectItem(t.item.id, !1);
386
387
  const u = o.getSelectedItemsList(), w = (u.length > 0 && D() ? u : [t.item]).map((F) => ({
@@ -396,24 +397,24 @@ function Ue(t) {
396
397
  t.dragContext.startDrag(w, e, s);
397
398
  }, q = (e) => {
398
399
  if ($ !== e.pointerId) return;
399
- const s = e.clientX - T, u = e.clientY - z, d = Math.sqrt(s * s + u * u);
400
+ const s = e.clientX - T, u = e.clientY - _, d = Math.sqrt(s * s + u * u);
400
401
  if (y() && !x && d > 10) {
401
402
  S(!1);
402
403
  return;
403
404
  }
404
- !y() && !x && d > U && H(e.clientX, e.clientY), x && t.dragContext && t.dragContext.updateDrag(e.clientX, e.clientY);
405
+ !y() && !x && d > U && B(e.clientX, e.clientY), x && t.dragContext && t.dragContext.updateDrag(e.clientX, e.clientY);
405
406
  }, G = (e) => {
406
407
  $ === e.pointerId && (C.onPointerUp(), S(!0));
407
408
  }, V = (e) => {
408
409
  $ === e.pointerId && (C.onPointerCancel(), S(!1));
409
410
  }, n = (e) => {
410
- g = e.pointerType, C.onPointerDown(e), !(e.pointerType === "mouse" && e.button !== 0) && (!t.enableDragDrop || !t.dragContext || ($ = e.pointerId, T = e.clientX, z = e.clientY, x = !1, A(), y() && (Y(), k = setTimeout(() => {
411
- $ !== null && !x && H(T, z);
411
+ g = e.pointerType, C.onPointerDown(e), !(e.pointerType === "mouse" && e.button !== 0) && (!t.enableDragDrop || !t.dragContext || ($ = e.pointerId, T = e.clientX, _ = e.clientY, x = !1, A(), y() && (Y(), k = setTimeout(() => {
412
+ $ !== null && !x && B(T, _);
412
413
  }, Q))));
413
414
  }, i = (e) => {
414
415
  g = e.pointerType, C.onPointerMove(e);
415
416
  }, l = (e) => {
416
- if (!B() || !t.dragContext) return;
417
+ if (!H() || !t.dragContext) return;
417
418
  const s = t.dragContext.dragState();
418
419
  if (!s.isDragging) return;
419
420
  O(!0);
@@ -457,7 +458,7 @@ function Ue(t) {
457
458
  items: u,
458
459
  source: "list"
459
460
  }));
460
- }, M = () => t.dragContext?.dragState(), a = () => M()?.isDragging ?? !1, r = () => j() && a() && B();
461
+ }, M = () => t.dragContext?.dragState(), a = () => M()?.isDragging ?? !1, r = () => j() && a() && H();
461
462
  return (() => {
462
463
  var e = Ge(), s = e.firstChild, u = s.firstChild;
463
464
  return ee((d) => {
@@ -1,7 +1,28 @@
1
1
  import { type Accessor } from 'solid-js';
2
2
  import type { ReplaceSelectionOptions } from './types';
3
+ export type ViewportRect = {
4
+ left: number;
5
+ top: number;
6
+ width: number;
7
+ height: number;
8
+ };
9
+ export type LocalOverlayRect = {
10
+ left: number;
11
+ top: number;
12
+ width: number;
13
+ height: number;
14
+ };
15
+ export interface OverlayHostGeometry {
16
+ left: number;
17
+ top: number;
18
+ scrollLeft: number;
19
+ scrollTop: number;
20
+ clientLeft: number;
21
+ clientTop: number;
22
+ }
3
23
  export interface FileBrowserMarqueeSelectionOptions {
4
24
  getContainer: () => HTMLElement | null;
25
+ getOverlayHost?: () => HTMLElement | null;
5
26
  getVisibleItemIdsInOrder: () => string[];
6
27
  getElementForId: (id: string) => HTMLElement | null | undefined;
7
28
  getSelectedIds: () => string[];
@@ -12,5 +33,6 @@ export interface FileBrowserMarqueeSelectionResult {
12
33
  overlayStyle: Accessor<Record<string, string> | null>;
13
34
  onPointerDown: (event: PointerEvent) => void;
14
35
  }
15
- export declare const FILE_BROWSER_MARQUEE_OVERLAY_CLASS = "pointer-events-none fixed z-40 rounded-md floe-file-browser-marquee-overlay";
36
+ export declare const FILE_BROWSER_MARQUEE_OVERLAY_CLASS = "pointer-events-none absolute z-40 rounded-md floe-file-browser-marquee-overlay";
37
+ export declare function projectViewportRectToOverlayHost(rect: ViewportRect, geometry: OverlayHostGeometry): LocalOverlayRect;
16
38
  export declare function createFileBrowserMarqueeSelection(options: FileBrowserMarqueeSelectionOptions): FileBrowserMarqueeSelectionResult;
@@ -1,69 +1,93 @@
1
- import { createSignal as R, createMemo as b, onCleanup as y } from "solid-js";
2
- import { isPrimaryModKeyPressed as L } from "../../utils/keybind.js";
3
- const w = 4, G = "pointer-events-none fixed z-40 rounded-md floe-file-browser-marquee-overlay";
4
- function x(t, n, l, o) {
5
- const r = Math.min(t, l), c = Math.min(n, o);
1
+ import { createSignal as S, createMemo as b, onCleanup as w } from "solid-js";
2
+ import { isPrimaryModKeyPressed as M } from "../../utils/keybind.js";
3
+ const y = 4, A = "pointer-events-none absolute z-40 rounded-md floe-file-browser-marquee-overlay";
4
+ function T(e, n, c, o) {
5
+ const l = Math.min(e, c), u = Math.min(n, o);
6
6
  return {
7
- left: r,
8
- top: c,
9
- width: Math.abs(l - t),
7
+ left: l,
8
+ top: u,
9
+ width: Math.abs(c - e),
10
10
  height: Math.abs(o - n)
11
11
  };
12
12
  }
13
- function P(t, n) {
14
- return !(t.left + t.width < n.left || n.right < t.left || t.top + t.height < n.top || n.bottom < t.top);
13
+ function O(e, n) {
14
+ return !(e.left + e.width < n.left || n.right < e.left || e.top + e.height < n.top || n.bottom < e.top);
15
15
  }
16
- function _(t) {
17
- return !(!(t instanceof Element) || t.closest("[data-file-browser-item-id]") || t.closest('button, input, textarea, select, a, [role="button"], [role="menuitem"]'));
16
+ function P(e) {
17
+ return !(!(e instanceof Element) || e.closest("[data-file-browser-item-id]") || e.closest('button, input, textarea, select, a, [role="button"], [role="menuitem"]'));
18
18
  }
19
- function C(t) {
20
- const [n, l] = R(null);
21
- let o = null, r = !1, c = [], s = 0, a = 0, u = !1;
22
- const g = () => {
23
- typeof document > "u" || (document.removeEventListener("pointermove", m, !0), document.removeEventListener("pointerup", p, !0), document.removeEventListener("pointercancel", h, !0));
24
- }, f = () => {
25
- g(), o = null, r = !1, c = [], s = 0, a = 0, u = !1, l(null);
26
- }, E = (e) => {
27
- const d = t.getVisibleItemIdsInOrder().filter((M) => {
28
- const I = t.getElementForId(M);
29
- return I ? P(e, I.getBoundingClientRect()) : !1;
30
- }), i = r ? [...c, ...d] : d;
31
- t.replaceSelection(i, {
32
- anchorId: r ? void 0 : i[0] ?? null,
33
- lastInteractedId: i[i.length - 1] ?? null,
34
- preserveAnchor: r
19
+ function x(e) {
20
+ const n = e.getBoundingClientRect();
21
+ return {
22
+ left: n.left,
23
+ top: n.top,
24
+ scrollLeft: e.scrollLeft,
25
+ scrollTop: e.scrollTop,
26
+ clientLeft: e.clientLeft,
27
+ clientTop: e.clientTop
28
+ };
29
+ }
30
+ function C(e, n) {
31
+ return {
32
+ left: e.left - n.left + n.scrollLeft - n.clientLeft,
33
+ top: e.top - n.top + n.scrollTop - n.clientTop,
34
+ width: e.width,
35
+ height: e.height
36
+ };
37
+ }
38
+ function D(e) {
39
+ const [n, c] = S(null);
40
+ let o = null, l = !1, u = [], a = 0, f = 0, s = !1;
41
+ const I = () => {
42
+ typeof document > "u" || (document.removeEventListener("pointermove", p, !0), document.removeEventListener("pointerup", m, !0), document.removeEventListener("pointercancel", h, !0));
43
+ }, d = () => {
44
+ I(), o = null, l = !1, u = [], a = 0, f = 0, s = !1, c(null);
45
+ }, L = (t) => {
46
+ const i = e.getVisibleItemIdsInOrder().filter((R) => {
47
+ const g = e.getElementForId(R);
48
+ return g ? O(t, g.getBoundingClientRect()) : !1;
49
+ }), r = l ? [...u, ...i] : i;
50
+ e.replaceSelection(r, {
51
+ anchorId: l ? void 0 : r[0] ?? null,
52
+ lastInteractedId: r[r.length - 1] ?? null,
53
+ preserveAnchor: l
35
54
  });
36
- }, m = (e) => {
37
- if (o !== e.pointerId) return;
38
- const d = Math.hypot(e.clientX - s, e.clientY - a);
39
- if (!u && d < w)
55
+ }, p = (t) => {
56
+ if (o !== t.pointerId) return;
57
+ const i = Math.hypot(t.clientX - a, t.clientY - f);
58
+ if (!s && i < y)
40
59
  return;
41
- e.preventDefault(), u = !0;
42
- const i = x(s, a, e.clientX, e.clientY);
43
- l(i), E(i);
44
- }, p = (e) => {
45
- o === e.pointerId && (!u && !r && t.clearSelection(), f());
46
- }, h = (e) => {
47
- o === e.pointerId && f();
48
- }, S = (e) => {
49
- e.pointerType !== "mouse" || e.button !== 0 || _(e.target) && t.getContainer() && (o = e.pointerId, r = L(e), c = r ? t.getSelectedIds() : [], s = e.clientX, a = e.clientY, u = !1, typeof document < "u" && (document.addEventListener("pointermove", m, !0), document.addEventListener("pointerup", p, !0), document.addEventListener("pointercancel", h, !0)), e.preventDefault());
50
- }, v = b(() => {
51
- const e = n();
52
- return e ? {
53
- left: `${e.left}px`,
54
- top: `${e.top}px`,
55
- width: `${e.width}px`,
56
- height: `${e.height}px`
57
- } : null;
60
+ t.preventDefault(), s = !0;
61
+ const r = T(a, f, t.clientX, t.clientY);
62
+ c(r), L(r);
63
+ }, m = (t) => {
64
+ o === t.pointerId && (!s && !l && e.clearSelection(), d());
65
+ }, h = (t) => {
66
+ o === t.pointerId && d();
67
+ }, v = (t) => {
68
+ t.pointerType !== "mouse" || t.button !== 0 || P(t.target) && e.getContainer() && (o = t.pointerId, l = M(t), u = l ? e.getSelectedIds() : [], a = t.clientX, f = t.clientY, s = !1, typeof document < "u" && (document.addEventListener("pointermove", p, !0), document.addEventListener("pointerup", m, !0), document.addEventListener("pointercancel", h, !0)), t.preventDefault());
69
+ }, E = b(() => {
70
+ const t = n();
71
+ if (!t) return null;
72
+ const i = e.getOverlayHost?.() ?? e.getContainer();
73
+ if (!i) return null;
74
+ const r = C(t, x(i));
75
+ return {
76
+ left: `${r.left}px`,
77
+ top: `${r.top}px`,
78
+ width: `${r.width}px`,
79
+ height: `${r.height}px`
80
+ };
58
81
  });
59
- return y(() => {
60
- f();
82
+ return w(() => {
83
+ d();
61
84
  }), {
62
- overlayStyle: v,
63
- onPointerDown: S
85
+ overlayStyle: E,
86
+ onPointerDown: v
64
87
  };
65
88
  }
66
89
  export {
67
- G as FILE_BROWSER_MARQUEE_OVERLAY_CLASS,
68
- C as createFileBrowserMarqueeSelection
90
+ A as FILE_BROWSER_MARQUEE_OVERLAY_CLASS,
91
+ D as createFileBrowserMarqueeSelection,
92
+ C as projectViewportRectToOverlayHost
69
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.35.49",
3
+ "version": "0.35.50",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",