@floegence/floe-webapp-core 0.35.47 → 0.35.49
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/FileBrowser.js +38 -37
- package/dist/components/file-browser/FileBrowserContext.js +359 -297
- package/dist/components/file-browser/FileGridView.js +190 -167
- package/dist/components/file-browser/FileListView.js +328 -307
- package/dist/components/file-browser/index.d.ts +1 -1
- package/dist/components/file-browser/longPressContextMenu.js +32 -33
- package/dist/components/file-browser/types.d.ts +10 -0
- package/dist/components/file-browser/useFileBrowserMarqueeSelection.d.ts +16 -0
- package/dist/components/file-browser/useFileBrowserMarqueeSelection.js +69 -0
- package/dist/floe.css +8 -0
- package/dist/full.js +66 -64
- package/dist/index.js +53 -51
- package/dist/styles.css +1 -1
- package/dist/utils/keybind.d.ts +2 -0
- package/dist/utils/keybind.js +24 -16
- package/package.json +1 -1
|
@@ -1,428 +1,490 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
import { createSignal as h, createEffect as S, createMemo as
|
|
3
|
-
import { createStore as
|
|
4
|
-
import { useResolvedFloeConfig as
|
|
5
|
-
import { deferAfterPaint as
|
|
6
|
-
const
|
|
1
|
+
import { createComponent as Lt } from "solid-js/web";
|
|
2
|
+
import { createSignal as h, createEffect as S, createMemo as U, useContext as _t, createContext as Ot, untrack as Tt } from "solid-js";
|
|
3
|
+
import { createStore as pe, produce as Se } from "solid-js/store";
|
|
4
|
+
import { useResolvedFloeConfig as zt } from "../../context/FloeConfigContext.js";
|
|
5
|
+
import { deferAfterPaint as Dt, deferNonBlocking as E } from "../../utils/defer.js";
|
|
6
|
+
const Ee = Ot(), M = {
|
|
7
7
|
name: 0.65,
|
|
8
8
|
modifiedAt: 0.2,
|
|
9
9
|
size: 0.15
|
|
10
|
-
},
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
return Math.max(
|
|
10
|
+
}, ge = "fileBrowser:listColumnRatios", xe = 220, Nt = "fileBrowser:sidebarWidth", Wt = 160, qt = 520, ye = "fileBrowser:viewMode", we = "fileBrowser:sortConfig", Ce = "fileBrowser:expandedFolders", ve = "fileBrowser:sidebarCollapsed";
|
|
11
|
+
function G(o, c) {
|
|
12
|
+
const i = typeof o == "number" && Number.isFinite(o) ? o : c;
|
|
13
|
+
return Math.max(Wt, Math.min(qt, Math.round(i)));
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function Vt(o, c) {
|
|
16
|
+
return o === "list" || o === "grid" ? o : c;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
if (!
|
|
20
|
-
const
|
|
21
|
-
return !(
|
|
22
|
-
field:
|
|
23
|
-
direction:
|
|
18
|
+
function kt(o, c) {
|
|
19
|
+
if (!o || typeof o != "object") return c;
|
|
20
|
+
const i = o, f = i.field, l = i.direction;
|
|
21
|
+
return !(f === "name" || f === "size" || f === "modifiedAt" || f === "type") || !(l === "asc" || l === "desc") ? c : {
|
|
22
|
+
field: f,
|
|
23
|
+
direction: l
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
if (!Array.isArray(
|
|
28
|
-
const
|
|
29
|
-
for (const
|
|
30
|
-
if (typeof
|
|
31
|
-
const
|
|
32
|
-
!
|
|
26
|
+
function Kt(o) {
|
|
27
|
+
if (!Array.isArray(o)) return ["/"];
|
|
28
|
+
const c = [], i = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const f of o) {
|
|
30
|
+
if (typeof f != "string") continue;
|
|
31
|
+
const l = f.trim();
|
|
32
|
+
!l || i.has(l) || (i.add(l), c.push(l));
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return i.has("/") || c.unshift("/"), c;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
for (const
|
|
39
|
-
if (typeof
|
|
40
|
-
const
|
|
41
|
-
!
|
|
36
|
+
function Ae(o) {
|
|
37
|
+
const c = [], i = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const f of o) {
|
|
39
|
+
if (typeof f != "string") continue;
|
|
40
|
+
const l = f.trim();
|
|
41
|
+
!l || i.has(l) || (i.add(l), c.push(l));
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return c;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
for (const
|
|
48
|
-
|
|
49
|
-
return
|
|
45
|
+
function Re(o) {
|
|
46
|
+
const c = {};
|
|
47
|
+
for (const i of o)
|
|
48
|
+
c[i] = !0;
|
|
49
|
+
return c;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
if (
|
|
53
|
-
for (let
|
|
54
|
-
if (
|
|
51
|
+
function X(o, c) {
|
|
52
|
+
if (o.length !== c.length) return !1;
|
|
53
|
+
for (let i = 0; i < o.length; i += 1)
|
|
54
|
+
if (o[i] !== c[i]) return !1;
|
|
55
55
|
return !0;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
return
|
|
60
|
-
name:
|
|
61
|
-
modifiedAt:
|
|
62
|
-
size:
|
|
57
|
+
function Pe(o) {
|
|
58
|
+
const c = Number.isFinite(o.name) ? o.name : M.name, i = Number.isFinite(o.modifiedAt) ? o.modifiedAt : M.modifiedAt, f = Number.isFinite(o.size) ? o.size : M.size, l = Math.max(0, c), m = Math.max(0, i), v = Math.max(0, f), x = l + m + v;
|
|
59
|
+
return x <= 0 ? M : {
|
|
60
|
+
name: l / x,
|
|
61
|
+
modifiedAt: m / x,
|
|
62
|
+
size: v / x
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
68
|
-
let
|
|
69
|
-
for (const
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
|
|
65
|
+
function be(o, c) {
|
|
66
|
+
if (!c) return [];
|
|
67
|
+
const i = [];
|
|
68
|
+
let f = 0;
|
|
69
|
+
for (const l of c) {
|
|
70
|
+
const m = o.indexOf(l, f);
|
|
71
|
+
if (m === -1) return null;
|
|
72
|
+
i.push(m), f = m + 1;
|
|
73
73
|
}
|
|
74
|
-
return
|
|
74
|
+
return i;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
76
|
+
function $t(o) {
|
|
77
|
+
const c = zt(), i = (e) => {
|
|
78
78
|
const t = (e ?? "").trim();
|
|
79
79
|
return t === "" ? "/" : t;
|
|
80
|
-
},
|
|
80
|
+
}, f = (o.persistenceKey ?? "").trim(), l = !!f, m = (e) => f ? `${f}:${e}` : e, v = l ? Vt(c.persist.load(m(ye), o.initialViewMode ?? "list"), o.initialViewMode ?? "list") : o.initialViewMode ?? "list", x = {
|
|
81
81
|
field: "name",
|
|
82
82
|
direction: "asc"
|
|
83
|
-
},
|
|
84
|
-
let
|
|
83
|
+
}, Me = l ? kt(c.persist.load(m(we), x), x) : x, Y = l ? Kt(c.persist.load(m(Ce), ["/"])) : ["/"], Be = l ? c.persist.load(m(ve), !1) === !0 : !1, Fe = () => typeof o.path == "string" ? i(o.path) : i(o.initialPath ?? "/"), [A, j] = h(Fe()), [F, Le] = pe({}), [y, _e] = h([]), [R, Oe] = h(null), [L, Q] = h(null), [H, Te] = h(v), [_, ze] = h(Me), De = Pe(c.persist.load(ge, o.initialListColumnRatios ?? M)), [$, Ne] = h(De), J = (o.sidebarWidthStorageKey ?? "").trim() || Nt, We = G(c.persist.load(J, o.initialSidebarWidth ?? xe), o.initialSidebarWidth ?? xe), [O, qe] = h(We), [T, Z] = pe(Re(Y)), [ee, te] = h(Y), [ne, Ve] = h(Be), [ke, oe] = h(null), [se, z] = h(""), [D, B] = h(""), [Ke, N] = h(!1), [W, re] = h(null);
|
|
84
|
+
let q = 0;
|
|
85
85
|
S(() => {
|
|
86
|
-
const e =
|
|
87
|
-
|
|
88
|
-
const t =
|
|
86
|
+
const e = se().trim();
|
|
87
|
+
q += 1;
|
|
88
|
+
const t = q;
|
|
89
89
|
if (!e) {
|
|
90
|
-
|
|
90
|
+
B("");
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
t ===
|
|
93
|
+
Dt(() => {
|
|
94
|
+
t === q && B(e);
|
|
95
95
|
});
|
|
96
96
|
}), S(() => {
|
|
97
|
-
|
|
97
|
+
c.persist.debouncedSave(ge, $());
|
|
98
98
|
}), S(() => {
|
|
99
|
-
|
|
99
|
+
c.persist.debouncedSave(J, O());
|
|
100
100
|
}), S(() => {
|
|
101
|
-
|
|
101
|
+
l && c.persist.debouncedSave(m(ye), H());
|
|
102
102
|
}), S(() => {
|
|
103
|
-
|
|
103
|
+
l && c.persist.debouncedSave(m(we), _());
|
|
104
104
|
}), S(() => {
|
|
105
|
-
if (!
|
|
106
|
-
const e = [...
|
|
107
|
-
|
|
105
|
+
if (!l) return;
|
|
106
|
+
const e = [...ee()].sort((t, n) => t.localeCompare(n));
|
|
107
|
+
c.persist.debouncedSave(m(Ce), e);
|
|
108
108
|
}), S(() => {
|
|
109
|
-
|
|
109
|
+
l && c.persist.debouncedSave(m(ve), ne());
|
|
110
110
|
}), S(() => {
|
|
111
|
-
const e =
|
|
112
|
-
|
|
111
|
+
const e = o.revealRequest ?? null;
|
|
112
|
+
re(e);
|
|
113
113
|
});
|
|
114
|
-
const
|
|
115
|
-
const t =
|
|
116
|
-
|
|
117
|
-
for (const
|
|
118
|
-
|
|
119
|
-
for (const
|
|
120
|
-
s[
|
|
121
|
-
})),
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
if (
|
|
126
|
-
|
|
114
|
+
const Ue = (e) => Te(e), Ge = (e) => ze(e), Xe = (e) => G(e, O()), Ye = () => o.homeLabel ?? "Root", je = () => new Set(y()), Qe = () => new Set(ee()), He = (e) => {
|
|
115
|
+
const t = Ae(e), n = Re(t);
|
|
116
|
+
Le(Se((s) => {
|
|
117
|
+
for (const r of Object.keys(s))
|
|
118
|
+
r in n || delete s[r];
|
|
119
|
+
for (const r of t)
|
|
120
|
+
s[r] = !0;
|
|
121
|
+
})), _e((s) => X(s, t) ? s : t);
|
|
122
|
+
}, ie = (e) => {
|
|
123
|
+
T[e] !== !0 && (Z(e, !0), te((t) => t.includes(e) ? t : [...t, e]));
|
|
124
|
+
}, $e = (e) => {
|
|
125
|
+
if (T[e] === !0) {
|
|
126
|
+
Z(Se((t) => {
|
|
127
127
|
delete t[e];
|
|
128
|
-
})),
|
|
128
|
+
})), te((t) => t.filter((n) => n !== e));
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
}, [
|
|
133
|
-
let
|
|
131
|
+
ie(e);
|
|
132
|
+
}, [ce, P] = h([]);
|
|
133
|
+
let w = null, V = {
|
|
134
134
|
top: 0,
|
|
135
135
|
left: 0
|
|
136
136
|
};
|
|
137
|
-
const
|
|
138
|
-
const t =
|
|
137
|
+
const ae = () => o.files, le = (e) => {
|
|
138
|
+
const t = i(e);
|
|
139
139
|
if (t === "/") return "/";
|
|
140
|
-
const
|
|
141
|
-
return
|
|
142
|
-
},
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
140
|
+
const n = t.split("/").filter(Boolean);
|
|
141
|
+
return n.pop(), n.length ? "/" + n.join("/") : "/";
|
|
142
|
+
}, Je = (e, t) => {
|
|
143
|
+
const n = ce();
|
|
144
|
+
if (n.length === 0) return e;
|
|
145
145
|
let s = [...e];
|
|
146
|
-
const
|
|
147
|
-
for (const
|
|
148
|
-
switch (
|
|
146
|
+
const r = i(t);
|
|
147
|
+
for (const a of n)
|
|
148
|
+
switch (a.type) {
|
|
149
149
|
case "remove": {
|
|
150
|
-
const
|
|
151
|
-
s = s.filter((
|
|
150
|
+
const u = new Set(a.paths.map(i));
|
|
151
|
+
s = s.filter((d) => !u.has(i(d.path)));
|
|
152
152
|
break;
|
|
153
153
|
}
|
|
154
154
|
case "update": {
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
...s[
|
|
160
|
-
...
|
|
161
|
-
} : s.splice(
|
|
155
|
+
const u = i(a.oldPath), d = s.findIndex((p) => i(p.path) === u);
|
|
156
|
+
if (d !== -1) {
|
|
157
|
+
const p = a.updates.path ?? s[d].path;
|
|
158
|
+
le(p) === r ? s[d] = {
|
|
159
|
+
...s[d],
|
|
160
|
+
...a.updates
|
|
161
|
+
} : s.splice(d, 1);
|
|
162
162
|
} else {
|
|
163
|
-
const
|
|
164
|
-
|
|
163
|
+
const p = a.updates.path;
|
|
164
|
+
p && le(p);
|
|
165
165
|
}
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
case "insert": {
|
|
169
|
-
|
|
169
|
+
i(a.parentPath) === r && (s.some((d) => i(d.path) === i(a.item.path)) || s.push(a.item));
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
return s;
|
|
174
|
-
},
|
|
174
|
+
}, Ze = U(() => {
|
|
175
175
|
const e = /* @__PURE__ */ new Map(), t = (s) => {
|
|
176
|
-
for (const
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
return e.set("/",
|
|
180
|
-
}),
|
|
181
|
-
const e =
|
|
182
|
-
let t =
|
|
183
|
-
t =
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
let
|
|
187
|
-
switch (
|
|
176
|
+
for (const r of s)
|
|
177
|
+
r.type === "folder" && (e.set(i(r.path), r.children ?? []), r.children?.length && t(r.children));
|
|
178
|
+
}, n = ae();
|
|
179
|
+
return e.set("/", n), t(n), e;
|
|
180
|
+
}), k = U(() => {
|
|
181
|
+
const e = i(A());
|
|
182
|
+
let t = Ze().get(e) ?? [];
|
|
183
|
+
t = Je(t, e);
|
|
184
|
+
const n = _(), s = [...t].sort((a, u) => {
|
|
185
|
+
if (a.type !== u.type) return a.type === "folder" ? -1 : 1;
|
|
186
|
+
let d = 0;
|
|
187
|
+
switch (n.field) {
|
|
188
188
|
case "name":
|
|
189
|
-
|
|
189
|
+
d = a.name.localeCompare(u.name);
|
|
190
190
|
break;
|
|
191
191
|
case "size":
|
|
192
|
-
|
|
192
|
+
d = (a.size ?? 0) - (u.size ?? 0);
|
|
193
193
|
break;
|
|
194
194
|
case "modifiedAt":
|
|
195
|
-
|
|
195
|
+
d = (a.modifiedAt?.getTime() ?? 0) - (u.modifiedAt?.getTime() ?? 0);
|
|
196
196
|
break;
|
|
197
197
|
case "type":
|
|
198
|
-
|
|
198
|
+
d = (a.extension ?? "").localeCompare(u.extension ?? "");
|
|
199
199
|
break;
|
|
200
200
|
}
|
|
201
|
-
return
|
|
202
|
-
}),
|
|
203
|
-
for (const
|
|
204
|
-
|
|
201
|
+
return n.direction === "asc" ? d : -d;
|
|
202
|
+
}), r = /* @__PURE__ */ new Map();
|
|
203
|
+
for (const a of s)
|
|
204
|
+
r.set(a.id, a.name.toLowerCase());
|
|
205
205
|
return {
|
|
206
206
|
items: s,
|
|
207
|
-
nameLowerById:
|
|
207
|
+
nameLowerById: r
|
|
208
208
|
};
|
|
209
|
-
}),
|
|
209
|
+
}), C = U(() => {
|
|
210
210
|
const {
|
|
211
211
|
items: e,
|
|
212
212
|
nameLowerById: t
|
|
213
|
-
} =
|
|
213
|
+
} = k(), s = D().trim().toLowerCase(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
214
214
|
if (!s) {
|
|
215
|
-
for (let
|
|
216
|
-
const
|
|
217
|
-
|
|
215
|
+
for (let I = 0; I < e.length; I++) {
|
|
216
|
+
const b = e[I];
|
|
217
|
+
a.set(b.id, b), u.set(b.id, I);
|
|
218
218
|
}
|
|
219
219
|
return {
|
|
220
220
|
items: e,
|
|
221
|
-
matchById:
|
|
222
|
-
fileById:
|
|
223
|
-
indexById:
|
|
221
|
+
matchById: r,
|
|
222
|
+
fileById: a,
|
|
223
|
+
indexById: u
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
let
|
|
228
|
-
for (const
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
matchedIndices:
|
|
232
|
-
}),
|
|
226
|
+
const d = [];
|
|
227
|
+
let p = 0;
|
|
228
|
+
for (const I of e) {
|
|
229
|
+
const b = t.get(I.id) ?? I.name.toLowerCase(), Ie = be(b, s);
|
|
230
|
+
Ie && (d.push(I), r.set(I.id, {
|
|
231
|
+
matchedIndices: Ie
|
|
232
|
+
}), a.set(I.id, I), u.set(I.id, p), p += 1);
|
|
233
233
|
}
|
|
234
234
|
return {
|
|
235
|
-
items:
|
|
236
|
-
matchById:
|
|
237
|
-
fileById:
|
|
238
|
-
indexById:
|
|
235
|
+
items: d,
|
|
236
|
+
matchById: r,
|
|
237
|
+
fileById: a,
|
|
238
|
+
indexById: u
|
|
239
239
|
};
|
|
240
|
-
}),
|
|
240
|
+
}), et = () => C().items;
|
|
241
241
|
S(() => {
|
|
242
|
-
const e =
|
|
243
|
-
!e || e.clearFilter !== "if-needed" ||
|
|
242
|
+
const e = W();
|
|
243
|
+
!e || e.clearFilter !== "if-needed" || C().fileById.has(e.targetId) || !k().items.some((s) => s.id === e.targetId) || (z(""), B(""), N(!1));
|
|
244
244
|
});
|
|
245
|
-
const
|
|
246
|
-
const t =
|
|
245
|
+
const de = (e) => {
|
|
246
|
+
const t = C(), n = [];
|
|
247
247
|
for (const s of e) {
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
index:
|
|
253
|
-
item:
|
|
248
|
+
const r = t.fileById.get(s);
|
|
249
|
+
if (!r) continue;
|
|
250
|
+
const a = t.indexById.get(s);
|
|
251
|
+
n.push({
|
|
252
|
+
index: a ?? Number.MAX_SAFE_INTEGER,
|
|
253
|
+
item: r
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
|
-
return
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
return n.sort((s, r) => s.index - r.index), n.map((s) => s.item);
|
|
257
|
+
}, tt = (e) => {
|
|
258
|
+
const t = o.onSelect;
|
|
259
|
+
if (!t) return;
|
|
260
|
+
const n = [...e];
|
|
261
|
+
E(() => {
|
|
262
|
+
const s = Tt(() => de(n));
|
|
263
|
+
t(s);
|
|
264
|
+
});
|
|
265
|
+
}, g = (e, t = {}) => {
|
|
266
|
+
const n = Ae(e), r = (t.preserveAnchor === !0 ? R() : void 0) ?? (t.anchorId !== void 0 ? t.anchorId : n[0] ?? null), a = t.lastInteractedId !== void 0 ? t.lastInteractedId : n[n.length - 1] ?? null, u = !X(y(), n), d = R() !== r, p = L() !== a;
|
|
267
|
+
!u && !d && !p || (He(n), Oe(r), Q(a), u && tt(n));
|
|
268
|
+
}, nt = (e, t) => {
|
|
269
|
+
const n = C(), s = n.indexById.get(e), r = n.indexById.get(t);
|
|
270
|
+
if (s === void 0 || r === void 0) return [];
|
|
271
|
+
const a = Math.min(s, r), u = Math.max(s, r);
|
|
272
|
+
return n.items.slice(a, u + 1).map((d) => d.id);
|
|
273
|
+
}, ot = () => {
|
|
274
|
+
const e = R();
|
|
275
|
+
return e && C().indexById.has(e) ? e : null;
|
|
276
|
+
}, ue = () => {
|
|
277
|
+
g([], {
|
|
278
|
+
anchorId: null,
|
|
279
|
+
lastInteractedId: null
|
|
280
|
+
}), z(""), B(""), N(!1);
|
|
261
281
|
};
|
|
262
282
|
S(() => {
|
|
263
|
-
if (typeof
|
|
264
|
-
const e = o
|
|
265
|
-
e !==
|
|
283
|
+
if (typeof o.path != "string") return;
|
|
284
|
+
const e = i(o.path);
|
|
285
|
+
e !== A() && (j(e), ue());
|
|
266
286
|
});
|
|
267
|
-
const
|
|
268
|
-
const t =
|
|
269
|
-
if (t ===
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const s =
|
|
274
|
-
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
},
|
|
278
|
-
const e =
|
|
287
|
+
const K = (e) => {
|
|
288
|
+
const t = i(e);
|
|
289
|
+
if (t === A()) return;
|
|
290
|
+
j(t), ue();
|
|
291
|
+
const n = o.onNavigate;
|
|
292
|
+
E(() => n?.(t));
|
|
293
|
+
const s = o.onPathChange;
|
|
294
|
+
E(() => s?.(t, "user"));
|
|
295
|
+
}, st = (e) => {
|
|
296
|
+
Ne(Pe(e));
|
|
297
|
+
}, rt = () => {
|
|
298
|
+
const e = A();
|
|
279
299
|
if (e === "/" || e === "") return;
|
|
280
300
|
const t = e.split("/").filter(Boolean);
|
|
281
|
-
t.pop(),
|
|
282
|
-
},
|
|
283
|
-
e.type === "folder" && (
|
|
284
|
-
},
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
301
|
+
t.pop(), K(t.length ? "/" + t.join("/") : "/");
|
|
302
|
+
}, fe = (e) => {
|
|
303
|
+
e.type === "folder" && (K(e.path), ie(e.path));
|
|
304
|
+
}, it = (e, t = !1) => {
|
|
305
|
+
const n = t ? F[e] === !0 ? y().filter((s) => s !== e) : [...y(), e] : [e];
|
|
306
|
+
g(n, {
|
|
307
|
+
anchorId: e,
|
|
308
|
+
lastInteractedId: e
|
|
309
|
+
});
|
|
310
|
+
}, ct = (e, t = !1) => {
|
|
311
|
+
const n = ot();
|
|
312
|
+
if (!n) {
|
|
313
|
+
g([e], {
|
|
314
|
+
anchorId: e,
|
|
315
|
+
lastInteractedId: e
|
|
316
|
+
});
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const s = nt(n, e);
|
|
320
|
+
if (s.length === 0) {
|
|
321
|
+
g([e], {
|
|
322
|
+
anchorId: e,
|
|
323
|
+
lastInteractedId: e
|
|
293
324
|
});
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const r = t ? [...y(), ...s] : s;
|
|
328
|
+
g(r, {
|
|
329
|
+
anchorId: n,
|
|
330
|
+
lastInteractedId: e
|
|
331
|
+
});
|
|
332
|
+
}, at = (e, t = {}) => {
|
|
333
|
+
g(e, t);
|
|
334
|
+
}, lt = (e) => {
|
|
335
|
+
if (F[e] === !0) {
|
|
336
|
+
Q(e);
|
|
337
|
+
return;
|
|
294
338
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
339
|
+
g([e], {
|
|
340
|
+
anchorId: e,
|
|
341
|
+
lastInteractedId: e
|
|
342
|
+
});
|
|
343
|
+
}, dt = () => {
|
|
344
|
+
g([], {
|
|
345
|
+
anchorId: null,
|
|
346
|
+
lastInteractedId: null
|
|
347
|
+
});
|
|
348
|
+
}, ut = (e) => F[e] === !0, ft = (e) => $e(e), mt = (e) => T[e] === !0, ht = () => Ve((e) => !e), It = (e) => {
|
|
349
|
+
qe((t) => G(e, t));
|
|
350
|
+
}, pt = (e) => oe(e), St = () => oe(null), gt = (e) => {
|
|
351
|
+
z(e);
|
|
352
|
+
}, xt = (e) => {
|
|
353
|
+
const t = D().trim();
|
|
305
354
|
if (!t) return null;
|
|
306
|
-
const
|
|
307
|
-
return
|
|
308
|
-
matchedIndices:
|
|
355
|
+
const n = be(e.toLowerCase(), t.toLowerCase());
|
|
356
|
+
return n ? {
|
|
357
|
+
matchedIndices: n
|
|
309
358
|
} : null;
|
|
310
|
-
},
|
|
311
|
-
|
|
359
|
+
}, yt = (e) => C().matchById.get(e) ?? null, wt = () => de(y());
|
|
360
|
+
S(() => {
|
|
361
|
+
const e = new Set(k().items.map((d) => d.id)), t = y(), n = t.filter((d) => e.has(d)), s = R(), r = L(), a = s && e.has(s) ? s : n[0] ?? null, u = r && e.has(r) ? r : n[n.length - 1] ?? null;
|
|
362
|
+
X(t, n) && s === a && r === u || g(n, {
|
|
363
|
+
anchorId: a,
|
|
364
|
+
lastInteractedId: u
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
const Ct = (e) => {
|
|
368
|
+
const t = W();
|
|
312
369
|
if (!t || t.requestId !== e) return;
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
},
|
|
370
|
+
re(null);
|
|
371
|
+
const n = o.onRevealRequestConsumed;
|
|
372
|
+
E(() => n?.(e));
|
|
373
|
+
}, vt = (e) => {
|
|
317
374
|
if (e.type === "folder")
|
|
318
|
-
|
|
375
|
+
fe(e);
|
|
319
376
|
else {
|
|
320
|
-
const t =
|
|
321
|
-
|
|
377
|
+
const t = o.onOpen;
|
|
378
|
+
E(() => t?.(e));
|
|
322
379
|
}
|
|
323
|
-
},
|
|
380
|
+
}, At = (e) => {
|
|
324
381
|
e.length !== 0 && P((t) => [...t, {
|
|
325
382
|
type: "remove",
|
|
326
383
|
paths: e
|
|
327
384
|
}]);
|
|
328
|
-
},
|
|
329
|
-
P((
|
|
385
|
+
}, Rt = (e, t) => {
|
|
386
|
+
P((n) => [...n, {
|
|
330
387
|
type: "update",
|
|
331
388
|
oldPath: e,
|
|
332
389
|
updates: t
|
|
333
390
|
}]);
|
|
334
|
-
},
|
|
335
|
-
P((
|
|
391
|
+
}, Pt = (e, t) => {
|
|
392
|
+
P((n) => [...n, {
|
|
336
393
|
type: "insert",
|
|
337
394
|
parentPath: e,
|
|
338
395
|
item: t
|
|
339
396
|
}]);
|
|
340
|
-
},
|
|
397
|
+
}, bt = () => {
|
|
341
398
|
P([]);
|
|
342
|
-
},
|
|
399
|
+
}, Et = () => {
|
|
343
400
|
P([]);
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
},
|
|
347
|
-
top:
|
|
348
|
-
left:
|
|
401
|
+
}, Mt = () => ce().length > 0, Bt = (e) => {
|
|
402
|
+
w = e;
|
|
403
|
+
}, me = () => w ? {
|
|
404
|
+
top: w.scrollTop,
|
|
405
|
+
left: w.scrollLeft
|
|
349
406
|
} : {
|
|
350
407
|
top: 0,
|
|
351
408
|
left: 0
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
},
|
|
355
|
-
currentPath:
|
|
356
|
-
setCurrentPath:
|
|
357
|
-
navigateUp:
|
|
358
|
-
navigateTo:
|
|
359
|
-
homeLabel:
|
|
360
|
-
selectedItems:
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
409
|
+
}, he = (e) => {
|
|
410
|
+
w && (w.scrollTop = e.top, w.scrollLeft = e.left);
|
|
411
|
+
}, Ft = {
|
|
412
|
+
currentPath: A,
|
|
413
|
+
setCurrentPath: K,
|
|
414
|
+
navigateUp: rt,
|
|
415
|
+
navigateTo: fe,
|
|
416
|
+
homeLabel: Ye,
|
|
417
|
+
selectedItems: je,
|
|
418
|
+
selectionAnchorId: R,
|
|
419
|
+
lastInteractedId: L,
|
|
420
|
+
selectItem: it,
|
|
421
|
+
selectRangeTo: ct,
|
|
422
|
+
replaceSelection: at,
|
|
423
|
+
ensureContextMenuSelection: lt,
|
|
424
|
+
clearSelection: dt,
|
|
425
|
+
isSelected: ut,
|
|
426
|
+
getSelectedItemsList: wt,
|
|
427
|
+
viewMode: H,
|
|
428
|
+
setViewMode: Ue,
|
|
429
|
+
sortConfig: _,
|
|
430
|
+
setSortConfig: Ge,
|
|
431
|
+
listColumnRatios: $,
|
|
432
|
+
setListColumnRatios: st,
|
|
433
|
+
expandedFolders: Qe,
|
|
434
|
+
toggleFolder: ft,
|
|
435
|
+
isExpanded: mt,
|
|
436
|
+
files: ae,
|
|
437
|
+
currentFiles: et,
|
|
438
|
+
filterQuery: se,
|
|
439
|
+
setFilterQuery: gt,
|
|
440
|
+
filterQueryApplied: D,
|
|
441
|
+
isFilterActive: Ke,
|
|
442
|
+
setFilterActive: N,
|
|
443
|
+
getFilterMatch: xt,
|
|
444
|
+
getFilterMatchForId: yt,
|
|
445
|
+
sidebarCollapsed: ne,
|
|
446
|
+
toggleSidebar: ht,
|
|
447
|
+
sidebarWidth: O,
|
|
448
|
+
clampSidebarWidth: Xe,
|
|
449
|
+
setSidebarWidth: It,
|
|
450
|
+
contextMenu: ke,
|
|
451
|
+
showContextMenu: pt,
|
|
452
|
+
hideContextMenu: St,
|
|
453
|
+
openItem: vt,
|
|
454
|
+
revealRequest: W,
|
|
455
|
+
consumeRevealRequest: Ct,
|
|
394
456
|
// Optimistic updates
|
|
395
|
-
optimisticRemove:
|
|
396
|
-
optimisticUpdate:
|
|
397
|
-
optimisticInsert:
|
|
398
|
-
clearOptimisticUpdates:
|
|
399
|
-
rollbackOptimisticUpdates:
|
|
400
|
-
hasOptimisticUpdates:
|
|
457
|
+
optimisticRemove: At,
|
|
458
|
+
optimisticUpdate: Rt,
|
|
459
|
+
optimisticInsert: Pt,
|
|
460
|
+
clearOptimisticUpdates: bt,
|
|
461
|
+
rollbackOptimisticUpdates: Et,
|
|
462
|
+
hasOptimisticUpdates: Mt,
|
|
401
463
|
// Scroll position management
|
|
402
|
-
setScrollContainer:
|
|
403
|
-
getScrollPosition:
|
|
404
|
-
setScrollPosition:
|
|
405
|
-
saveScrollPosition: () => (
|
|
464
|
+
setScrollContainer: Bt,
|
|
465
|
+
getScrollPosition: me,
|
|
466
|
+
setScrollPosition: he,
|
|
467
|
+
saveScrollPosition: () => (V = me(), V),
|
|
406
468
|
restoreScrollPosition: () => {
|
|
407
469
|
requestAnimationFrame(() => {
|
|
408
|
-
|
|
470
|
+
he(V);
|
|
409
471
|
});
|
|
410
472
|
}
|
|
411
473
|
};
|
|
412
|
-
return
|
|
413
|
-
value:
|
|
474
|
+
return Lt(Ee.Provider, {
|
|
475
|
+
value: Ft,
|
|
414
476
|
get children() {
|
|
415
|
-
return
|
|
477
|
+
return o.children;
|
|
416
478
|
}
|
|
417
479
|
});
|
|
418
480
|
}
|
|
419
|
-
function
|
|
420
|
-
const
|
|
421
|
-
if (!
|
|
481
|
+
function Jt() {
|
|
482
|
+
const o = _t(Ee);
|
|
483
|
+
if (!o)
|
|
422
484
|
throw new Error("useFileBrowser must be used within a FileBrowserProvider");
|
|
423
|
-
return
|
|
485
|
+
return o;
|
|
424
486
|
}
|
|
425
487
|
export {
|
|
426
|
-
|
|
427
|
-
|
|
488
|
+
$t as FileBrowserProvider,
|
|
489
|
+
Jt as useFileBrowser
|
|
428
490
|
};
|