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