@aiquants/directory-tree 0.2.0 → 1.0.1
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/README.md +28 -0
- package/dist/directory-tree.css +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +306 -259
- package/dist/index.js.map +1 -1
- package/dist/src/DirectoryTree.d.ts +1 -1
- package/dist/src/DirectoryTree.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +25 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { VirtualScroll as
|
|
3
|
-
import { ChevronDownIcon as
|
|
4
|
-
import { FileIcon as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
var
|
|
1
|
+
import ke, { memo as Te, useRef as he, useState as W, useEffect as ee, useCallback as N, Fragment as Ie, useMemo as le, useTransition as Re } from "react";
|
|
2
|
+
import { VirtualScroll as Ce } from "@aiquants/virtualscroll";
|
|
3
|
+
import { ChevronDownIcon as je, ChevronRightIcon as $e, FolderIcon as Oe, DocumentTextIcon as Le } from "@heroicons/react/24/solid";
|
|
4
|
+
import { FileIcon as Ne } from "@phosphor-icons/react";
|
|
5
|
+
import { twMerge as R } from "tailwind-merge";
|
|
6
|
+
var ce = { exports: {} }, Q = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.js
|
|
@@ -13,10 +13,10 @@ var Q = { exports: {} }, G = {};
|
|
|
13
13
|
* This source code is licensed under the MIT license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
if (
|
|
19
|
-
|
|
16
|
+
var ge;
|
|
17
|
+
function Ae() {
|
|
18
|
+
if (ge) return Q;
|
|
19
|
+
ge = 1;
|
|
20
20
|
var t = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
21
21
|
function u(c, s, i) {
|
|
22
22
|
var f = null;
|
|
@@ -33,9 +33,9 @@ function _e() {
|
|
|
33
33
|
props: i
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return Q.Fragment = r, Q.jsx = u, Q.jsxs = u, Q;
|
|
37
37
|
}
|
|
38
|
-
var
|
|
38
|
+
var K = {};
|
|
39
39
|
/**
|
|
40
40
|
* @license React
|
|
41
41
|
* react-jsx-runtime.development.js
|
|
@@ -45,26 +45,26 @@ var X = {};
|
|
|
45
45
|
* This source code is licensed under the MIT license found in the
|
|
46
46
|
* LICENSE file in the root directory of this source tree.
|
|
47
47
|
*/
|
|
48
|
-
var
|
|
49
|
-
function
|
|
50
|
-
return
|
|
48
|
+
var pe;
|
|
49
|
+
function De() {
|
|
50
|
+
return pe || (pe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
51
51
|
function t(e) {
|
|
52
52
|
if (e == null) return null;
|
|
53
53
|
if (typeof e == "function")
|
|
54
|
-
return e.$$typeof ===
|
|
54
|
+
return e.$$typeof === q ? null : e.displayName || e.name || null;
|
|
55
55
|
if (typeof e == "string") return e;
|
|
56
56
|
switch (e) {
|
|
57
|
-
case
|
|
57
|
+
case d:
|
|
58
58
|
return "Fragment";
|
|
59
|
-
case
|
|
59
|
+
case m:
|
|
60
60
|
return "Profiler";
|
|
61
|
-
case
|
|
61
|
+
case O:
|
|
62
62
|
return "StrictMode";
|
|
63
|
-
case
|
|
63
|
+
case S:
|
|
64
64
|
return "Suspense";
|
|
65
|
-
case
|
|
65
|
+
case B:
|
|
66
66
|
return "SuspenseList";
|
|
67
|
-
case
|
|
67
|
+
case j:
|
|
68
68
|
return "Activity";
|
|
69
69
|
}
|
|
70
70
|
if (typeof e == "object")
|
|
@@ -73,16 +73,16 @@ function Ie() {
|
|
|
73
73
|
), e.$$typeof) {
|
|
74
74
|
case n:
|
|
75
75
|
return "Portal";
|
|
76
|
-
case
|
|
76
|
+
case A:
|
|
77
77
|
return e.displayName || "Context";
|
|
78
|
-
case
|
|
78
|
+
case x:
|
|
79
79
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
80
|
-
case
|
|
80
|
+
case D:
|
|
81
81
|
var o = e.render;
|
|
82
82
|
return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
83
|
-
case
|
|
83
|
+
case H:
|
|
84
84
|
return o = e.displayName || null, o !== null ? o : t(e.type) || "Memo";
|
|
85
|
-
case
|
|
85
|
+
case Y:
|
|
86
86
|
o = e._payload, e = e._init;
|
|
87
87
|
try {
|
|
88
88
|
return t(e(o));
|
|
@@ -103,8 +103,8 @@ function Ie() {
|
|
|
103
103
|
}
|
|
104
104
|
if (o) {
|
|
105
105
|
o = console;
|
|
106
|
-
var
|
|
107
|
-
return
|
|
106
|
+
var h = o.error, y = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
107
|
+
return h.call(
|
|
108
108
|
o,
|
|
109
109
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
110
110
|
y
|
|
@@ -112,8 +112,8 @@ function Ie() {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
function c(e) {
|
|
115
|
-
if (e ===
|
|
116
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
115
|
+
if (e === d) return "<>";
|
|
116
|
+
if (typeof e == "object" && e !== null && e.$$typeof === Y)
|
|
117
117
|
return "<...>";
|
|
118
118
|
try {
|
|
119
119
|
var o = t(e);
|
|
@@ -123,44 +123,44 @@ function Ie() {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
function s() {
|
|
126
|
-
var e =
|
|
126
|
+
var e = P.A;
|
|
127
127
|
return e === null ? null : e.getOwner();
|
|
128
128
|
}
|
|
129
129
|
function i() {
|
|
130
130
|
return Error("react-stack-top-frame");
|
|
131
131
|
}
|
|
132
132
|
function f(e) {
|
|
133
|
-
if (
|
|
133
|
+
if (te.call(e, "key")) {
|
|
134
134
|
var o = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
135
135
|
if (o && o.isReactWarning) return !1;
|
|
136
136
|
}
|
|
137
137
|
return e.key !== void 0;
|
|
138
138
|
}
|
|
139
139
|
function p(e, o) {
|
|
140
|
-
function
|
|
141
|
-
|
|
140
|
+
function h() {
|
|
141
|
+
re || (re = !0, console.error(
|
|
142
142
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
143
143
|
o
|
|
144
144
|
));
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
get:
|
|
146
|
+
h.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
147
|
+
get: h,
|
|
148
148
|
configurable: !0
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
function E() {
|
|
152
152
|
var e = t(this.type);
|
|
153
|
-
return
|
|
153
|
+
return ne[e] || (ne[e] = !0, console.error(
|
|
154
154
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
155
155
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
156
156
|
}
|
|
157
|
-
function k(e, o,
|
|
158
|
-
var g =
|
|
157
|
+
function k(e, o, h, y, I, U) {
|
|
158
|
+
var g = h.ref;
|
|
159
159
|
return e = {
|
|
160
160
|
$$typeof: l,
|
|
161
161
|
type: e,
|
|
162
162
|
key: o,
|
|
163
|
-
props:
|
|
163
|
+
props: h,
|
|
164
164
|
_owner: y
|
|
165
165
|
}, (g !== void 0 ? g : null) !== null ? Object.defineProperty(e, "ref", {
|
|
166
166
|
enumerable: !1,
|
|
@@ -179,33 +179,33 @@ function Ie() {
|
|
|
179
179
|
configurable: !1,
|
|
180
180
|
enumerable: !1,
|
|
181
181
|
writable: !0,
|
|
182
|
-
value:
|
|
182
|
+
value: I
|
|
183
183
|
}), Object.defineProperty(e, "_debugTask", {
|
|
184
184
|
configurable: !1,
|
|
185
185
|
enumerable: !1,
|
|
186
186
|
writable: !0,
|
|
187
|
-
value:
|
|
187
|
+
value: U
|
|
188
188
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function C(e, o, h, y, I, U) {
|
|
191
191
|
var g = o.children;
|
|
192
192
|
if (g !== void 0)
|
|
193
193
|
if (y)
|
|
194
|
-
if (
|
|
194
|
+
if (ue(g)) {
|
|
195
195
|
for (y = 0; y < g.length; y++)
|
|
196
|
-
|
|
196
|
+
T(g[y]);
|
|
197
197
|
Object.freeze && Object.freeze(g);
|
|
198
198
|
} else
|
|
199
199
|
console.error(
|
|
200
200
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
201
201
|
);
|
|
202
|
-
else
|
|
203
|
-
if (
|
|
202
|
+
else T(g);
|
|
203
|
+
if (te.call(o, "key")) {
|
|
204
204
|
g = t(e);
|
|
205
|
-
var
|
|
206
|
-
return
|
|
205
|
+
var M = Object.keys(o).filter(function(de) {
|
|
206
|
+
return de !== "key";
|
|
207
207
|
});
|
|
208
|
-
y = 0 <
|
|
208
|
+
y = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", se[g + y] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
209
209
|
`A props object containing a "key" prop is being spread into JSX:
|
|
210
210
|
let props = %s;
|
|
211
211
|
<%s {...props} />
|
|
@@ -214,34 +214,34 @@ React keys must be passed directly to JSX without using spread:
|
|
|
214
214
|
<%s key={someKey} {...props} />`,
|
|
215
215
|
y,
|
|
216
216
|
g,
|
|
217
|
-
|
|
217
|
+
M,
|
|
218
218
|
g
|
|
219
|
-
),
|
|
219
|
+
), se[g + y] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (g = null,
|
|
222
|
-
|
|
223
|
-
for (var
|
|
224
|
-
|
|
225
|
-
} else
|
|
221
|
+
if (g = null, h !== void 0 && (u(h), g = "" + h), f(o) && (u(o.key), g = "" + o.key), "key" in o) {
|
|
222
|
+
h = {};
|
|
223
|
+
for (var V in o)
|
|
224
|
+
V !== "key" && (h[V] = o[V]);
|
|
225
|
+
} else h = o;
|
|
226
226
|
return g && p(
|
|
227
|
-
|
|
227
|
+
h,
|
|
228
228
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
229
229
|
), k(
|
|
230
230
|
e,
|
|
231
231
|
g,
|
|
232
|
-
|
|
232
|
+
h,
|
|
233
233
|
s(),
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
I,
|
|
235
|
+
U
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
w(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof ===
|
|
238
|
+
function T(e) {
|
|
239
|
+
w(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === Y && (e._payload.status === "fulfilled" ? w(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
240
240
|
}
|
|
241
241
|
function w(e) {
|
|
242
242
|
return typeof e == "object" && e !== null && e.$$typeof === l;
|
|
243
243
|
}
|
|
244
|
-
var a =
|
|
244
|
+
var a = ke, l = Symbol.for("react.transitional.element"), n = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), m = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), A = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), S = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), Y = Symbol.for("react.lazy"), j = Symbol.for("react.activity"), q = Symbol.for("react.client.reference"), P = a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, te = Object.prototype.hasOwnProperty, ue = Array.isArray, G = console.createTask ? console.createTask : function() {
|
|
245
245
|
return null;
|
|
246
246
|
};
|
|
247
247
|
a = {
|
|
@@ -249,67 +249,67 @@ React keys must be passed directly to JSX without using spread:
|
|
|
249
249
|
return e();
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
var
|
|
252
|
+
var re, ne = {}, ae = a.react_stack_bottom_frame.bind(
|
|
253
253
|
a,
|
|
254
254
|
i
|
|
255
|
-
)(),
|
|
256
|
-
|
|
257
|
-
var y = 1e4 >
|
|
258
|
-
return
|
|
255
|
+
)(), oe = G(c(i)), se = {};
|
|
256
|
+
K.Fragment = d, K.jsx = function(e, o, h) {
|
|
257
|
+
var y = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
258
|
+
return C(
|
|
259
259
|
e,
|
|
260
260
|
o,
|
|
261
|
-
|
|
261
|
+
h,
|
|
262
262
|
!1,
|
|
263
|
-
y ? Error("react-stack-top-frame") :
|
|
264
|
-
y ?
|
|
263
|
+
y ? Error("react-stack-top-frame") : ae,
|
|
264
|
+
y ? G(c(e)) : oe
|
|
265
265
|
);
|
|
266
|
-
},
|
|
267
|
-
var y = 1e4 >
|
|
268
|
-
return
|
|
266
|
+
}, K.jsxs = function(e, o, h) {
|
|
267
|
+
var y = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
268
|
+
return C(
|
|
269
269
|
e,
|
|
270
270
|
o,
|
|
271
|
-
|
|
271
|
+
h,
|
|
272
272
|
!0,
|
|
273
|
-
y ? Error("react-stack-top-frame") :
|
|
274
|
-
y ?
|
|
273
|
+
y ? Error("react-stack-top-frame") : ae,
|
|
274
|
+
y ? G(c(e)) : oe
|
|
275
275
|
);
|
|
276
276
|
};
|
|
277
|
-
})()),
|
|
277
|
+
})()), K;
|
|
278
278
|
}
|
|
279
|
-
var
|
|
280
|
-
function
|
|
281
|
-
return
|
|
279
|
+
var Ee;
|
|
280
|
+
function Pe() {
|
|
281
|
+
return Ee || (Ee = 1, process.env.NODE_ENV === "production" ? ce.exports = Ae() : ce.exports = De()), ce.exports;
|
|
282
282
|
}
|
|
283
|
-
var b =
|
|
284
|
-
const
|
|
285
|
-
const E = [], k = Math.max(0, Math.floor(f / r)),
|
|
286
|
-
for (let a = k; a <
|
|
287
|
-
const l = t[a], n = a * r,
|
|
288
|
-
for (let
|
|
289
|
-
const
|
|
290
|
-
let
|
|
291
|
-
for (let
|
|
292
|
-
if (t[
|
|
293
|
-
|
|
283
|
+
var b = Pe();
|
|
284
|
+
const Me = ({ items: t, itemHeight: r, width: u, segmentWidth: c, color: s = "#a0aec0", strokeWidth: i = 1, renderFromY: f = 0, renderHeight: p }) => {
|
|
285
|
+
const E = [], k = Math.max(0, Math.floor(f / r)), C = p ?? t.length * r, T = Math.min(t.length, Math.ceil((f + C) / r));
|
|
286
|
+
for (let a = k; a < T; a++) {
|
|
287
|
+
const l = t[a], n = a * r, d = n + r / 2;
|
|
288
|
+
for (let x = 0; x < l.indentLevel; x++) {
|
|
289
|
+
const A = x * c + c / 2;
|
|
290
|
+
let D = !1;
|
|
291
|
+
for (let S = a; S < t.length; S++) {
|
|
292
|
+
if (t[S].indentLevel > x && t[S].ancestorIsLast.length > x && !t[S].ancestorIsLast[x]) {
|
|
293
|
+
D = !0;
|
|
294
294
|
break;
|
|
295
295
|
}
|
|
296
|
-
if (t[
|
|
296
|
+
if (t[S].indentLevel === x && S > a)
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
D && l.ancestorIsLast.length > x && !l.ancestorIsLast[x] && E.push(`M ${A},${n} L ${A},${n + r}`);
|
|
300
300
|
}
|
|
301
|
-
const
|
|
301
|
+
const O = l.indentLevel * c, m = O + c / 2;
|
|
302
302
|
if (l.isDirectory) {
|
|
303
|
-
const
|
|
304
|
-
E.push(`M ${
|
|
303
|
+
const x = c / 1.5;
|
|
304
|
+
E.push(`M ${m},${n} L ${m},${d - x}`);
|
|
305
305
|
} else
|
|
306
|
-
E.push(`M ${
|
|
307
|
-
if (l.isDirectory || l.isLastChild && E.push(`M ${
|
|
306
|
+
E.push(`M ${m},${n} L ${m},${d}`);
|
|
307
|
+
if (l.isDirectory || l.isLastChild && E.push(`M ${m},${d} L ${O + c},${d}`), !l.isLastChild)
|
|
308
308
|
if (l.isDirectory) {
|
|
309
|
-
const
|
|
310
|
-
E.push(`M ${
|
|
309
|
+
const x = c / 1.5;
|
|
310
|
+
E.push(`M ${m},${d + x} L ${m},${n + r}`);
|
|
311
311
|
} else
|
|
312
|
-
E.push(`M ${
|
|
312
|
+
E.push(`M ${m},${d} L ${m},${n + r}`);
|
|
313
313
|
}
|
|
314
314
|
const w = t.length * r;
|
|
315
315
|
return /* @__PURE__ */ b.jsxs(
|
|
@@ -327,79 +327,79 @@ const Se = ({ items: t, itemHeight: r, width: u, segmentWidth: c, color: s = "#a
|
|
|
327
327
|
]
|
|
328
328
|
}
|
|
329
329
|
);
|
|
330
|
-
},
|
|
330
|
+
}, _ = {
|
|
331
331
|
container: "directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden",
|
|
332
332
|
containerPending: "opacity-70",
|
|
333
333
|
entry: "flex items-center cursor-pointer relative select-none",
|
|
334
334
|
// ホバー時のスタイル(ライト/ダークモード対応)
|
|
335
|
-
entryHover:
|
|
335
|
+
entryHover: R(
|
|
336
336
|
"hover:bg-gray-400/15",
|
|
337
337
|
"dark:hover:bg-gray-200/10"
|
|
338
338
|
),
|
|
339
339
|
// 選択時のスタイル(ライト/ダークモード対応)
|
|
340
|
-
entrySelected:
|
|
340
|
+
entrySelected: R(
|
|
341
341
|
"bg-blue-400/10",
|
|
342
342
|
"dark:bg-blue-400/15"
|
|
343
343
|
),
|
|
344
344
|
// アイテム選択時のスタイル(ライト/ダークモード対応)
|
|
345
|
-
entryItemSelected:
|
|
345
|
+
entryItemSelected: R(
|
|
346
346
|
"bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]",
|
|
347
347
|
"dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"
|
|
348
348
|
),
|
|
349
349
|
// アイコンのスタイル
|
|
350
|
-
expandIcon:
|
|
350
|
+
expandIcon: R(
|
|
351
351
|
"w-5 h-5 flex-shrink-0 flex items-center justify-center",
|
|
352
352
|
"text-gray-500",
|
|
353
353
|
"dark:text-gray-400"
|
|
354
354
|
),
|
|
355
|
-
expandIconSelected:
|
|
355
|
+
expandIconSelected: R(
|
|
356
356
|
"text-blue-700",
|
|
357
357
|
"dark:text-blue-400"
|
|
358
358
|
),
|
|
359
|
-
typeIcon:
|
|
359
|
+
typeIcon: R(
|
|
360
360
|
"w-5 h-5 flex-shrink-0 flex items-center justify-center",
|
|
361
361
|
"text-gray-500",
|
|
362
362
|
"dark:text-gray-400"
|
|
363
363
|
),
|
|
364
|
-
typeIconSelected:
|
|
364
|
+
typeIconSelected: R(
|
|
365
365
|
"text-blue-700",
|
|
366
366
|
"dark:text-blue-400"
|
|
367
367
|
),
|
|
368
368
|
// テキストのスタイル
|
|
369
|
-
name:
|
|
369
|
+
name: R(
|
|
370
370
|
"overflow-hidden text-ellipsis whitespace-nowrap ml-1",
|
|
371
371
|
"text-gray-700",
|
|
372
372
|
"dark:text-gray-200"
|
|
373
373
|
),
|
|
374
374
|
nameDirectory: "font-bold",
|
|
375
|
-
nameSelected:
|
|
375
|
+
nameSelected: R(
|
|
376
376
|
"text-blue-800 font-medium",
|
|
377
377
|
"dark:text-blue-300"
|
|
378
378
|
)
|
|
379
|
-
},
|
|
379
|
+
}, xe = {
|
|
380
380
|
msOverflowStyle: "none",
|
|
381
381
|
/* IE and Edge */
|
|
382
382
|
scrollbarWidth: "none"
|
|
383
383
|
/* Firefox */
|
|
384
|
-
},
|
|
384
|
+
}, Fe = () => {
|
|
385
385
|
let t = document.getElementById("directory-tree-webkit-scrollbar-hide");
|
|
386
386
|
t || (t = document.createElement("style"), t.id = "directory-tree-webkit-scrollbar-hide", t.textContent = ".directory-tree-container::-webkit-scrollbar { display: none; }", document.head.appendChild(t));
|
|
387
|
-
},
|
|
388
|
-
|
|
389
|
-
t &&
|
|
390
|
-
r &&
|
|
391
|
-
u &&
|
|
392
|
-
),
|
|
393
|
-
|
|
394
|
-
t &&
|
|
395
|
-
),
|
|
396
|
-
|
|
397
|
-
t &&
|
|
398
|
-
),
|
|
399
|
-
|
|
400
|
-
t &&
|
|
401
|
-
r &&
|
|
402
|
-
),
|
|
387
|
+
}, Ye = (t = !1, r = !1, u = !1) => R(
|
|
388
|
+
_.entry,
|
|
389
|
+
t && _.entryHover,
|
|
390
|
+
r && _.entrySelected,
|
|
391
|
+
u && _.entryItemSelected
|
|
392
|
+
), Ve = (t = !1) => R(
|
|
393
|
+
_.expandIcon,
|
|
394
|
+
t && _.expandIconSelected
|
|
395
|
+
), ze = (t = !1) => R(
|
|
396
|
+
_.typeIcon,
|
|
397
|
+
t && _.typeIconSelected
|
|
398
|
+
), Ue = (t = !1, r = !1) => R(
|
|
399
|
+
_.name,
|
|
400
|
+
t && _.nameDirectory,
|
|
401
|
+
r && _.nameSelected
|
|
402
|
+
), Je = Ce, We = (t) => t.slice((t.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase(), be = Te(
|
|
403
403
|
({
|
|
404
404
|
entry: t,
|
|
405
405
|
indentLevel: r,
|
|
@@ -411,76 +411,76 @@ const Se = ({ items: t, itemHeight: r, width: u, segmentWidth: c, color: s = "#a
|
|
|
411
411
|
parentIsLast: p,
|
|
412
412
|
renderChildren: E = !0,
|
|
413
413
|
selectionMode: k = "none",
|
|
414
|
-
selectedItems:
|
|
415
|
-
onSelectionChange:
|
|
414
|
+
selectedItems: C,
|
|
415
|
+
onSelectionChange: T
|
|
416
416
|
}) => {
|
|
417
|
-
const w =
|
|
417
|
+
const w = he(null), [a, l] = W(null);
|
|
418
418
|
ee(() => () => {
|
|
419
419
|
w.current && window.clearTimeout(w.current);
|
|
420
420
|
}, []);
|
|
421
|
-
const n = t.children !== void 0,
|
|
421
|
+
const n = t.children !== void 0, d = n && u(t.absolutePath, t.relativePath), O = t.absolutePath === f, m = !n && C?.has(t.absolutePath);
|
|
422
422
|
ee(() => {
|
|
423
|
-
|
|
423
|
+
d && t.children ? Promise.resolve().then(() => {
|
|
424
424
|
l(t.children ?? []);
|
|
425
425
|
}) : l(null);
|
|
426
|
-
}, [
|
|
427
|
-
const
|
|
428
|
-
(
|
|
429
|
-
|
|
426
|
+
}, [d, t.children]);
|
|
427
|
+
const x = N(
|
|
428
|
+
(j) => {
|
|
429
|
+
j.stopPropagation(), k !== "none" && !n && T && T(t.absolutePath, !m), n ? w.current ? (window.clearTimeout(w.current), w.current = null, i(t)) : w.current = window.setTimeout(() => {
|
|
430
430
|
s(t.absolutePath, t.relativePath), w.current = null;
|
|
431
431
|
}, 500) : c(t.absolutePath, t.relativePath);
|
|
432
432
|
},
|
|
433
|
-
[n, t, i, s, c, k,
|
|
434
|
-
), [
|
|
435
|
-
return /* @__PURE__ */ b.jsxs(
|
|
433
|
+
[n, t, i, s, c, k, T, m]
|
|
434
|
+
), [A, D] = W(!1), S = Ye(A, O, m), B = Ve(O || m), H = ze(O || m), Y = Ue(n, O || m);
|
|
435
|
+
return /* @__PURE__ */ b.jsxs(Ie, { children: [
|
|
436
436
|
/* @__PURE__ */ b.jsxs(
|
|
437
437
|
"div",
|
|
438
438
|
{
|
|
439
|
-
className:
|
|
439
|
+
className: S,
|
|
440
440
|
style: {
|
|
441
|
-
paddingLeft: `${r *
|
|
442
|
-
height: `${
|
|
441
|
+
paddingLeft: `${r * me}px`,
|
|
442
|
+
height: `${ie}px`
|
|
443
443
|
},
|
|
444
|
-
onClick:
|
|
445
|
-
onMouseEnter: () =>
|
|
446
|
-
onMouseLeave: () =>
|
|
447
|
-
onKeyDown: (
|
|
448
|
-
|
|
444
|
+
onClick: x,
|
|
445
|
+
onMouseEnter: () => D(!0),
|
|
446
|
+
onMouseLeave: () => D(!1),
|
|
447
|
+
onKeyDown: (j) => {
|
|
448
|
+
j.key === "Enter" && x(j);
|
|
449
449
|
},
|
|
450
450
|
tabIndex: 0,
|
|
451
451
|
role: "treeitem",
|
|
452
|
-
"aria-expanded": n ?
|
|
452
|
+
"aria-expanded": n ? d : void 0,
|
|
453
453
|
"aria-label": `${t.name} (${n ? "directory" : "file"})`,
|
|
454
454
|
children: [
|
|
455
|
-
/* @__PURE__ */ b.jsx("span", { className:
|
|
456
|
-
/* @__PURE__ */ b.jsx("span", { className:
|
|
457
|
-
switch (
|
|
455
|
+
/* @__PURE__ */ b.jsx("span", { className: B, children: n ? d ? /* @__PURE__ */ b.jsx(je, { className: "h-4 w-4" }) : /* @__PURE__ */ b.jsx($e, { className: "h-4 w-4" }) : /* @__PURE__ */ b.jsx("span", { className: "w-4" }) }),
|
|
456
|
+
/* @__PURE__ */ b.jsx("span", { className: H, children: n ? /* @__PURE__ */ b.jsx(Oe, { className: "h-4 w-4" }) : (() => {
|
|
457
|
+
switch (We(t.name)) {
|
|
458
458
|
case "md":
|
|
459
|
-
return /* @__PURE__ */ b.jsx(
|
|
459
|
+
return /* @__PURE__ */ b.jsx(Le, { className: "h-4 w-4" });
|
|
460
460
|
default:
|
|
461
|
-
return /* @__PURE__ */ b.jsx(
|
|
461
|
+
return /* @__PURE__ */ b.jsx(Ne, { className: "h-4 w-4" });
|
|
462
462
|
}
|
|
463
463
|
})() }),
|
|
464
|
-
/* @__PURE__ */ b.jsx("span", { className:
|
|
464
|
+
/* @__PURE__ */ b.jsx("span", { className: Y, children: t.name })
|
|
465
465
|
]
|
|
466
466
|
}
|
|
467
467
|
),
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
d && a && E && /* @__PURE__ */ b.jsx("fieldset", { children: a.map((j, q) => /* @__PURE__ */ b.jsx(
|
|
469
|
+
be,
|
|
470
470
|
{
|
|
471
|
-
entry:
|
|
471
|
+
entry: j,
|
|
472
472
|
indentLevel: r + 1,
|
|
473
473
|
isDirOpen: u,
|
|
474
474
|
onFileSelect: c,
|
|
475
475
|
toggleDirectory: s,
|
|
476
476
|
onToggleDirectoryRecursive: i,
|
|
477
477
|
selectedPath: f,
|
|
478
|
-
parentIsLast: [...p,
|
|
478
|
+
parentIsLast: [...p, q === (a || []).length - 1],
|
|
479
479
|
selectionMode: k,
|
|
480
|
-
selectedItems:
|
|
481
|
-
onSelectionChange:
|
|
480
|
+
selectedItems: C,
|
|
481
|
+
onSelectionChange: T
|
|
482
482
|
},
|
|
483
|
-
|
|
483
|
+
j.absolutePath
|
|
484
484
|
)) })
|
|
485
485
|
] }, t.absolutePath);
|
|
486
486
|
},
|
|
@@ -498,17 +498,17 @@ const Se = ({ items: t, itemHeight: r, width: u, segmentWidth: c, color: s = "#a
|
|
|
498
498
|
return !0;
|
|
499
499
|
}
|
|
500
500
|
);
|
|
501
|
-
|
|
502
|
-
const
|
|
501
|
+
be.displayName = "DirectoryEntryItem";
|
|
502
|
+
const ie = 20, me = 16, we = (t) => {
|
|
503
503
|
const r = [];
|
|
504
504
|
if (t.children)
|
|
505
505
|
for (const u of t.children)
|
|
506
|
-
u.type === "directory" && (r.push(u.absolutePath), r.push(...
|
|
506
|
+
u.type === "directory" && (r.push(u.absolutePath), r.push(...we(u)));
|
|
507
507
|
return r;
|
|
508
|
-
},
|
|
508
|
+
}, Se = (t, r, u = [], c = 0) => t.flatMap((s, i) => {
|
|
509
509
|
const f = i === t.length - 1, p = [...u, f], E = { entry: s, indentLevel: c, parentIsLast: p };
|
|
510
|
-
return s.children && s.children.length > 0 && r(s.absolutePath, s.relativePath) ? [E, ...
|
|
511
|
-
}),
|
|
510
|
+
return s.children && s.children.length > 0 && r(s.absolutePath, s.relativePath) ? [E, ...Se(s.children, r, p, c + 1)] : [E];
|
|
511
|
+
}), Ze = ({
|
|
512
512
|
entries: t,
|
|
513
513
|
onFileSelect: r,
|
|
514
514
|
className: u,
|
|
@@ -519,92 +519,139 @@ const K = 20, ae = 16, ue = (t) => {
|
|
|
519
519
|
expandMultiple: p,
|
|
520
520
|
collapseMultiple: E,
|
|
521
521
|
isPending: k,
|
|
522
|
-
doubleClickAction:
|
|
523
|
-
selectionMode:
|
|
522
|
+
doubleClickAction: C = "recursive",
|
|
523
|
+
selectionMode: T = "none",
|
|
524
524
|
selectedItems: w,
|
|
525
525
|
onSelectionChange: a,
|
|
526
|
-
lineColor: l = "#A0AEC0"
|
|
526
|
+
lineColor: l = "#A0AEC0",
|
|
527
|
+
virtualScrollOptions: n
|
|
527
528
|
}) => {
|
|
528
|
-
const [
|
|
529
|
+
const [d, O] = W(!1), m = he(null), x = he(null), [A, D] = W(0), {
|
|
530
|
+
overscanCount: S,
|
|
531
|
+
className: B,
|
|
532
|
+
background: H,
|
|
533
|
+
onScroll: Y,
|
|
534
|
+
onRangeChange: j,
|
|
535
|
+
initialScrollIndex: q,
|
|
536
|
+
initialScrollOffset: P,
|
|
537
|
+
tapScrollCircleOptions: te,
|
|
538
|
+
scrollBarWidth: ue,
|
|
539
|
+
enableThumbDrag: G,
|
|
540
|
+
enableTrackClick: re,
|
|
541
|
+
enableArrowButtons: ne,
|
|
542
|
+
enablePointerDrag: ae,
|
|
543
|
+
inertiaOptions: oe
|
|
544
|
+
} = n ?? {}, se = typeof P == "number" ? P : 0, [e, o] = W(se), h = typeof S == "number" ? S : 10, y = N(
|
|
545
|
+
(v, $) => {
|
|
546
|
+
o(v), Y?.(v, $);
|
|
547
|
+
},
|
|
548
|
+
[Y]
|
|
549
|
+
);
|
|
529
550
|
ee(() => {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
551
|
+
typeof P == "number" && o(P);
|
|
552
|
+
}, [P]), ee(() => {
|
|
553
|
+
if (O(!0), Fe(), m.current) {
|
|
554
|
+
D(m.current.clientHeight);
|
|
555
|
+
const v = new ResizeObserver(($) => {
|
|
556
|
+
for (const F of $)
|
|
557
|
+
D(F.contentRect.height);
|
|
535
558
|
});
|
|
536
|
-
return
|
|
559
|
+
return v.observe(m.current), () => v.disconnect();
|
|
537
560
|
}
|
|
538
561
|
}, []);
|
|
539
|
-
const
|
|
540
|
-
(
|
|
541
|
-
[
|
|
542
|
-
), U = k ? `${
|
|
543
|
-
(
|
|
544
|
-
const
|
|
545
|
-
|
|
562
|
+
const I = N(
|
|
563
|
+
(v) => d ? f(v) : !1,
|
|
564
|
+
[d, f]
|
|
565
|
+
), U = k ? `${_.container} ${_.containerPending}` : _.container, g = N(
|
|
566
|
+
(v, $) => {
|
|
567
|
+
const F = we(v), L = [v.absolutePath, ...F], z = $ || C;
|
|
568
|
+
L.every((X) => I(X)) ? E(L) : L.every((Z) => !I(Z)) || z === "recursive" ? p(L) : z === "toggle" ? E(L) : console.warn(`[DirectoryTree] Unknown double click action: ${z}. No action taken.`);
|
|
546
569
|
},
|
|
547
|
-
[
|
|
548
|
-
),
|
|
570
|
+
[I, p, E, C]
|
|
571
|
+
), M = le(() => {
|
|
549
572
|
if (t.length === 0)
|
|
550
573
|
return [];
|
|
551
|
-
const
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
id:
|
|
556
|
-
name:
|
|
557
|
-
absolutePath:
|
|
558
|
-
indentLevel:
|
|
559
|
-
isLastChild:
|
|
560
|
-
isDirectory:
|
|
561
|
-
isExpanded:
|
|
562
|
-
ancestorIsLast: [...
|
|
574
|
+
const v = [];
|
|
575
|
+
function $(F, L, z) {
|
|
576
|
+
F.forEach((J, X) => {
|
|
577
|
+
const Z = J.children !== void 0, fe = J.absolutePath, ye = Z && I(fe), _e = {
|
|
578
|
+
id: fe,
|
|
579
|
+
name: J.name,
|
|
580
|
+
absolutePath: fe,
|
|
581
|
+
indentLevel: L,
|
|
582
|
+
isLastChild: X === F.length - 1,
|
|
583
|
+
isDirectory: Z,
|
|
584
|
+
isExpanded: ye,
|
|
585
|
+
ancestorIsLast: [...z]
|
|
563
586
|
// 祖先の状態をコピーして渡す
|
|
564
587
|
};
|
|
565
|
-
|
|
588
|
+
v.push(_e), Z && ye && J.children && $(J.children, L + 1, [...z, X === F.length - 1]);
|
|
566
589
|
});
|
|
567
590
|
}
|
|
568
|
-
return
|
|
569
|
-
}, [t,
|
|
591
|
+
return $(t, 0, []), v;
|
|
592
|
+
}, [t, I]), V = le(() => Se(t, I), [t, I]), de = le(() => V.length * ie, [V]), ve = le(() => {
|
|
570
593
|
if (t.length === 0)
|
|
571
594
|
return 0;
|
|
572
|
-
let
|
|
573
|
-
for (const
|
|
574
|
-
|
|
575
|
-
return (
|
|
576
|
-
}, [
|
|
577
|
-
return t.length === 0 ? /* @__PURE__ */ b.jsx("div", { className: `${U} ${u || ""}`, style: { ...c, ...
|
|
578
|
-
/* @__PURE__ */ b.jsx("div", { style: { position: "absolute", top: 0, left: 0, width:
|
|
579
|
-
/* @__PURE__ */ b.jsx(
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
595
|
+
let v = 0;
|
|
596
|
+
for (const $ of M)
|
|
597
|
+
$.indentLevel > v && (v = $.indentLevel);
|
|
598
|
+
return (v + 2) * me;
|
|
599
|
+
}, [M, t]);
|
|
600
|
+
return t.length === 0 ? /* @__PURE__ */ b.jsx("div", { className: `${U} ${u || ""}`, style: { ...c, ...xe } }) : /* @__PURE__ */ b.jsx("div", { ref: m, className: `${U} ${u || ""}`, style: { ...c, ...xe }, role: "tree", children: /* @__PURE__ */ b.jsxs("div", { className: "w-full", style: { position: "relative", height: `${de}px` }, children: [
|
|
601
|
+
/* @__PURE__ */ b.jsx("div", { style: { position: "absolute", top: 0, left: 0, width: ve, height: `${A}px`, overflow: "hidden" }, children: /* @__PURE__ */ b.jsx(Me, { items: M, itemHeight: ie, width: ve, segmentWidth: me, color: l, "aria-hidden": "true", role: "presentation", renderFromY: e, renderHeight: A }) }),
|
|
602
|
+
/* @__PURE__ */ b.jsx(
|
|
603
|
+
Je,
|
|
604
|
+
{
|
|
605
|
+
ref: x,
|
|
606
|
+
itemCount: V.length,
|
|
607
|
+
getItem: (v) => V[v],
|
|
608
|
+
getItemHeight: () => ie,
|
|
609
|
+
viewportSize: A,
|
|
610
|
+
overscanCount: h,
|
|
611
|
+
onScroll: y,
|
|
612
|
+
onRangeChange: j,
|
|
613
|
+
className: B,
|
|
614
|
+
background: H,
|
|
615
|
+
initialScrollIndex: q,
|
|
616
|
+
initialScrollOffset: P,
|
|
617
|
+
tapScrollCircleOptions: te,
|
|
618
|
+
scrollBarWidth: ue,
|
|
619
|
+
enableThumbDrag: G,
|
|
620
|
+
enableTrackClick: re,
|
|
621
|
+
enableArrowButtons: ne,
|
|
622
|
+
enablePointerDrag: ae,
|
|
623
|
+
inertiaOptions: oe,
|
|
624
|
+
children: (v, $) => {
|
|
625
|
+
if (!v)
|
|
626
|
+
return null;
|
|
627
|
+
const { entry: F, indentLevel: L, parentIsLast: z } = v;
|
|
628
|
+
return /* @__PURE__ */ b.jsx(
|
|
629
|
+
be,
|
|
630
|
+
{
|
|
631
|
+
entry: F,
|
|
632
|
+
indentLevel: L,
|
|
633
|
+
isDirOpen: I,
|
|
634
|
+
onFileSelect: r,
|
|
635
|
+
toggleDirectory: i,
|
|
636
|
+
onToggleDirectoryRecursive: g,
|
|
637
|
+
selectedPath: s,
|
|
638
|
+
parentIsLast: z,
|
|
639
|
+
renderChildren: !1,
|
|
640
|
+
selectionMode: T,
|
|
641
|
+
selectedItems: w,
|
|
642
|
+
onSelectionChange: a
|
|
643
|
+
},
|
|
644
|
+
F.absolutePath
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
)
|
|
602
649
|
] }) });
|
|
603
|
-
},
|
|
650
|
+
}, Qe = ({
|
|
604
651
|
initialExpanded: t = /* @__PURE__ */ new Set(),
|
|
605
652
|
storageKey: r
|
|
606
653
|
} = {}) => {
|
|
607
|
-
const [u, c] =
|
|
654
|
+
const [u, c] = Re(), [s, i] = W(() => {
|
|
608
655
|
if (typeof window < "u" && r)
|
|
609
656
|
try {
|
|
610
657
|
const a = window.localStorage.getItem(r);
|
|
@@ -625,70 +672,70 @@ const K = 20, ae = 16, ue = (t) => {
|
|
|
625
672
|
console.warn(`Error setting localStorage key "${r}":`, a);
|
|
626
673
|
}
|
|
627
674
|
}, [s, r]);
|
|
628
|
-
const f =
|
|
675
|
+
const f = N((a) => {
|
|
629
676
|
c(() => {
|
|
630
677
|
i((l) => {
|
|
631
678
|
const n = new Set(l);
|
|
632
679
|
return n.has(a) ? n.delete(a) : n.add(a), n;
|
|
633
680
|
});
|
|
634
681
|
});
|
|
635
|
-
}, []), p =
|
|
682
|
+
}, []), p = N((a) => {
|
|
636
683
|
c(() => {
|
|
637
684
|
i((l) => {
|
|
638
685
|
const n = new Set(l);
|
|
639
686
|
return n.has(a) || n.add(a), n;
|
|
640
687
|
});
|
|
641
688
|
});
|
|
642
|
-
}, []), E =
|
|
689
|
+
}, []), E = N((a) => {
|
|
643
690
|
c(() => {
|
|
644
691
|
i((l) => {
|
|
645
692
|
const n = new Set(l);
|
|
646
693
|
return n.has(a) && n.delete(a), n;
|
|
647
694
|
});
|
|
648
695
|
});
|
|
649
|
-
}, []), k =
|
|
696
|
+
}, []), k = N((a) => {
|
|
650
697
|
c(() => {
|
|
651
698
|
i((l) => {
|
|
652
699
|
const n = new Set(l);
|
|
653
|
-
for (const
|
|
654
|
-
n.has(
|
|
700
|
+
for (const d of a)
|
|
701
|
+
n.has(d) && n.delete(d);
|
|
655
702
|
return n;
|
|
656
703
|
});
|
|
657
704
|
});
|
|
658
|
-
}, []),
|
|
705
|
+
}, []), C = N((a) => {
|
|
659
706
|
c(() => {
|
|
660
707
|
i((l) => {
|
|
661
708
|
const n = new Set(l);
|
|
662
|
-
for (const
|
|
663
|
-
n.has(
|
|
709
|
+
for (const d of a)
|
|
710
|
+
n.has(d) || n.add(d);
|
|
664
711
|
return n;
|
|
665
712
|
});
|
|
666
713
|
});
|
|
667
|
-
}, []),
|
|
714
|
+
}, []), T = N(() => {
|
|
668
715
|
c(() => {
|
|
669
716
|
i(/* @__PURE__ */ new Set());
|
|
670
717
|
});
|
|
671
|
-
}, []), w =
|
|
718
|
+
}, []), w = N((a) => s.has(a), [s]);
|
|
672
719
|
return {
|
|
673
720
|
expanded: s,
|
|
674
721
|
toggle: f,
|
|
675
722
|
expand: p,
|
|
676
723
|
collapse: E,
|
|
677
724
|
collapseMultiple: k,
|
|
678
|
-
expandMultiple:
|
|
679
|
-
collapseAll:
|
|
725
|
+
expandMultiple: C,
|
|
726
|
+
collapseAll: T,
|
|
680
727
|
isExpanded: w,
|
|
681
728
|
isPending: u
|
|
682
729
|
};
|
|
683
730
|
};
|
|
684
731
|
export {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
732
|
+
Ze as DirectoryTree,
|
|
733
|
+
Me as TreeLine,
|
|
734
|
+
_ as directoryTreeClasses,
|
|
735
|
+
Ye as getEntryClasses,
|
|
736
|
+
Ve as getExpandIconClasses,
|
|
737
|
+
Ue as getNameClasses,
|
|
738
|
+
ze as getTypeIconClasses,
|
|
739
|
+
Qe as useDirectoryTreeState
|
|
693
740
|
};
|
|
694
741
|
//# sourceMappingURL=index.js.map
|