@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.
- package/dist/components/file-browser/FileContextMenu.d.ts +12 -2
- package/dist/components/file-browser/FileContextMenu.js +394 -268
- package/dist/components/file-browser/index.d.ts +1 -0
- package/dist/components/file-browser/longPressContextMenu.js +58 -45
- package/dist/components/ui/SurfaceFloatingLayer.d.ts +2 -0
- package/dist/components/ui/SurfaceFloatingLayer.js +29 -24
- package/dist/components/ui/dialogSurfaceScope.d.ts +5 -0
- package/dist/components/ui/dialogSurfaceScope.js +81 -70
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/surfaceFloatingBoundary.d.ts +12 -0
- package/dist/components/ui/surfaceFloatingBoundary.js +53 -0
- package/dist/components/ui/surfacePortalScope.d.ts +1 -1
- package/dist/file-browser.js +26 -24
- package/dist/full.js +204 -200
- package/dist/styles.css +1 -1
- package/dist/ui.js +15 -13
- package/package.json +1 -1
|
@@ -1,149 +1,151 @@
|
|
|
1
|
-
import { createComponent as d, Portal as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { deferAfterPaint as
|
|
5
|
-
import { ChevronRight as
|
|
6
|
-
import { focusMenuItem as
|
|
7
|
-
import { LOCAL_INTERACTION_SURFACE_ATTR as
|
|
8
|
-
import {
|
|
9
|
-
import { resolveSurfacePortalHost as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
34
|
-
const
|
|
35
|
+
let rt = 0;
|
|
36
|
+
const pe = {
|
|
35
37
|
x: -9999,
|
|
36
38
|
y: -9999
|
|
37
39
|
};
|
|
38
|
-
function
|
|
40
|
+
function T(e, t = 0, s = pe, a = s) {
|
|
39
41
|
return {
|
|
40
42
|
phase: e,
|
|
41
43
|
requestId: t,
|
|
42
|
-
anchor:
|
|
43
|
-
position:
|
|
44
|
+
anchor: s,
|
|
45
|
+
position: a
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
function
|
|
48
|
+
function te(e) {
|
|
47
49
|
return e.phase === "positioned";
|
|
48
50
|
}
|
|
49
|
-
function
|
|
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
|
|
58
|
+
function oe(e) {
|
|
57
59
|
e === void 0 || typeof cancelAnimationFrame != "function" || cancelAnimationFrame(e);
|
|
58
60
|
}
|
|
59
|
-
function
|
|
60
|
-
const t = !!e?.onAskAgent,
|
|
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:
|
|
67
|
+
icon: Je,
|
|
66
68
|
shortcut: "Cmd+D",
|
|
67
|
-
separator: !
|
|
68
|
-
}, ...
|
|
69
|
+
separator: !s && !t
|
|
70
|
+
}, ...s ? [{
|
|
69
71
|
id: "copy-name",
|
|
70
72
|
label: "Copy Name",
|
|
71
73
|
type: "copy-name",
|
|
72
|
-
icon:
|
|
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:
|
|
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:
|
|
86
|
+
icon: et
|
|
85
87
|
}, {
|
|
86
88
|
id: "move-to",
|
|
87
89
|
label: "Move to...",
|
|
88
90
|
type: "move-to",
|
|
89
|
-
icon:
|
|
91
|
+
icon: tt,
|
|
90
92
|
separator: !0
|
|
91
93
|
}, {
|
|
92
94
|
id: "rename",
|
|
93
95
|
label: "Rename",
|
|
94
96
|
type: "rename",
|
|
95
|
-
icon:
|
|
97
|
+
icon: ot,
|
|
96
98
|
shortcut: "Enter"
|
|
97
99
|
}, {
|
|
98
100
|
id: "delete",
|
|
99
101
|
label: "Delete",
|
|
100
102
|
type: "delete",
|
|
101
|
-
icon:
|
|
103
|
+
icon: nt,
|
|
102
104
|
shortcut: "Del"
|
|
103
105
|
}];
|
|
104
106
|
}
|
|
105
|
-
function
|
|
107
|
+
function st(e, t, s, a) {
|
|
106
108
|
switch (e.type) {
|
|
107
109
|
case "duplicate":
|
|
108
|
-
|
|
110
|
+
s?.onDuplicate?.(t);
|
|
109
111
|
break;
|
|
110
112
|
case "copy-name":
|
|
111
|
-
|
|
113
|
+
s?.onCopyName?.(t);
|
|
112
114
|
break;
|
|
113
115
|
case "ask-agent":
|
|
114
|
-
|
|
116
|
+
s?.onAskAgent?.(t);
|
|
115
117
|
break;
|
|
116
118
|
case "copy-to":
|
|
117
|
-
|
|
119
|
+
s?.onCopyTo?.(t);
|
|
118
120
|
break;
|
|
119
121
|
case "move-to":
|
|
120
|
-
|
|
122
|
+
s?.onMoveTo?.(t);
|
|
121
123
|
break;
|
|
122
124
|
case "delete":
|
|
123
|
-
|
|
125
|
+
s?.onDelete?.(t);
|
|
124
126
|
break;
|
|
125
127
|
case "rename":
|
|
126
|
-
t.length === 1 &&
|
|
128
|
+
t.length === 1 && s?.onRename?.(t[0]);
|
|
127
129
|
break;
|
|
128
130
|
case "custom":
|
|
129
|
-
e.onAction?.(t,
|
|
131
|
+
e.onAction?.(t, a);
|
|
130
132
|
break;
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
function
|
|
134
|
-
const
|
|
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(),
|
|
139
|
+
e.preventDefault(), le(a, g, 1);
|
|
138
140
|
return;
|
|
139
141
|
case "ArrowUp":
|
|
140
|
-
e.preventDefault(),
|
|
142
|
+
e.preventDefault(), le(a, g, -1);
|
|
141
143
|
return;
|
|
142
144
|
case "Home":
|
|
143
|
-
e.preventDefault(),
|
|
145
|
+
e.preventDefault(), X(a, "first");
|
|
144
146
|
return;
|
|
145
147
|
case "End":
|
|
146
|
-
e.preventDefault(),
|
|
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
|
|
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
|
|
171
|
+
function G(e, t) {
|
|
170
172
|
if (typeof e.composedPath == "function") {
|
|
171
|
-
const
|
|
172
|
-
for (const
|
|
173
|
-
if (
|
|
173
|
+
const a = e.composedPath();
|
|
174
|
+
for (const g of a)
|
|
175
|
+
if (at(g, t)) return !0;
|
|
174
176
|
}
|
|
175
|
-
const
|
|
176
|
-
return typeof Element < "u" &&
|
|
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
|
|
180
|
+
function ut(e) {
|
|
179
181
|
const {
|
|
180
182
|
ownerWindow: t,
|
|
181
|
-
contextMenuId:
|
|
182
|
-
onDismiss:
|
|
183
|
-
} = e,
|
|
184
|
-
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
|
|
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",
|
|
191
|
-
t.removeEventListener("pointerdown",
|
|
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
|
|
195
|
-
const [t,
|
|
196
|
-
let
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
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:
|
|
202
|
-
y:
|
|
209
|
+
x: l.right,
|
|
210
|
+
y: l.top
|
|
203
211
|
};
|
|
204
|
-
},
|
|
205
|
-
if (!
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
},
|
|
215
|
-
if (!
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
},
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
},
|
|
232
|
-
|
|
233
|
-
|
|
249
|
+
}, b = () => {
|
|
250
|
+
h() && (k(), v = setTimeout(() => {
|
|
251
|
+
y({
|
|
234
252
|
restoreFocus: !1
|
|
235
253
|
});
|
|
236
254
|
}, 150));
|
|
237
|
-
},
|
|
255
|
+
}, K = (l) => {
|
|
238
256
|
if (!e.item.disabled) {
|
|
239
|
-
if (
|
|
240
|
-
|
|
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
|
-
|
|
247
|
-
|
|
264
|
+
Q(() => {
|
|
265
|
+
k(), S(), q();
|
|
248
266
|
});
|
|
249
|
-
const
|
|
267
|
+
const U = () => e.portalLayout.projectPosition(t().position);
|
|
250
268
|
return (() => {
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
var
|
|
254
|
-
typeof
|
|
255
|
-
e.item.disabled || !
|
|
256
|
-
},
|
|
257
|
-
var
|
|
258
|
-
return typeof
|
|
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: (
|
|
280
|
+
children: (n) => d(Me, {
|
|
263
281
|
get component() {
|
|
264
|
-
return
|
|
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
|
-
}),
|
|
286
|
+
}), p), M(p, () => e.item.label), M(u, d(F, {
|
|
269
287
|
get when() {
|
|
270
|
-
return
|
|
288
|
+
return ae(() => !!e.item.shortcut)() && !h();
|
|
271
289
|
},
|
|
272
290
|
get children() {
|
|
273
|
-
var
|
|
274
|
-
return M(
|
|
291
|
+
var n = We();
|
|
292
|
+
return M(n, () => e.item.shortcut), n;
|
|
275
293
|
}
|
|
276
|
-
}), null), M(
|
|
294
|
+
}), null), M(u, d(F, {
|
|
277
295
|
get when() {
|
|
278
|
-
return
|
|
296
|
+
return h();
|
|
279
297
|
},
|
|
280
298
|
get children() {
|
|
281
|
-
return d(
|
|
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(
|
|
303
|
+
}), null), M(l, d(F, {
|
|
286
304
|
get when() {
|
|
287
|
-
return
|
|
305
|
+
return ae(() => !!A())() && h();
|
|
288
306
|
},
|
|
289
307
|
get children() {
|
|
290
|
-
return d(
|
|
308
|
+
return d(ce, {
|
|
291
309
|
get mount() {
|
|
292
310
|
return e.portalLayout.mount();
|
|
293
311
|
},
|
|
294
312
|
get children() {
|
|
295
|
-
var
|
|
296
|
-
return typeof
|
|
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
|
|
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
|
-
[
|
|
323
|
+
[ge]: "true",
|
|
324
|
+
[ve]: e.portalLayout.isSurfaceMode() ? "true" : void 0
|
|
305
325
|
}), {
|
|
306
326
|
get style() {
|
|
307
327
|
return {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
|
337
|
+
return _() ? void 0 : "true";
|
|
317
338
|
},
|
|
318
|
-
onMouseEnter:
|
|
319
|
-
onMouseLeave:
|
|
320
|
-
onKeyDown: (
|
|
339
|
+
onMouseEnter: k,
|
|
340
|
+
onMouseLeave: b,
|
|
341
|
+
onKeyDown: (r) => be(r, {
|
|
321
342
|
onDismiss: e.onDismiss,
|
|
322
|
-
onCloseSubmenu:
|
|
343
|
+
onCloseSubmenu: y
|
|
323
344
|
})
|
|
324
|
-
}), !1, !0), M(
|
|
345
|
+
}), !1, !0), M(n, d(he, {
|
|
325
346
|
get each() {
|
|
326
347
|
return e.item.children;
|
|
327
348
|
},
|
|
328
|
-
children: (
|
|
329
|
-
item:
|
|
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(
|
|
372
|
+
}), d(F, {
|
|
346
373
|
get when() {
|
|
347
|
-
return
|
|
374
|
+
return r.separator;
|
|
348
375
|
},
|
|
349
376
|
get children() {
|
|
350
|
-
return
|
|
377
|
+
return ye();
|
|
351
378
|
}
|
|
352
379
|
})]
|
|
353
|
-
})),
|
|
380
|
+
})), n;
|
|
354
381
|
}
|
|
355
382
|
});
|
|
356
383
|
}
|
|
357
|
-
}), null),
|
|
358
|
-
var
|
|
359
|
-
return
|
|
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
|
-
|
|
391
|
+
o: void 0,
|
|
392
|
+
i: void 0,
|
|
393
|
+
n: void 0
|
|
394
|
+
}), l;
|
|
366
395
|
})();
|
|
367
396
|
}
|
|
368
|
-
function
|
|
369
|
-
const t =
|
|
370
|
-
let
|
|
371
|
-
const
|
|
372
|
-
let
|
|
373
|
-
const
|
|
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
|
-
}),
|
|
379
|
-
mount: () =>
|
|
380
|
-
isSurfaceMode: () =>
|
|
381
|
-
boundaryRect: () =>
|
|
382
|
-
|
|
383
|
-
|
|
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
|
|
387
|
-
const
|
|
388
|
-
if (!
|
|
389
|
-
if (typeof
|
|
390
|
-
const
|
|
391
|
-
return
|
|
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
|
|
449
|
+
return m;
|
|
394
450
|
};
|
|
395
|
-
let
|
|
396
|
-
const
|
|
397
|
-
return
|
|
398
|
-
},
|
|
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
|
|
401
|
-
|
|
402
|
-
|
|
463
|
+
const r = [...o.items], i = e.callbacks;
|
|
464
|
+
Ee(() => {
|
|
465
|
+
st(n, r, i, o);
|
|
403
466
|
});
|
|
404
|
-
},
|
|
405
|
-
if (!
|
|
406
|
-
const o =
|
|
407
|
-
return
|
|
408
|
-
},
|
|
409
|
-
|
|
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
|
-
|
|
412
|
-
if (
|
|
413
|
-
const
|
|
474
|
+
H(() => {
|
|
475
|
+
if (h || !t.contextMenu()) return;
|
|
476
|
+
const n = ut({
|
|
414
477
|
ownerWindow: window,
|
|
415
|
-
contextMenuId:
|
|
416
|
-
onDismiss:
|
|
478
|
+
contextMenuId: A,
|
|
479
|
+
onDismiss: (o) => b(o === "escape")
|
|
417
480
|
});
|
|
418
|
-
|
|
419
|
-
|
|
481
|
+
Q(() => {
|
|
482
|
+
n();
|
|
420
483
|
});
|
|
421
|
-
}),
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
-
|
|
438
|
-
|
|
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
|
|
441
|
-
var o =
|
|
442
|
-
return typeof
|
|
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
|
|
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
|
-
[
|
|
555
|
+
[ge]: "true",
|
|
556
|
+
[ve]: y.isSurfaceMode() ? "true" : void 0
|
|
448
557
|
}), {
|
|
449
558
|
get style() {
|
|
450
559
|
return {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
|
569
|
+
return p() ? void 0 : "true";
|
|
460
570
|
},
|
|
461
571
|
"aria-orientation": "vertical",
|
|
462
|
-
onKeyDown: (
|
|
463
|
-
onDismiss:
|
|
464
|
-
|
|
465
|
-
|
|
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
|
|
589
|
+
return Y();
|
|
468
590
|
},
|
|
469
|
-
children: (
|
|
470
|
-
item:
|
|
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
|
|
600
|
+
return n.menu();
|
|
473
601
|
},
|
|
474
|
-
contextMenuId:
|
|
475
|
-
portalLayout:
|
|
476
|
-
onSelect:
|
|
477
|
-
|
|
478
|
-
|
|
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
|
|
608
|
+
return i.separator;
|
|
483
609
|
},
|
|
484
610
|
get children() {
|
|
485
|
-
return
|
|
611
|
+
return ye();
|
|
486
612
|
}
|
|
487
613
|
})]
|
|
488
|
-
})), o;
|
|
614
|
+
}), null), o;
|
|
489
615
|
})();
|
|
490
|
-
return d(
|
|
616
|
+
return d(F, {
|
|
491
617
|
get when() {
|
|
492
618
|
return t.contextMenu();
|
|
493
619
|
},
|
|
494
|
-
children: (
|
|
495
|
-
menu:
|
|
496
|
-
}) : d(
|
|
620
|
+
children: (n) => h ? d(P, {
|
|
621
|
+
menu: n
|
|
622
|
+
}) : d(ce, {
|
|
497
623
|
get mount() {
|
|
498
|
-
return
|
|
624
|
+
return y.mount();
|
|
499
625
|
},
|
|
500
626
|
get children() {
|
|
501
|
-
return d(
|
|
502
|
-
menu:
|
|
627
|
+
return d(P, {
|
|
628
|
+
menu: n
|
|
503
629
|
});
|
|
504
630
|
}
|
|
505
631
|
})
|
|
506
632
|
});
|
|
507
633
|
}
|
|
508
|
-
|
|
634
|
+
ke(["click", "keydown"]);
|
|
509
635
|
export {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
636
|
+
bt as FileContextMenu,
|
|
637
|
+
it as createDefaultContextMenuItems,
|
|
638
|
+
st as dispatchContextMenuAction,
|
|
639
|
+
ut as installContextMenuDismissListeners
|
|
514
640
|
};
|