@floegence/floe-webapp-core 0.36.54 → 0.36.56

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,83 +1,108 @@
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;
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;
32
32
  })();
33
- let De = 0;
34
- function Pe(e) {
33
+ let Be = 0;
34
+ const re = {
35
+ x: -9999,
36
+ y: -9999
37
+ };
38
+ function k(e, t = 0, n = re, i = n) {
39
+ return {
40
+ phase: e,
41
+ requestId: t,
42
+ anchor: n,
43
+ position: i
44
+ };
45
+ }
46
+ function ie(e) {
47
+ return e.phase === "positioned";
48
+ }
49
+ function z(e) {
50
+ if (typeof requestAnimationFrame != "function") {
51
+ e(0);
52
+ return;
53
+ }
54
+ return requestAnimationFrame(e);
55
+ }
56
+ function O(e) {
57
+ e === void 0 || typeof cancelAnimationFrame != "function" || cancelAnimationFrame(e);
58
+ }
59
+ function Ne(e) {
35
60
  const t = !!e?.onAskAgent, n = !!e?.onCopyName;
36
61
  return [{
37
62
  id: "duplicate",
38
63
  label: "Duplicate",
39
64
  type: "duplicate",
40
- icon: xe,
65
+ icon: _e,
41
66
  shortcut: "Cmd+D",
42
67
  separator: !n && !t
43
68
  }, ...n ? [{
44
69
  id: "copy-name",
45
70
  label: "Copy Name",
46
71
  type: "copy-name",
47
- icon: be,
72
+ icon: Ae,
48
73
  separator: !t
49
74
  }] : [], ...t ? [{
50
75
  id: "ask-agent",
51
76
  label: "Ask Agent",
52
77
  type: "ask-agent",
53
- icon: Me,
78
+ icon: Le,
54
79
  separator: !0
55
80
  }] : [], {
56
81
  id: "copy-to",
57
82
  label: "Copy to...",
58
83
  type: "copy-to",
59
- icon: ke
84
+ icon: Re
60
85
  }, {
61
86
  id: "move-to",
62
87
  label: "Move to...",
63
88
  type: "move-to",
64
- icon: Ce,
89
+ icon: Fe,
65
90
  separator: !0
66
91
  }, {
67
92
  id: "rename",
68
93
  label: "Rename",
69
94
  type: "rename",
70
- icon: Se,
95
+ icon: Te,
71
96
  shortcut: "Enter"
72
97
  }, {
73
98
  id: "delete",
74
99
  label: "Delete",
75
100
  type: "delete",
76
- icon: $e,
101
+ icon: je,
77
102
  shortcut: "Del"
78
103
  }];
79
104
  }
80
- function Ie(e, t, n, i) {
105
+ function He(e, t, n, i) {
81
106
  switch (e.type) {
82
107
  case "duplicate":
83
108
  n?.onDuplicate?.(t);
@@ -105,20 +130,20 @@ function Ie(e, t, n, i) {
105
130
  break;
106
131
  }
107
132
  }
108
- function G(e, t) {
133
+ function se(e, t) {
109
134
  const n = e.target, i = n?.closest('[role="menu"]'), m = n?.closest('[role="menuitem"]');
110
135
  switch (e.key) {
111
136
  case "ArrowDown":
112
- e.preventDefault(), N(i, m, 1);
137
+ e.preventDefault(), G(i, m, 1);
113
138
  return;
114
139
  case "ArrowUp":
115
- e.preventDefault(), N(i, m, -1);
140
+ e.preventDefault(), G(i, m, -1);
116
141
  return;
117
142
  case "Home":
118
- e.preventDefault(), L(i, "first");
143
+ e.preventDefault(), T(i, "first");
119
144
  return;
120
145
  case "End":
121
- e.preventDefault(), L(i, "last");
146
+ e.preventDefault(), T(i, "last");
122
147
  return;
123
148
  case "ArrowLeft":
124
149
  if (!t.onCloseSubmenu) return;
@@ -138,148 +163,170 @@ function G(e, t) {
138
163
  return;
139
164
  }
140
165
  }
141
- function Le(e, t) {
166
+ function qe(e, t) {
142
167
  return !e || typeof e != "object" ? !1 : ("dataset" in e ? e.dataset : void 0)?.floeContextMenu === t;
143
168
  }
144
- function _e(e, t) {
169
+ function ze(e, t) {
145
170
  if (typeof e.composedPath == "function") {
146
171
  const i = e.composedPath();
147
172
  for (const m of i)
148
- if (Le(m, t)) return !0;
173
+ if (qe(m, t)) return !0;
149
174
  }
150
175
  const n = e.target;
151
176
  return typeof Element < "u" && n instanceof Element ? !!n.closest(`[data-floe-context-menu="${t}"]`) : !1;
152
177
  }
153
- function Ee(e) {
178
+ function Oe(e) {
154
179
  const {
155
180
  ownerWindow: t,
156
181
  contextMenuId: n,
157
182
  onDismiss: i
158
- } = e, m = (c) => {
159
- _e(c, n) || i();
160
- }, y = (c) => {
161
- c.key === "Escape" && i();
162
- }, h = () => {
183
+ } = e, m = (h) => {
184
+ ze(h, n) || i();
185
+ }, v = (h) => {
186
+ h.key === "Escape" && i();
187
+ }, f = () => {
163
188
  i();
164
189
  };
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);
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);
167
192
  };
168
193
  }
169
- function J(e) {
170
- const [t, n] = E(!1), [i, m] = E({
171
- x: -9999,
172
- y: -9999
173
- });
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);
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();
200
+ return {
201
+ x: a.right,
202
+ y: a.top
203
+ };
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();
184
226
  }));
185
- }, S = () => {
186
- x(), n(!1), requestAnimationFrame(() => h?.focus());
187
- }, o = () => {
188
- !f() || e.item.disabled || (x(), p = setTimeout(() => {
189
- $("first");
227
+ }, p = () => {
228
+ !u() || e.item.disabled || (g(), f = setTimeout(() => {
229
+ s("first");
190
230
  }, 100));
191
- }, s = () => {
192
- f() && (x(), p = setTimeout(() => {
193
- n(!1);
231
+ }, c = () => {
232
+ u() && (g(), f = setTimeout(() => {
233
+ o({
234
+ restoreFocus: !1
235
+ });
194
236
  }, 150));
195
- }, w = (l) => {
237
+ }, N = (a) => {
196
238
  if (!e.item.disabled) {
197
- if (f()) {
198
- l.preventDefault(), l.stopPropagation(), t() ? S() : $("first");
239
+ if (u()) {
240
+ a.preventDefault(), a.stopPropagation(), A() ? o() : s("first");
199
241
  return;
200
242
  }
201
243
  e.onSelect(e.item, e.menu);
202
244
  }
203
245
  };
204
- q(() => {
205
- x();
246
+ H(() => {
247
+ g(), D(), E();
206
248
  });
207
- const u = () => e.portalLayout.projectPosition(i());
249
+ const V = () => e.portalLayout.projectPosition(t().position);
208
250
  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, {
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, {
217
259
  get when() {
218
260
  return e.item.icon;
219
261
  },
220
- children: (r) => a(Q, {
262
+ children: (r) => d(ue, {
221
263
  get component() {
222
264
  return r();
223
265
  },
224
266
  class: "w-3.5 h-3.5 opacity-60"
225
267
  })
226
- }), P), b(P, () => e.item.label), b(d, a(C, {
268
+ }), b), M(b, () => e.item.label), M(l, d(S, {
227
269
  get when() {
228
- return H(() => !!e.item.shortcut)() && !f();
270
+ return U(() => !!e.item.shortcut)() && !u();
229
271
  },
230
272
  get children() {
231
- var r = ye();
232
- return b(r, () => e.item.shortcut), r;
273
+ var r = De();
274
+ return M(r, () => e.item.shortcut), r;
233
275
  }
234
- }), null), b(d, a(C, {
276
+ }), null), M(l, d(S, {
235
277
  get when() {
236
- return f();
278
+ return u();
237
279
  },
238
280
  get children() {
239
- return a(ne, {
281
+ return d(fe, {
240
282
  class: "w-3 h-3 text-muted-foreground"
241
283
  });
242
284
  }
243
- }), null), b(l, a(C, {
285
+ }), null), M(a, d(S, {
244
286
  get when() {
245
- return H(() => !!t())() && f();
287
+ return U(() => !!A())() && u();
246
288
  },
247
289
  get children() {
248
- return a(z, {
290
+ return d(J, {
249
291
  get mount() {
250
292
  return e.portalLayout.mount();
251
293
  },
252
294
  get children() {
253
- var r = U(), D = c;
254
- return typeof D == "function" ? I(D, r) : c = r, V(r, O({
295
+ var r = ne(), R = v;
296
+ return typeof R == "function" ? j(R, r) : v = r, Q(r, X({
255
297
  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");
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");
257
299
  },
258
300
  get "data-floe-context-menu"() {
259
301
  return e.contextMenuId;
260
302
  }
261
303
  }, () => ({
262
- [K]: e.portalLayout.isSurfaceMode() ? "true" : void 0
304
+ [te]: e.portalLayout.isSurfaceMode() ? "true" : void 0
263
305
  }), {
264
306
  get style() {
265
307
  return {
266
- left: `${u().x}px`,
267
- top: `${u().y}px`
308
+ left: `${V().x}px`,
309
+ top: `${V().y}px`,
310
+ visibility: $() ? "visible" : "hidden",
311
+ "pointer-events": $() ? "auto" : "none"
268
312
  };
269
313
  },
270
314
  role: "menu",
271
- onMouseEnter: x,
272
- onMouseLeave: s,
273
- onKeyDown: (k) => G(k, {
315
+ get "aria-hidden"() {
316
+ return $() ? void 0 : "true";
317
+ },
318
+ onMouseEnter: g,
319
+ onMouseLeave: c,
320
+ onKeyDown: (I) => se(I, {
274
321
  onDismiss: e.onDismiss,
275
- onCloseSubmenu: S
322
+ onCloseSubmenu: o
276
323
  })
277
- }), !1, !0), b(r, a(Z, {
324
+ }), !1, !0), M(r, d(ee, {
278
325
  get each() {
279
326
  return e.item.children;
280
327
  },
281
- children: (k) => [a(J, {
282
- item: k,
328
+ children: (I) => [d(ae, {
329
+ item: I,
283
330
  get menu() {
284
331
  return e.menu;
285
332
  },
@@ -295,175 +342,173 @@ function J(e) {
295
342
  get onDismiss() {
296
343
  return e.onDismiss;
297
344
  }
298
- }), a(C, {
345
+ }), d(S, {
299
346
  get when() {
300
- return k.separator;
347
+ return I.separator;
301
348
  },
302
349
  get children() {
303
- return W();
350
+ return oe();
304
351
  }
305
352
  })]
306
353
  })), r;
307
354
  }
308
355
  });
309
356
  }
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;
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;
313
360
  }, {
314
361
  e: void 0,
315
362
  t: void 0,
316
363
  a: void 0,
317
364
  o: void 0
318
- }), l;
365
+ }), a;
319
366
  })();
320
367
  }
321
- function Ve(e) {
322
- const t = se();
368
+ function Ye(e) {
369
+ const t = ve();
323
370
  let n;
324
- const i = typeof window > "u" || typeof document > "u", m = `floe-context-menu-${De += 1}`, [y, h] = E({
325
- x: -9999,
326
- y: -9999
327
- }), c = ee(() => t.contextMenu() ? ie() : {
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() : {
328
374
  host: null,
329
375
  boundaryHost: null,
330
376
  mountHost: null,
331
377
  mode: "global"
332
- }), p = {
333
- mount: () => ce(c()),
334
- isSurfaceMode: () => le(c()),
335
- boundaryRect: () => ue(c()),
336
- projectPosition: (o) => ae(o, c())
337
- }, f = () => {
378
+ }), u = {
379
+ mount: () => be(x()),
380
+ isSurfaceMode: () => xe(x()),
381
+ boundaryRect: () => we(x()),
382
+ projectPosition: (s) => ye(s, x())
383
+ }, A = () => {
338
384
  if (e.overrideItems)
339
385
  return e.overrideItems;
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);
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);
346
392
  }
347
- return u;
393
+ return c;
348
394
  };
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) => {
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) => {
353
399
  t.hideContextMenu();
354
- const w = [...s.items], u = e.callbacks;
355
- te(() => {
356
- Ie(o, w, u, s);
400
+ const p = [...o.items], c = e.callbacks;
401
+ me(() => {
402
+ He(s, p, c, o);
357
403
  });
358
- }, x = () => {
359
- const o = t.contextMenu();
360
- if (!o || !n) return {
361
- x: o?.x ?? 0,
362
- y: o?.y ?? 0
363
- };
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());
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;
372
410
  };
373
- F(() => {
411
+ W(() => {
374
412
  if (i || !t.contextMenu()) return;
375
- const o = Ee({
413
+ const s = Oe({
376
414
  ownerWindow: window,
377
415
  contextMenuId: m,
378
416
  onDismiss: t.hideContextMenu
379
417
  });
380
- q(() => {
381
- o();
418
+ H(() => {
419
+ s();
382
420
  });
383
- }), F(() => {
384
- const o = t.contextMenu();
385
- if (!o) {
386
- h({
387
- x: -9999,
388
- y: -9999
389
- });
421
+ }), W(() => {
422
+ const s = t.contextMenu();
423
+ if (!s) {
424
+ L(), f(k("closed", ++P));
390
425
  return;
391
426
  }
392
- h({
393
- x: o.x,
394
- y: o.y
395
- }), requestAnimationFrame(() => {
396
- const s = x();
397
- h(s), L(n, "first");
427
+ L();
428
+ const o = ++P, p = {
429
+ x: s.x,
430
+ y: s.y
431
+ };
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");
398
436
  });
437
+ }), H(() => {
438
+ L();
399
439
  });
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({
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({
403
443
  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");
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");
405
445
  }
406
446
  }, () => ({
407
- [K]: p.isSurfaceMode() ? "true" : void 0
447
+ [te]: u.isSurfaceMode() ? "true" : void 0
408
448
  }), {
409
449
  get style() {
410
450
  return {
411
- left: `${$().x}px`,
412
- top: `${$().y}px`
451
+ left: `${D().x}px`,
452
+ top: `${D().y}px`,
453
+ visibility: g() ? "visible" : "hidden",
454
+ "pointer-events": g() ? "auto" : "none"
413
455
  };
414
456
  },
415
457
  role: "menu",
458
+ get "aria-hidden"() {
459
+ return g() ? void 0 : "true";
460
+ },
416
461
  "aria-orientation": "vertical",
417
- onKeyDown: (u) => G(u, {
462
+ onKeyDown: (c) => se(c, {
418
463
  onDismiss: t.hideContextMenu
419
464
  })
420
- }), !1, !0), b(s, a(Z, {
465
+ }), !1, !0), M(o, d(ee, {
421
466
  get each() {
422
- return f();
467
+ return A();
423
468
  },
424
- children: (u) => [a(J, {
425
- item: u,
469
+ children: (c) => [d(ae, {
470
+ item: c,
426
471
  get menu() {
427
- return o.menu();
472
+ return s.menu();
428
473
  },
429
474
  contextMenuId: m,
430
- portalLayout: p,
431
- onSelect: _,
475
+ portalLayout: u,
476
+ onSelect: $,
432
477
  get onDismiss() {
433
478
  return t.hideContextMenu;
434
479
  }
435
- }), a(C, {
480
+ }), d(S, {
436
481
  get when() {
437
- return u.separator;
482
+ return c.separator;
438
483
  },
439
484
  get children() {
440
- return W();
485
+ return oe();
441
486
  }
442
487
  })]
443
- })), s;
488
+ })), o;
444
489
  })();
445
- return a(C, {
490
+ return d(S, {
446
491
  get when() {
447
492
  return t.contextMenu();
448
493
  },
449
- children: (o) => i ? a(S, {
450
- menu: o
451
- }) : a(z, {
494
+ children: (s) => i ? d(E, {
495
+ menu: s
496
+ }) : d(J, {
452
497
  get mount() {
453
- return p.mount();
498
+ return u.mount();
454
499
  },
455
500
  get children() {
456
- return a(S, {
457
- menu: o
501
+ return d(E, {
502
+ menu: s
458
503
  });
459
504
  }
460
505
  })
461
506
  });
462
507
  }
463
- Y(["click", "keydown"]);
508
+ le(["click", "keydown"]);
464
509
  export {
465
- Ve as FileContextMenu,
466
- Pe as createDefaultContextMenuItems,
467
- Ie as dispatchContextMenuAction,
468
- Ee as installContextMenuDismissListeners
510
+ Ye as FileContextMenu,
511
+ Ne as createDefaultContextMenuItems,
512
+ He as dispatchContextMenuAction,
513
+ Oe as installContextMenuDismissListeners
469
514
  };
@@ -67,7 +67,7 @@ function ve(e) {
67
67
  }), te({
68
68
  open: h,
69
69
  root: () => p,
70
- containsTarget: (t) => r() && V(t),
70
+ containsTarget: r() ? (t) => V(t) : void 0,
71
71
  onClose: () => e.onOpenChange(!1),
72
72
  lockBodyScroll: () => !r(),
73
73
  trapFocus: !0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.54",
3
+ "version": "0.36.56",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",