@floegence/floe-webapp-core 0.8.1 → 0.8.2

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.
@@ -5,6 +5,8 @@ export interface FileBrowserProviderProps {
5
5
  files: FileItem[];
6
6
  initialPath?: string;
7
7
  initialViewMode?: ViewMode;
8
+ /** Label for the root/home directory in breadcrumb (default: 'Root') */
9
+ homeLabel?: string;
8
10
  onNavigate?: (path: string) => void;
9
11
  onSelect?: (items: FileItem[]) => void;
10
12
  onOpen?: (item: FileItem) => void;
@@ -133,6 +133,7 @@ export interface FileBrowserContextValue {
133
133
  setCurrentPath: (path: string) => void;
134
134
  navigateUp: () => void;
135
135
  navigateTo: (item: FileItem) => void;
136
+ homeLabel: Accessor<string>;
136
137
  selectedItems: Accessor<Set<string>>;
137
138
  selectItem: (id: string, multi?: boolean) => void;
138
139
  clearSelection: () => void;
package/dist/index41.js CHANGED
@@ -1,23 +1,23 @@
1
- import { createComponent as he } from "solid-js/web";
2
- import { createContext as me, createSignal as a, createMemo as N, useContext as we } from "solid-js";
1
+ import { createComponent as me } from "solid-js/web";
2
+ import { createContext as we, createSignal as a, createMemo as N, useContext as Pe } from "solid-js";
3
3
  import { deferNonBlocking as I } from "./index70.js";
4
- const V = me();
5
- function Q(r, p) {
6
- if (!p) return [];
7
- const x = r.toLowerCase(), w = p.toLowerCase(), h = [];
4
+ const R = we();
5
+ function Q(r, h) {
6
+ if (!h) return [];
7
+ const x = r.toLowerCase(), w = h.toLowerCase(), p = [];
8
8
  let g = 0;
9
9
  for (const S of w) {
10
10
  const m = x.indexOf(S, g);
11
11
  if (m === -1) return null;
12
- h.push(m), g = m + 1;
12
+ p.push(m), g = m + 1;
13
13
  }
14
- return h;
14
+ return p;
15
15
  }
16
- function Ce(r) {
17
- const [p, x] = a(r.initialPath ?? "/"), [w, h] = a(/* @__PURE__ */ new Set()), [g, S] = a(r.initialViewMode ?? "list"), [m, j] = a({
16
+ function ye(r) {
17
+ const [h, x] = a(r.initialPath ?? "/"), [w, p] = a(/* @__PURE__ */ new Set()), [g, S] = a(r.initialViewMode ?? "list"), [m, V] = a({
18
18
  field: "name",
19
19
  direction: "asc"
20
- }), [M, O] = a(/* @__PURE__ */ new Set(["/"])), [R, D] = a(!1), [G, k] = a(null), [v, b] = a(""), [H, B] = a(!1), [z, P] = a([]);
20
+ }), [M, b] = a(/* @__PURE__ */ new Set(["/"])), [j, D] = a(!1), [G, O] = a(null), [v, k] = a(""), [H, B] = a(!1), J = () => r.homeLabel ?? "Root", [z, P] = a([]);
21
21
  let u = null, C = {
22
22
  top: 0,
23
23
  left: 0
@@ -25,12 +25,12 @@ function Ce(r) {
25
25
  const A = () => r.files, c = (e) => {
26
26
  const t = (e ?? "").trim();
27
27
  return t === "" ? "/" : t;
28
- }, T = (e) => {
28
+ }, L = (e) => {
29
29
  const t = c(e);
30
30
  if (t === "/") return "/";
31
31
  const n = t.split("/").filter(Boolean);
32
32
  return n.pop(), n.length ? "/" + n.join("/") : "/";
33
- }, J = (e, t) => {
33
+ }, K = (e, t) => {
34
34
  const n = z();
35
35
  if (n.length === 0) return e;
36
36
  let s = [...e];
@@ -46,13 +46,13 @@ function Ce(r) {
46
46
  const l = c(o.oldPath), i = s.findIndex((f) => c(f.path) === l);
47
47
  if (i !== -1) {
48
48
  const f = o.updates.path ?? s[i].path;
49
- T(f) === d ? s[i] = {
49
+ L(f) === d ? s[i] = {
50
50
  ...s[i],
51
51
  ...o.updates
52
52
  } : s.splice(i, 1);
53
53
  } else {
54
54
  const f = o.updates.path;
55
- f && T(f);
55
+ f && L(f);
56
56
  }
57
57
  break;
58
58
  }
@@ -62,17 +62,17 @@ function Ce(r) {
62
62
  }
63
63
  }
64
64
  return s;
65
- }, K = N(() => {
65
+ }, W = N(() => {
66
66
  const e = /* @__PURE__ */ new Map(), t = (s) => {
67
67
  var d;
68
68
  for (const o of s)
69
69
  o.type === "folder" && (e.set(c(o.path), o.children ?? []), (d = o.children) != null && d.length && t(o.children));
70
70
  }, n = A();
71
71
  return e.set("/", n), t(n), e;
72
- }), U = N(() => {
73
- const e = c(p());
74
- let t = K().get(e) ?? [];
75
- t = J(t, e);
72
+ }), T = N(() => {
73
+ const e = c(h());
74
+ let t = W().get(e) ?? [];
75
+ t = K(t, e);
76
76
  const n = v().trim();
77
77
  n && (t = t.filter((o) => Q(o.name, n) !== null));
78
78
  const s = m();
@@ -100,69 +100,69 @@ function Ce(r) {
100
100
  }), y = (e) => {
101
101
  var s;
102
102
  const t = c(e);
103
- x(t), h(/* @__PURE__ */ new Set()), b(""), B(!1);
103
+ x(t), p(/* @__PURE__ */ new Set()), k(""), B(!1);
104
104
  const n = r.onSelect;
105
105
  I(() => n == null ? void 0 : n([])), (s = r.onNavigate) == null || s.call(r, t);
106
- }, W = () => {
107
- const e = p();
106
+ }, X = () => {
107
+ const e = h();
108
108
  if (e === "/" || e === "") return;
109
109
  const t = e.split("/").filter(Boolean);
110
110
  t.pop(), y(t.length ? "/" + t.join("/") : "/");
111
- }, E = (e) => {
112
- e.type === "folder" && (y(e.path), O((t) => {
111
+ }, U = (e) => {
112
+ e.type === "folder" && (y(e.path), b((t) => {
113
113
  const n = new Set(t);
114
114
  return n.add(e.path), n;
115
115
  }));
116
- }, X = (e, t = !1) => {
116
+ }, Y = (e, t = !1) => {
117
117
  const n = w(), s = t ? new Set(n) : /* @__PURE__ */ new Set();
118
- t ? s.has(e) ? s.delete(e) : s.add(e) : (s.clear(), s.add(e)), h(s);
119
- const d = U().filter((l) => s.has(l.id)), o = r.onSelect;
118
+ t ? s.has(e) ? s.delete(e) : s.add(e) : (s.clear(), s.add(e)), p(s);
119
+ const d = T().filter((l) => s.has(l.id)), o = r.onSelect;
120
120
  I(() => o == null ? void 0 : o(d));
121
- }, Y = () => {
122
- h(/* @__PURE__ */ new Set());
121
+ }, Z = () => {
122
+ p(/* @__PURE__ */ new Set());
123
123
  const e = r.onSelect;
124
124
  I(() => e == null ? void 0 : e([]));
125
- }, Z = (e) => w().has(e), _ = (e) => {
126
- O((t) => {
125
+ }, _ = (e) => w().has(e), $ = (e) => {
126
+ b((t) => {
127
127
  const n = new Set(t);
128
128
  return n.has(e) ? n.delete(e) : n.add(e), n;
129
129
  });
130
- }, $ = (e) => M().has(e), ee = () => D((e) => !e), te = (e) => k(e), ne = () => k(null), oe = (e) => {
131
- b(e);
132
- }, se = (e) => {
130
+ }, ee = (e) => M().has(e), te = () => D((e) => !e), ne = (e) => O(e), oe = () => O(null), se = (e) => {
131
+ k(e);
132
+ }, re = (e) => {
133
133
  const t = v().trim();
134
134
  if (!t) return null;
135
135
  const n = Q(e, t);
136
136
  return n ? {
137
137
  matchedIndices: n
138
138
  } : null;
139
- }, re = (e) => {
140
- var t;
141
- e.type === "folder" ? E(e) : (t = r.onOpen) == null || t.call(r, e);
142
139
  }, ie = (e) => {
140
+ var t;
141
+ e.type === "folder" ? U(e) : (t = r.onOpen) == null || t.call(r, e);
142
+ }, ce = (e) => {
143
143
  e.length !== 0 && P((t) => [...t, {
144
144
  type: "remove",
145
145
  paths: e
146
146
  }]);
147
- }, ce = (e, t) => {
147
+ }, le = (e, t) => {
148
148
  P((n) => [...n, {
149
149
  type: "update",
150
150
  oldPath: e,
151
151
  updates: t
152
152
  }]);
153
- }, le = (e, t) => {
153
+ }, ae = (e, t) => {
154
154
  P((n) => [...n, {
155
155
  type: "insert",
156
156
  parentPath: e,
157
157
  item: t
158
158
  }]);
159
- }, ae = () => {
160
- P([]);
161
159
  }, de = () => {
162
160
  P([]);
163
- }, fe = () => z().length > 0, ue = (e) => {
161
+ }, fe = () => {
162
+ P([]);
163
+ }, ue = () => z().length > 0, he = (e) => {
164
164
  u = e;
165
- }, L = () => u ? {
165
+ }, E = () => u ? {
166
166
  top: u.scrollTop,
167
167
  left: u.scrollLeft
168
168
  } : {
@@ -171,66 +171,67 @@ function Ce(r) {
171
171
  }, q = (e) => {
172
172
  u && (u.scrollTop = e.top, u.scrollLeft = e.left);
173
173
  }, pe = {
174
- currentPath: p,
174
+ currentPath: h,
175
175
  setCurrentPath: y,
176
- navigateUp: W,
177
- navigateTo: E,
176
+ navigateUp: X,
177
+ navigateTo: U,
178
+ homeLabel: J,
178
179
  selectedItems: () => w(),
179
- selectItem: X,
180
- clearSelection: Y,
181
- isSelected: Z,
180
+ selectItem: Y,
181
+ clearSelection: Z,
182
+ isSelected: _,
182
183
  viewMode: g,
183
184
  setViewMode: S,
184
185
  sortConfig: m,
185
- setSortConfig: j,
186
+ setSortConfig: V,
186
187
  expandedFolders: M,
187
- toggleFolder: _,
188
- isExpanded: $,
188
+ toggleFolder: $,
189
+ isExpanded: ee,
189
190
  files: A,
190
- currentFiles: U,
191
+ currentFiles: T,
191
192
  filterQuery: v,
192
- setFilterQuery: oe,
193
+ setFilterQuery: se,
193
194
  isFilterActive: H,
194
195
  setFilterActive: B,
195
- getFilterMatch: se,
196
- sidebarCollapsed: R,
197
- toggleSidebar: ee,
196
+ getFilterMatch: re,
197
+ sidebarCollapsed: j,
198
+ toggleSidebar: te,
198
199
  contextMenu: G,
199
- showContextMenu: te,
200
- hideContextMenu: ne,
201
- openItem: re,
200
+ showContextMenu: ne,
201
+ hideContextMenu: oe,
202
+ openItem: ie,
202
203
  // Optimistic updates
203
- optimisticRemove: ie,
204
- optimisticUpdate: ce,
205
- optimisticInsert: le,
206
- clearOptimisticUpdates: ae,
207
- rollbackOptimisticUpdates: de,
208
- hasOptimisticUpdates: fe,
204
+ optimisticRemove: ce,
205
+ optimisticUpdate: le,
206
+ optimisticInsert: ae,
207
+ clearOptimisticUpdates: de,
208
+ rollbackOptimisticUpdates: fe,
209
+ hasOptimisticUpdates: ue,
209
210
  // Scroll position management
210
- setScrollContainer: ue,
211
- getScrollPosition: L,
211
+ setScrollContainer: he,
212
+ getScrollPosition: E,
212
213
  setScrollPosition: q,
213
- saveScrollPosition: () => (C = L(), C),
214
+ saveScrollPosition: () => (C = E(), C),
214
215
  restoreScrollPosition: () => {
215
216
  requestAnimationFrame(() => {
216
217
  q(C);
217
218
  });
218
219
  }
219
220
  };
220
- return he(V.Provider, {
221
+ return me(R.Provider, {
221
222
  value: pe,
222
223
  get children() {
223
224
  return r.children;
224
225
  }
225
226
  });
226
227
  }
227
- function ye() {
228
- const r = we(V);
228
+ function Fe() {
229
+ const r = Pe(R);
229
230
  if (!r)
230
231
  throw new Error("useFileBrowser must be used within a FileBrowserProvider");
231
232
  return r;
232
233
  }
233
234
  export {
234
- Ce as FileBrowserProvider,
235
- ye as useFileBrowser
235
+ ye as FileBrowserProvider,
236
+ Fe as useFileBrowser
236
237
  };
package/dist/index46.js CHANGED
@@ -1,20 +1,20 @@
1
- import { delegateEvents as H, template as v, insert as E, createComponent as a, memo as P, effect as b, className as x, use as y } from "solid-js/web";
2
- import { createSignal as B, onMount as L, createMemo as k, For as O, Show as M, onCleanup as F } from "solid-js";
3
- import { cn as W } from "./index69.js";
1
+ import { delegateEvents as A, template as b, insert as R, createComponent as a, memo as H, effect as x, className as W, use as P } from "solid-js/web";
2
+ import { createSignal as y, onMount as B, createMemo as M, For as O, Show as T, onCleanup as F } from "solid-js";
3
+ import { cn as C } from "./index69.js";
4
4
  import { useFileBrowser as G } from "./index41.js";
5
- import { ChevronRight as T } from "./index34.js";
5
+ import { ChevronRight as E } from "./index34.js";
6
6
  import { Dropdown as z } from "./index24.js";
7
- var X = /* @__PURE__ */ v("<nav aria-label=Breadcrumb>"), j = /* @__PURE__ */ v('<button type=button title="Show hidden path segments">…'), q = /* @__PURE__ */ v('<button type=button><span class="truncate max-w-[120px] block">');
8
- const g = 16, J = 28, R = 12, K = 7, Q = 120, U = 100;
9
- function V(n) {
10
- const r = n.length * K;
11
- return Math.min(r + R, Q + R);
7
+ var X = /* @__PURE__ */ b("<nav aria-label=Breadcrumb>"), j = /* @__PURE__ */ b('<button type=button title="Show hidden path segments">…'), q = /* @__PURE__ */ b('<button type=button><span class="truncate max-w-[120px] block">');
8
+ const p = 16, J = 28, D = 12, K = 7, Q = 120, U = 100;
9
+ function V(r) {
10
+ const n = r.length * K;
11
+ return Math.min(n + D, Q + D);
12
12
  }
13
- function ce(n) {
14
- const r = G();
13
+ function ce(r) {
14
+ const n = G();
15
15
  let s;
16
- const [t, c] = B(0);
17
- L(() => {
16
+ const [t, c] = y(0);
17
+ B(() => {
18
18
  if (!s) return;
19
19
  const e = () => {
20
20
  s && c(s.offsetWidth);
@@ -23,25 +23,25 @@ function ce(n) {
23
23
  const o = new ResizeObserver(e);
24
24
  o.observe(s), F(() => o.disconnect());
25
25
  });
26
- const d = k(() => {
27
- const e = r.currentPath();
26
+ const d = M(() => {
27
+ const e = n.currentPath(), o = n.homeLabel();
28
28
  if (e === "/" || e === "")
29
29
  return [{
30
- name: "Root",
30
+ name: o,
31
31
  path: "/"
32
32
  }];
33
- const o = e.split("/").filter(Boolean), i = [{
34
- name: "Root",
33
+ const l = e.split("/").filter(Boolean), i = [{
34
+ name: o,
35
35
  path: "/"
36
36
  }];
37
- let l = "";
38
- for (const f of o)
39
- l += "/" + f, i.push({
40
- name: f,
41
- path: l
37
+ let f = "";
38
+ for (const g of l)
39
+ f += "/" + g, i.push({
40
+ name: g,
41
+ path: f
42
42
  });
43
43
  return i;
44
- }), m = k(() => {
44
+ }), m = M(() => {
45
45
  const e = d(), o = t();
46
46
  if (o < U || e.length <= 2)
47
47
  return {
@@ -49,73 +49,73 @@ function ce(n) {
49
49
  visible: e,
50
50
  shouldCollapse: !1
51
51
  };
52
- const i = e.map((u) => V(u.name)), l = i[0], f = i[e.length - 1], D = g, $ = e.length > 1 ? g : 0, S = l + f + D + $;
53
- if (S > o && e.length > 2)
52
+ const l = e.map((u) => V(u.name)), i = l[0], f = l[e.length - 1], g = p, $ = e.length > 1 ? p : 0, _ = i + f + g + $;
53
+ if (_ > o && e.length > 2)
54
54
  return {
55
55
  collapsed: e.slice(1, -1),
56
56
  visible: [e[0], e[e.length - 1]],
57
57
  shouldCollapse: !0
58
58
  };
59
- const h = e.slice(1, -1), p = [];
60
- let _ = o - S;
61
- const N = h.length > 0 ? J + g : 0;
59
+ const h = e.slice(1, -1), v = [];
60
+ let w = o - _;
61
+ const L = h.length > 0 ? J + p : 0;
62
62
  for (let u = h.length - 1; u >= 0; u--) {
63
- const I = i[u + 1] + g, A = u > 0 ? N : 0;
64
- if (_ - A >= I)
65
- p.unshift(h[u]), _ -= I;
63
+ const k = l[u + 1] + p, N = u > 0 ? L : 0;
64
+ if (w - N >= k)
65
+ v.unshift(h[u]), w -= k;
66
66
  else
67
67
  break;
68
68
  }
69
- const w = h.slice(0, h.length - p.length);
69
+ const I = h.slice(0, h.length - v.length);
70
70
  return {
71
- collapsed: w,
72
- visible: [e[0], ...p, e[e.length - 1]],
73
- shouldCollapse: w.length > 0
71
+ collapsed: I,
72
+ visible: [e[0], ...v, e[e.length - 1]],
73
+ shouldCollapse: I.length > 0
74
74
  };
75
- }), C = (e) => {
76
- r.setCurrentPath(e.path);
75
+ }), S = (e) => {
76
+ n.setCurrentPath(e.path);
77
77
  };
78
78
  return (() => {
79
79
  var e = X(), o = s;
80
- return typeof o == "function" ? y(o, e) : s = e, E(e, a(O, {
80
+ return typeof o == "function" ? P(o, e) : s = e, R(e, a(O, {
81
81
  get each() {
82
82
  return m().visible;
83
83
  },
84
- children: (i, l) => [a(M, {
84
+ children: (l, i) => [a(T, {
85
85
  get when() {
86
- return l() > 0;
86
+ return i() > 0;
87
87
  },
88
88
  get children() {
89
- return a(T, {
89
+ return a(E, {
90
90
  class: "w-3 h-3 text-muted-foreground/50 flex-shrink-0"
91
91
  });
92
92
  }
93
- }), a(M, {
93
+ }), a(T, {
94
94
  get when() {
95
- return P(() => !!m().shouldCollapse)() && l() === 1;
95
+ return H(() => !!m().shouldCollapse)() && i() === 1;
96
96
  },
97
97
  get children() {
98
98
  return [a(Y, {
99
99
  get segments() {
100
100
  return m().collapsed;
101
101
  },
102
- onSelect: C
103
- }), a(T, {
102
+ onSelect: S
103
+ }), a(E, {
104
104
  class: "w-3 h-3 text-muted-foreground/50 flex-shrink-0"
105
105
  })];
106
106
  }
107
107
  }), a(Z, {
108
- segment: i,
108
+ segment: l,
109
109
  get isLast() {
110
- return l() === m().visible.length - 1;
110
+ return i() === m().visible.length - 1;
111
111
  },
112
- onClick: () => C(i)
112
+ onClick: () => S(l)
113
113
  })]
114
- })), b(() => x(e, W("flex items-center gap-1 min-w-0 overflow-hidden", n.class))), e;
114
+ })), x(() => W(e, C("flex items-center gap-1 min-w-0 overflow-hidden", r.class))), e;
115
115
  })();
116
116
  }
117
- function Y(n) {
118
- const r = () => n.segments.map((t) => ({
117
+ function Y(r) {
118
+ const n = () => r.segments.map((t) => ({
119
119
  id: t.path,
120
120
  label: t.name
121
121
  }));
@@ -123,32 +123,32 @@ function Y(n) {
123
123
  get trigger() {
124
124
  return (() => {
125
125
  var t = j();
126
- return b(() => x(t, W("text-xs px-1.5 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-all duration-100", "text-muted-foreground hover:text-foreground hover:bg-muted/50", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"))), t;
126
+ return x(() => W(t, C("text-xs px-1.5 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-all duration-100", "text-muted-foreground hover:text-foreground hover:bg-muted/50", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring"))), t;
127
127
  })();
128
128
  },
129
129
  get items() {
130
- return r();
130
+ return n();
131
131
  },
132
132
  onSelect: (t) => {
133
- const c = n.segments.find((d) => d.path === t);
134
- c && n.onSelect(c);
133
+ const c = r.segments.find((d) => d.path === t);
134
+ c && r.onSelect(c);
135
135
  },
136
136
  align: "start"
137
137
  });
138
138
  }
139
- function Z(n) {
139
+ function Z(r) {
140
140
  return (() => {
141
- var r = q(), s = r.firstChild;
142
- return r.$$click = () => n.onClick(), E(s, () => n.segment.name), b((t) => {
143
- var c = n.isLast, d = W("text-xs px-1.5 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-all duration-100", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", n.isLast ? "font-medium text-foreground cursor-default" : "text-muted-foreground hover:text-foreground hover:bg-muted/50");
144
- return c !== t.e && (r.disabled = t.e = c), d !== t.t && x(r, t.t = d), t;
141
+ var n = q(), s = n.firstChild;
142
+ return n.$$click = () => r.onClick(), R(s, () => r.segment.name), x((t) => {
143
+ var c = r.isLast, d = C("text-xs px-1.5 py-0.5 rounded cursor-pointer flex-shrink-0", "transition-all duration-100", "focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", r.isLast ? "font-medium text-foreground cursor-default" : "text-muted-foreground hover:text-foreground hover:bg-muted/50");
144
+ return c !== t.e && (n.disabled = t.e = c), d !== t.t && W(n, t.t = d), t;
145
145
  }, {
146
146
  e: void 0,
147
147
  t: void 0
148
- }), r;
148
+ }), n;
149
149
  })();
150
150
  }
151
- H(["click"]);
151
+ A(["click"]);
152
152
  export {
153
153
  ce as Breadcrumb
154
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",