@floegence/floe-webapp-core 0.11.2 → 0.11.3

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/index120.js CHANGED
@@ -1,410 +1,42 @@
1
- import { delegateEvents as Z, insert as h, createComponent as s, effect as T, className as C, style as ee, memo as B, template as w, setAttribute as te, setStyleProperty as ne } from "solid-js/web";
2
- import { createSignal as S, createMemo as E, createEffect as A, on as G, For as z, Show as I } from "solid-js";
3
- import { cn as _ } from "./index106.js";
4
- import { deferAfterPaint as re } from "./index107.js";
5
- import { Button as N } from "./index20.js";
6
- import { Input as H } from "./index21.js";
7
- import { ChevronRight as M, Check as le, X as oe, Plus as ae } from "./index38.js";
8
- import { FolderOpenIcon as W, FolderIcon as ie } from "./index52.js";
9
- var O = /* @__PURE__ */ w('<div class="flex items-center gap-1.5"><div class=flex-1>'), ce = /* @__PURE__ */ w('<p class="text-[11px] text-muted-foreground -mt-1">Creating in: '), se = /* @__PURE__ */ w("<button type=button><span>New Folder"), ue = /* @__PURE__ */ w('<nav class="flex items-center gap-0.5 min-w-0 overflow-x-auto py-0.5"aria-label="Selected path">'), V = /* @__PURE__ */ w("<button type=button>"), de = /* @__PURE__ */ w('<div class="flex items-center justify-center py-6 text-xs text-muted-foreground">'), he = /* @__PURE__ */ w("<div><button type=button><span>"), fe = /* @__PURE__ */ w("<div class=overflow-hidden>"), ge = /* @__PURE__ */ w('<div class="flex flex-col"><div><button type=button><span class="flex-shrink-0 w-4 h-4"></span><span class=truncate>'), me = /* @__PURE__ */ w('<span class="flex-shrink-0 w-4 h-4">');
10
- function k(e) {
11
- const o = (e ?? "").trim();
12
- if (o === "" || o === "/") return "/";
13
- const n = o.replace(/\/+$/, "");
14
- return n.startsWith("/") ? n : "/" + n;
15
- }
16
- function j(e) {
17
- const o = e.split("/").filter(Boolean), n = [];
18
- let c = "";
19
- for (let r = 0; r < o.length - 1; r++)
20
- c += "/" + o[r], n.push(c);
21
- return n;
22
- }
23
- function ve(e) {
24
- return E(() => {
25
- const o = /* @__PURE__ */ new Map(), n = (c) => {
26
- for (const r of c)
27
- r.type === "folder" && (o.set(k(r.path), r), r.children?.length && n(r.children));
28
- };
29
- return n(e()), o;
30
- });
31
- }
32
- function _e(e) {
33
- const o = e.initialPath ?? "/", n = () => (typeof e.homeLabel == "function" ? e.homeLabel() : e.homeLabel) ?? "Root", c = () => {
34
- const t = typeof e.homePath == "function" ? e.homePath() : e.homePath;
35
- return t ? k(t) : void 0;
36
- }, r = (t) => {
37
- const i = c();
38
- if (!i) return t;
39
- const d = k(t);
40
- return d === "/" ? i : i === "/" ? d : i + d;
41
- }, u = (t) => {
42
- const i = c();
43
- if (!i) return k(t);
44
- const d = k(t);
45
- return d === i ? "/" : i !== "/" && d.startsWith(i + "/") ? d.slice(i.length) || "/" : k(t);
46
- }, [b, m] = S(o), [f, v] = S(/* @__PURE__ */ new Set(["/"])), [P, l] = S(r(o)), [x, a] = S(""), g = ve(e.files), y = E(() => e.files().filter((t) => t.type === "folder"));
47
- A(G(e.open, (t) => {
48
- if (t) {
49
- const i = e.initialPath ?? "/";
50
- m(i), l(r(i)), a("");
51
- const d = j(i);
52
- v(/* @__PURE__ */ new Set(["/", ...d])), e.onReset?.(i);
1
+ import { onCleanup as F } from "solid-js";
2
+ function g(n, i, u) {
3
+ const f = u?.delayMs ?? 500, p = u?.moveTolerancePx ?? 10, m = u?.selectOnOpen ?? !0;
4
+ let t = null, l = null, c = !1;
5
+ const r = () => {
6
+ t !== null && typeof window < "u" && (window.clearTimeout(t), t = null), l = null;
7
+ }, a = () => {
8
+ c = !0;
9
+ }, w = (e, o) => {
10
+ if (!m) {
11
+ n.showContextMenu({ x: e, y: o, items: [i] }), a();
12
+ return;
53
13
  }
54
- })), A(G(b, (t) => {
55
- l(r(t)), a("");
56
- }));
57
- const $ = (t) => {
58
- const i = k(t);
59
- return i === "/" || g().has(i);
60
- }, F = (t) => e.filter ? e.filter(t) : !0, L = (t) => {
61
- const i = j(t);
62
- v((d) => {
63
- const p = new Set(d);
64
- for (const D of i) p.add(D);
65
- return p.add(t), p;
66
- });
67
- }, q = (t) => {
68
- v((i) => {
69
- const d = new Set(i);
70
- return d.has(t) ? d.delete(t) : d.add(t), d;
71
- });
72
- }, J = (t) => {
73
- F(t) && (m(t.path), v((i) => {
74
- const d = new Set(i);
75
- return d.add(t.path), d;
76
- }));
77
- }, Q = () => {
78
- m("/");
79
- }, R = () => {
80
- const t = u(P().trim());
81
- $(t) ? (m(t), a(""), L(t)) : a("Path not found");
82
- }, U = (t) => {
83
- t.key === "Enter" && (t.preventDefault(), R());
84
- }, Y = E(() => {
85
- const t = b(), i = n();
86
- if (t === "/" || t === "") return [{
87
- name: i,
88
- path: "/"
89
- }];
90
- const d = t.split("/").filter(Boolean), p = [{
91
- name: i,
92
- path: "/"
93
- }];
94
- let D = "";
95
- for (const K of d)
96
- D += "/" + K, p.push({
97
- name: K,
98
- path: D
99
- });
100
- return p;
101
- });
102
- return {
103
- selectedPath: b,
104
- setSelectedPath: m,
105
- expandedPaths: f,
106
- toggleExpand: q,
107
- pathInput: P,
108
- setPathInput: l,
109
- pathInputError: x,
110
- setPathInputError: a,
111
- folderIndex: g,
112
- rootFolders: y,
113
- isValidPath: $,
114
- isSelectable: F,
115
- handleSelectFolder: J,
116
- handleSelectRoot: Q,
117
- handlePathInputGo: R,
118
- handlePathInputKeyDown: U,
119
- expandToPath: L,
120
- breadcrumbSegments: Y,
121
- handleBreadcrumbClick: (t) => {
122
- m(t), L(t);
123
- },
124
- homeLabel: n,
125
- toDisplayPath: r
126
- };
127
- }
128
- function pe(e) {
129
- const [o, n] = S(!1), [c, r] = S(""), [u, b] = S(!1), m = () => {
130
- n(!0), r("");
131
- }, f = () => {
132
- n(!1), r("");
133
- }, v = () => {
134
- const l = c().trim();
135
- if (!l || u()) return;
136
- b(!0);
137
- const x = e.parentPath(), a = l, g = e.onCreateFolder;
138
- re(() => {
139
- g(x, a).then(() => {
140
- n(!1), r("");
141
- }).catch((y) => {
142
- console.error("Failed to create folder:", y);
143
- }).finally(() => {
144
- b(!1);
145
- });
146
- });
147
- }, P = (l) => {
148
- l.key === "Enter" ? (l.preventDefault(), v()) : l.key === "Escape" && (l.preventDefault(), f());
149
- };
150
- return s(I, {
151
- get when() {
152
- return o();
153
- },
154
- get fallback() {
155
- return (() => {
156
- var l = se(), x = l.firstChild;
157
- return l.$$click = m, h(l, s(ae, {
158
- class: "w-3.5 h-3.5"
159
- }), x), T(() => C(l, _("flex items-center gap-1 text-xs text-muted-foreground cursor-pointer", "hover:text-foreground transition-colors duration-100", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring rounded px-1 py-0.5"))), l;
160
- })();
161
- },
162
- get children() {
163
- return [(() => {
164
- var l = O(), x = l.firstChild;
165
- return h(x, s(H, {
166
- size: "sm",
167
- get value() {
168
- return c();
169
- },
170
- onInput: (a) => r(a.currentTarget.value),
171
- onKeyDown: P,
172
- placeholder: "Folder name",
173
- get disabled() {
174
- return u();
175
- },
176
- autofocus: !0
177
- })), h(l, s(N, {
178
- variant: "primary",
179
- size: "sm",
180
- onClick: v,
181
- get loading() {
182
- return u();
183
- },
184
- get disabled() {
185
- return !c().trim();
186
- },
187
- get children() {
188
- return s(le, {
189
- class: "w-3.5 h-3.5"
190
- });
191
- }
192
- }), null), h(l, s(N, {
193
- variant: "ghost",
194
- size: "sm",
195
- class: "bg-transparent text-muted-foreground hover:bg-red-500 hover:text-white",
196
- onClick: f,
197
- get disabled() {
198
- return u();
199
- },
200
- get children() {
201
- return s(oe, {
202
- class: "w-3.5 h-3.5"
203
- });
204
- }
205
- }), null), l;
206
- })(), (() => {
207
- var l = ce();
208
- return l.firstChild, h(l, (() => {
209
- var x = B(() => !!e.toDisplayPath);
210
- return () => x() ? e.toDisplayPath(e.parentPath()) : e.parentPath();
211
- })(), null), l;
212
- })()];
213
- }
214
- });
215
- }
216
- function Ie(e) {
217
- return (() => {
218
- var o = O(), n = o.firstChild;
219
- return h(n, s(H, {
220
- size: "sm",
221
- get value() {
222
- return e.value();
223
- },
224
- onInput: (c) => e.onInput(c.currentTarget.value),
225
- get onKeyDown() {
226
- return e.onKeyDown;
227
- },
228
- get placeholder() {
229
- return e.placeholder ?? "/path/to/directory";
230
- },
231
- get error() {
232
- return e.error();
233
- }
234
- })), h(o, s(N, {
235
- variant: "outline",
236
- size: "sm",
237
- get onClick() {
238
- return e.onGo;
239
- },
240
- children: "Go"
241
- }), null), o;
242
- })();
243
- }
244
- function Fe(e) {
245
- return (() => {
246
- var o = ue();
247
- return h(o, s(z, {
248
- get each() {
249
- return e.segments();
250
- },
251
- children: (n, c) => [s(I, {
252
- get when() {
253
- return c() > 0;
254
- },
255
- get children() {
256
- return s(M, {
257
- class: "w-3 h-3 text-muted-foreground/50 flex-shrink-0"
258
- });
259
- }
260
- }), (() => {
261
- var r = V();
262
- return r.$$click = () => e.onClick(n.path), h(r, () => n.name), T(() => C(r, _("text-xs px-1 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-colors duration-100", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", c() === e.segments().length - 1 ? "font-medium text-foreground" : "text-muted-foreground hover:text-foreground hover:bg-muted/50"))), r;
263
- })()]
264
- })), o;
265
- })();
266
- }
267
- function Te(e) {
268
- const o = () => (typeof e.homeLabel == "function" ? e.homeLabel() : e.homeLabel) ?? "Root";
269
- return (() => {
270
- var n = he(), c = n.firstChild, r = c.firstChild;
271
- return c.$$click = () => e.onSelectRoot(), h(c, s(W, {
272
- class: "w-4 h-4 flex-shrink-0"
273
- }), r), h(r, o), h(n, s(z, {
274
- get each() {
275
- return e.rootFolders();
276
- },
277
- children: (u) => s(X, {
278
- item: u,
279
- depth: 1,
280
- get selectedPath() {
281
- return e.selectedPath;
282
- },
283
- get expandedPaths() {
284
- return e.expandedPaths;
285
- },
286
- get onToggle() {
287
- return e.onToggle;
288
- },
289
- get onSelect() {
290
- return e.onSelect;
291
- },
292
- get isSelectable() {
293
- return e.isSelectable;
294
- }
295
- })
296
- }), null), h(n, s(I, {
297
- get when() {
298
- return e.rootFolders().length === 0;
299
- },
300
- get children() {
301
- var u = de();
302
- return h(u, () => e.emptyText ?? "No directories available"), u;
303
- }
304
- }), null), T((u) => {
305
- var b = _("border border-border rounded overflow-y-auto", e.class), m = e.style, f = _("flex items-center gap-1.5 w-full text-left text-xs py-1.5 px-2 cursor-pointer", "transition-colors duration-100", "hover:bg-accent/60", "focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring", e.selectedPath() === "/" && "bg-accent text-accent-foreground font-medium");
306
- return b !== u.e && C(n, u.e = b), u.t = ee(n, m, u.t), f !== u.a && C(c, u.a = f), u;
307
- }, {
308
- e: void 0,
309
- t: void 0,
310
- a: void 0
311
- }), n;
312
- })();
313
- }
314
- function X(e) {
315
- const o = () => e.expandedPaths().has(e.item.path), n = () => e.selectedPath() === e.item.path, c = () => e.isSelectable(e.item), r = E(() => e.item.children?.filter((f) => f.type === "folder") ?? []), u = () => r().length > 0, b = (f) => {
316
- f.stopPropagation(), e.onToggle(e.item.path);
317
- }, m = () => {
318
- e.onSelect(e.item);
14
+ const s = i.id;
15
+ n.isSelected(s) || n.selectItem(s, !1);
16
+ const x = n.selectedItems(), d = n.currentFiles().filter((v) => x.has(v.id)), T = d.length > 0 ? d : [i];
17
+ n.showContextMenu({ x: e, y: o, items: T }), a();
18
+ }, y = (e) => {
19
+ if (c = !1, e.pointerType === "mouse" || typeof window > "u") return;
20
+ r(), l = { x: e.clientX, y: e.clientY };
21
+ const o = e.clientX, s = e.clientY;
22
+ t = window.setTimeout(() => {
23
+ t = null, w(o, s);
24
+ }, f);
25
+ }, C = (e) => {
26
+ if (t === null || !l) return;
27
+ const o = e.clientX - l.x, s = e.clientY - l.y;
28
+ Math.hypot(o, s) > p && (r(), a());
29
+ }, M = () => r(), P = () => r(), h = (e) => c ? (c = !1, e.preventDefault(), e.stopPropagation(), !0) : !1;
30
+ return F(() => {
31
+ r();
32
+ }), {
33
+ onPointerDown: y,
34
+ onPointerMove: C,
35
+ onPointerUp: M,
36
+ onPointerCancel: P,
37
+ consumeClickSuppression: h
319
38
  };
320
- return (() => {
321
- var f = ge(), v = f.firstChild, P = v.firstChild, l = P.firstChild, x = l.nextSibling;
322
- return h(v, s(I, {
323
- get when() {
324
- return u();
325
- },
326
- get fallback() {
327
- return me();
328
- },
329
- get children() {
330
- var a = V();
331
- return a.$$click = b, h(a, s(M, {
332
- class: "w-3 h-3 opacity-60"
333
- })), T((g) => {
334
- var y = _("flex-shrink-0 w-4 h-4 flex items-center justify-center cursor-pointer", "transition-transform duration-150", o() && "rotate-90", "focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring"), $ = o() ? "Collapse folder" : "Expand folder";
335
- return y !== g.e && C(a, g.e = y), $ !== g.t && te(a, "aria-label", g.t = $), g;
336
- }, {
337
- e: void 0,
338
- t: void 0
339
- }), a;
340
- }
341
- }), P), P.$$click = m, h(l, s(I, {
342
- get when() {
343
- return B(() => !!u())() && o();
344
- },
345
- get fallback() {
346
- return s(ie, {
347
- class: "w-4 h-4"
348
- });
349
- },
350
- get children() {
351
- return s(W, {
352
- class: "w-4 h-4"
353
- });
354
- }
355
- })), h(x, () => e.item.name), h(f, s(I, {
356
- get when() {
357
- return B(() => !!o())() && u();
358
- },
359
- get children() {
360
- var a = fe();
361
- return h(a, s(z, {
362
- get each() {
363
- return r();
364
- },
365
- children: (g) => s(X, {
366
- item: g,
367
- get depth() {
368
- return e.depth + 1;
369
- },
370
- get selectedPath() {
371
- return e.selectedPath;
372
- },
373
- get expandedPaths() {
374
- return e.expandedPaths;
375
- },
376
- get onToggle() {
377
- return e.onToggle;
378
- },
379
- get onSelect() {
380
- return e.onSelect;
381
- },
382
- get isSelectable() {
383
- return e.isSelectable;
384
- }
385
- })
386
- })), a;
387
- }
388
- }), null), T((a) => {
389
- var g = _("group flex items-center w-full text-xs", "transition-colors duration-100", c() ? "hover:bg-accent/60" : "opacity-50", n() && c() && "bg-accent text-accent-foreground font-medium"), y = `${4 + e.depth * 14}px`, $ = !c(), F = _("flex items-center gap-1 flex-1 min-w-0 text-left py-1.5 pl-0.5 pr-2", c() ? "cursor-pointer" : "cursor-not-allowed", "focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring");
390
- return g !== a.e && C(v, a.e = g), y !== a.t && ne(v, "padding-left", a.t = y), $ !== a.a && (P.disabled = a.a = $), F !== a.o && C(P, a.o = F), a;
391
- }, {
392
- e: void 0,
393
- t: void 0,
394
- a: void 0,
395
- o: void 0
396
- }), f;
397
- })();
398
39
  }
399
- Z(["click"]);
400
40
  export {
401
- pe as NewFolderSection,
402
- Ie as PathInputBar,
403
- Fe as PickerBreadcrumb,
404
- Te as PickerFolderTree,
405
- X as PickerTreeNode,
406
- j as getAncestorPaths,
407
- k as normalizePath,
408
- ve as useFolderIndex,
409
- _e as usePickerTree
41
+ g as createLongPressContextMenuHandlers
410
42
  };