@hachej/boring-workspace 0.1.20 → 0.1.23

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.
@@ -1,61 +1,71 @@
1
- import { jsx as i, jsxs as C } from "react/jsx-runtime";
2
- import { useRef as w, useEffect as I, useMemo as P, useCallback as x, createContext as H, useContext as L } from "react";
1
+ import { jsx as i, jsxs as B } from "react/jsx-runtime";
2
+ import { useRef as T, useEffect as I, useMemo as R, useCallback as x, createContext as C, useContext as _ } from "react";
3
3
  import { Tree as q } from "react-arborist";
4
- import { FolderOpenIcon as z, FolderIcon as B, ChevronRightIcon as E, Loader2Icon as K } from "lucide-react";
5
- import { I as Y } from "./WorkspaceProvider-CDPaAO5u.js";
6
- import { Input as G } from "@hachej/boring-ui-kit";
4
+ import { FolderOpenIcon as z, FolderIcon as S, ChevronRightIcon as J, Loader2Icon as K } from "lucide-react";
5
+ import { I as Q } from "./WorkspaceProvider-Cn0sPgaB.js";
6
+ import { Input as U } from "@hachej/boring-ui-kit";
7
7
  import { c as v } from "./utils-B6yFEsav.js";
8
- const T = /* @__PURE__ */ new Set(), A = H({
8
+ import { createDragDropManager as X } from "dnd-core";
9
+ import { HTML5Backend as Y } from "react-dnd-html5-backend";
10
+ const k = Symbol.for("@hachej/boring-workspace/file-tree-dnd-manager");
11
+ function Z() {
12
+ const r = globalThis;
13
+ return r[k] ?? (r[k] = X(
14
+ Y,
15
+ typeof window > "u" ? void 0 : window
16
+ )), r[k];
17
+ }
18
+ const y = /* @__PURE__ */ new Set(), D = C({
9
19
  onContextMenu: void 0,
10
20
  editing: null,
11
- pendingPaths: T,
21
+ pendingPaths: y,
12
22
  onSubmitEdit: void 0,
13
23
  onCancelEdit: void 0
14
24
  });
15
- function J({
16
- initialValue: n,
25
+ function $({
26
+ initialValue: r,
17
27
  onSubmit: p,
18
28
  onCancel: h,
19
29
  isDraft: c
20
30
  }) {
21
- const t = w(null), u = w(!1);
31
+ const t = T(null), u = T(!1);
22
32
  I(() => {
23
33
  const e = t.current;
24
34
  if (e)
25
- if (e.focus(), !c && n.includes(".")) {
26
- const o = n.lastIndexOf(".");
35
+ if (e.focus(), !c && r.includes(".")) {
36
+ const o = r.lastIndexOf(".");
27
37
  e.setSelectionRange(0, o);
28
38
  } else
29
39
  e.select();
30
- }, [n, c]);
31
- const l = () => {
40
+ }, [r, c]);
41
+ const d = () => {
32
42
  var o;
33
43
  if (u.current) return;
34
44
  u.current = !0;
35
45
  const e = ((o = t.current) == null ? void 0 : o.value.trim()) ?? "";
36
- !e || e === n ? h() : p(e);
46
+ !e || e === r ? h() : p(e);
37
47
  };
38
48
  return /* @__PURE__ */ i(
39
- G,
49
+ U,
40
50
  {
41
51
  ref: t,
42
52
  type: "text",
43
- defaultValue: n,
53
+ defaultValue: r,
44
54
  "data-testid": "file-tree-edit-input",
45
55
  "aria-label": c ? "Name" : "Rename",
46
56
  onPointerDown: (e) => e.stopPropagation(),
47
57
  onClick: (e) => e.stopPropagation(),
48
58
  onKeyDown: (e) => {
49
- e.stopPropagation(), e.key === "Enter" ? (e.preventDefault(), l()) : e.key === "Escape" && (e.preventDefault(), u.current = !0, h());
59
+ e.stopPropagation(), e.key === "Enter" ? (e.preventDefault(), d()) : e.key === "Escape" && (e.preventDefault(), u.current = !0, h());
50
60
  },
51
- onBlur: l,
61
+ onBlur: d,
52
62
  className: "h-5 min-w-0 flex-1 rounded-sm border-[color:var(--accent)]/60 px-1 text-[13px] leading-[1.2] focus-visible:ring-[color:var(--accent)]"
53
63
  }
54
64
  );
55
65
  }
56
- function Q({ node: n, style: p, dragHandle: h }) {
57
- const { onContextMenu: c, editing: t, pendingPaths: u, onSubmitEdit: l, onCancelEdit: e } = L(A), o = n.data, f = o.kind === "dir", d = (t == null ? void 0 : t.path) === o.path, N = u.has(o.path), b = f ? n.isOpen ? z : B : Y(o.name || "untitled");
58
- return /* @__PURE__ */ C(
66
+ function E({ node: r, style: p, dragHandle: h }) {
67
+ const { onContextMenu: c, editing: t, pendingPaths: u, onSubmitEdit: d, onCancelEdit: e } = _(D), o = r.data, f = o.kind === "dir", l = (t == null ? void 0 : t.path) === o.path, g = u.has(o.path), b = f ? r.isOpen ? z : S : Q(o.name || "untitled");
68
+ return /* @__PURE__ */ B(
59
69
  "div",
60
70
  {
61
71
  ref: h,
@@ -63,23 +73,23 @@ function Q({ node: n, style: p, dragHandle: h }) {
63
73
  className: v(
64
74
  "group relative mx-1 flex items-center gap-1.5 rounded-md px-2 py-0.5 text-[13px] leading-[1.4] cursor-pointer select-none text-foreground",
65
75
  "transition-colors duration-150 ease-[cubic-bezier(0.22,1,0.36,1)]",
66
- !d && "hover:bg-foreground/[0.04]",
67
- n.isSelected && !d && "bg-[oklch(from_var(--accent)_l_c_h/0.10)] text-foreground font-medium",
68
- n.willReceiveDrop && "bg-foreground/5 outline outline-1 outline-border"
76
+ !l && "hover:bg-foreground/[0.04]",
77
+ r.isSelected && !l && "bg-[oklch(from_var(--accent)_l_c_h/0.10)] text-foreground font-medium",
78
+ r.willReceiveDrop && "bg-foreground/5 outline outline-1 outline-border"
69
79
  ),
70
80
  onClick: (s) => {
71
- d || (s.stopPropagation(), f ? n.toggle() : (n.select(), n.activate()));
81
+ l || (s.stopPropagation(), f ? r.toggle() : (r.select(), r.activate()));
72
82
  },
73
83
  onContextMenu: (s) => {
74
- d || o.isDraft || (s.preventDefault(), s.stopPropagation(), c == null || c(s, o));
84
+ l || o.isDraft || (s.preventDefault(), s.stopPropagation(), c == null || c(s, o));
75
85
  },
76
86
  children: [
77
87
  f ? /* @__PURE__ */ i(
78
- E,
88
+ J,
79
89
  {
80
90
  className: v(
81
91
  "h-3 w-3 shrink-0 text-muted-foreground/70 transition-transform duration-150 ease-[cubic-bezier(0.22,1,0.36,1)]",
82
- n.isOpen && "rotate-90"
92
+ r.isOpen && "rotate-90"
83
93
  ),
84
94
  strokeWidth: 2
85
95
  }
@@ -89,17 +99,17 @@ function Q({ node: n, style: p, dragHandle: h }) {
89
99
  {
90
100
  className: v(
91
101
  "h-4 w-4 shrink-0",
92
- n.isSelected ? "text-[color:var(--accent)]" : "text-muted-foreground/80"
102
+ r.isSelected ? "text-[color:var(--accent)]" : "text-muted-foreground/80"
93
103
  ),
94
104
  strokeWidth: 1.5
95
105
  }
96
106
  ),
97
- d ? /* @__PURE__ */ i(
98
- J,
107
+ l ? /* @__PURE__ */ i(
108
+ $,
99
109
  {
100
110
  initialValue: (t == null ? void 0 : t.initialValue) ?? o.name ?? "",
101
111
  isDraft: !!(t != null && t.isDraft),
102
- onSubmit: (s) => l == null ? void 0 : l(o.path, s),
112
+ onSubmit: (s) => d == null ? void 0 : d(o.path, s),
103
113
  onCancel: () => e == null ? void 0 : e()
104
114
  }
105
115
  ) : /* @__PURE__ */ i(
@@ -107,12 +117,12 @@ function Q({ node: n, style: p, dragHandle: h }) {
107
117
  {
108
118
  className: v(
109
119
  "truncate",
110
- N && "text-muted-foreground italic"
120
+ g && "text-muted-foreground italic"
111
121
  ),
112
122
  children: o.name
113
123
  }
114
124
  ),
115
- N && !d && /* @__PURE__ */ i(
125
+ g && !l && /* @__PURE__ */ i(
116
126
  K,
117
127
  {
118
128
  "data-testid": "file-tree-pending-spinner",
@@ -125,102 +135,102 @@ function Q({ node: n, style: p, dragHandle: h }) {
125
135
  }
126
136
  );
127
137
  }
128
- function te({
129
- files: n,
138
+ function ie({
139
+ files: r,
130
140
  selectedPath: p,
131
141
  searchQuery: h,
132
142
  height: c = 400,
133
143
  editing: t,
134
144
  revealPath: u,
135
- pendingPaths: l,
145
+ pendingPaths: d,
136
146
  onSelect: e,
137
147
  onExpand: o,
138
148
  onCollapse: f,
139
- onContextMenu: d,
140
- onSubmitEdit: N,
149
+ onContextMenu: l,
150
+ onSubmitEdit: g,
141
151
  onCancelEdit: b,
142
152
  onDragDrop: s,
143
- className: R
153
+ className: P
144
154
  }) {
145
- const k = w(null);
155
+ const N = T(null);
146
156
  I(() => {
147
157
  if (!(t != null && t.isDraft)) return;
148
- const r = requestAnimationFrame(() => {
158
+ const n = requestAnimationFrame(() => {
149
159
  var a;
150
- (a = k.current) == null || a.scrollTo(t.path);
160
+ (a = N.current) == null || a.scrollTo(t.path);
151
161
  });
152
- return () => cancelAnimationFrame(r);
162
+ return () => cancelAnimationFrame(n);
153
163
  }, [t == null ? void 0 : t.isDraft, t == null ? void 0 : t.path]), I(() => {
154
164
  if (!u) return;
155
- const r = requestAnimationFrame(() => {
165
+ const n = requestAnimationFrame(() => {
156
166
  var a;
157
- (a = k.current) == null || a.scrollTo(u);
167
+ (a = N.current) == null || a.scrollTo(u);
158
168
  });
159
- return () => cancelAnimationFrame(r);
160
- }, [n, u]);
161
- const D = P(
169
+ return () => cancelAnimationFrame(n);
170
+ }, [r, u]);
171
+ const F = R(
162
172
  () => p || void 0,
163
173
  [p]
164
- ), F = x(
165
- (r) => {
166
- r.data.kind === "file" && (e == null || e(r.data.path));
174
+ ), M = x(
175
+ (n) => {
176
+ n.data.kind === "file" && (e == null || e(n.data.path));
167
177
  },
168
178
  [e]
169
- ), y = x(
170
- (r) => {
179
+ ), A = x(
180
+ (n) => {
171
181
  var m;
172
- const a = (m = k.current) == null ? void 0 : m.get(r);
182
+ const a = (m = N.current) == null ? void 0 : m.get(n);
173
183
  a && (a.isOpen ? o == null || o(a.data.path) : f == null || f(a.data.path));
174
184
  },
175
185
  [o, f]
176
- ), M = x(
177
- (r) => {
186
+ ), O = x(
187
+ (n) => {
178
188
  if (!s) return;
179
- const a = !r.parentNode || r.parentNode.isRoot, m = a ? "." : r.parentNode.data.path;
180
- if (!(!a && r.parentNode.data.kind !== "dir"))
181
- for (const j of r.dragNodes) {
182
- const g = j.data.path;
183
- if (m === g || m !== "." && m.startsWith(g + "/")) return;
184
- s(g, m);
189
+ const a = !n.parentNode || n.parentNode.isRoot, m = a ? "." : n.parentNode.data.path;
190
+ if (!(!a && n.parentNode.data.kind !== "dir"))
191
+ for (const L of n.dragNodes) {
192
+ const w = L.data.path;
193
+ if (m === w || m !== "." && m.startsWith(w + "/")) return;
194
+ s(w, m);
185
195
  }
186
196
  },
187
197
  [s]
188
- ), O = x(
189
- (r) => {
190
- if (!r.parentNode || r.parentNode.isRoot) return !1;
191
- if (r.parentNode.data.kind !== "dir") return !0;
192
- for (const a of r.dragNodes)
193
- if (r.parentNode.data.path === a.data.path || r.parentNode.data.path.startsWith(a.data.path + "/")) return !0;
198
+ ), W = x(
199
+ (n) => {
200
+ if (!n.parentNode || n.parentNode.isRoot) return !1;
201
+ if (n.parentNode.data.kind !== "dir") return !0;
202
+ for (const a of n.dragNodes)
203
+ if (n.parentNode.data.path === a.data.path || n.parentNode.data.path.startsWith(a.data.path + "/")) return !0;
194
204
  return !1;
195
205
  },
196
206
  []
197
- ), W = x(
198
- (r, a) => r.data.name.toLowerCase().includes(a.toLowerCase()),
207
+ ), j = x(
208
+ (n, a) => n.data.name.toLowerCase().includes(a.toLowerCase()),
199
209
  []
200
- ), _ = P(
210
+ ), H = R(
201
211
  () => ({
202
- onContextMenu: d,
212
+ onContextMenu: l,
203
213
  editing: t ?? null,
204
- pendingPaths: l ?? T,
205
- onSubmitEdit: N,
214
+ pendingPaths: d ?? y,
215
+ onSubmitEdit: g,
206
216
  onCancelEdit: b
207
217
  }),
208
- [d, t, l, N, b]
218
+ [l, t, d, g, b]
209
219
  );
210
- return n.length === 0 ? /* @__PURE__ */ i(
220
+ return r.length === 0 ? /* @__PURE__ */ i(
211
221
  "div",
212
222
  {
213
223
  className: v(
214
224
  "flex h-full items-center justify-center text-sm text-muted-foreground",
215
- R
225
+ P
216
226
  ),
217
227
  children: "No files"
218
228
  }
219
- ) : /* @__PURE__ */ i(A.Provider, { value: _, children: /* @__PURE__ */ i("div", { "data-boring-workspace-part": "file-tree", className: v("file-tree", R), children: /* @__PURE__ */ i(
229
+ ) : /* @__PURE__ */ i(D.Provider, { value: H, children: /* @__PURE__ */ i("div", { "data-boring-workspace-part": "file-tree", className: v("file-tree", P), children: /* @__PURE__ */ i(
220
230
  q,
221
231
  {
222
- ref: k,
223
- data: n,
232
+ ref: N,
233
+ data: r,
224
234
  idAccessor: "path",
225
235
  childrenAccessor: "children",
226
236
  openByDefault: !1,
@@ -228,18 +238,19 @@ function te({
228
238
  height: c,
229
239
  rowHeight: 26,
230
240
  indent: 14,
231
- selection: D,
241
+ selection: F,
232
242
  searchTerm: h ?? "",
233
- searchMatch: W,
234
- onActivate: F,
235
- onToggle: y,
236
- onMove: M,
237
- disableDrop: O,
243
+ searchMatch: j,
244
+ onActivate: M,
245
+ onToggle: A,
246
+ onMove: O,
247
+ disableDrop: W,
238
248
  disableEdit: !0,
239
- children: Q
249
+ dndManager: Z(),
250
+ children: E
240
251
  }
241
252
  ) }) });
242
253
  }
243
254
  export {
244
- te as FileTree
255
+ ie as FileTree
245
256
  };
@@ -15,7 +15,7 @@ import { TableHeader as ut } from "@tiptap/extension-table-header";
15
15
  import { TableCell as gt } from "@tiptap/extension-table-cell";
16
16
  import dt from "@tiptap/extension-image";
17
17
  import { c as U } from "./utils-B6yFEsav.js";
18
- import { ao as q, ap as _ } from "./WorkspaceProvider-CDPaAO5u.js";
18
+ import { ao as q, ap as _ } from "./WorkspaceProvider-Cn0sPgaB.js";
19
19
  import { uploadFile as ft } from "@hachej/boring-agent/front";
20
20
  import mt from "@tiptap/extension-code-block-lowlight";
21
21
  import { createLowlight as pt, common as ht } from "lowlight";