@floegence/floe-webapp-core 0.35.5 → 0.35.6

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.
@@ -28,6 +28,8 @@ export interface FileContextMenuProps {
28
28
  */
29
29
  hideItems?: HideItemsValue;
30
30
  }
31
+ export declare function createDefaultContextMenuItems(callbacks?: ContextMenuCallbacks): ContextMenuItem[];
32
+ export declare function dispatchContextMenuAction(item: ContextMenuItem, items: FileItem[], callbacks?: ContextMenuCallbacks): void;
31
33
  /**
32
34
  * Context menu for file browser items
33
35
  */
@@ -1,145 +1,161 @@
1
- import { createComponent as d, Portal as E, insert as m, Dynamic as L, effect as u, className as M, setStyleProperty as C, template as l, setAttribute as p, use as P, delegateEvents as F } from "solid-js/web";
2
- import { createSignal as H, createEffect as $, onCleanup as S, Show as v, For as R } from "solid-js";
1
+ import { createComponent as u, Portal as D, insert as v, Dynamic as E, effect as h, className as C, setStyleProperty as M, template as c, setAttribute as p, use as L, delegateEvents as P } from "solid-js/web";
2
+ import { createSignal as H, createEffect as $, onCleanup as F, Show as m, For as N } from "solid-js";
3
3
  import { cn as I } from "../../utils/cn.js";
4
- import { deferAfterPaint as T } from "../../utils/defer.js";
4
+ import { deferAfterPaint as S } from "../../utils/defer.js";
5
5
  import { useFileBrowser as V } from "./FileBrowserContext.js";
6
- var Z = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=14 x=8 y=8 rx=2 ry=2></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2">'), z = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3Z">'), W = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"></path><path d="M8 10v4"></path><path d="M12 10v2"></path><path d="M16 10v6">'), q = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M12 3v18"></path><path d="m8 7-4 4 4 4"></path><path d="m16 7 4 4-4 4">'), K = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2">'), N = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"></path><path d="m15 5 4 4">'), O = /* @__PURE__ */ l("<div role=menu aria-orientation=vertical>"), G = /* @__PURE__ */ l('<span class="text-[10px] text-muted-foreground opacity-60">'), J = /* @__PURE__ */ l('<button type=button role=menuitem><span class="flex-1 text-left">'), Q = /* @__PURE__ */ l('<div class="my-1 h-px bg-border">');
7
- const U = (s) => (() => {
8
- var n = Z();
9
- return u(() => p(n, "class", s.class)), n;
10
- })(), X = (s) => (() => {
11
- var n = z();
12
- return u(() => p(n, "class", s.class)), n;
13
- })(), Y = (s) => (() => {
14
- var n = W();
15
- return u(() => p(n, "class", s.class)), n;
16
- })(), ee = (s) => (() => {
17
- var n = q();
18
- return u(() => p(n, "class", s.class)), n;
19
- })(), te = (s) => (() => {
20
- var n = K();
21
- return u(() => p(n, "class", s.class)), n;
22
- })(), ne = (s) => (() => {
23
- var n = N();
24
- return u(() => p(n, "class", s.class)), n;
6
+ var R = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=14 x=8 y=8 rx=2 ry=2></rect><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2">'), T = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect width=14 height=16 x=5 y=4 rx=2></rect><path d="M9 4.5h6a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v.5a1 1 0 0 0 1 1Z">'), Z = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3Z">'), z = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"></path><path d="M8 10v4"></path><path d="M12 10v2"></path><path d="M16 10v6">'), W = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M12 3v18"></path><path d="m8 7-4 4 4 4"></path><path d="m16 7 4 4-4 4">'), q = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2">'), K = /* @__PURE__ */ c('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"></path><path d="m15 5 4 4">'), O = /* @__PURE__ */ c("<div role=menu aria-orientation=vertical>"), G = /* @__PURE__ */ c('<span class="text-[10px] text-muted-foreground opacity-60">'), J = /* @__PURE__ */ c('<button type=button role=menuitem><span class="flex-1 text-left">'), Q = /* @__PURE__ */ c('<div class="my-1 h-px bg-border">');
7
+ const U = (n) => (() => {
8
+ var e = R();
9
+ return h(() => p(e, "class", n.class)), e;
10
+ })(), X = (n) => (() => {
11
+ var e = T();
12
+ return h(() => p(e, "class", n.class)), e;
13
+ })(), Y = (n) => (() => {
14
+ var e = Z();
15
+ return h(() => p(e, "class", n.class)), e;
16
+ })(), ee = (n) => (() => {
17
+ var e = z();
18
+ return h(() => p(e, "class", n.class)), e;
19
+ })(), te = (n) => (() => {
20
+ var e = W();
21
+ return h(() => p(e, "class", n.class)), e;
22
+ })(), ne = (n) => (() => {
23
+ var e = q();
24
+ return h(() => p(e, "class", n.class)), e;
25
+ })(), oe = (n) => (() => {
26
+ var e = K();
27
+ return h(() => p(e, "class", n.class)), e;
25
28
  })();
26
- function ce(s) {
27
- const n = V();
28
- let h;
29
+ function re(n) {
30
+ const e = !!n?.onAskAgent, a = !!n?.onCopyName;
31
+ return [{
32
+ id: "duplicate",
33
+ label: "Duplicate",
34
+ type: "duplicate",
35
+ icon: U,
36
+ shortcut: "Cmd+D",
37
+ separator: !a && !e
38
+ }, ...a ? [{
39
+ id: "copy-name",
40
+ label: "Copy Name",
41
+ type: "copy-name",
42
+ icon: X,
43
+ separator: !e
44
+ }] : [], ...e ? [{
45
+ id: "ask-agent",
46
+ label: "Ask Agent",
47
+ type: "ask-agent",
48
+ icon: Y,
49
+ separator: !0
50
+ }] : [], {
51
+ id: "copy-to",
52
+ label: "Copy to...",
53
+ type: "copy-to",
54
+ icon: ee
55
+ }, {
56
+ id: "move-to",
57
+ label: "Move to...",
58
+ type: "move-to",
59
+ icon: te,
60
+ separator: !0
61
+ }, {
62
+ id: "rename",
63
+ label: "Rename",
64
+ type: "rename",
65
+ icon: oe,
66
+ shortcut: "Enter"
67
+ }, {
68
+ id: "delete",
69
+ label: "Delete",
70
+ type: "delete",
71
+ icon: ne,
72
+ shortcut: "Del"
73
+ }];
74
+ }
75
+ function ae(n, e, a) {
76
+ switch (n.type) {
77
+ case "duplicate":
78
+ a?.onDuplicate?.(e);
79
+ break;
80
+ case "copy-name":
81
+ a?.onCopyName?.(e);
82
+ break;
83
+ case "ask-agent":
84
+ a?.onAskAgent?.(e);
85
+ break;
86
+ case "copy-to":
87
+ a?.onCopyTo?.(e);
88
+ break;
89
+ case "move-to":
90
+ a?.onMoveTo?.(e);
91
+ break;
92
+ case "delete":
93
+ a?.onDelete?.(e);
94
+ break;
95
+ case "rename":
96
+ e.length === 1 && a?.onRename?.(e[0]);
97
+ break;
98
+ case "custom":
99
+ n.onAction?.(e);
100
+ break;
101
+ }
102
+ }
103
+ function ue(n) {
104
+ const e = V();
105
+ let a;
29
106
  const _ = typeof window > "u" || typeof document > "u", [g, w] = H({
30
107
  x: -9999,
31
108
  y: -9999
32
109
  }), A = () => {
33
- const t = !!s.callbacks?.onAskAgent;
34
- return [{
35
- id: "duplicate",
36
- label: "Duplicate",
37
- type: "duplicate",
38
- icon: U,
39
- shortcut: "Cmd+D",
40
- separator: !t
41
- }, ...t ? [{
42
- id: "ask-agent",
43
- label: "Ask Agent",
44
- type: "ask-agent",
45
- icon: X,
46
- separator: !0
47
- }] : [], {
48
- id: "copy-to",
49
- label: "Copy to...",
50
- type: "copy-to",
51
- icon: Y
52
- }, {
53
- id: "move-to",
54
- label: "Move to...",
55
- type: "move-to",
56
- icon: ee,
57
- separator: !0
58
- }, {
59
- id: "rename",
60
- label: "Rename",
61
- type: "rename",
62
- icon: ne,
63
- shortcut: "Enter"
64
- }, {
65
- id: "delete",
66
- label: "Delete",
67
- type: "delete",
68
- icon: te,
69
- shortcut: "Del"
70
- }];
71
- }, j = () => {
72
- if (s.overrideItems)
73
- return s.overrideItems;
74
- const t = () => {
75
- const e = s.hideItems;
76
- if (!e) return [];
77
- if (typeof e == "function") {
78
- const r = n.contextMenu()?.items ?? [];
79
- return e(r);
110
+ if (n.overrideItems)
111
+ return n.overrideItems;
112
+ const r = () => {
113
+ const t = n.hideItems;
114
+ if (!t) return [];
115
+ if (typeof t == "function") {
116
+ const s = e.contextMenu()?.items ?? [];
117
+ return t(s);
80
118
  }
81
- return e;
119
+ return t;
82
120
  };
83
- let o = A();
84
- const c = t();
85
- return c.length > 0 && (o = o.filter((e) => !c.includes(e.type))), s.customItems?.length && (o = [...o, ...s.customItems]), o;
86
- }, B = (t, o) => {
87
- n.hideContextMenu();
88
- const c = t.type, e = [...o], r = s.callbacks, i = t.onAction;
89
- T(() => {
90
- switch (c) {
91
- case "duplicate":
92
- r?.onDuplicate?.(e);
93
- break;
94
- case "ask-agent":
95
- r?.onAskAgent?.(e);
96
- break;
97
- case "copy-to":
98
- r?.onCopyTo?.(e);
99
- break;
100
- case "move-to":
101
- r?.onMoveTo?.(e);
102
- break;
103
- case "delete":
104
- r?.onDelete?.(e);
105
- break;
106
- case "rename":
107
- e.length === 1 && r?.onRename?.(e[0]);
108
- break;
109
- case "custom":
110
- i?.(e);
111
- break;
112
- }
121
+ let o = re(n.callbacks);
122
+ const l = r();
123
+ return l.length > 0 && (o = o.filter((t) => !l.includes(t.type))), n.customItems?.length && (o = [...o, ...n.customItems]), o;
124
+ }, j = (r, o) => {
125
+ e.hideContextMenu();
126
+ const l = [...o], t = n.callbacks;
127
+ S(() => {
128
+ ae(r, l, t);
113
129
  });
114
- }, f = (t) => {
115
- h && !h.contains(t.target) && n.hideContextMenu();
116
- }, x = (t) => {
117
- t.key === "Escape" && n.hideContextMenu();
130
+ }, f = (r) => {
131
+ a && !a.contains(r.target) && e.hideContextMenu();
132
+ }, x = (r) => {
133
+ r.key === "Escape" && e.hideContextMenu();
118
134
  };
119
135
  $(() => {
120
- n.contextMenu() && (document.addEventListener("click", f), document.addEventListener("keydown", x), S(() => {
136
+ e.contextMenu() && (document.addEventListener("click", f), document.addEventListener("keydown", x), F(() => {
121
137
  document.removeEventListener("click", f), document.removeEventListener("keydown", x);
122
138
  }));
123
139
  });
124
- const D = () => {
125
- const t = n.contextMenu();
126
- if (!t || !h) return {
127
- x: t?.x ?? 0,
128
- y: t?.y ?? 0
140
+ const B = () => {
141
+ const r = e.contextMenu();
142
+ if (!r || !a) return {
143
+ x: r?.x ?? 0,
144
+ y: r?.y ?? 0
129
145
  };
130
- const o = h.getBoundingClientRect(), c = window.innerWidth, e = window.innerHeight;
131
- let r = t.x, i = t.y;
146
+ const o = a.getBoundingClientRect(), l = window.innerWidth, t = window.innerHeight;
147
+ let s = r.x, d = r.y;
132
148
  return o.width === 0 || o.height === 0 ? {
133
- x: r,
134
- y: i
135
- } : (r + o.width > c && (r = c - o.width - 8), i + o.height > e && (i = e - o.height - 8), {
136
- x: Math.max(8, r),
137
- y: Math.max(8, i)
149
+ x: s,
150
+ y: d
151
+ } : (s + o.width > l && (s = l - o.width - 8), d + o.height > t && (d = t - o.height - 8), {
152
+ x: Math.max(8, s),
153
+ y: Math.max(8, d)
138
154
  });
139
155
  };
140
156
  $(() => {
141
- const t = n.contextMenu();
142
- if (!t) {
157
+ const r = e.contextMenu();
158
+ if (!r) {
143
159
  w({
144
160
  x: -9999,
145
161
  y: -9999
@@ -147,79 +163,81 @@ function ce(s) {
147
163
  return;
148
164
  }
149
165
  w({
150
- x: t.x,
151
- y: t.y
166
+ x: r.x,
167
+ y: r.y
152
168
  }), requestAnimationFrame(() => {
153
- const o = D();
169
+ const o = B();
154
170
  w(o);
155
171
  });
156
172
  });
157
- const k = (t) => (() => {
158
- var o = O(), c = h;
159
- return typeof c == "function" ? P(c, o) : h = o, m(o, d(R, {
173
+ const y = (r) => (() => {
174
+ var o = O(), l = a;
175
+ return typeof l == "function" ? L(l, o) : a = o, v(o, u(N, {
160
176
  get each() {
161
- return j();
177
+ return A();
162
178
  },
163
- children: (e) => [(() => {
164
- var r = J(), i = r.firstChild;
165
- return r.$$click = () => B(e, t.menu().items), m(r, d(v, {
179
+ children: (t) => [(() => {
180
+ var s = J(), d = s.firstChild;
181
+ return s.$$click = () => j(t, r.menu().items), v(s, u(m, {
166
182
  get when() {
167
- return e.icon;
183
+ return t.icon;
168
184
  },
169
- children: (a) => d(L, {
185
+ children: (i) => u(E, {
170
186
  get component() {
171
- return a();
187
+ return i();
172
188
  },
173
189
  class: "w-3.5 h-3.5 opacity-60"
174
190
  })
175
- }), i), m(i, () => e.label), m(r, d(v, {
191
+ }), d), v(d, () => t.label), v(s, u(m, {
176
192
  get when() {
177
- return e.shortcut;
193
+ return t.shortcut;
178
194
  },
179
195
  get children() {
180
- var a = G();
181
- return m(a, () => e.shortcut), a;
196
+ var i = G();
197
+ return v(i, () => t.shortcut), i;
182
198
  }
183
- }), null), u((a) => {
184
- var y = e.disabled || e.type === "rename" && t.menu().items.length > 1, b = I("w-full flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer", "transition-colors duration-75", "hover:bg-accent hover:text-accent-foreground", "focus:outline-none focus-visible:bg-accent focus-visible:text-accent-foreground", "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent", e.type === "delete" && "text-error hover:bg-error/10 hover:text-error");
185
- return y !== a.e && (r.disabled = a.e = y), b !== a.t && M(r, a.t = b), a;
199
+ }), null), h((i) => {
200
+ var k = t.disabled || t.type === "rename" && r.menu().items.length > 1, b = I("w-full flex items-center gap-2 px-3 py-1.5 text-xs cursor-pointer", "transition-colors duration-75", "hover:bg-accent hover:text-accent-foreground", "focus:outline-none focus-visible:bg-accent focus-visible:text-accent-foreground", "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent", t.type === "delete" && "text-error hover:bg-error/10 hover:text-error");
201
+ return k !== i.e && (s.disabled = i.e = k), b !== i.t && C(s, i.t = b), i;
186
202
  }, {
187
203
  e: void 0,
188
204
  t: void 0
189
- }), r;
190
- })(), d(v, {
205
+ }), s;
206
+ })(), u(m, {
191
207
  get when() {
192
- return e.separator;
208
+ return t.separator;
193
209
  },
194
210
  get children() {
195
211
  return Q();
196
212
  }
197
213
  })]
198
- })), u((e) => {
199
- var r = I("fixed z-50 min-w-[180px] py-1", "bg-popover border border-border rounded-lg shadow-lg", "animate-in fade-in zoom-in-95 duration-100"), i = `${g().x}px`, a = `${g().y}px`;
200
- return r !== e.e && M(o, e.e = r), i !== e.t && C(o, "left", e.t = i), a !== e.a && C(o, "top", e.a = a), e;
214
+ })), h((t) => {
215
+ var s = I("fixed z-50 min-w-[180px] py-1", "bg-popover border border-border rounded-lg shadow-lg", "animate-in fade-in zoom-in-95 duration-100"), d = `${g().x}px`, i = `${g().y}px`;
216
+ return s !== t.e && C(o, t.e = s), d !== t.t && M(o, "left", t.t = d), i !== t.a && M(o, "top", t.a = i), t;
201
217
  }, {
202
218
  e: void 0,
203
219
  t: void 0,
204
220
  a: void 0
205
221
  }), o;
206
222
  })();
207
- return d(v, {
223
+ return u(m, {
208
224
  get when() {
209
- return n.contextMenu();
225
+ return e.contextMenu();
210
226
  },
211
- children: (t) => _ ? d(k, {
212
- menu: t
213
- }) : d(E, {
227
+ children: (r) => _ ? u(y, {
228
+ menu: r
229
+ }) : u(D, {
214
230
  get children() {
215
- return d(k, {
216
- menu: t
231
+ return u(y, {
232
+ menu: r
217
233
  });
218
234
  }
219
235
  })
220
236
  });
221
237
  }
222
- F(["click"]);
238
+ P(["click"]);
223
239
  export {
224
- ce as FileContextMenu
240
+ ue as FileContextMenu,
241
+ re as createDefaultContextMenuItems,
242
+ ae as dispatchContextMenuAction
225
243
  };
@@ -38,7 +38,7 @@ export interface FileListColumnRatios {
38
38
  /**
39
39
  * Built-in context menu action types
40
40
  */
41
- export type ContextMenuActionType = 'duplicate' | 'ask-agent' | 'copy-to' | 'move-to' | 'delete' | 'rename' | 'custom';
41
+ export type ContextMenuActionType = 'duplicate' | 'copy-name' | 'ask-agent' | 'copy-to' | 'move-to' | 'delete' | 'rename' | 'custom';
42
42
  /**
43
43
  * Context menu item definition
44
44
  */
@@ -78,6 +78,7 @@ export interface ContextMenuEvent {
78
78
  */
79
79
  export interface ContextMenuCallbacks {
80
80
  onDuplicate?: (items: FileItem[]) => void;
81
+ onCopyName?: (items: FileItem[]) => void;
81
82
  onAskAgent?: (items: FileItem[]) => void;
82
83
  onCopyTo?: (items: FileItem[]) => void;
83
84
  onMoveTo?: (items: FileItem[]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.35.5",
3
+ "version": "0.35.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",