@floegence/floe-webapp-core 0.36.12 → 0.36.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,122 +1,124 @@
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
- import { cn as T } from "../../utils/cn.js";
4
- import { deferAfterPaint as X } from "../../utils/defer.js";
5
- import { ChevronRight as Y } from "../icons/index.js";
6
- import { focusMenuItem as _, moveMenuFocus as q, calculateSubmenuPosition as ee } from "../ui/menuUtils.js";
7
- import { useFileBrowser as te } from "./FileBrowserContext.js";
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
- const he = (e) => (() => {
10
- var t = ne();
11
- return b(() => x(t, "class", e.class)), t;
12
- })(), fe = (e) => (() => {
13
- var t = re();
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
- })(), ge = (e) => (() => {
19
- var t = ie();
20
- return b(() => x(t, "class", e.class)), t;
21
- })(), pe = (e) => (() => {
22
- var t = se();
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
- })(), xe = (e) => (() => {
28
- var t = ue();
29
- return b(() => x(t, "class", e.class)), t;
1
+ import { createComponent as a, Portal as z, setAttribute as v, spread as V, mergeProps as O, insert as b, template as g, Dynamic as Q, memo as H, effect as M, className as X, use as I, delegateEvents as Y } from "solid-js/web";
2
+ import { createSignal as E, createMemo as ee, createEffect as F, onCleanup as q, Show as C, For as Z } from "solid-js";
3
+ import { cn as A } from "../../utils/cn.js";
4
+ import { deferAfterPaint as te } from "../../utils/defer.js";
5
+ import { ChevronRight as ne } from "../icons/index.js";
6
+ import { focusMenuItem as L, moveMenuFocus as N, calculateSubmenuPosition as oe, clampMenuPosition as re } from "../ui/menuUtils.js";
7
+ import { LOCAL_INTERACTION_SURFACE_ATTR as K } from "../ui/localInteractionSurface.js";
8
+ import { useFileBrowser as se } from "./FileBrowserContext.js";
9
+ import { resolveSurfacePortalHost as ie, projectSurfacePortalPosition as ae, resolveSurfacePortalBoundaryRect as ue, isSurfacePortalMode as le, resolveSurfacePortalMount as ce } from "../ui/dialogSurfaceScope.js";
10
+ var de = /* @__PURE__ */ g('<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">'), me = /* @__PURE__ */ g('<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">'), fe = /* @__PURE__ */ g('<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">'), he = /* @__PURE__ */ g('<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">'), pe = /* @__PURE__ */ g('<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">'), ge = /* @__PURE__ */ g('<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">'), ve = /* @__PURE__ */ g('<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">'), ye = /* @__PURE__ */ g('<span class="text-[10px] text-muted-foreground opacity-60">'), U = /* @__PURE__ */ g("<div>"), we = /* @__PURE__ */ g('<div class=relative><button type=button role=menuitem><span class="flex-1 text-left">'), W = /* @__PURE__ */ g('<div class="my-1 h-px bg-border"role=separator>');
11
+ const xe = (e) => (() => {
12
+ var t = de();
13
+ return M(() => v(t, "class", e.class)), t;
14
+ })(), be = (e) => (() => {
15
+ var t = me();
16
+ return M(() => v(t, "class", e.class)), t;
17
+ })(), Me = (e) => (() => {
18
+ var t = fe();
19
+ return M(() => v(t, "class", e.class)), t;
20
+ })(), ke = (e) => (() => {
21
+ var t = he();
22
+ return M(() => v(t, "class", e.class)), t;
23
+ })(), Ce = (e) => (() => {
24
+ var t = pe();
25
+ return M(() => v(t, "class", e.class)), t;
26
+ })(), $e = (e) => (() => {
27
+ var t = ge();
28
+ return M(() => v(t, "class", e.class)), t;
29
+ })(), Se = (e) => (() => {
30
+ var t = ve();
31
+ return M(() => v(t, "class", e.class)), t;
30
32
  })();
31
- let ye = 0;
32
- function be(e) {
33
- const t = !!e?.onAskAgent, o = !!e?.onCopyName;
33
+ let De = 0;
34
+ function Pe(e) {
35
+ const t = !!e?.onAskAgent, n = !!e?.onCopyName;
34
36
  return [{
35
37
  id: "duplicate",
36
38
  label: "Duplicate",
37
39
  type: "duplicate",
38
- icon: he,
40
+ icon: xe,
39
41
  shortcut: "Cmd+D",
40
- separator: !o && !t
41
- }, ...o ? [{
42
+ separator: !n && !t
43
+ }, ...n ? [{
42
44
  id: "copy-name",
43
45
  label: "Copy Name",
44
46
  type: "copy-name",
45
- icon: fe,
47
+ icon: be,
46
48
  separator: !t
47
49
  }] : [], ...t ? [{
48
50
  id: "ask-agent",
49
51
  label: "Ask Agent",
50
52
  type: "ask-agent",
51
- icon: ve,
53
+ icon: Me,
52
54
  separator: !0
53
55
  }] : [], {
54
56
  id: "copy-to",
55
57
  label: "Copy to...",
56
58
  type: "copy-to",
57
- icon: ge
59
+ icon: ke
58
60
  }, {
59
61
  id: "move-to",
60
62
  label: "Move to...",
61
63
  type: "move-to",
62
- icon: pe,
64
+ icon: Ce,
63
65
  separator: !0
64
66
  }, {
65
67
  id: "rename",
66
68
  label: "Rename",
67
69
  type: "rename",
68
- icon: xe,
70
+ icon: Se,
69
71
  shortcut: "Enter"
70
72
  }, {
71
73
  id: "delete",
72
74
  label: "Delete",
73
75
  type: "delete",
74
- icon: we,
76
+ icon: $e,
75
77
  shortcut: "Del"
76
78
  }];
77
79
  }
78
- function ke(e, t, o, a) {
80
+ function Ie(e, t, n, i) {
79
81
  switch (e.type) {
80
82
  case "duplicate":
81
- o?.onDuplicate?.(t);
83
+ n?.onDuplicate?.(t);
82
84
  break;
83
85
  case "copy-name":
84
- o?.onCopyName?.(t);
86
+ n?.onCopyName?.(t);
85
87
  break;
86
88
  case "ask-agent":
87
- o?.onAskAgent?.(t);
89
+ n?.onAskAgent?.(t);
88
90
  break;
89
91
  case "copy-to":
90
- o?.onCopyTo?.(t);
92
+ n?.onCopyTo?.(t);
91
93
  break;
92
94
  case "move-to":
93
- o?.onMoveTo?.(t);
95
+ n?.onMoveTo?.(t);
94
96
  break;
95
97
  case "delete":
96
- o?.onDelete?.(t);
98
+ n?.onDelete?.(t);
97
99
  break;
98
100
  case "rename":
99
- t.length === 1 && o?.onRename?.(t[0]);
101
+ t.length === 1 && n?.onRename?.(t[0]);
100
102
  break;
101
103
  case "custom":
102
- e.onAction?.(t, a);
104
+ e.onAction?.(t, i);
103
105
  break;
104
106
  }
105
107
  }
106
- function U(e, t) {
107
- const o = e.target, a = o?.closest('[role="menu"]'), m = o?.closest('[role="menuitem"]');
108
+ function G(e, t) {
109
+ const n = e.target, i = n?.closest('[role="menu"]'), m = n?.closest('[role="menuitem"]');
108
110
  switch (e.key) {
109
111
  case "ArrowDown":
110
- e.preventDefault(), q(a, m, 1);
112
+ e.preventDefault(), N(i, m, 1);
111
113
  return;
112
114
  case "ArrowUp":
113
- e.preventDefault(), q(a, m, -1);
115
+ e.preventDefault(), N(i, m, -1);
114
116
  return;
115
117
  case "Home":
116
- e.preventDefault(), _(a, "first");
118
+ e.preventDefault(), L(i, "first");
117
119
  return;
118
120
  case "End":
119
- e.preventDefault(), _(a, "last");
121
+ e.preventDefault(), L(i, "last");
120
122
  return;
121
123
  case "ArrowLeft":
122
124
  if (!t.onCloseSubmenu) return;
@@ -136,294 +138,332 @@ function U(e, t) {
136
138
  return;
137
139
  }
138
140
  }
139
- function Ce(e, t) {
141
+ function Le(e, t) {
140
142
  return !e || typeof e != "object" ? !1 : ("dataset" in e ? e.dataset : void 0)?.floeContextMenu === t;
141
143
  }
142
- function Me(e, t) {
144
+ function _e(e, t) {
143
145
  if (typeof e.composedPath == "function") {
144
- const a = e.composedPath();
145
- for (const m of a)
146
- if (Ce(m, t)) return !0;
146
+ const i = e.composedPath();
147
+ for (const m of i)
148
+ if (Le(m, t)) return !0;
147
149
  }
148
- const o = e.target;
149
- return typeof Element < "u" && o instanceof Element ? !!o.closest(`[data-floe-context-menu="${t}"]`) : !1;
150
+ const n = e.target;
151
+ return typeof Element < "u" && n instanceof Element ? !!n.closest(`[data-floe-context-menu="${t}"]`) : !1;
150
152
  }
151
- function $e(e) {
153
+ function Ee(e) {
152
154
  const {
153
155
  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();
156
+ contextMenuId: n,
157
+ onDismiss: i
158
+ } = e, m = (c) => {
159
+ _e(c, n) || i();
160
+ }, y = (c) => {
161
+ c.key === "Escape" && i();
162
+ }, h = () => {
163
+ i();
162
164
  };
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
+ return t.addEventListener("pointerdown", m, !0), t.addEventListener("keydown", y, !0), t.addEventListener("resize", h), t.addEventListener("scroll", h, !0), () => {
166
+ t.removeEventListener("pointerdown", m, !0), t.removeEventListener("keydown", y, !0), t.removeEventListener("resize", h), t.removeEventListener("scroll", h, !0);
165
167
  };
166
168
  }
167
- function G(e) {
168
- const [t, o] = B(!1), [a, m] = B({
169
+ function J(e) {
170
+ const [t, n] = E(!1), [i, m] = E({
169
171
  x: -9999,
170
172
  y: -9999
171
173
  });
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 = () => {
178
- M && (clearTimeout(M), M = void 0);
179
- }, n = (u = "first") => {
180
- !h() || e.item.disabled || (i(), o(!0), requestAnimationFrame(() => {
181
- S(), _(w, u);
174
+ let y, h, c, p;
175
+ const f = () => (e.item.children?.length ?? 0) > 0, _ = () => {
176
+ if (!y || !c) return;
177
+ const l = y.getBoundingClientRect(), d = c.getBoundingClientRect(), P = oe(l, d, e.portalLayout.boundaryRect());
178
+ m(P);
179
+ }, x = () => {
180
+ p && (clearTimeout(p), p = void 0);
181
+ }, $ = (l = "first") => {
182
+ !f() || e.item.disabled || (x(), n(!0), requestAnimationFrame(() => {
183
+ _(), L(c, l);
182
184
  }));
183
- }, f = () => {
184
- i(), o(!1), requestAnimationFrame(() => v?.focus());
185
- }, s = () => {
186
- !h() || e.item.disabled || (i(), M = setTimeout(() => {
187
- n("first");
185
+ }, S = () => {
186
+ x(), n(!1), requestAnimationFrame(() => h?.focus());
187
+ }, o = () => {
188
+ !f() || e.item.disabled || (x(), p = setTimeout(() => {
189
+ $("first");
188
190
  }, 100));
189
- }, g = () => {
190
- h() && (i(), M = setTimeout(() => {
191
- o(!1);
191
+ }, s = () => {
192
+ f() && (x(), p = setTimeout(() => {
193
+ n(!1);
192
194
  }, 150));
193
- }, k = (u) => {
195
+ }, w = (l) => {
194
196
  if (!e.item.disabled) {
195
- if (h()) {
196
- u.preventDefault(), u.stopPropagation(), t() ? f() : n("first");
197
+ if (f()) {
198
+ l.preventDefault(), l.stopPropagation(), t() ? S() : $("first");
197
199
  return;
198
200
  }
199
201
  e.onSelect(e.item, e.menu);
200
202
  }
201
203
  };
202
- return Z(() => {
203
- i();
204
- }), (() => {
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($, {
204
+ q(() => {
205
+ x();
206
+ });
207
+ const u = () => e.portalLayout.projectPosition(i());
208
+ return (() => {
209
+ var l = we(), d = l.firstChild, P = d.firstChild;
210
+ l.addEventListener("mouseleave", s), l.addEventListener("mouseenter", o);
211
+ var R = y;
212
+ typeof R == "function" ? I(R, l) : y = l, d.$$keydown = (r) => {
213
+ e.item.disabled || !f() || (r.key === "ArrowRight" || r.key === "Enter" || r.key === " ") && (r.preventDefault(), $("first"));
214
+ }, d.$$click = w;
215
+ var j = h;
216
+ return typeof j == "function" ? I(j, d) : h = d, b(d, a(C, {
213
217
  get when() {
214
218
  return e.item.icon;
215
219
  },
216
- children: (r) => c(J, {
220
+ children: (r) => a(Q, {
217
221
  get component() {
218
222
  return r();
219
223
  },
220
224
  class: "w-3.5 h-3.5 opacity-60"
221
225
  })
222
- }), A), C(A, () => e.item.label), C(d, c($, {
226
+ }), P), b(P, () => e.item.label), b(d, a(C, {
223
227
  get when() {
224
- return V(() => !!e.item.shortcut)() && !h();
228
+ return H(() => !!e.item.shortcut)() && !f();
225
229
  },
226
230
  get children() {
227
- var r = le();
228
- return C(r, () => e.item.shortcut), r;
231
+ var r = ye();
232
+ return b(r, () => e.item.shortcut), r;
229
233
  }
230
- }), null), C(d, c($, {
234
+ }), null), b(d, a(C, {
231
235
  get when() {
232
- return h();
236
+ return f();
233
237
  },
234
238
  get children() {
235
- return c(Y, {
239
+ return a(ne, {
236
240
  class: "w-3 h-3 text-muted-foreground"
237
241
  });
238
242
  }
239
- }), null), C(u, c($, {
243
+ }), null), b(l, a(C, {
240
244
  get when() {
241
- return V(() => !!t())() && h();
245
+ return H(() => !!t())() && f();
242
246
  },
243
247
  get children() {
244
- return c(W, {
248
+ return a(z, {
249
+ get mount() {
250
+ return e.portalLayout.mount();
251
+ },
245
252
  get children() {
246
- var r = ce();
247
- r.$$keydown = (l) => U(l, {
248
- onDismiss: e.onDismiss,
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, {
253
+ var r = U(), D = c;
254
+ return typeof D == "function" ? I(D, r) : c = r, V(r, O({
255
+ get class() {
256
+ return A(e.portalLayout.isSurfaceMode() ? "absolute z-20 min-w-[180px] py-1" : "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");
257
+ },
258
+ get "data-floe-context-menu"() {
259
+ return e.contextMenuId;
260
+ }
261
+ }, () => ({
262
+ [K]: e.portalLayout.isSurfaceMode() ? "true" : void 0
263
+ }), {
264
+ get style() {
265
+ return {
266
+ left: `${u().x}px`,
267
+ top: `${u().y}px`
268
+ };
269
+ },
270
+ role: "menu",
271
+ onMouseEnter: x,
272
+ onMouseLeave: s,
273
+ onKeyDown: (k) => G(k, {
274
+ onDismiss: e.onDismiss,
275
+ onCloseSubmenu: S
276
+ })
277
+ }), !1, !0), b(r, a(Z, {
253
278
  get each() {
254
279
  return e.item.children;
255
280
  },
256
- children: (l) => [c(G, {
257
- item: l,
281
+ children: (k) => [a(J, {
282
+ item: k,
258
283
  get menu() {
259
284
  return e.menu;
260
285
  },
261
286
  get contextMenuId() {
262
287
  return e.contextMenuId;
263
288
  },
289
+ get portalLayout() {
290
+ return e.portalLayout;
291
+ },
264
292
  get onSelect() {
265
293
  return e.onSelect;
266
294
  },
267
295
  get onDismiss() {
268
296
  return e.onDismiss;
269
297
  }
270
- }), c($, {
298
+ }), a(C, {
271
299
  get when() {
272
- return l.separator;
300
+ return k.separator;
273
301
  },
274
302
  get children() {
275
- return K();
303
+ return W();
276
304
  }
277
305
  })]
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;
281
- }, {
282
- e: void 0,
283
- t: void 0,
284
- a: void 0,
285
- o: void 0
286
- }), r;
306
+ })), r;
287
307
  }
288
308
  });
289
309
  }
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;
310
+ }), null), M((r) => {
311
+ var D = e.item.disabled || !f() && e.item.type === "rename" && e.menu.items.length > 1, k = A("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"), T = f() ? "menu" : void 0, B = f() ? t() : void 0;
312
+ return D !== r.e && (d.disabled = r.e = D), k !== r.t && X(d, r.t = k), T !== r.a && v(d, "aria-haspopup", r.a = T), B !== r.o && v(d, "aria-expanded", r.o = B), r;
293
313
  }, {
294
314
  e: void 0,
295
315
  t: void 0,
296
316
  a: void 0,
297
317
  o: void 0
298
- }), u;
318
+ }), l;
299
319
  })();
300
320
  }
301
- function _e(e) {
302
- const t = te();
303
- let o;
304
- const a = typeof window > "u" || typeof document > "u", m = `floe-context-menu-${ye += 1}`, [y, v] = B({
321
+ function Ve(e) {
322
+ const t = se();
323
+ let n;
324
+ const i = typeof window > "u" || typeof document > "u", m = `floe-context-menu-${De += 1}`, [y, h] = E({
305
325
  x: -9999,
306
326
  y: -9999
307
- }), w = () => {
327
+ }), c = ee(() => t.contextMenu() ? ie() : {
328
+ host: null,
329
+ boundaryHost: null,
330
+ mountHost: null,
331
+ mode: "global"
332
+ }), p = {
333
+ mount: () => ce(c()),
334
+ isSurfaceMode: () => le(c()),
335
+ boundaryRect: () => ue(c()),
336
+ projectPosition: (o) => ae(o, c())
337
+ }, f = () => {
308
338
  if (e.overrideItems)
309
339
  return e.overrideItems;
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);
340
+ const o = () => {
341
+ const u = e.hideItems;
342
+ if (!u) return [];
343
+ if (typeof u == "function") {
344
+ const l = t.contextMenu()?.items ?? [];
345
+ return u(l);
316
346
  }
317
- return s;
347
+ return u;
318
348
  };
319
- let n = be(e.callbacks);
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) => {
349
+ let s = Pe(e.callbacks);
350
+ const w = o();
351
+ return w.length > 0 && (s = s.filter((u) => !w.includes(u.type))), e.customItems?.length && (s = [...s, ...e.customItems]), s;
352
+ }, _ = (o, s) => {
323
353
  t.hideContextMenu();
324
- const f = [...n.items], s = e.callbacks;
325
- X(() => {
326
- ke(i, f, s, n);
354
+ const w = [...s.items], u = e.callbacks;
355
+ te(() => {
356
+ Ie(o, w, u, s);
327
357
  });
328
- }, h = () => {
329
- const i = t.contextMenu();
330
- if (!i || !o) return {
331
- x: i?.x ?? 0,
332
- y: i?.y ?? 0
358
+ }, x = () => {
359
+ const o = t.contextMenu();
360
+ if (!o || !n) return {
361
+ x: o?.x ?? 0,
362
+ y: o?.y ?? 0
333
363
  };
334
- const n = o.getBoundingClientRect(), f = window.innerWidth, s = window.innerHeight;
335
- let g = i.x, k = i.y;
336
- return n.width === 0 || n.height === 0 ? {
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)
342
- });
364
+ const s = n.getBoundingClientRect();
365
+ return s.width === 0 || s.height === 0 ? {
366
+ x: o.x,
367
+ y: o.y
368
+ } : re({
369
+ x: o.x,
370
+ y: o.y
371
+ }, s, p.boundaryRect());
343
372
  };
344
- z(() => {
345
- if (a || !t.contextMenu()) return;
346
- const i = $e({
373
+ F(() => {
374
+ if (i || !t.contextMenu()) return;
375
+ const o = Ee({
347
376
  ownerWindow: window,
348
377
  contextMenuId: m,
349
378
  onDismiss: t.hideContextMenu
350
379
  });
351
- Z(() => {
352
- i();
380
+ q(() => {
381
+ o();
353
382
  });
354
- }), z(() => {
355
- const i = t.contextMenu();
356
- if (!i) {
357
- v({
383
+ }), F(() => {
384
+ const o = t.contextMenu();
385
+ if (!o) {
386
+ h({
358
387
  x: -9999,
359
388
  y: -9999
360
389
  });
361
390
  return;
362
391
  }
363
- v({
364
- x: i.x,
365
- y: i.y
392
+ h({
393
+ x: o.x,
394
+ y: o.y
366
395
  }), requestAnimationFrame(() => {
367
- const n = h();
368
- v(n), _(o, "first");
396
+ const s = x();
397
+ h(s), L(n, "first");
369
398
  });
370
399
  });
371
- const S = (i) => (() => {
372
- var n = me();
373
- n.$$keydown = (s) => U(s, {
374
- onDismiss: t.hideContextMenu
375
- });
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, {
400
+ const $ = () => p.projectPosition(y()), S = (o) => (() => {
401
+ var s = U(), w = n;
402
+ return typeof w == "function" ? I(w, s) : n = s, v(s, "data-floe-context-menu", m), V(s, O({
403
+ get class() {
404
+ return A(p.isSurfaceMode() ? "absolute z-20 min-w-[180px] py-1" : "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");
405
+ }
406
+ }, () => ({
407
+ [K]: p.isSurfaceMode() ? "true" : void 0
408
+ }), {
409
+ get style() {
410
+ return {
411
+ left: `${$().x}px`,
412
+ top: `${$().y}px`
413
+ };
414
+ },
415
+ role: "menu",
416
+ "aria-orientation": "vertical",
417
+ onKeyDown: (u) => G(u, {
418
+ onDismiss: t.hideContextMenu
419
+ })
420
+ }), !1, !0), b(s, a(Z, {
378
421
  get each() {
379
- return w();
422
+ return f();
380
423
  },
381
- children: (s) => [c(G, {
382
- item: s,
424
+ children: (u) => [a(J, {
425
+ item: u,
383
426
  get menu() {
384
- return i.menu();
427
+ return o.menu();
385
428
  },
386
429
  contextMenuId: m,
387
- onSelect: M,
430
+ portalLayout: p,
431
+ onSelect: _,
388
432
  get onDismiss() {
389
433
  return t.hideContextMenu;
390
434
  }
391
- }), c($, {
435
+ }), a(C, {
392
436
  get when() {
393
- return s.separator;
437
+ return u.separator;
394
438
  },
395
439
  get children() {
396
- return K();
440
+ return W();
397
441
  }
398
442
  })]
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;
402
- }, {
403
- e: void 0,
404
- t: void 0,
405
- a: void 0
406
- }), n;
443
+ })), s;
407
444
  })();
408
- return c($, {
445
+ return a(C, {
409
446
  get when() {
410
447
  return t.contextMenu();
411
448
  },
412
- children: (i) => a ? c(S, {
413
- menu: i
414
- }) : c(W, {
449
+ children: (o) => i ? a(S, {
450
+ menu: o
451
+ }) : a(z, {
452
+ get mount() {
453
+ return p.mount();
454
+ },
415
455
  get children() {
416
- return c(S, {
417
- menu: i
456
+ return a(S, {
457
+ menu: o
418
458
  });
419
459
  }
420
460
  })
421
461
  });
422
462
  }
423
- Q(["click", "keydown"]);
463
+ Y(["click", "keydown"]);
424
464
  export {
425
- _e as FileContextMenu,
426
- be as createDefaultContextMenuItems,
427
- ke as dispatchContextMenuAction,
428
- $e as installContextMenuDismissListeners
465
+ Ve as FileContextMenu,
466
+ Pe as createDefaultContextMenuItems,
467
+ Ie as dispatchContextMenuAction,
468
+ Ee as installContextMenuDismissListeners
429
469
  };