@floegence/floe-webapp-core 0.52.3 → 0.52.4

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,149 +1,151 @@
1
- import { createComponent as d, Portal as J, setAttribute as w, spread as Q, mergeProps as X, insert as M, template as y, Dynamic as ue, memo as U, effect as C, className as ce, use as j, delegateEvents as le } from "solid-js/web";
2
- import { createSignal as Y, createMemo as de, createEffect as W, onCleanup as H, Show as S, For as ee } from "solid-js";
3
- import { cn as q } from "../../utils/cn.js";
4
- import { deferAfterPaint as me } from "../../utils/defer.js";
5
- import { ChevronRight as fe } from "../icons/index.js";
6
- import { focusMenuItem as T, moveMenuFocus as G, calculateSubmenuPosition as he, clampMenuPosition as pe } from "../ui/menuUtils.js";
7
- import { LOCAL_INTERACTION_SURFACE_ATTR as te } from "../ui/localInteractionSurface.js";
8
- import { useFileBrowser as ve } from "./FileBrowserContext.js";
9
- import { resolveSurfacePortalHost as ge, projectSurfacePortalPosition as ye, resolveSurfacePortalBoundaryRect as we, isSurfacePortalMode as xe, resolveSurfacePortalMount as be } from "../ui/dialogSurfaceScope.js";
10
- var Me = /* @__PURE__ */ y('<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">'), ke = /* @__PURE__ */ y('<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">'), Ce = /* @__PURE__ */ y('<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">'), Pe = /* @__PURE__ */ y('<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">'), Ie = /* @__PURE__ */ y('<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__ */ y('<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">'), $e = /* @__PURE__ */ y('<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">'), De = /* @__PURE__ */ y('<span class="text-[10px] text-muted-foreground opacity-60">'), ne = /* @__PURE__ */ y("<div>"), Ee = /* @__PURE__ */ y('<div class=relative><button type=button role=menuitem><span class="flex-1 text-left">'), oe = /* @__PURE__ */ y('<div class="my-1 h-px bg-border"role=separator>');
11
- const _e = (e) => (() => {
12
- var t = Me();
13
- return C(() => w(t, "class", e.class)), t;
14
- })(), Ae = (e) => (() => {
15
- var t = ke();
16
- return C(() => w(t, "class", e.class)), t;
17
- })(), Le = (e) => (() => {
18
- var t = Ce();
19
- return C(() => w(t, "class", e.class)), t;
20
- })(), Re = (e) => (() => {
21
- var t = Pe();
22
- return C(() => w(t, "class", e.class)), t;
23
- })(), Fe = (e) => (() => {
24
- var t = Ie();
25
- return C(() => w(t, "class", e.class)), t;
26
- })(), je = (e) => (() => {
27
- var t = Se();
28
- return C(() => w(t, "class", e.class)), t;
29
- })(), Te = (e) => (() => {
30
- var t = $e();
31
- return C(() => w(t, "class", e.class)), t;
1
+ import { createComponent as d, Portal as ce, spread as de, mergeProps as me, insert as M, effect as R, setStyleProperty as fe, template as C, Dynamic as Me, memo as ae, className as Ce, setAttribute as E, use as W, delegateEvents as ke } from "solid-js/web";
2
+ import { createSignal as z, createMemo as ue, createEffect as H, onCleanup as Q, untrack as J, on as Se, Show as F, For as he } from "solid-js";
3
+ import { cn as ee } from "../../utils/cn.js";
4
+ import { deferAfterPaint as Ee } from "../../utils/defer.js";
5
+ import { ChevronLeft as Le, ChevronRight as Pe } from "../icons/index.js";
6
+ import { focusMenuItem as X, moveMenuFocus as le, calculateSubmenuPosition as Re, clampMenuPosition as $e } from "../ui/menuUtils.js";
7
+ import { LOCAL_INTERACTION_SURFACE_ATTR as ve, CANVAS_WHEEL_INTERACTIVE_ATTR as ge } from "../ui/localInteractionSurface.js";
8
+ import { readSurfaceSafeArea as Ie, resolveFloatingBoundary as Ae } from "../ui/surfaceFloatingBoundary.js";
9
+ import { resolveSurfacePortalHost as _e, readFreshInteractionSnapshot as De, projectSurfacePortalPosition as Fe, resolveSurfacePortalScale as Te, isSurfacePortalMode as Be, resolveSurfacePortalMount as je } from "../ui/dialogSurfaceScope.js";
10
+ import { useResolvedFloeConfig as Ve } from "../../context/FloeConfigContext.js";
11
+ import { useFileBrowser as He } from "./FileBrowserContext.js";
12
+ var ze = /* @__PURE__ */ C('<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__ */ C('<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">'), Ne = /* @__PURE__ */ C('<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">'), qe = /* @__PURE__ */ C('<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">'), Ze = /* @__PURE__ */ C('<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">'), Ke = /* @__PURE__ */ C('<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__ */ C('<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">'), We = /* @__PURE__ */ C('<span class="shrink-0 text-[10px] text-muted-foreground opacity-60">'), we = /* @__PURE__ */ C("<div>"), Qe = /* @__PURE__ */ C('<div class=relative><button type=button role=menuitem><span class="min-w-0 flex-1 text-left [overflow-wrap:anywhere]">'), ye = /* @__PURE__ */ C('<div class="my-1 h-px bg-border"role=separator>'), Ge = /* @__PURE__ */ C('<button type=button role=menuitem class="flex w-full items-center gap-2 border-b px-3 py-1.5 text-xs cursor-pointer hover:bg-accent focus-visible:bg-accent focus:outline-none"><span></span><span class="min-w-0 flex-1 truncate text-right text-muted-foreground">');
13
+ const Je = (e) => (() => {
14
+ var t = ze();
15
+ return R(() => E(t, "class", e.class)), t;
16
+ })(), Xe = (e) => (() => {
17
+ var t = Oe();
18
+ return R(() => E(t, "class", e.class)), t;
19
+ })(), Ye = (e) => (() => {
20
+ var t = Ne();
21
+ return R(() => E(t, "class", e.class)), t;
22
+ })(), et = (e) => (() => {
23
+ var t = qe();
24
+ return R(() => E(t, "class", e.class)), t;
25
+ })(), tt = (e) => (() => {
26
+ var t = Ze();
27
+ return R(() => E(t, "class", e.class)), t;
28
+ })(), nt = (e) => (() => {
29
+ var t = Ke();
30
+ return R(() => E(t, "class", e.class)), t;
31
+ })(), ot = (e) => (() => {
32
+ var t = Ue();
33
+ return R(() => E(t, "class", e.class)), t;
32
34
  })();
33
- let Be = 0;
34
- const re = {
35
+ let rt = 0;
36
+ const pe = {
35
37
  x: -9999,
36
38
  y: -9999
37
39
  };
38
- function k(e, t = 0, n = re, i = n) {
40
+ function T(e, t = 0, s = pe, a = s) {
39
41
  return {
40
42
  phase: e,
41
43
  requestId: t,
42
- anchor: n,
43
- position: i
44
+ anchor: s,
45
+ position: a
44
46
  };
45
47
  }
46
- function ie(e) {
48
+ function te(e) {
47
49
  return e.phase === "positioned";
48
50
  }
49
- function z(e) {
51
+ function ne(e) {
50
52
  if (typeof requestAnimationFrame != "function") {
51
53
  e(0);
52
54
  return;
53
55
  }
54
56
  return requestAnimationFrame(e);
55
57
  }
56
- function O(e) {
58
+ function oe(e) {
57
59
  e === void 0 || typeof cancelAnimationFrame != "function" || cancelAnimationFrame(e);
58
60
  }
59
- function Ne(e) {
60
- const t = !!e?.onAskAgent, n = !!e?.onCopyName;
61
+ function it(e) {
62
+ const t = !!e?.onAskAgent, s = !!e?.onCopyName;
61
63
  return [{
62
64
  id: "duplicate",
63
65
  label: "Duplicate",
64
66
  type: "duplicate",
65
- icon: _e,
67
+ icon: Je,
66
68
  shortcut: "Cmd+D",
67
- separator: !n && !t
68
- }, ...n ? [{
69
+ separator: !s && !t
70
+ }, ...s ? [{
69
71
  id: "copy-name",
70
72
  label: "Copy Name",
71
73
  type: "copy-name",
72
- icon: Ae,
74
+ icon: Xe,
73
75
  separator: !t
74
76
  }] : [], ...t ? [{
75
77
  id: "ask-agent",
76
78
  label: "Ask Agent",
77
79
  type: "ask-agent",
78
- icon: Le,
80
+ icon: Ye,
79
81
  separator: !0
80
82
  }] : [], {
81
83
  id: "copy-to",
82
84
  label: "Copy to...",
83
85
  type: "copy-to",
84
- icon: Re
86
+ icon: et
85
87
  }, {
86
88
  id: "move-to",
87
89
  label: "Move to...",
88
90
  type: "move-to",
89
- icon: Fe,
91
+ icon: tt,
90
92
  separator: !0
91
93
  }, {
92
94
  id: "rename",
93
95
  label: "Rename",
94
96
  type: "rename",
95
- icon: Te,
97
+ icon: ot,
96
98
  shortcut: "Enter"
97
99
  }, {
98
100
  id: "delete",
99
101
  label: "Delete",
100
102
  type: "delete",
101
- icon: je,
103
+ icon: nt,
102
104
  shortcut: "Del"
103
105
  }];
104
106
  }
105
- function He(e, t, n, i) {
107
+ function st(e, t, s, a) {
106
108
  switch (e.type) {
107
109
  case "duplicate":
108
- n?.onDuplicate?.(t);
110
+ s?.onDuplicate?.(t);
109
111
  break;
110
112
  case "copy-name":
111
- n?.onCopyName?.(t);
113
+ s?.onCopyName?.(t);
112
114
  break;
113
115
  case "ask-agent":
114
- n?.onAskAgent?.(t);
116
+ s?.onAskAgent?.(t);
115
117
  break;
116
118
  case "copy-to":
117
- n?.onCopyTo?.(t);
119
+ s?.onCopyTo?.(t);
118
120
  break;
119
121
  case "move-to":
120
- n?.onMoveTo?.(t);
122
+ s?.onMoveTo?.(t);
121
123
  break;
122
124
  case "delete":
123
- n?.onDelete?.(t);
125
+ s?.onDelete?.(t);
124
126
  break;
125
127
  case "rename":
126
- t.length === 1 && n?.onRename?.(t[0]);
128
+ t.length === 1 && s?.onRename?.(t[0]);
127
129
  break;
128
130
  case "custom":
129
- e.onAction?.(t, i);
131
+ e.onAction?.(t, a);
130
132
  break;
131
133
  }
132
134
  }
133
- function se(e, t) {
134
- const n = e.target, i = n?.closest('[role="menu"]'), m = n?.closest('[role="menuitem"]');
135
+ function be(e, t) {
136
+ const s = e.target, a = s?.closest('[role="menu"]'), g = s?.closest('[role="menuitem"]');
135
137
  switch (e.key) {
136
138
  case "ArrowDown":
137
- e.preventDefault(), G(i, m, 1);
139
+ e.preventDefault(), le(a, g, 1);
138
140
  return;
139
141
  case "ArrowUp":
140
- e.preventDefault(), G(i, m, -1);
142
+ e.preventDefault(), le(a, g, -1);
141
143
  return;
142
144
  case "Home":
143
- e.preventDefault(), T(i, "first");
145
+ e.preventDefault(), X(a, "first");
144
146
  return;
145
147
  case "End":
146
- e.preventDefault(), T(i, "last");
148
+ e.preventDefault(), X(a, "last");
147
149
  return;
148
150
  case "ArrowLeft":
149
151
  if (!t.onCloseSubmenu) return;
@@ -163,170 +165,195 @@ function se(e, t) {
163
165
  return;
164
166
  }
165
167
  }
166
- function qe(e, t) {
168
+ function at(e, t) {
167
169
  return !e || typeof e != "object" ? !1 : ("dataset" in e ? e.dataset : void 0)?.floeContextMenu === t;
168
170
  }
169
- function ze(e, t) {
171
+ function G(e, t) {
170
172
  if (typeof e.composedPath == "function") {
171
- const i = e.composedPath();
172
- for (const m of i)
173
- if (qe(m, t)) return !0;
173
+ const a = e.composedPath();
174
+ for (const g of a)
175
+ if (at(g, t)) return !0;
174
176
  }
175
- const n = e.target;
176
- return typeof Element < "u" && n instanceof Element ? !!n.closest(`[data-floe-context-menu="${t}"]`) : !1;
177
+ const s = e.target;
178
+ return typeof Element < "u" && s instanceof Element ? !!s.closest(`[data-floe-context-menu="${t}"]`) : !1;
177
179
  }
178
- function Oe(e) {
180
+ function ut(e) {
179
181
  const {
180
182
  ownerWindow: t,
181
- contextMenuId: n,
182
- onDismiss: i
183
- } = e, m = (h) => {
184
- ze(h, n) || i();
185
- }, v = (h) => {
186
- h.key === "Escape" && i();
187
- }, f = () => {
188
- i();
183
+ contextMenuId: s,
184
+ onDismiss: a
185
+ } = e, g = (w) => {
186
+ G(w, s) || a();
187
+ }, f = (w) => {
188
+ w.key !== "Escape" || G(w, s) || a("escape");
189
+ }, v = (w) => {
190
+ G(w, s) || a();
189
191
  };
190
- return t.addEventListener("pointerdown", m, !0), t.addEventListener("keydown", v, !0), t.addEventListener("resize", f), t.addEventListener("scroll", f, !0), () => {
191
- t.removeEventListener("pointerdown", m, !0), t.removeEventListener("keydown", v, !0), t.removeEventListener("resize", f), t.removeEventListener("scroll", f, !0);
192
+ return t.addEventListener("pointerdown", g, !0), t.addEventListener("keydown", f, !0), t.addEventListener("resize", v), t.addEventListener("scroll", v, !0), () => {
193
+ t.removeEventListener("pointerdown", g, !0), t.removeEventListener("keydown", f, !0), t.removeEventListener("resize", v), t.removeEventListener("scroll", v, !0);
192
194
  };
193
195
  }
194
- function ae(e) {
195
- const [t, n] = Y(k("closed", 0));
196
- let i, m, v, f, h, P = 0, x;
197
- const u = () => (e.item.children?.length ?? 0) > 0, A = () => t().phase !== "closed", $ = () => ie(t()), B = () => {
198
- if (!i) return re;
199
- const a = i.getBoundingClientRect();
196
+ function xe(e) {
197
+ const [t, s] = z(T("closed", 0));
198
+ let a, g, f, v, w, O = 0, $;
199
+ const [B, I] = z(0);
200
+ H(() => {
201
+ e.scrollRevision, J(() => y({
202
+ restoreFocus: !1
203
+ }));
204
+ });
205
+ const h = () => (e.item.children?.length ?? 0) > 0, A = () => t().phase !== "closed", _ = () => te(t()), N = () => {
206
+ if (!a) return pe;
207
+ const l = a.getBoundingClientRect();
200
208
  return {
201
- x: a.right,
202
- y: a.top
209
+ x: l.right,
210
+ y: l.top
203
211
  };
204
- }, L = (a, l) => {
205
- if (!i || !v) return a;
206
- const b = i.getBoundingClientRect(), _ = v.getBoundingClientRect();
207
- return he(b, _, l);
208
- }, g = () => {
209
- f && (clearTimeout(f), f = void 0);
210
- }, D = () => {
211
- O(h), h = void 0;
212
- }, E = () => {
213
- O(x), x = void 0;
214
- }, s = (a = "first") => {
215
- if (!u() || e.item.disabled) return;
216
- g(), D(), E();
217
- const l = ++P, b = B(), _ = e.portalLayout.boundaryRect;
218
- n(k("measuring", l, b)), h = z(() => {
219
- if (h = void 0, P !== l) return;
220
- const F = L(b, _());
221
- n(k("positioned", l, b, F)), T(v, a);
222
- });
223
- }, o = (a = {}) => {
224
- g(), D(), n(k("closed", ++P)), (a.restoreFocus ?? !0) && (E(), x = z(() => {
225
- x = void 0, m?.focus();
212
+ }, V = (l, u) => {
213
+ if (!a || !f) return l;
214
+ const p = a.getBoundingClientRect(), L = f.getBoundingClientRect();
215
+ return Re(p, L, u);
216
+ }, k = () => {
217
+ v && (clearTimeout(v), v = void 0);
218
+ }, S = () => {
219
+ oe(w), w = void 0;
220
+ }, q = () => {
221
+ oe($), $ = void 0;
222
+ }, j = (l = "first") => {
223
+ if (!h() || e.item.disabled) return;
224
+ if (k(), S(), q(), e.portalLayout.touch()) {
225
+ e.portalLayout.enterChild([...e.path, e.item], l);
226
+ return;
227
+ }
228
+ const u = ++O, p = N(), L = e.portalLayout.boundaryRect;
229
+ s(T("measuring", u, p)), w = ne(() => J(() => {
230
+ if (w = void 0, O !== u) return;
231
+ const P = L(), n = a?.getBoundingClientRect(), o = f?.getBoundingClientRect();
232
+ if (n && o && o.width > 0 && Math.max(P.right - n.right - 8, n.left - P.left - 8) < o.width) {
233
+ y({
234
+ restoreFocus: !1
235
+ }), e.portalLayout.enterChild([...e.path, e.item], l);
236
+ return;
237
+ }
238
+ const r = V(p, P);
239
+ s(T("positioned", u, p, r)), X(f, l);
226
240
  }));
227
- }, p = () => {
228
- !u() || e.item.disabled || (g(), f = setTimeout(() => {
229
- s("first");
241
+ }, y = (l = {}) => {
242
+ k(), S(), s(T("closed", ++O)), (l.restoreFocus ?? !0) && (q(), $ = ne(() => {
243
+ $ = void 0, g?.focus();
244
+ }));
245
+ }, Y = () => {
246
+ !h() || e.item.disabled || e.portalLayout.touch() || (k(), v = setTimeout(() => {
247
+ j("first");
230
248
  }, 100));
231
- }, c = () => {
232
- u() && (g(), f = setTimeout(() => {
233
- o({
249
+ }, b = () => {
250
+ h() && (k(), v = setTimeout(() => {
251
+ y({
234
252
  restoreFocus: !1
235
253
  });
236
254
  }, 150));
237
- }, N = (a) => {
255
+ }, K = (l) => {
238
256
  if (!e.item.disabled) {
239
- if (u()) {
240
- a.preventDefault(), a.stopPropagation(), A() ? o() : s("first");
257
+ if (h()) {
258
+ l.preventDefault(), l.stopPropagation(), A() ? y() : j("first");
241
259
  return;
242
260
  }
243
261
  e.onSelect(e.item, e.menu);
244
262
  }
245
263
  };
246
- H(() => {
247
- g(), D(), E();
264
+ Q(() => {
265
+ k(), S(), q();
248
266
  });
249
- const V = () => e.portalLayout.projectPosition(t().position);
267
+ const U = () => e.portalLayout.projectPosition(t().position);
250
268
  return (() => {
251
- var a = Ee(), l = a.firstChild, b = l.firstChild;
252
- a.addEventListener("mouseleave", c), a.addEventListener("mouseenter", p);
253
- var _ = i;
254
- typeof _ == "function" ? j(_, a) : i = a, l.$$keydown = (r) => {
255
- e.item.disabled || !u() || (r.key === "ArrowRight" || r.key === "Enter" || r.key === " ") && (r.preventDefault(), s("first"));
256
- }, l.$$click = N;
257
- var F = m;
258
- return typeof F == "function" ? j(F, l) : m = l, M(l, d(S, {
269
+ var l = Qe(), u = l.firstChild, p = u.firstChild;
270
+ l.addEventListener("mouseleave", b), l.addEventListener("mouseenter", Y);
271
+ var L = a;
272
+ typeof L == "function" ? W(L, l) : a = l, u.$$keydown = (n) => {
273
+ e.item.disabled || !h() || (n.key === "ArrowRight" || n.key === "Enter" || n.key === " ") && (n.preventDefault(), j("first"));
274
+ }, u.$$click = K;
275
+ var P = g;
276
+ return typeof P == "function" ? W(P, u) : g = u, M(u, d(F, {
259
277
  get when() {
260
278
  return e.item.icon;
261
279
  },
262
- children: (r) => d(ue, {
280
+ children: (n) => d(Me, {
263
281
  get component() {
264
- return r();
282
+ return n();
265
283
  },
266
- class: "w-3.5 h-3.5 opacity-60"
284
+ class: "w-3.5 h-3.5 shrink-0 opacity-60"
267
285
  })
268
- }), b), M(b, () => e.item.label), M(l, d(S, {
286
+ }), p), M(p, () => e.item.label), M(u, d(F, {
269
287
  get when() {
270
- return U(() => !!e.item.shortcut)() && !u();
288
+ return ae(() => !!e.item.shortcut)() && !h();
271
289
  },
272
290
  get children() {
273
- var r = De();
274
- return M(r, () => e.item.shortcut), r;
291
+ var n = We();
292
+ return M(n, () => e.item.shortcut), n;
275
293
  }
276
- }), null), M(l, d(S, {
294
+ }), null), M(u, d(F, {
277
295
  get when() {
278
- return u();
296
+ return h();
279
297
  },
280
298
  get children() {
281
- return d(fe, {
282
- class: "w-3 h-3 text-muted-foreground"
299
+ return d(Pe, {
300
+ class: "w-3 h-3 shrink-0 text-muted-foreground"
283
301
  });
284
302
  }
285
- }), null), M(a, d(S, {
303
+ }), null), M(l, d(F, {
286
304
  get when() {
287
- return U(() => !!A())() && u();
305
+ return ae(() => !!A())() && h();
288
306
  },
289
307
  get children() {
290
- return d(J, {
308
+ return d(ce, {
291
309
  get mount() {
292
310
  return e.portalLayout.mount();
293
311
  },
294
312
  get children() {
295
- var r = ne(), R = v;
296
- return typeof R == "function" ? j(R, r) : v = r, Q(r, X({
313
+ var n = we(), o = f;
314
+ return typeof o == "function" ? W(o, n) : f = n, de(n, me(() => e.portalLayout.scrollViewportProps(), {
315
+ onScroll: () => I((r) => r + 1),
297
316
  get class() {
298
- return q(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");
317
+ return ee(e.portalLayout.isSurfaceMode() ? "absolute z-20 py-1" : "fixed z-50 py-1", "bg-popover border border-border rounded-lg shadow-lg overflow-y-auto overscroll-contain touch-pan-y motion-reduce:animate-none", _() && "animate-in fade-in slide-in-from-left-1");
299
318
  },
300
319
  get "data-floe-context-menu"() {
301
320
  return e.contextMenuId;
302
321
  }
303
322
  }, () => ({
304
- [te]: e.portalLayout.isSurfaceMode() ? "true" : void 0
323
+ [ge]: "true",
324
+ [ve]: e.portalLayout.isSurfaceMode() ? "true" : void 0
305
325
  }), {
306
326
  get style() {
307
327
  return {
308
- left: `${V().x}px`,
309
- top: `${V().y}px`,
310
- visibility: $() ? "visible" : "hidden",
311
- "pointer-events": $() ? "auto" : "none"
328
+ ...e.portalLayout.sizeStyle(),
329
+ left: `${U().x}px`,
330
+ top: `${U().y}px`,
331
+ visibility: _() ? "visible" : "hidden",
332
+ "pointer-events": _() ? "auto" : "none"
312
333
  };
313
334
  },
314
335
  role: "menu",
315
336
  get "aria-hidden"() {
316
- return $() ? void 0 : "true";
337
+ return _() ? void 0 : "true";
317
338
  },
318
- onMouseEnter: g,
319
- onMouseLeave: c,
320
- onKeyDown: (I) => se(I, {
339
+ onMouseEnter: k,
340
+ onMouseLeave: b,
341
+ onKeyDown: (r) => be(r, {
321
342
  onDismiss: e.onDismiss,
322
- onCloseSubmenu: o
343
+ onCloseSubmenu: y
323
344
  })
324
- }), !1, !0), M(r, d(ee, {
345
+ }), !1, !0), M(n, d(he, {
325
346
  get each() {
326
347
  return e.item.children;
327
348
  },
328
- children: (I) => [d(ae, {
329
- item: I,
349
+ children: (r) => [d(xe, {
350
+ item: r,
351
+ get path() {
352
+ return [...e.path, e.item];
353
+ },
354
+ get scrollRevision() {
355
+ return B();
356
+ },
330
357
  get menu() {
331
358
  return e.menu;
332
359
  },
@@ -342,173 +369,272 @@ function ae(e) {
342
369
  get onDismiss() {
343
370
  return e.onDismiss;
344
371
  }
345
- }), d(S, {
372
+ }), d(F, {
346
373
  get when() {
347
- return I.separator;
374
+ return r.separator;
348
375
  },
349
376
  get children() {
350
- return oe();
377
+ return ye();
351
378
  }
352
379
  })]
353
- })), r;
380
+ })), n;
354
381
  }
355
382
  });
356
383
  }
357
- }), null), C((r) => {
358
- var R = e.item.disabled || !u() && e.item.type === "rename" && e.menu.items.length > 1, I = q("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"), Z = u() ? "menu" : void 0, K = u() ? A() : void 0;
359
- return R !== r.e && (l.disabled = r.e = R), I !== r.t && ce(l, r.t = I), Z !== r.a && w(l, "aria-haspopup", r.a = Z), K !== r.o && w(l, "aria-expanded", r.o = K), r;
384
+ }), null), R((n) => {
385
+ var o = e.item.disabled || !h() && e.item.type === "rename" && e.menu.items.length > 1, r = ee("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 = e.item.id, m = e.portalLayout.touch() ? "44px" : void 0, x = h() ? "menu" : void 0, D = h() ? A() : void 0;
386
+ return o !== n.e && (u.disabled = n.e = o), r !== n.t && Ce(u, n.t = r), i !== n.a && E(u, "data-file-menu-item", n.a = i), m !== n.o && fe(u, "min-height", n.o = m), x !== n.i && E(u, "aria-haspopup", n.i = x), D !== n.n && E(u, "aria-expanded", n.n = D), n;
360
387
  }, {
361
388
  e: void 0,
362
389
  t: void 0,
363
390
  a: void 0,
364
- o: void 0
365
- }), a;
391
+ o: void 0,
392
+ i: void 0,
393
+ n: void 0
394
+ }), l;
366
395
  })();
367
396
  }
368
- function Ye(e) {
369
- const t = ve();
370
- let n;
371
- const i = typeof window > "u" || typeof document > "u", m = `floe-context-menu-${Be += 1}`, [v, f] = Y(k("closed"));
372
- let h, P = 0;
373
- const x = de(() => t.contextMenu() ? ge() : {
397
+ function bt(e) {
398
+ const t = He(), s = Ve(), [a, g] = z(!1), [f, v] = z([]), [w, O] = z(0);
399
+ let $ = null, B = "first", I;
400
+ const h = typeof window > "u" || typeof document > "u", A = `floe-context-menu-${rt += 1}`, [_, N] = z(T("closed"));
401
+ let V, k = 0;
402
+ const S = ue(() => t.contextMenu() ? _e({
403
+ owner: e.owner
404
+ }) : {
374
405
  host: null,
375
406
  boundaryHost: null,
376
407
  mountHost: null,
377
408
  mode: "global"
378
- }), u = {
379
- mount: () => be(x()),
380
- isSurfaceMode: () => xe(x()),
381
- boundaryRect: () => we(x()),
382
- projectPosition: (s) => ye(s, x())
383
- }, A = () => {
409
+ }), q = ue(() => (t.contextMenu(), Ie())), j = () => Ae(S(), e.boundary, q()), y = {
410
+ mount: () => je(S()),
411
+ isSurfaceMode: () => Be(S()),
412
+ boundaryRect: () => j() ?? {
413
+ left: 0,
414
+ top: 0,
415
+ right: 0,
416
+ bottom: 0,
417
+ width: 0,
418
+ height: 0
419
+ },
420
+ touch: a,
421
+ scrollViewportProps: () => e.scrollViewportProps,
422
+ enterChild: (n, o) => {
423
+ B = o, v(n);
424
+ },
425
+ sizeStyle: () => {
426
+ const n = j(), o = Te(S()), r = Math.max(0, (n?.width ?? 0) - 16) / o.x;
427
+ return {
428
+ width: "max-content",
429
+ "transition-property": "none",
430
+ "animation-duration": "100ms",
431
+ "min-width": `${Math.min(180, r)}px`,
432
+ "max-width": `${r}px`,
433
+ "max-height": `${Math.max(0, (n?.height ?? 0) - 16) / o.y}px`
434
+ };
435
+ },
436
+ projectPosition: (n) => Fe(n, S())
437
+ }, Y = () => {
438
+ const n = f().at(-1);
439
+ if (n) return n.children ?? [];
384
440
  if (e.overrideItems)
385
441
  return e.overrideItems;
386
- const s = () => {
387
- const c = e.hideItems;
388
- if (!c) return [];
389
- if (typeof c == "function") {
390
- const N = t.contextMenu()?.items ?? [];
391
- return c(N);
442
+ const o = () => {
443
+ const m = e.hideItems;
444
+ if (!m) return [];
445
+ if (typeof m == "function") {
446
+ const x = t.contextMenu()?.items ?? [];
447
+ return m(x);
392
448
  }
393
- return c;
449
+ return m;
394
450
  };
395
- let o = Ne(e.callbacks);
396
- const p = s();
397
- return p.length > 0 && (o = o.filter((c) => !p.includes(c.type))), e.customItems?.length && (o = [...o, ...e.customItems]), o;
398
- }, $ = (s, o) => {
451
+ let r = it(e.callbacks);
452
+ const i = o();
453
+ return i.length > 0 && (r = r.filter((m) => !i.includes(m.type))), e.customItems?.length && (r = [...r, ...e.customItems]), r;
454
+ }, b = (n = !1) => {
455
+ const o = $;
456
+ t.hideContextMenu(), n && o?.isConnected && o.focus({
457
+ preventScroll: !0
458
+ });
459
+ }, K = () => {
460
+ B = f().at(-1)?.id ?? "first", v((n) => n.slice(0, -1));
461
+ }, U = (n, o) => {
399
462
  t.hideContextMenu();
400
- const p = [...o.items], c = e.callbacks;
401
- me(() => {
402
- He(s, p, c, o);
463
+ const r = [...o.items], i = e.callbacks;
464
+ Ee(() => {
465
+ st(n, r, i, o);
403
466
  });
404
- }, B = (s) => {
405
- if (!n) return s;
406
- const o = n.getBoundingClientRect();
407
- return pe(s, o, u.boundaryRect());
408
- }, L = () => {
409
- O(h), h = void 0;
467
+ }, l = (n) => {
468
+ if (!I) return n;
469
+ const o = I.getBoundingClientRect();
470
+ return $e(n, o, y.boundaryRect());
471
+ }, u = () => {
472
+ oe(V), V = void 0;
410
473
  };
411
- W(() => {
412
- if (i || !t.contextMenu()) return;
413
- const s = Oe({
474
+ H(() => {
475
+ if (h || !t.contextMenu()) return;
476
+ const n = ut({
414
477
  ownerWindow: window,
415
- contextMenuId: m,
416
- onDismiss: t.hideContextMenu
478
+ contextMenuId: A,
479
+ onDismiss: (o) => b(o === "escape")
417
480
  });
418
- H(() => {
419
- s();
481
+ Q(() => {
482
+ n();
420
483
  });
421
- }), W(() => {
422
- const s = t.contextMenu();
423
- if (!s) {
424
- L(), f(k("closed", ++P));
425
- return;
426
- }
427
- L();
428
- const o = ++P, p = {
429
- x: s.x,
430
- y: s.y
484
+ }), H(() => {
485
+ const n = t.contextMenu();
486
+ J(() => {
487
+ v([]), B = "first";
488
+ const o = De()?.target, r = o?.closest("button, [tabindex], a[href]") ?? o;
489
+ $ = e.owner ?? (r instanceof HTMLElement ? r : !h && document.activeElement instanceof HTMLElement ? document.activeElement : null), g(typeof window < "u" && !!window.matchMedia?.(`${s.config.layout.mobileQuery}, (pointer: coarse)`).matches);
490
+ }), n || (u(), N(T("closed", ++k)));
491
+ }), H(() => {
492
+ const n = t.contextMenu();
493
+ if (f(), e.boundary, !n) return;
494
+ u();
495
+ const o = ++k, r = {
496
+ x: n.x,
497
+ y: n.y
498
+ };
499
+ N(T("measuring", o, r)), V = ne(() => J(() => {
500
+ if (V = void 0, k !== o) return;
501
+ const i = j();
502
+ if (!i || e.boundary !== void 0 && (i.width <= 16 || i.height <= 16)) {
503
+ b();
504
+ return;
505
+ }
506
+ const m = l(r);
507
+ N(T("positioned", o, r, m));
508
+ const x = B, D = Array.from(I?.querySelectorAll("[data-file-menu-item]") ?? []).find((Z) => Z.dataset.fileMenuItem === x);
509
+ D ? D.focus({
510
+ preventScroll: !0
511
+ }) : X(I, x === "last" ? "last" : "first"), B = "first";
512
+ }));
513
+ }), H(Se(() => e.boundary, () => {
514
+ t.contextMenu() && b();
515
+ }, {
516
+ defer: !0
517
+ })), H(() => {
518
+ if (!t.contextMenu() || h) return;
519
+ const n = () => b();
520
+ window.visualViewport?.addEventListener("resize", n), window.visualViewport?.addEventListener("scroll", n), window.addEventListener("blur", n);
521
+ const o = (c) => {
522
+ te(_()) && !G(c, A) && b();
431
523
  };
432
- f(k("measuring", o, p)), h = z(() => {
433
- if (h = void 0, P !== o) return;
434
- const c = B(p);
435
- f(k("positioned", o, p, c)), T(n, "first");
524
+ document.addEventListener("focusin", o, !0);
525
+ const r = e.boundary, i = [S().boundaryHost, r instanceof HTMLElement ? r : null].filter((c) => !!c), m = i.map((c) => c.getBoundingClientRect()), x = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
526
+ i.some((c, ie) => {
527
+ const se = c.getBoundingClientRect();
528
+ return se.width !== m[ie].width || se.height !== m[ie].height;
529
+ }) && b();
436
530
  });
437
- }), H(() => {
438
- L();
531
+ i.forEach((c) => x?.observe(c));
532
+ const D = e.owner ?? $ ?? i[0], Z = [];
533
+ for (let c = D; c; c = c.parentElement) Z.push(c);
534
+ const re = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
535
+ Z.some((c) => !c.isConnected || c.inert || c.hidden || c.getAttribute("aria-hidden") === "true" || getComputedStyle(c).display === "none" || getComputedStyle(c).visibility === "hidden") && b();
536
+ });
537
+ Z.forEach((c) => re?.observe(c, {
538
+ attributes: !0,
539
+ attributeFilter: ["hidden", "inert", "aria-hidden", "style", "class"]
540
+ })), Q(() => {
541
+ x?.disconnect(), re?.disconnect(), document.removeEventListener("focusin", o, !0), window.visualViewport?.removeEventListener("resize", n), window.visualViewport?.removeEventListener("scroll", n), window.removeEventListener("blur", n);
542
+ });
543
+ }), Q(() => {
544
+ u();
439
545
  });
440
- const g = () => ie(v()), D = () => u.projectPosition(v().position), E = (s) => (() => {
441
- var o = ne(), p = n;
442
- return typeof p == "function" ? j(p, o) : n = o, w(o, "data-floe-context-menu", m), Q(o, X({
546
+ const p = () => te(_()), L = () => y.projectPosition(_().position), P = (n) => (() => {
547
+ var o = we(), r = I;
548
+ return typeof r == "function" ? W(r, o) : I = o, de(o, me(() => e.scrollViewportProps, {
549
+ onScroll: () => O((i) => i + 1),
443
550
  get class() {
444
- return q(u.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", g() && "animate-in fade-in zoom-in-95 duration-100");
445
- }
551
+ return ee(y.isSurfaceMode() ? "absolute z-20 py-1" : "fixed z-50 py-1", "bg-popover border border-border rounded-lg shadow-lg overflow-y-auto overscroll-contain touch-pan-y motion-reduce:animate-none", p() && (a() ? "animate-in fade-in" : "animate-in fade-in zoom-in-95"));
552
+ },
553
+ "data-floe-context-menu": A
446
554
  }, () => ({
447
- [te]: u.isSurfaceMode() ? "true" : void 0
555
+ [ge]: "true",
556
+ [ve]: y.isSurfaceMode() ? "true" : void 0
448
557
  }), {
449
558
  get style() {
450
559
  return {
451
- left: `${D().x}px`,
452
- top: `${D().y}px`,
453
- visibility: g() ? "visible" : "hidden",
454
- "pointer-events": g() ? "auto" : "none"
560
+ ...y.sizeStyle(),
561
+ left: `${L().x}px`,
562
+ top: `${L().y}px`,
563
+ visibility: p() ? "visible" : "hidden",
564
+ "pointer-events": p() ? "auto" : "none"
455
565
  };
456
566
  },
457
567
  role: "menu",
458
568
  get "aria-hidden"() {
459
- return g() ? void 0 : "true";
569
+ return p() ? void 0 : "true";
460
570
  },
461
571
  "aria-orientation": "vertical",
462
- onKeyDown: (c) => se(c, {
463
- onDismiss: t.hideContextMenu
464
- })
465
- }), !1, !0), M(o, d(ee, {
572
+ onKeyDown: (i) => be(i, {
573
+ onDismiss: () => b(i.key === "Escape" || i.key === "Tab"),
574
+ onCloseSubmenu: f().length ? K : void 0
575
+ }),
576
+ onContextMenu: (i) => i.preventDefault()
577
+ }), !1, !0), M(o, d(F, {
578
+ get when() {
579
+ return f().length > 0;
580
+ },
581
+ get children() {
582
+ var i = Ge(), m = i.firstChild, x = m.nextSibling;
583
+ return i.$$click = K, M(i, d(Le, {
584
+ class: "h-3.5 w-3.5 shrink-0"
585
+ }), m), M(m, () => e.backLabel ?? "Back"), M(x, () => f().at(-1)?.label), R((D) => fe(i, "min-height", a() ? "44px" : void 0)), i;
586
+ }
587
+ }), null), M(o, d(he, {
466
588
  get each() {
467
- return A();
589
+ return Y();
468
590
  },
469
- children: (c) => [d(ae, {
470
- item: c,
591
+ children: (i) => [d(xe, {
592
+ item: i,
593
+ get path() {
594
+ return f();
595
+ },
596
+ get scrollRevision() {
597
+ return w();
598
+ },
471
599
  get menu() {
472
- return s.menu();
600
+ return n.menu();
473
601
  },
474
- contextMenuId: m,
475
- portalLayout: u,
476
- onSelect: $,
477
- get onDismiss() {
478
- return t.hideContextMenu;
479
- }
480
- }), d(S, {
602
+ contextMenuId: A,
603
+ portalLayout: y,
604
+ onSelect: U,
605
+ onDismiss: () => b(!0)
606
+ }), d(F, {
481
607
  get when() {
482
- return c.separator;
608
+ return i.separator;
483
609
  },
484
610
  get children() {
485
- return oe();
611
+ return ye();
486
612
  }
487
613
  })]
488
- })), o;
614
+ }), null), o;
489
615
  })();
490
- return d(S, {
616
+ return d(F, {
491
617
  get when() {
492
618
  return t.contextMenu();
493
619
  },
494
- children: (s) => i ? d(E, {
495
- menu: s
496
- }) : d(J, {
620
+ children: (n) => h ? d(P, {
621
+ menu: n
622
+ }) : d(ce, {
497
623
  get mount() {
498
- return u.mount();
624
+ return y.mount();
499
625
  },
500
626
  get children() {
501
- return d(E, {
502
- menu: s
627
+ return d(P, {
628
+ menu: n
503
629
  });
504
630
  }
505
631
  })
506
632
  });
507
633
  }
508
- le(["click", "keydown"]);
634
+ ke(["click", "keydown"]);
509
635
  export {
510
- Ye as FileContextMenu,
511
- Ne as createDefaultContextMenuItems,
512
- He as dispatchContextMenuAction,
513
- Oe as installContextMenuDismissListeners
636
+ bt as FileContextMenu,
637
+ it as createDefaultContextMenuItems,
638
+ st as dispatchContextMenuAction,
639
+ ut as installContextMenuDismissListeners
514
640
  };