@floegence/floe-webapp-core 0.86.50 → 0.86.51
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/ui/DirectoryPicker.js +25 -29
- package/dist/components/ui/FileOpenPicker.js +106 -98
- package/dist/components/ui/FileSavePicker.js +74 -66
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/picker/DirectoryFavorites.d.ts +29 -0
- package/dist/components/ui/picker/DirectoryFavorites.js +163 -0
- package/dist/components/ui/picker/PickerBase.d.ts +16 -5
- package/dist/components/ui/picker/PickerBase.js +366 -225
- package/dist/components/ui/picker/PickerNavigation.d.ts +7 -0
- package/dist/components/ui/picker/PickerNavigation.js +73 -66
- package/dist/full.js +465 -463
- package/dist/styles.css +1 -1
- package/dist/ui.js +128 -126
- package/package.json +1 -1
|
@@ -18,6 +18,13 @@ export type PickerDirectoryLoader = (path: string, options: {
|
|
|
18
18
|
showHidden: boolean;
|
|
19
19
|
}) => Promise<readonly FileItem[]>;
|
|
20
20
|
export interface PickerCopy {
|
|
21
|
+
favorites: string;
|
|
22
|
+
favoriteDirectory: string;
|
|
23
|
+
unfavoriteDirectory: string;
|
|
24
|
+
favoritesEmpty: string;
|
|
25
|
+
favoritesFilter: string;
|
|
26
|
+
favoritesNoMatches: string;
|
|
27
|
+
favoritesLoadFailed: string;
|
|
21
28
|
path: string;
|
|
22
29
|
go: string;
|
|
23
30
|
roots: string;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { createSignal as l, onCleanup as z, batch as d } from "solid-js";
|
|
2
2
|
const J = {
|
|
3
|
+
favorites: "Favorites",
|
|
4
|
+
favoriteDirectory: "Add directory to favorites",
|
|
5
|
+
unfavoriteDirectory: "Remove directory from favorites",
|
|
6
|
+
favoritesEmpty: "Star a directory to keep it here.",
|
|
7
|
+
favoritesFilter: "Filter favorites by name or path",
|
|
8
|
+
favoritesNoMatches: "No matching favorites",
|
|
9
|
+
favoritesLoadFailed: "Could not load favorites",
|
|
3
10
|
path: "Directory path",
|
|
4
11
|
go: "Go",
|
|
5
12
|
roots: "Locations",
|
|
@@ -24,138 +31,138 @@ const J = {
|
|
|
24
31
|
selectionLimit: "Selection limit reached",
|
|
25
32
|
selectedCount: (t) => `${t} selected`
|
|
26
33
|
};
|
|
27
|
-
class
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
34
|
+
class N extends Error {
|
|
35
|
+
constructor(r) {
|
|
36
|
+
super(r), this.kind = r;
|
|
30
37
|
}
|
|
31
38
|
kind;
|
|
32
39
|
}
|
|
33
|
-
function
|
|
40
|
+
function P(t, r = "") {
|
|
34
41
|
let e = String(t ?? "").trim();
|
|
35
|
-
if (e === "~" ? e =
|
|
36
|
-
const
|
|
37
|
-
for (const
|
|
38
|
-
!
|
|
39
|
-
return `/${
|
|
42
|
+
if (e === "~" ? e = r : e.startsWith("~/") && (e = r ? `${r}/${e.slice(2)}` : ""), !e.startsWith("/") || e.includes("\0")) return "";
|
|
43
|
+
const f = [];
|
|
44
|
+
for (const i of e.split("/"))
|
|
45
|
+
!i || i === "." || (i === ".." ? f.pop() : f.push(i));
|
|
46
|
+
return `/${f.join("/")}`;
|
|
40
47
|
}
|
|
41
48
|
function Q(t) {
|
|
42
|
-
const
|
|
43
|
-
return
|
|
49
|
+
const r = P(t);
|
|
50
|
+
return r.slice(0, r.lastIndexOf("/")) || "/";
|
|
44
51
|
}
|
|
45
|
-
function U(t,
|
|
46
|
-
const e =
|
|
52
|
+
function U(t, r = "") {
|
|
53
|
+
const e = P(r);
|
|
47
54
|
return e && t === e ? "~" : e && e !== "/" && t.startsWith(`${e}/`) ? `~${t.slice(e.length)}` : t;
|
|
48
55
|
}
|
|
49
|
-
function j(t,
|
|
50
|
-
if (
|
|
56
|
+
function j(t, r) {
|
|
57
|
+
if (r === "/") return t;
|
|
51
58
|
for (const e of t)
|
|
52
59
|
if (e.type === "folder") {
|
|
53
|
-
if (
|
|
60
|
+
if (P(e.path) === r) return e.children ?? [];
|
|
54
61
|
if (e.children)
|
|
55
62
|
try {
|
|
56
|
-
return j(e.children,
|
|
63
|
+
return j(e.children, r);
|
|
57
64
|
} catch {
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
|
-
throw new
|
|
67
|
+
throw new N("missingPath");
|
|
61
68
|
}
|
|
62
|
-
function V(t,
|
|
63
|
-
const [e,
|
|
64
|
-
let
|
|
65
|
-
const G = () => h() && !
|
|
66
|
-
|
|
69
|
+
function V(t, r) {
|
|
70
|
+
const [e, f] = l(null), [i, k] = l(""), [B, E] = l([]), [g, C] = l(""), [H, c] = l(!1), [$, u] = l(null), [I, q] = l(!1), [h, R] = l(!1);
|
|
71
|
+
let y = 0, b = 0, A, m = /* @__PURE__ */ new Map();
|
|
72
|
+
const G = () => h() && !H() && !$() && !!i() && P(g(), e()?.homePathAbs) === i(), L = () => {
|
|
73
|
+
y += 1, b += 1, m = /* @__PURE__ */ new Map();
|
|
67
74
|
}, W = () => {
|
|
68
75
|
L(), d(() => {
|
|
69
76
|
R(!1), c(!1);
|
|
70
77
|
});
|
|
71
78
|
};
|
|
72
79
|
z(W);
|
|
73
|
-
const
|
|
80
|
+
const F = async (n) => {
|
|
74
81
|
if (!h() || !e()) return !1;
|
|
75
|
-
const
|
|
82
|
+
const x = y, a = ++b, o = P(n, e()?.homePathAbs);
|
|
76
83
|
d(() => {
|
|
77
|
-
C(
|
|
84
|
+
C(n), u(null), c(!0);
|
|
78
85
|
});
|
|
79
|
-
const
|
|
86
|
+
const p = () => h() && y === x && b === a;
|
|
80
87
|
try {
|
|
81
|
-
if (!
|
|
82
|
-
const s = t(),
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
let
|
|
88
|
+
if (!o) throw new N("invalidPath");
|
|
89
|
+
const s = t(), v = { showHidden: I() }, D = `${o}\0${v.showHidden}`;
|
|
90
|
+
let w = m.get(D);
|
|
91
|
+
w || (w = Promise.resolve().then(() => s.loadDirectory ? s.loadDirectory(o, v) : j(s.files ?? [], o)), m.set(D, w));
|
|
92
|
+
let S;
|
|
86
93
|
try {
|
|
87
|
-
|
|
94
|
+
S = await w;
|
|
88
95
|
} finally {
|
|
89
|
-
|
|
96
|
+
m.get(D) === w && m.delete(D);
|
|
90
97
|
}
|
|
91
|
-
if (!
|
|
92
|
-
const O = s.loadDirectory ||
|
|
98
|
+
if (!p()) return !1;
|
|
99
|
+
const O = s.loadDirectory || v.showHidden ? S : S.filter((T) => !T.name.startsWith("."));
|
|
93
100
|
return d(() => {
|
|
94
|
-
|
|
95
|
-
}),
|
|
101
|
+
k(o), E(O), C(o), c(!1), u(null);
|
|
102
|
+
}), r?.(o), !0;
|
|
96
103
|
} catch (s) {
|
|
97
|
-
return
|
|
98
|
-
|
|
104
|
+
return p() && d(() => {
|
|
105
|
+
u(s), c(!1);
|
|
99
106
|
}), !1;
|
|
100
107
|
}
|
|
101
|
-
}, M = async (
|
|
108
|
+
}, M = async (n) => {
|
|
102
109
|
L();
|
|
103
|
-
const
|
|
104
|
-
A =
|
|
110
|
+
const x = y;
|
|
111
|
+
A = n;
|
|
105
112
|
const a = t();
|
|
106
113
|
d(() => {
|
|
107
|
-
R(!0),
|
|
114
|
+
R(!0), f(null), k(""), E([]), C(n ?? ""), c(!0), u(null), q(a.initialShowHidden ?? !a.loadDirectory);
|
|
108
115
|
});
|
|
109
116
|
try {
|
|
110
|
-
const
|
|
111
|
-
if (!h() ||
|
|
112
|
-
if (!
|
|
113
|
-
const
|
|
117
|
+
const o = a.loadPathContext ? await a.loadPathContext() : a.pathContext;
|
|
118
|
+
if (!h() || y !== x) return;
|
|
119
|
+
if (!o && a.loadDirectory) throw new N("unavailableContext");
|
|
120
|
+
const p = o ?? {
|
|
114
121
|
homePathAbs: a.homePath ?? "",
|
|
115
122
|
defaultRootId: "root",
|
|
116
123
|
roots: [{ id: "root", label: a.homeLabel ?? J.root, pathAbs: "/" }]
|
|
117
124
|
};
|
|
118
|
-
|
|
119
|
-
const s =
|
|
120
|
-
if (!s) throw new
|
|
121
|
-
await
|
|
122
|
-
} catch (
|
|
123
|
-
h() &&
|
|
124
|
-
|
|
125
|
+
f(p);
|
|
126
|
+
const s = n || p.roots.find((v) => v.id === p.defaultRootId)?.pathAbs;
|
|
127
|
+
if (!s) throw new N("unavailableContext");
|
|
128
|
+
await F(s);
|
|
129
|
+
} catch (o) {
|
|
130
|
+
h() && y === x && d(() => {
|
|
131
|
+
u(o), c(!1);
|
|
125
132
|
});
|
|
126
133
|
}
|
|
127
134
|
};
|
|
128
135
|
return {
|
|
129
136
|
context: e,
|
|
130
|
-
currentPath:
|
|
137
|
+
currentPath: i,
|
|
131
138
|
entries: B,
|
|
132
|
-
pathInput:
|
|
133
|
-
pending:
|
|
139
|
+
pathInput: g,
|
|
140
|
+
pending: H,
|
|
134
141
|
error: $,
|
|
135
142
|
showHidden: I,
|
|
136
143
|
active: h,
|
|
137
144
|
valid: G,
|
|
138
145
|
open: M,
|
|
139
146
|
close: W,
|
|
140
|
-
navigate:
|
|
141
|
-
setPathInput(
|
|
147
|
+
navigate: F,
|
|
148
|
+
setPathInput(n) {
|
|
142
149
|
b += 1, d(() => {
|
|
143
|
-
C(
|
|
150
|
+
C(n), c(!1), u(null);
|
|
144
151
|
});
|
|
145
152
|
},
|
|
146
|
-
async setShowHidden(
|
|
147
|
-
q(
|
|
153
|
+
async setShowHidden(n) {
|
|
154
|
+
q(n), await F(g() || i());
|
|
148
155
|
},
|
|
149
156
|
async retry() {
|
|
150
|
-
e() ? await
|
|
157
|
+
e() ? await F(g() || i()) : await M(A);
|
|
151
158
|
}
|
|
152
159
|
};
|
|
153
160
|
}
|
|
154
161
|
export {
|
|
155
|
-
|
|
162
|
+
N as PickerNavigationError,
|
|
156
163
|
V as createFilesystemPickerDataSource,
|
|
157
164
|
J as defaultPickerCopy,
|
|
158
165
|
U as formatPickerPath,
|
|
159
|
-
|
|
166
|
+
P as parsePickerPath,
|
|
160
167
|
Q as pickerParentPath
|
|
161
168
|
};
|