@almadar/shell-web 0.0.0-stage → 0.1.0
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/bundling.d.mts +18 -0
- package/bundling.mjs +28 -0
- package/dist/ArbitraryClassCompiler-Mzabq-UB.d.ts +100 -0
- package/dist/AvlGlyph-JKJOAH23.js +6 -0
- package/dist/AvlStateMachine-PI4YGREK.js +8 -0
- package/dist/AvlTransitionDetail-ZH7V24UG.js +12 -0
- package/dist/AvlTransitionExplainer-ZSRT7L6Y.js +13 -0
- package/dist/BehaviorValueFrame-6RUJXT4A.js +29 -0
- package/dist/BehaviorValueFrame-SSEMEBTG.css +1756 -0
- package/dist/BehaviorView-RFEE5J6E.js +10 -0
- package/dist/Canvas3DHost-_Y-5uLM_.d.ts +552 -0
- package/dist/EventBusProvider-CVwjkV_2.d.ts +284 -0
- package/dist/FileTree-BCFnBEuQ.d.ts +254 -0
- package/dist/FlowCanvas-3JRMNJLV.css +1756 -0
- package/dist/FlowCanvas-STDC4OWK.js +27 -0
- package/dist/GameAudioProvider-Cm9BnvmP.d.ts +93 -0
- package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/dist/KernelEngineContext-BOCQoFwk.d.ts +43 -0
- package/dist/LayersPanel-BBQ54IVG.js +7 -0
- package/dist/ModuleCard-3TT2X7IW.js +7 -0
- package/dist/OrbInspector-K6T6O7GI.js +27 -0
- package/dist/OrbInspector-MHLJ6OEE.css +1756 -0
- package/dist/Select-mDZIwNqN.d.ts +199 -0
- package/dist/ServerBridge-Cm1On51b.d.ts +233 -0
- package/dist/ThemeContext-DJmO59xd.d.ts +147 -0
- package/dist/TraitValueFrame-2PJGLLVI.js +28 -0
- package/dist/TraitValueFrame-4G3KOUBR.css +1756 -0
- package/dist/UISlotContext-Dl_ewwCI.d.ts +79 -0
- package/dist/UISlotRenderer-JKFSX24W.js +27 -0
- package/dist/UISlotRenderer-KVFO6J7R.css +1756 -0
- package/dist/UserContext-DqWeZkUZ.d.ts +100 -0
- package/dist/auth/browser/index.d.ts +2 -0
- package/dist/auth/browser/index.js +1 -0
- package/dist/auth/react/index.d.ts +49 -0
- package/dist/auth/react/index.js +119 -0
- package/dist/avl/index.css +1756 -0
- package/dist/avl/index.d.ts +2238 -0
- package/dist/avl/index.js +2693 -0
- package/dist/avl-3d-context-BIRKWpaL.d.ts +204 -0
- package/dist/avl-schema-parser-CtJxJ9KU.d.ts +132 -0
- package/dist/avl-zoom-state-CKMVuBFg.d.ts +17 -0
- package/dist/chunk-2PY54Z44.js +227 -0
- package/dist/chunk-2QOH2HWM.js +95 -0
- package/dist/chunk-3BBUBJFF.js +339 -0
- package/dist/chunk-42FY4RYA.js +191 -0
- package/dist/chunk-5QTYQTPS.js +15 -0
- package/dist/chunk-6P3MWXYE.js +440 -0
- package/dist/chunk-73SRAB4P.js +1053 -0
- package/dist/chunk-A2LR6VQQ.js +349 -0
- package/dist/chunk-AILY3XPS.js +562 -0
- package/dist/chunk-B4BU77LT.js +432 -0
- package/dist/chunk-DFNZUYX4.js +378 -0
- package/dist/chunk-DJ433ET5.js +1327 -0
- package/dist/chunk-DLZF4PVE.js +24 -0
- package/dist/chunk-DYEKAA4L.js +787 -0
- package/dist/chunk-DZ42OJQC.js +176 -0
- package/dist/chunk-EOWMARUB.js +16 -0
- package/dist/chunk-EQAMU2ZC.js +14 -0
- package/dist/chunk-FAJDTHWC.js +98 -0
- package/dist/chunk-FIW6WN23.js +508 -0
- package/dist/chunk-FP3WIKTC.js +303 -0
- package/dist/chunk-G7DCAZ22.js +19 -0
- package/dist/chunk-GAR5TQ5B.js +199 -0
- package/dist/chunk-GKIFONTE.js +131 -0
- package/dist/chunk-GYTPOFVC.js +47155 -0
- package/dist/chunk-KVQS4GXU.js +328 -0
- package/dist/chunk-L2DEKY4J.js +97 -0
- package/dist/chunk-L677XGY3.js +701 -0
- package/dist/chunk-MBQAMMSE.js +11877 -0
- package/dist/chunk-P4LNHAFI.js +1051 -0
- package/dist/chunk-P4ZFUQFF.js +93 -0
- package/dist/chunk-PC7K4SK7.js +1384 -0
- package/dist/chunk-R5O5AUPI.js +573 -0
- package/dist/chunk-SGM3FASH.js +672 -0
- package/dist/chunk-SJGJJKBY.js +502 -0
- package/dist/chunk-TESBIVUA.js +11 -0
- package/dist/chunk-TZZBINQY.js +82 -0
- package/dist/chunk-U6QRZASX.js +280 -0
- package/dist/chunk-VFF5OO47.js +319 -0
- package/dist/chunk-YDNJLLG6.js +516 -0
- package/dist/chunk-YHMRX6YA.js +455 -0
- package/dist/chunk-ZO6MXAS3.js +69 -0
- package/dist/components/index.css +1756 -0
- package/dist/components/index.d.ts +11093 -0
- package/dist/components/index.js +1110 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/index.js +7 -0
- package/dist/core.d.ts +2523 -0
- package/dist/core.js +2 -0
- package/dist/design-classes/index.cjs +429 -0
- package/dist/design-classes/index.d.cts +165 -0
- package/dist/design-classes/index.d.ts +165 -0
- package/dist/design-classes/index.js +397 -0
- package/dist/emojiItems-QGSNAABW.js +20 -0
- package/dist/fx-CmQjnHmT.d.ts +371 -0
- package/dist/hooks/index.d.ts +936 -0
- package/dist/hooks/index.js +7 -0
- package/dist/index.d.ts +486 -0
- package/dist/index.js +38 -0
- package/dist/katexPlugin-FA7NX4PE.css +1161 -0
- package/dist/katexPlugin-NCDKOOQY.js +2 -0
- package/dist/kernel-client-ZH4PSMCN.js +367 -0
- package/dist/kernel-wire-B4S8pnP3.d.ts +65 -0
- package/dist/lib/index.d.ts +602 -0
- package/dist/lib/index.js +1288 -0
- package/dist/paintDispatch-ChW5mVuK.d.ts +698 -0
- package/dist/parseLessonSegments-GpCeMrb2.d.ts +334 -0
- package/dist/perf-CKiBKbkw.d.ts +22 -0
- package/dist/perf-Dr28-AgT.d.ts +57 -0
- package/dist/prism-AIWGN2X5.js +134 -0
- package/dist/providers/index.css +1756 -0
- package/dist/providers/index.d.ts +340 -0
- package/dist/providers/index.js +30 -0
- package/dist/renderer/index.d.ts +467 -0
- package/dist/renderer/index.js +3 -0
- package/dist/runtime/index.css +1756 -0
- package/dist/runtime/index.d.ts +440 -0
- package/dist/runtime/index.js +31 -0
- package/dist/slot-host-CPzrxLo9.d.ts +48 -0
- package/dist/ssr/index.cjs +7631 -0
- package/dist/ssr/index.d.cts +487 -0
- package/dist/ssr/index.d.ts +487 -0
- package/dist/ssr/index.js +7599 -0
- package/dist/storage/browser/index.d.ts +1 -0
- package/dist/storage/browser/index.js +1 -0
- package/dist/test-support.d.ts +35 -0
- package/dist/test-support.js +114 -0
- package/dist/themeTokens-CRd8AEDF.d.ts +125 -0
- package/dist/three/index.css +503 -0
- package/dist/three/index.d.ts +1185 -0
- package/dist/three/index.js +3896 -0
- package/dist/useKeyboardRouter-Dsq553Ur.d.ts +42 -0
- package/dist/useUISlots-CiobNFGb.d.ts +211 -0
- package/dist/verification-C5pTeMJv.d.ts +66 -0
- package/dist/verificationRegistry-CabxhfTv.d.ts +122 -0
- package/dist/wrapCallbackForEvent-B9QLbhxX.d.ts +19 -0
- package/index.css +199 -0
- package/package.json +269 -3
- package/src/core/locales/ar.json +1263 -0
- package/src/core/locales/en.json +1263 -0
- package/src/core/locales/index.ts +54 -0
- package/src/core/locales/sl.json +1263 -0
- package/src/core/tokens/native-tokens.json +369 -0
- package/tailwind-compile.cjs +29 -0
- package/tailwind-preset.cjs +991 -0
- package/themes/_base.css +451 -0
- package/themes/_contract.md +307 -0
- package/themes/_fonts-kenney.css +11 -0
- package/themes/_fonts.css +12 -0
- package/themes/_foundation.css +105 -0
- package/themes/_head.css +22 -0
- package/themes/_presets.css +67 -0
- package/themes/almadar-heritage.css +455 -0
- package/themes/almadar-website.css +269 -0
- package/themes/almadar.css +269 -0
- package/themes/aqua.css +455 -0
- package/themes/arabesque.css +459 -0
- package/themes/art-deco.css +457 -0
- package/themes/art-nouveau.css +459 -0
- package/themes/atelier.css +463 -0
- package/themes/bauhaus.css +461 -0
- package/themes/bloomberg-dense.css +463 -0
- package/themes/blueprint.css +457 -0
- package/themes/clay.css +449 -0
- package/themes/comic.css +453 -0
- package/themes/constructivist.css +457 -0
- package/themes/corporate.css +449 -0
- package/themes/cyberpunk.css +453 -0
- package/themes/frutiger-aero.css +458 -0
- package/themes/game-adventure.css +201 -0
- package/themes/game-rpg.css +203 -0
- package/themes/game-sci-fi.css +201 -0
- package/themes/game-ui-pack.css +200 -0
- package/themes/gazette.css +449 -0
- package/themes/glass.css +457 -0
- package/themes/gothic.css +453 -0
- package/themes/index.css +21 -0
- package/themes/ink-wash.css +459 -0
- package/themes/kawaii.css +459 -0
- package/themes/kflow.css +310 -0
- package/themes/kiosk.css +449 -0
- package/themes/linear-clean.css +463 -0
- package/themes/luxury.css +451 -0
- package/themes/mac-classic.css +455 -0
- package/themes/material.css +463 -0
- package/themes/memphis.css +453 -0
- package/themes/mid-century.css +455 -0
- package/themes/minimalist.css +449 -0
- package/themes/mudcloth.css +459 -0
- package/themes/nata.css +310 -0
- package/themes/neon.css +453 -0
- package/themes/neumorphic.css +451 -0
- package/themes/newsprint.css +455 -0
- package/themes/notion-editorial.css +463 -0
- package/themes/orb.css +465 -0
- package/themes/pixel.css +449 -0
- package/themes/prism.css +309 -0
- package/themes/rawi.css +310 -0
- package/themes/retro.css +452 -0
- package/themes/risograph.css +463 -0
- package/themes/scandi.css +469 -0
- package/themes/sketch.css +455 -0
- package/themes/solarpunk.css +469 -0
- package/themes/steampunk.css +451 -0
- package/themes/swiss.css +455 -0
- package/themes/terminal.css +466 -0
- package/themes/trait-wars.css +487 -0
- package/themes/ukiyo-e.css +459 -0
- package/themes/vaporwave.css +455 -0
- package/themes/victorian.css +453 -0
- package/themes/wabi-sabi.css +459 -0
- package/themes/win95.css +455 -0
- package/themes/wireframe.css +439 -0
- package/themes/zine.css +455 -0
- package/README.md +0 -3
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { useDraggable, useDropZone } from './chunk-L2DEKY4J.js';
|
|
2
|
+
import { Box, domPassthrough, useTranslate, Icon, pressableProps, Typography } from './chunk-MBQAMMSE.js';
|
|
3
|
+
import React, { createContext, useState, useCallback, useRef, useEffect, useContext } from 'react';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function fileIcon(name) {
|
|
7
|
+
const ext = name.split(".").pop()?.toLowerCase() ?? "";
|
|
8
|
+
switch (ext) {
|
|
9
|
+
case "ts":
|
|
10
|
+
case "tsx":
|
|
11
|
+
return "file-code";
|
|
12
|
+
case "js":
|
|
13
|
+
case "jsx":
|
|
14
|
+
return "file-code";
|
|
15
|
+
case "json":
|
|
16
|
+
case "orb":
|
|
17
|
+
return "file-json";
|
|
18
|
+
case "css":
|
|
19
|
+
case "scss":
|
|
20
|
+
return "file-text";
|
|
21
|
+
case "md":
|
|
22
|
+
return "file-text";
|
|
23
|
+
case "py":
|
|
24
|
+
return "file-code";
|
|
25
|
+
case "html":
|
|
26
|
+
return "file-code";
|
|
27
|
+
default:
|
|
28
|
+
return "file";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var TreeNavContext = createContext({ activeKey: void 0, setActive: () => {
|
|
32
|
+
} });
|
|
33
|
+
function levelOf(el) {
|
|
34
|
+
return Number(el.getAttribute("aria-level") ?? "1");
|
|
35
|
+
}
|
|
36
|
+
function treeRowKeyDown(e, state) {
|
|
37
|
+
if (e.target !== e.currentTarget) return;
|
|
38
|
+
const row = e.currentTarget;
|
|
39
|
+
const tree = row.closest('[role="tree"]');
|
|
40
|
+
if (!tree) return;
|
|
41
|
+
const rows = Array.from(tree.querySelectorAll('[role="treeitem"]'));
|
|
42
|
+
const idx = rows.indexOf(row);
|
|
43
|
+
const focusRow = (target) => {
|
|
44
|
+
if (!target) return;
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
target.focus();
|
|
47
|
+
};
|
|
48
|
+
switch (e.key) {
|
|
49
|
+
case "Enter":
|
|
50
|
+
case " ":
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
row.click();
|
|
53
|
+
return;
|
|
54
|
+
case "ArrowDown":
|
|
55
|
+
focusRow(rows[idx + 1]);
|
|
56
|
+
return;
|
|
57
|
+
case "ArrowUp":
|
|
58
|
+
focusRow(rows[idx - 1]);
|
|
59
|
+
return;
|
|
60
|
+
case "Home":
|
|
61
|
+
focusRow(rows[0]);
|
|
62
|
+
return;
|
|
63
|
+
case "End":
|
|
64
|
+
focusRow(rows[rows.length - 1]);
|
|
65
|
+
return;
|
|
66
|
+
case "ArrowRight":
|
|
67
|
+
if (state.expanded === false) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
state.toggle();
|
|
70
|
+
} else if (state.expanded === true) {
|
|
71
|
+
const next = rows[idx + 1];
|
|
72
|
+
if (next && levelOf(next) > levelOf(row)) focusRow(next);
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
case "ArrowLeft":
|
|
76
|
+
if (state.expanded === true) {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
state.toggle();
|
|
79
|
+
} else {
|
|
80
|
+
const level = levelOf(row);
|
|
81
|
+
focusRow(rows.slice(0, idx).reverse().find((r) => levelOf(r) < level));
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function TreeRoot({
|
|
87
|
+
defaultKey,
|
|
88
|
+
className,
|
|
89
|
+
rest,
|
|
90
|
+
children
|
|
91
|
+
}) {
|
|
92
|
+
const [active, setActive] = useState(void 0);
|
|
93
|
+
const rootRef = useRef(null);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (active === void 0) return;
|
|
96
|
+
if (!rootRef.current?.querySelector('[role="treeitem"][tabindex="0"]')) setActive(void 0);
|
|
97
|
+
});
|
|
98
|
+
const value = React.useMemo(() => ({ activeKey: active ?? defaultKey, setActive }), [active, defaultKey]);
|
|
99
|
+
return /* @__PURE__ */ jsx(TreeNavContext.Provider, { value, children: /* @__PURE__ */ jsx(Box, { ref: rootRef, className: `py-1 overflow-y-auto ${className ?? ""}`, ...domPassthrough(rest), role: "tree", children }) });
|
|
100
|
+
}
|
|
101
|
+
var TreeNodeItem = ({
|
|
102
|
+
node,
|
|
103
|
+
depth,
|
|
104
|
+
indent,
|
|
105
|
+
selectedPath,
|
|
106
|
+
onFileSelect,
|
|
107
|
+
onNodeExpand,
|
|
108
|
+
expandedPaths,
|
|
109
|
+
defaultExpanded = false
|
|
110
|
+
}) => {
|
|
111
|
+
const isDir = node.type === "dir";
|
|
112
|
+
const hasDerived = !isDir && ((node.children?.length ?? 0) > 0 || node.expandable === true);
|
|
113
|
+
const askedRef = useRef(false);
|
|
114
|
+
const revealed = expandedPaths?.includes(node.path) === true;
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!revealed) return;
|
|
117
|
+
setExpanded(true);
|
|
118
|
+
if (node.expandable === true && !askedRef.current) {
|
|
119
|
+
askedRef.current = true;
|
|
120
|
+
onNodeExpand?.(node.path);
|
|
121
|
+
}
|
|
122
|
+
}, [revealed, node.expandable, node.path, onNodeExpand]);
|
|
123
|
+
const [expanded, setExpanded] = useState(isDir && (defaultExpanded || depth < 1));
|
|
124
|
+
const isSelected = node.path === selectedPath;
|
|
125
|
+
const { t } = useTranslate();
|
|
126
|
+
const nav = useContext(TreeNavContext);
|
|
127
|
+
const toggleDerived = useCallback(() => {
|
|
128
|
+
if (!expanded && node.expandable === true && !askedRef.current) {
|
|
129
|
+
askedRef.current = true;
|
|
130
|
+
onNodeExpand?.(node.path);
|
|
131
|
+
}
|
|
132
|
+
setExpanded((prev) => !prev);
|
|
133
|
+
}, [expanded, node.expandable, node.path, onNodeExpand]);
|
|
134
|
+
const handleClick = useCallback(() => {
|
|
135
|
+
if (isDir) {
|
|
136
|
+
setExpanded((prev) => !prev);
|
|
137
|
+
} else {
|
|
138
|
+
onFileSelect?.(node.path);
|
|
139
|
+
}
|
|
140
|
+
}, [isDir, node.path, onFileSelect]);
|
|
141
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
142
|
+
/* @__PURE__ */ jsxs(
|
|
143
|
+
Box,
|
|
144
|
+
{
|
|
145
|
+
className: `flex items-center gap-1.5 py-0.5 px-2 cursor-pointer rounded-interactive transition-colors ${isSelected ? "bg-primary text-primary-foreground" : "hover:bg-muted"}`,
|
|
146
|
+
style: { paddingLeft: depth * indent + 8 },
|
|
147
|
+
onClick: handleClick,
|
|
148
|
+
role: "treeitem",
|
|
149
|
+
tabIndex: nav.activeKey === node.path ? 0 : -1,
|
|
150
|
+
"aria-level": depth + 1,
|
|
151
|
+
"aria-selected": isSelected,
|
|
152
|
+
"aria-expanded": isDir || hasDerived ? expanded : void 0,
|
|
153
|
+
onFocus: () => nav.setActive(node.path),
|
|
154
|
+
onKeyDown: (e) => treeRowKeyDown(e, {
|
|
155
|
+
expanded: isDir || hasDerived ? expanded : void 0,
|
|
156
|
+
toggle: isDir ? () => setExpanded((prev) => !prev) : toggleDerived
|
|
157
|
+
}),
|
|
158
|
+
children: [
|
|
159
|
+
isDir ? /* @__PURE__ */ jsx(
|
|
160
|
+
Icon,
|
|
161
|
+
{
|
|
162
|
+
name: expanded ? "chevron-down" : "chevron-right",
|
|
163
|
+
size: "xs",
|
|
164
|
+
className: "text-[var(--color-muted-foreground)] flex-shrink-0"
|
|
165
|
+
}
|
|
166
|
+
) : hasDerived ? /* @__PURE__ */ jsx(
|
|
167
|
+
Box,
|
|
168
|
+
{
|
|
169
|
+
...pressableProps((e) => {
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
toggleDerived();
|
|
172
|
+
}),
|
|
173
|
+
tabIndex: -1,
|
|
174
|
+
"aria-expanded": expanded,
|
|
175
|
+
"aria-label": expanded ? t("fileTree.collapse") : t("fileTree.expand"),
|
|
176
|
+
"data-testid": `file-tree-toggle-${node.path}`,
|
|
177
|
+
className: "flex-shrink-0 flex items-center",
|
|
178
|
+
children: /* @__PURE__ */ jsx(Icon, { name: expanded ? "chevron-down" : "chevron-right", size: "xs", className: "text-[var(--color-muted-foreground)]" })
|
|
179
|
+
}
|
|
180
|
+
) : /* @__PURE__ */ jsx(Box, { style: { width: 12, flexShrink: 0 } }),
|
|
181
|
+
/* @__PURE__ */ jsx(
|
|
182
|
+
Icon,
|
|
183
|
+
{
|
|
184
|
+
name: isDir ? expanded ? "folder-open" : "folder" : fileIcon(node.name),
|
|
185
|
+
size: "xs",
|
|
186
|
+
className: isSelected ? "text-inherit" : isDir ? "text-[var(--color-warning)]" : "text-[var(--color-muted-foreground)]"
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
Typography,
|
|
191
|
+
{
|
|
192
|
+
variant: "caption",
|
|
193
|
+
className: `truncate font-mono text-xs !text-inherit ${isSelected ? "font-semibold" : ""}`,
|
|
194
|
+
children: node.name
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
node.note !== void 0 && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: `text-[9px] flex-shrink-0 ${isSelected ? "!text-inherit opacity-80" : "text-[var(--color-muted-foreground)]"}`, children: node.note }),
|
|
198
|
+
!isDir && node.size !== void 0 && /* @__PURE__ */ jsx(
|
|
199
|
+
Typography,
|
|
200
|
+
{
|
|
201
|
+
variant: "caption",
|
|
202
|
+
className: `text-[9px] ml-auto flex-shrink-0 ${isSelected ? "!text-inherit opacity-80" : "text-[var(--color-muted-foreground)]"}`,
|
|
203
|
+
children: node.size < 1024 ? `${node.size}B` : `${Math.round(node.size / 1024)}KB`
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
(isDir || hasDerived) && expanded && node.children && /* @__PURE__ */ jsx(Box, { role: "group", children: node.children.map((child) => /* @__PURE__ */ jsx(
|
|
210
|
+
TreeNodeItem,
|
|
211
|
+
{
|
|
212
|
+
node: child,
|
|
213
|
+
depth: depth + 1,
|
|
214
|
+
indent,
|
|
215
|
+
selectedPath,
|
|
216
|
+
onFileSelect,
|
|
217
|
+
onNodeExpand,
|
|
218
|
+
expandedPaths,
|
|
219
|
+
defaultExpanded: depth < 0
|
|
220
|
+
},
|
|
221
|
+
child.path
|
|
222
|
+
)) })
|
|
223
|
+
] });
|
|
224
|
+
};
|
|
225
|
+
function siblingsOf(target, roots, childrenByParent) {
|
|
226
|
+
if (target.parentId) {
|
|
227
|
+
const parentSiblings = childrenByParent.get(target.parentId);
|
|
228
|
+
if (parentSiblings?.some((sibling) => sibling.id === target.id)) return parentSiblings;
|
|
229
|
+
}
|
|
230
|
+
return roots;
|
|
231
|
+
}
|
|
232
|
+
var FlatTreeNodeItem = ({
|
|
233
|
+
item,
|
|
234
|
+
depth,
|
|
235
|
+
indent,
|
|
236
|
+
childrenByParent,
|
|
237
|
+
roots,
|
|
238
|
+
onNodeSelect,
|
|
239
|
+
onNodeAction,
|
|
240
|
+
nodeActionIcon,
|
|
241
|
+
nodeActionLabel,
|
|
242
|
+
onNodeReorder,
|
|
243
|
+
selectedId,
|
|
244
|
+
look,
|
|
245
|
+
isExpanded,
|
|
246
|
+
onToggle
|
|
247
|
+
}) => {
|
|
248
|
+
const { t } = useTranslate();
|
|
249
|
+
const children = childrenByParent.get(item.id);
|
|
250
|
+
const hasChildren = !!children && children.length > 0;
|
|
251
|
+
const expanded = hasChildren && isExpanded(item.id, depth);
|
|
252
|
+
const isSelected = selectedId !== void 0 && selectedId !== "" && item.id === selectedId;
|
|
253
|
+
const nav = look === "nav";
|
|
254
|
+
const rowRef = useRef(null);
|
|
255
|
+
const treeNav = useContext(TreeNavContext);
|
|
256
|
+
const handleClick = useCallback(() => {
|
|
257
|
+
if (hasChildren && !onNodeSelect) onToggle(item.id, expanded);
|
|
258
|
+
onNodeSelect?.(item.id);
|
|
259
|
+
}, [hasChildren, expanded, item.id, onNodeSelect, onToggle]);
|
|
260
|
+
const handleChevron = useCallback((e) => {
|
|
261
|
+
e.stopPropagation();
|
|
262
|
+
onToggle(item.id, expanded);
|
|
263
|
+
}, [item.id, expanded, onToggle]);
|
|
264
|
+
const handleAction = useCallback((e) => {
|
|
265
|
+
e.stopPropagation();
|
|
266
|
+
onNodeAction?.(item.id);
|
|
267
|
+
}, [item.id, onNodeAction]);
|
|
268
|
+
const { dragProps } = useDraggable({
|
|
269
|
+
payload: { kind: "tree-node", data: { id: item.id } },
|
|
270
|
+
disabled: !onNodeReorder
|
|
271
|
+
});
|
|
272
|
+
const handleRowDrop = useCallback(
|
|
273
|
+
(payload, position) => {
|
|
274
|
+
if (!onNodeReorder) return;
|
|
275
|
+
const draggedId = typeof payload.data.id === "string" ? payload.data.id : void 0;
|
|
276
|
+
if (!draggedId || draggedId === item.id) return;
|
|
277
|
+
const rect = rowRef.current?.getBoundingClientRect();
|
|
278
|
+
if (!rect || rect.height === 0) return;
|
|
279
|
+
const relY = position.y - rect.top;
|
|
280
|
+
const third = rect.height / 3;
|
|
281
|
+
if (relY >= third && relY <= third * 2) {
|
|
282
|
+
const existingChildren = childrenByParent.get(item.id);
|
|
283
|
+
onNodeReorder(draggedId, item.id, existingChildren ? existingChildren.length : 0);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const siblings = siblingsOf(item, roots, childrenByParent);
|
|
287
|
+
const newParentId = siblings === roots ? null : item.parentId ?? null;
|
|
288
|
+
const targetIndex = siblings.findIndex((sibling) => sibling.id === item.id);
|
|
289
|
+
const index = relY < third ? targetIndex < 0 ? 0 : targetIndex : targetIndex < 0 ? siblings.length : targetIndex + 1;
|
|
290
|
+
onNodeReorder(draggedId, newParentId, index);
|
|
291
|
+
},
|
|
292
|
+
[onNodeReorder, item, roots, childrenByParent]
|
|
293
|
+
);
|
|
294
|
+
const { dropProps } = useDropZone({
|
|
295
|
+
accepts: ["tree-node"],
|
|
296
|
+
onDrop: handleRowDrop,
|
|
297
|
+
disabled: !onNodeReorder
|
|
298
|
+
});
|
|
299
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
300
|
+
/* @__PURE__ */ jsxs(
|
|
301
|
+
Box,
|
|
302
|
+
{
|
|
303
|
+
ref: rowRef,
|
|
304
|
+
className: `group/treerow flex items-center gap-1.5 px-2 cursor-pointer rounded-interactive transition-colors ${nav ? "py-1" : "py-0.5"} ${isSelected ? "bg-primary text-primary-foreground" : nav ? "text-foreground hover:bg-muted" : "hover:bg-muted"}`,
|
|
305
|
+
style: { paddingLeft: depth * indent + 8 },
|
|
306
|
+
onClick: handleClick,
|
|
307
|
+
role: "treeitem",
|
|
308
|
+
tabIndex: treeNav.activeKey === item.id ? 0 : -1,
|
|
309
|
+
"aria-level": depth + 1,
|
|
310
|
+
"aria-selected": isSelected,
|
|
311
|
+
"aria-expanded": hasChildren ? expanded : void 0,
|
|
312
|
+
onFocus: () => treeNav.setActive(item.id),
|
|
313
|
+
onKeyDown: (e) => treeRowKeyDown(e, {
|
|
314
|
+
expanded: hasChildren ? expanded : void 0,
|
|
315
|
+
toggle: () => onToggle(item.id, expanded)
|
|
316
|
+
}),
|
|
317
|
+
...dragProps,
|
|
318
|
+
...dropProps,
|
|
319
|
+
children: [
|
|
320
|
+
hasChildren ? /* @__PURE__ */ jsx(Box, { ...pressableProps(handleChevron), tabIndex: -1, className: "flex items-center flex-shrink-0", "aria-label": expanded ? t("fileTree.collapse") : t("fileTree.expand"), children: /* @__PURE__ */ jsx(
|
|
321
|
+
Icon,
|
|
322
|
+
{
|
|
323
|
+
name: expanded ? "chevron-down" : "chevron-right",
|
|
324
|
+
size: "xs",
|
|
325
|
+
className: isSelected ? "text-inherit" : "text-[var(--color-muted-foreground)]"
|
|
326
|
+
}
|
|
327
|
+
) }) : /* @__PURE__ */ jsx(Box, { style: { width: 12, flexShrink: 0 } }),
|
|
328
|
+
/* @__PURE__ */ jsx(
|
|
329
|
+
Icon,
|
|
330
|
+
{
|
|
331
|
+
name: item.icon || (nav ? "file-text" : hasChildren ? expanded ? "folder-open" : "folder" : "file"),
|
|
332
|
+
size: "xs",
|
|
333
|
+
className: isSelected ? "text-inherit" : nav || !hasChildren ? "text-[var(--color-muted-foreground)]" : "text-[var(--color-warning)]"
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
/* @__PURE__ */ jsx(
|
|
337
|
+
Typography,
|
|
338
|
+
{
|
|
339
|
+
variant: "caption",
|
|
340
|
+
className: `truncate ${nav ? "text-sm" : "font-mono text-xs"} !text-inherit ${isSelected ? "font-semibold" : ""}`,
|
|
341
|
+
children: item.label
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
onNodeAction && /* @__PURE__ */ jsx(
|
|
345
|
+
Box,
|
|
346
|
+
{
|
|
347
|
+
...pressableProps(handleAction),
|
|
348
|
+
tabIndex: treeNav.activeKey === item.id ? 0 : -1,
|
|
349
|
+
"aria-label": nodeActionLabel ?? t("fileTree.nodeAction"),
|
|
350
|
+
title: nodeActionLabel,
|
|
351
|
+
className: `ml-auto flex-shrink-0 rounded-interactive p-0.5 opacity-0 group-hover/treerow:opacity-100 group-focus-within/treerow:opacity-100 transition-opacity ${isSelected ? "hover:bg-primary-foreground/20" : "hover:bg-border"}`,
|
|
352
|
+
children: /* @__PURE__ */ jsx(Icon, { name: nodeActionIcon ?? "plus", size: "xs", className: "text-inherit" })
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
),
|
|
358
|
+
hasChildren && expanded && /* @__PURE__ */ jsx(Box, { role: "group", children: children.map((child) => /* @__PURE__ */ jsx(
|
|
359
|
+
FlatTreeNodeItem,
|
|
360
|
+
{
|
|
361
|
+
item: child,
|
|
362
|
+
depth: depth + 1,
|
|
363
|
+
indent,
|
|
364
|
+
childrenByParent,
|
|
365
|
+
roots,
|
|
366
|
+
onNodeSelect,
|
|
367
|
+
onNodeAction,
|
|
368
|
+
nodeActionIcon,
|
|
369
|
+
nodeActionLabel,
|
|
370
|
+
onNodeReorder,
|
|
371
|
+
selectedId,
|
|
372
|
+
look,
|
|
373
|
+
isExpanded,
|
|
374
|
+
onToggle
|
|
375
|
+
},
|
|
376
|
+
child.id
|
|
377
|
+
)) })
|
|
378
|
+
] });
|
|
379
|
+
};
|
|
380
|
+
function ancestorsOf(id, byId) {
|
|
381
|
+
const out = /* @__PURE__ */ new Set();
|
|
382
|
+
if (!id) return out;
|
|
383
|
+
let cur = byId.get(id)?.parentId;
|
|
384
|
+
while (cur && byId.has(cur) && !out.has(cur)) {
|
|
385
|
+
out.add(cur);
|
|
386
|
+
cur = byId.get(cur)?.parentId;
|
|
387
|
+
}
|
|
388
|
+
return out;
|
|
389
|
+
}
|
|
390
|
+
var FlatFileTree = ({
|
|
391
|
+
items,
|
|
392
|
+
selectedId,
|
|
393
|
+
look = "files",
|
|
394
|
+
onNodeSelect,
|
|
395
|
+
onNodeAction,
|
|
396
|
+
nodeActionIcon,
|
|
397
|
+
nodeActionLabel,
|
|
398
|
+
onNodeReorder,
|
|
399
|
+
className,
|
|
400
|
+
indent = 16,
|
|
401
|
+
...rest
|
|
402
|
+
}) => {
|
|
403
|
+
const [overrides, setOverrides] = useState(() => /* @__PURE__ */ new Map());
|
|
404
|
+
const byId = React.useMemo(() => new Map(items.map((node) => [node.id, node])), [items]);
|
|
405
|
+
const selectedAncestors = React.useMemo(() => ancestorsOf(selectedId, byId), [selectedId, byId]);
|
|
406
|
+
const lastSelectedRef = React.useRef(selectedId);
|
|
407
|
+
React.useEffect(() => {
|
|
408
|
+
if (selectedId === lastSelectedRef.current) return;
|
|
409
|
+
lastSelectedRef.current = selectedId;
|
|
410
|
+
setOverrides((prev) => {
|
|
411
|
+
if (![...selectedAncestors].some((a) => prev.get(a) === false)) return prev;
|
|
412
|
+
const next = new Map(prev);
|
|
413
|
+
for (const a of selectedAncestors) if (next.get(a) === false) next.delete(a);
|
|
414
|
+
return next;
|
|
415
|
+
});
|
|
416
|
+
}, [selectedId, selectedAncestors]);
|
|
417
|
+
const isExpanded = useCallback(
|
|
418
|
+
(id, depth) => overrides.get(id) ?? (depth < 1 || selectedAncestors.has(id)),
|
|
419
|
+
[overrides, selectedAncestors]
|
|
420
|
+
);
|
|
421
|
+
const onToggle = useCallback((id, effective) => {
|
|
422
|
+
setOverrides((prev) => {
|
|
423
|
+
const next = new Map(prev);
|
|
424
|
+
next.set(id, !effective);
|
|
425
|
+
return next;
|
|
426
|
+
});
|
|
427
|
+
}, []);
|
|
428
|
+
if (items.length === 0) return null;
|
|
429
|
+
const ids = new Set(items.map((node) => node.id));
|
|
430
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
431
|
+
const roots = [];
|
|
432
|
+
for (const item of items) {
|
|
433
|
+
if (item.parentId && ids.has(item.parentId)) {
|
|
434
|
+
const siblings = childrenByParent.get(item.parentId);
|
|
435
|
+
if (siblings) siblings.push(item);
|
|
436
|
+
else childrenByParent.set(item.parentId, [item]);
|
|
437
|
+
} else {
|
|
438
|
+
roots.push(item);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return /* @__PURE__ */ jsx(TreeRoot, { defaultKey: roots[0]?.id, className, rest, children: roots.map((item) => /* @__PURE__ */ jsx(
|
|
442
|
+
FlatTreeNodeItem,
|
|
443
|
+
{
|
|
444
|
+
item,
|
|
445
|
+
depth: 0,
|
|
446
|
+
indent,
|
|
447
|
+
childrenByParent,
|
|
448
|
+
roots,
|
|
449
|
+
onNodeSelect,
|
|
450
|
+
onNodeAction,
|
|
451
|
+
nodeActionIcon,
|
|
452
|
+
nodeActionLabel,
|
|
453
|
+
onNodeReorder,
|
|
454
|
+
selectedId,
|
|
455
|
+
look,
|
|
456
|
+
isExpanded,
|
|
457
|
+
onToggle
|
|
458
|
+
},
|
|
459
|
+
item.id
|
|
460
|
+
)) });
|
|
461
|
+
};
|
|
462
|
+
var FileTree = ({
|
|
463
|
+
tree,
|
|
464
|
+
items,
|
|
465
|
+
selectedPath,
|
|
466
|
+
selectedId,
|
|
467
|
+
look = "files",
|
|
468
|
+
onFileSelect,
|
|
469
|
+
onNodeExpand,
|
|
470
|
+
expandedPaths,
|
|
471
|
+
onNodeSelect,
|
|
472
|
+
onNodeAction,
|
|
473
|
+
nodeActionIcon,
|
|
474
|
+
nodeActionLabel,
|
|
475
|
+
onNodeReorder,
|
|
476
|
+
className,
|
|
477
|
+
indent = 16,
|
|
478
|
+
...rest
|
|
479
|
+
}) => {
|
|
480
|
+
if (items) {
|
|
481
|
+
return /* @__PURE__ */ jsx(
|
|
482
|
+
FlatFileTree,
|
|
483
|
+
{
|
|
484
|
+
...rest,
|
|
485
|
+
items,
|
|
486
|
+
selectedId,
|
|
487
|
+
look,
|
|
488
|
+
onNodeSelect,
|
|
489
|
+
onNodeAction,
|
|
490
|
+
nodeActionIcon,
|
|
491
|
+
nodeActionLabel,
|
|
492
|
+
onNodeReorder,
|
|
493
|
+
className,
|
|
494
|
+
indent
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
if (!tree || tree.length === 0) return null;
|
|
499
|
+
return /* @__PURE__ */ jsx(TreeRoot, { defaultKey: tree[0]?.path, className, rest, children: tree.map((node) => /* @__PURE__ */ jsx(
|
|
500
|
+
TreeNodeItem,
|
|
501
|
+
{
|
|
502
|
+
node,
|
|
503
|
+
depth: 0,
|
|
504
|
+
indent,
|
|
505
|
+
selectedPath,
|
|
506
|
+
onFileSelect,
|
|
507
|
+
onNodeExpand,
|
|
508
|
+
expandedPaths,
|
|
509
|
+
defaultExpanded: true
|
|
510
|
+
},
|
|
511
|
+
node.path
|
|
512
|
+
)) });
|
|
513
|
+
};
|
|
514
|
+
FileTree.displayName = "FileTree";
|
|
515
|
+
|
|
516
|
+
export { FileTree };
|