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