@floegence/floe-webapp-core 0.35.20 → 0.35.21
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,15 +1,15 @@
|
|
|
1
|
-
import { addEventListener as
|
|
2
|
-
import { createSignal as
|
|
1
|
+
import { addEventListener as le, use as K, insert as w, createComponent as b, effect as Y, setStyleProperty as X, className as G, template as C, spread as ce, mergeProps as se, memo as de, delegateEvents as ge } from "solid-js/web";
|
|
2
|
+
import { createSignal as W, createMemo as j, createEffect as ue, Show as p, For as q, untrack as me, onCleanup as fe } from "solid-js";
|
|
3
3
|
import { cn as $ } from "../../utils/cn.js";
|
|
4
|
-
import { useResizeObserver as
|
|
5
|
-
import { useVirtualWindow as
|
|
6
|
-
import { useFileBrowser as
|
|
7
|
-
import { useFileBrowserDrag as
|
|
8
|
-
import { FileItemIcon as
|
|
9
|
-
import { createLongPressContextMenuHandlers as
|
|
10
|
-
import { fileBrowserTouchTargetAttrs as
|
|
11
|
-
var
|
|
12
|
-
function
|
|
4
|
+
import { useResizeObserver as he } from "../../hooks/useResizeObserver.js";
|
|
5
|
+
import { useVirtualWindow as ve } from "../../hooks/useVirtualWindow.js";
|
|
6
|
+
import { useFileBrowser as J } from "./FileBrowserContext.js";
|
|
7
|
+
import { useFileBrowserDrag as xe } from "../../context/FileBrowserDragContext.js";
|
|
8
|
+
import { FileItemIcon as be } from "./FileIcons.js";
|
|
9
|
+
import { createLongPressContextMenuHandlers as Ce } from "./longPressContextMenu.js";
|
|
10
|
+
import { fileBrowserTouchTargetAttrs as De } from "./touchInteractionGuard.js";
|
|
11
|
+
var Ie = /* @__PURE__ */ C('<mark class="bg-warning/40 text-inherit rounded-sm">'), we = /* @__PURE__ */ C('<div class="grid gap-2">'), ye = /* @__PURE__ */ C('<div><div class=p-3><div class="w-full h-0"aria-hidden=true>'), Pe = /* @__PURE__ */ C('<span>No files matching "<!>"'), Se = /* @__PURE__ */ C('<button type=button class="px-2 py-1 rounded bg-muted hover:bg-muted/80 transition-colors">Clear Filter'), Me = /* @__PURE__ */ C('<div class="flex flex-col items-center justify-center h-32 gap-2 text-xs text-muted-foreground">'), _e = /* @__PURE__ */ C("<span>This folder is empty"), Te = /* @__PURE__ */ C('<div class="absolute top-1.5 right-1.5 w-4 h-4 rounded-full bg-primary flex items-center justify-center"><svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=3 stroke-linecap=round stroke-linejoin=round class="w-2.5 h-2.5 text-primary-foreground"><polyline points="20 6 9 17 4 12">'), Ee = /* @__PURE__ */ C("<button type=button><div></div><span></span><div>");
|
|
12
|
+
function Le(e) {
|
|
13
13
|
const n = j(() => {
|
|
14
14
|
if (!e.match || e.match.matchedIndices.length === 0)
|
|
15
15
|
return [{
|
|
@@ -17,82 +17,82 @@ function ke(e) {
|
|
|
17
17
|
highlight: !1
|
|
18
18
|
}];
|
|
19
19
|
const o = [], D = new Set(e.match.matchedIndices);
|
|
20
|
-
let h = "",
|
|
20
|
+
let h = "", d = !1;
|
|
21
21
|
for (let l = 0; l < e.name.length; l++) {
|
|
22
22
|
const f = D.has(l);
|
|
23
|
-
l === 0 ? (
|
|
23
|
+
l === 0 ? (d = f, h = e.name[l]) : f === d ? h += e.name[l] : (o.push({
|
|
24
24
|
text: h,
|
|
25
|
-
highlight:
|
|
26
|
-
}), h = e.name[l],
|
|
25
|
+
highlight: d
|
|
26
|
+
}), h = e.name[l], d = f);
|
|
27
27
|
}
|
|
28
28
|
return h && o.push({
|
|
29
29
|
text: h,
|
|
30
|
-
highlight:
|
|
30
|
+
highlight: d
|
|
31
31
|
}), o;
|
|
32
32
|
});
|
|
33
|
-
return b(
|
|
33
|
+
return b(q, {
|
|
34
34
|
get each() {
|
|
35
35
|
return n();
|
|
36
36
|
},
|
|
37
|
-
children: (o) => b(
|
|
37
|
+
children: (o) => b(p, {
|
|
38
38
|
get when() {
|
|
39
39
|
return o.highlight;
|
|
40
40
|
},
|
|
41
41
|
get fallback() {
|
|
42
|
-
return
|
|
42
|
+
return de(() => o.text);
|
|
43
43
|
},
|
|
44
44
|
get children() {
|
|
45
|
-
var D =
|
|
45
|
+
var D = Ie();
|
|
46
46
|
return w(D, () => o.text), D;
|
|
47
47
|
}
|
|
48
48
|
})
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
const n =
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
const x = Math.floor((
|
|
51
|
+
function Ne(e) {
|
|
52
|
+
const n = J(), o = xe(), D = () => (e.enableDragDrop ?? !0) && !!o, h = () => e.instanceId ?? "default", d = 112, l = 8, f = 180, y = 2, E = 6, [g, A] = W(null), O = he(g), v = j(() => {
|
|
53
|
+
const s = O()?.width ?? 0;
|
|
54
|
+
if (s <= 0) return y;
|
|
55
|
+
const x = Math.floor((s + l) / (f + l));
|
|
56
56
|
return Math.max(y, Math.min(E, x));
|
|
57
|
-
}), k = () =>
|
|
57
|
+
}), k = () => d + l, c = ve({
|
|
58
58
|
count: () => Math.ceil(n.currentFiles().length / Math.max(1, v())),
|
|
59
59
|
itemSize: k,
|
|
60
60
|
overscan: 2
|
|
61
|
-
}), N = () =>
|
|
62
|
-
let
|
|
63
|
-
return
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
P =
|
|
61
|
+
}), N = () => c.range().start * v(), L = () => Math.min(n.currentFiles().length, c.range().end * v()), F = j(() => n.currentFiles().slice(N(), L()));
|
|
62
|
+
let T = null, P = y;
|
|
63
|
+
return ue(() => {
|
|
64
|
+
const s = v();
|
|
65
|
+
if (!T) {
|
|
66
|
+
P = s;
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
if (
|
|
70
|
-
const x = k(), a = Math.floor(
|
|
71
|
-
|
|
69
|
+
if (s === P) return;
|
|
70
|
+
const x = k(), a = Math.floor(T.scrollTop / Math.max(1, x)) * Math.max(1, P), r = Math.floor(a / Math.max(1, s));
|
|
71
|
+
T.scrollTop = r * x, c.onScroll(), P = s;
|
|
72
72
|
}), (() => {
|
|
73
|
-
var
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
},
|
|
73
|
+
var s = ye(), x = s.firstChild, S = x.firstChild;
|
|
74
|
+
return le(s, "scroll", c.onScroll), K((a) => {
|
|
75
|
+
T = a, c.scrollRef(a), n.setScrollContainer(a);
|
|
76
|
+
}, s), K((a) => A(a), S), w(x, b(p, {
|
|
77
77
|
get when() {
|
|
78
78
|
return n.currentFiles().length > 0;
|
|
79
79
|
},
|
|
80
80
|
get fallback() {
|
|
81
81
|
return (() => {
|
|
82
|
-
var a =
|
|
83
|
-
return w(a, b(
|
|
82
|
+
var a = Me();
|
|
83
|
+
return w(a, b(p, {
|
|
84
84
|
get when() {
|
|
85
85
|
return n.filterQueryApplied().trim();
|
|
86
86
|
},
|
|
87
87
|
get fallback() {
|
|
88
|
-
return
|
|
88
|
+
return _e();
|
|
89
89
|
},
|
|
90
90
|
get children() {
|
|
91
91
|
return [(() => {
|
|
92
|
-
var r =
|
|
92
|
+
var r = Pe(), M = r.firstChild, I = M.nextSibling;
|
|
93
93
|
return I.nextSibling, w(r, () => n.filterQueryApplied(), I), r;
|
|
94
94
|
})(), (() => {
|
|
95
|
-
var r =
|
|
95
|
+
var r = Se();
|
|
96
96
|
return r.$$click = () => n.setFilterQuery(""), r;
|
|
97
97
|
})()];
|
|
98
98
|
}
|
|
@@ -100,12 +100,12 @@ function je(e) {
|
|
|
100
100
|
})();
|
|
101
101
|
},
|
|
102
102
|
get children() {
|
|
103
|
-
var a =
|
|
104
|
-
return w(a, b(
|
|
103
|
+
var a = we();
|
|
104
|
+
return w(a, b(q, {
|
|
105
105
|
get each() {
|
|
106
106
|
return F();
|
|
107
107
|
},
|
|
108
|
-
children: (r) => b(
|
|
108
|
+
children: (r) => b($e, {
|
|
109
109
|
item: r,
|
|
110
110
|
get instanceId() {
|
|
111
111
|
return h();
|
|
@@ -116,7 +116,7 @@ function je(e) {
|
|
|
116
116
|
dragContext: o
|
|
117
117
|
})
|
|
118
118
|
})), Y((r) => {
|
|
119
|
-
var M = `repeat(${v()}, minmax(0, 1fr))`, I = `${
|
|
119
|
+
var M = `repeat(${v()}, minmax(0, 1fr))`, I = `${c.paddingTop()}px`, H = `${c.paddingBottom()}px`;
|
|
120
120
|
return M !== r.e && X(a, "grid-template-columns", r.e = M), I !== r.t && X(a, "padding-top", r.t = I), H !== r.a && X(a, "padding-bottom", r.a = H), r;
|
|
121
121
|
}, {
|
|
122
122
|
e: void 0,
|
|
@@ -124,116 +124,119 @@ function je(e) {
|
|
|
124
124
|
a: void 0
|
|
125
125
|
}), a;
|
|
126
126
|
}
|
|
127
|
-
}), null), Y(() => G(
|
|
127
|
+
}), null), Y(() => G(s, $("h-full min-h-0 overflow-auto", e.class))), s;
|
|
128
128
|
})();
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
const n =
|
|
132
|
-
let l, f = null, y = 0, E = 0,
|
|
133
|
-
const
|
|
130
|
+
function $e(e) {
|
|
131
|
+
const n = J(), o = () => n.isSelected(e.item.id), D = () => n.getFilterMatchForId(e.item.id), h = me(() => e.item), d = Ce(n, h);
|
|
132
|
+
let l, f = null, y = 0, E = 0, g = !1;
|
|
133
|
+
const A = 5, O = 500;
|
|
134
134
|
let v = null;
|
|
135
|
-
const [k, B] =
|
|
135
|
+
const [k, B] = W(!1), c = () => l === "touch" || l === "pen", N = () => e.item.type === "folder", L = () => N() && e.enableDragDrop && e.dragContext, F = () => {
|
|
136
136
|
if (!L() || !e.dragContext) return !1;
|
|
137
137
|
const t = e.dragContext.dragState();
|
|
138
138
|
return t.isDragging ? e.dragContext.canDropOn(t.draggedItems, e.item.path, e.item, e.instanceId) : !1;
|
|
139
|
-
},
|
|
139
|
+
}, T = () => {
|
|
140
140
|
if (!e.dragContext) return !1;
|
|
141
141
|
const t = e.dragContext.dragState();
|
|
142
142
|
return t.isDragging ? t.draggedItems.some((i) => i.item.id === e.item.id) : !1;
|
|
143
143
|
}, P = () => {
|
|
144
144
|
v !== null && (clearTimeout(v), v = null);
|
|
145
|
-
},
|
|
145
|
+
}, s = () => {
|
|
146
146
|
typeof document > "u" || (document.removeEventListener("pointermove", r, !0), document.removeEventListener("pointerup", M, !0), document.removeEventListener("pointercancel", I, !0));
|
|
147
147
|
}, x = () => {
|
|
148
148
|
typeof document > "u" || (document.addEventListener("pointermove", r, !0), document.addEventListener("pointerup", M, !0), document.addEventListener("pointercancel", I, !0));
|
|
149
149
|
}, S = (t) => {
|
|
150
|
-
P(),
|
|
150
|
+
P(), s(), g && e.dragContext && e.dragContext.endDrag(t), f = null, g = !1;
|
|
151
151
|
};
|
|
152
|
-
|
|
152
|
+
fe(() => {
|
|
153
153
|
S(!1);
|
|
154
154
|
});
|
|
155
155
|
const a = (t, i) => {
|
|
156
|
-
if (!e.enableDragDrop || !e.dragContext ||
|
|
157
|
-
|
|
158
|
-
const
|
|
156
|
+
if (!e.enableDragDrop || !e.dragContext || g) return;
|
|
157
|
+
g = !0, o() || n.selectItem(e.item.id, !1);
|
|
158
|
+
const u = n.getSelectedItemsList(), m = (u.length > 0 && o() ? u : [e.item]).map((R) => ({
|
|
159
159
|
item: R,
|
|
160
160
|
sourceInstanceId: e.instanceId,
|
|
161
161
|
sourcePath: n.currentPath()
|
|
162
162
|
}));
|
|
163
|
-
if (
|
|
163
|
+
if (c() && "vibrate" in navigator)
|
|
164
164
|
try {
|
|
165
165
|
navigator.vibrate(50);
|
|
166
166
|
} catch {
|
|
167
167
|
}
|
|
168
|
-
e.dragContext.startDrag(
|
|
168
|
+
e.dragContext.startDrag(m, t, i);
|
|
169
169
|
}, r = (t) => {
|
|
170
170
|
if (f !== t.pointerId) return;
|
|
171
|
-
const i = t.clientX - y,
|
|
172
|
-
if (
|
|
171
|
+
const i = t.clientX - y, u = t.clientY - E, _ = Math.sqrt(i * i + u * u);
|
|
172
|
+
if (c() && !g && _ > 10) {
|
|
173
173
|
S(!1);
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
!
|
|
176
|
+
!c() && !g && _ > A && a(t.clientX, t.clientY), g && e.dragContext && e.dragContext.updateDrag(t.clientX, t.clientY);
|
|
177
177
|
}, M = (t) => {
|
|
178
|
-
f === t.pointerId && (
|
|
178
|
+
f === t.pointerId && (d.onPointerUp(), S(!0));
|
|
179
179
|
}, I = (t) => {
|
|
180
|
-
f === t.pointerId && (
|
|
180
|
+
f === t.pointerId && (d.onPointerCancel(), S(!1));
|
|
181
181
|
}, H = (t) => {
|
|
182
|
-
l = t.pointerType,
|
|
183
|
-
f !== null && !
|
|
184
|
-
},
|
|
182
|
+
l = t.pointerType, d.onPointerDown(t), !(t.pointerType === "mouse" && t.button !== 0) && (!e.enableDragDrop || !e.dragContext || (f = t.pointerId, y = t.clientX, E = t.clientY, g = !1, x(), c() && (P(), v = setTimeout(() => {
|
|
183
|
+
f !== null && !g && a(y, E);
|
|
184
|
+
}, O))));
|
|
185
|
+
}, Z = (t) => {
|
|
186
|
+
l = t.pointerType, d.onPointerMove(t);
|
|
185
187
|
}, ee = (t) => {
|
|
186
|
-
l = t.pointerType, u.onPointerMove(t);
|
|
187
|
-
}, te = (t) => {
|
|
188
188
|
if (!L() || !e.dragContext) return;
|
|
189
189
|
const i = e.dragContext.dragState();
|
|
190
190
|
if (!i.isDragging) return;
|
|
191
191
|
B(!0);
|
|
192
|
-
const
|
|
192
|
+
const u = e.dragContext.canDropOn(i.draggedItems, e.item.path, e.item, e.instanceId), m = t.currentTarget?.getBoundingClientRect() ?? null;
|
|
193
193
|
e.dragContext.setDropTarget({
|
|
194
194
|
instanceId: e.instanceId,
|
|
195
195
|
targetPath: e.item.path,
|
|
196
196
|
targetItem: e.item
|
|
197
|
-
},
|
|
198
|
-
},
|
|
197
|
+
}, u, m);
|
|
198
|
+
}, te = (t) => {
|
|
199
199
|
if (!e.dragContext) return;
|
|
200
200
|
B(!1);
|
|
201
201
|
const i = e.dragContext.dragState();
|
|
202
202
|
i.isDragging && i.dropTarget?.targetPath === e.item.path && e.dragContext.setDropTarget(null, !1);
|
|
203
|
-
},
|
|
204
|
-
if (
|
|
205
|
-
|
|
203
|
+
}, ne = (t) => {
|
|
204
|
+
if (g) {
|
|
205
|
+
g = !1;
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
if (!
|
|
209
|
-
if (
|
|
208
|
+
if (!d.consumeClickSuppression(t)) {
|
|
209
|
+
if (c()) {
|
|
210
210
|
n.openItem(e.item);
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
n.selectItem(e.item.id, t.metaKey || t.ctrlKey);
|
|
214
214
|
}
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
if (t.preventDefault(), t.stopPropagation(),
|
|
215
|
+
}, re = () => {
|
|
216
|
+
c() || n.openItem(e.item);
|
|
217
|
+
}, ie = (t) => {
|
|
218
|
+
if (t.preventDefault(), t.stopPropagation(), c()) return;
|
|
219
219
|
o() || n.selectItem(e.item.id, !1);
|
|
220
|
-
const i = n.getSelectedItemsList(),
|
|
220
|
+
const i = n.getSelectedItemsList(), u = i.length > 0 ? i : [e.item];
|
|
221
221
|
n.showContextMenu({
|
|
222
222
|
x: t.clientX,
|
|
223
223
|
y: t.clientY,
|
|
224
|
-
items:
|
|
224
|
+
items: u
|
|
225
225
|
});
|
|
226
|
-
},
|
|
226
|
+
}, ae = () => e.dragContext?.dragState(), oe = () => ae()?.isDragging ?? !1, U = () => k() && oe() && L();
|
|
227
227
|
return (() => {
|
|
228
|
-
var t =
|
|
229
|
-
return ce(t,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
var t = Ee(), i = t.firstChild, u = i.nextSibling, _ = u.nextSibling;
|
|
229
|
+
return ce(t, se(De, {
|
|
230
|
+
get title() {
|
|
231
|
+
return e.item.name;
|
|
232
|
+
},
|
|
233
|
+
onClick: ne,
|
|
234
|
+
onDblClick: re,
|
|
235
|
+
onContextMenu: ie,
|
|
233
236
|
onPointerDown: H,
|
|
234
|
-
onPointerMove:
|
|
235
|
-
onPointerEnter:
|
|
236
|
-
onPointerLeave:
|
|
237
|
+
onPointerMove: Z,
|
|
238
|
+
onPointerEnter: ee,
|
|
239
|
+
onPointerLeave: te,
|
|
237
240
|
get class() {
|
|
238
241
|
return $(
|
|
239
242
|
"group relative flex flex-col items-center gap-2 p-3 rounded-lg cursor-pointer h-28",
|
|
@@ -243,44 +246,43 @@ function Fe(e) {
|
|
|
243
246
|
"active:scale-[0.98]",
|
|
244
247
|
o() && "bg-accent ring-2 ring-primary/50",
|
|
245
248
|
// Drag state styling - being dragged items become translucent and shrink
|
|
246
|
-
|
|
249
|
+
T() && "opacity-40 scale-90",
|
|
247
250
|
// Drop target styling - enhanced visual feedback for folders
|
|
248
251
|
U() && F() && ["bg-primary/15 ring-2 ring-primary/60", "scale-105 shadow-lg shadow-primary/15"],
|
|
249
252
|
U() && !F() && ["bg-destructive/10 ring-2 ring-dashed ring-destructive/50"]
|
|
250
253
|
);
|
|
251
254
|
}
|
|
252
|
-
}), !1, !0), w(t, b(
|
|
255
|
+
}), !1, !0), w(t, b(p, {
|
|
253
256
|
get when() {
|
|
254
257
|
return o();
|
|
255
258
|
},
|
|
256
259
|
get children() {
|
|
257
|
-
return
|
|
260
|
+
return Te();
|
|
258
261
|
}
|
|
259
|
-
}), i), w(i, b(
|
|
262
|
+
}), i), w(i, b(be, {
|
|
260
263
|
get item() {
|
|
261
264
|
return e.item;
|
|
262
265
|
},
|
|
263
266
|
class: "w-8 h-8"
|
|
264
|
-
})), w(
|
|
267
|
+
})), w(u, b(Le, {
|
|
265
268
|
get name() {
|
|
266
269
|
return e.item.name;
|
|
267
270
|
},
|
|
268
271
|
get match() {
|
|
269
272
|
return D();
|
|
270
273
|
}
|
|
271
|
-
})), Y((
|
|
272
|
-
var R = $("w-12 h-12 flex items-center justify-center rounded-lg", "transition-transform duration-200", "group-hover:scale-110", e.item.type === "folder" ? "bg-warning/10" : "bg-muted/50"), V = $("
|
|
273
|
-
return R !==
|
|
274
|
+
})), Y((m) => {
|
|
275
|
+
var R = $("w-12 h-12 flex items-center justify-center rounded-lg", "transition-transform duration-200", "group-hover:scale-110", e.item.type === "folder" ? "bg-warning/10" : "bg-muted/50"), V = $("block w-full min-w-0 truncate px-1 text-xs text-center", "transition-colors duration-150", o() && "font-medium"), z = $("absolute inset-0 rounded-lg opacity-0 transition-opacity duration-300", "group-hover:opacity-100", "pointer-events-none"), Q = e.item.type === "folder" ? "radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--warning) 8%, transparent), transparent 70%)" : "radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 70%)";
|
|
276
|
+
return R !== m.e && G(i, m.e = R), V !== m.t && G(u, m.t = V), z !== m.a && G(_, m.a = z), Q !== m.o && X(_, "background", m.o = Q), m;
|
|
274
277
|
}, {
|
|
275
278
|
e: void 0,
|
|
276
279
|
t: void 0,
|
|
277
280
|
a: void 0,
|
|
278
|
-
o: void 0
|
|
279
|
-
i: void 0
|
|
281
|
+
o: void 0
|
|
280
282
|
}), t;
|
|
281
283
|
})();
|
|
282
284
|
}
|
|
283
|
-
|
|
285
|
+
ge(["click"]);
|
|
284
286
|
export {
|
|
285
|
-
|
|
287
|
+
Ne as FileGridView
|
|
286
288
|
};
|