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