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