@floegence/floe-webapp-core 0.35.48 → 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
  };