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