@djangocfg/ui-tools 2.1.390 → 2.1.394

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.
Files changed (184) hide show
  1. package/README.md +7 -10
  2. package/dist/chunk-PAWJFY3S.mjs +6 -0
  3. package/dist/{chunk-N2XQF2OL.mjs.map → chunk-PAWJFY3S.mjs.map} +1 -1
  4. package/dist/chunk-PK6SKIKE.cjs +8 -0
  5. package/dist/{chunk-OLISEQHS.cjs.map → chunk-PK6SKIKE.cjs.map} +1 -1
  6. package/dist/file-icon/index.cjs +6 -6
  7. package/dist/file-icon/index.d.cts +1 -1
  8. package/dist/file-icon/index.d.ts +1 -1
  9. package/dist/file-icon/index.mjs +1 -1
  10. package/dist/tree/index.cjs +1372 -143
  11. package/dist/tree/index.cjs.map +1 -1
  12. package/dist/tree/index.d.cts +2 -2
  13. package/dist/tree/index.d.ts +2 -2
  14. package/dist/tree/index.mjs +1322 -3
  15. package/dist/tree/index.mjs.map +1 -1
  16. package/dist/{types-CevSbyfD.d.cts → types-B_zhyAqR.d.cts} +1 -1
  17. package/dist/{types-CevSbyfD.d.ts → types-B_zhyAqR.d.ts} +1 -1
  18. package/package.json +6 -14
  19. package/src/tools/AudioPlayer/README.md +4 -4
  20. package/src/tools/Chat/README.md +6 -6
  21. package/src/tools/CronScheduler/index.tsx +1 -1
  22. package/src/tools/CronScheduler/lazy.tsx +1 -1
  23. package/src/tools/ImageViewer/README.md +1 -1
  24. package/src/tools/JsonForm/README.md +2 -2
  25. package/src/tools/MarkdownEditor/README.md +3 -3
  26. package/src/tools/MarkdownMessage/README.md +2 -2
  27. package/src/tools/OpenapiViewer/components/DocsLayout/grouping.ts +5 -1
  28. package/src/tools/PrettyCode/lazy.tsx +6 -0
  29. package/src/tools/SpeechRecognition/README.md +1 -1
  30. package/dist/ChatRoot-EFNXQXXN.cjs +0 -15
  31. package/dist/ChatRoot-EFNXQXXN.cjs.map +0 -1
  32. package/dist/ChatRoot-FITF5RVP.mjs +0 -6
  33. package/dist/ChatRoot-FITF5RVP.mjs.map +0 -1
  34. package/dist/ChatRoot-PNNGQCYF.css +0 -7
  35. package/dist/ChatRoot-PNNGQCYF.css.map +0 -1
  36. package/dist/CronScheduler.client-DLMXCPAJ.mjs +0 -67
  37. package/dist/CronScheduler.client-DLMXCPAJ.mjs.map +0 -1
  38. package/dist/CronScheduler.client-WEJF4PWQ.cjs +0 -72
  39. package/dist/CronScheduler.client-WEJF4PWQ.cjs.map +0 -1
  40. package/dist/DictationField-AS2F33WI.cjs +0 -13
  41. package/dist/DictationField-AS2F33WI.cjs.map +0 -1
  42. package/dist/DictationField-WPONUCYE.mjs +0 -4
  43. package/dist/DictationField-WPONUCYE.mjs.map +0 -1
  44. package/dist/DocsLayout-EKASBSP7.mjs +0 -3448
  45. package/dist/DocsLayout-EKASBSP7.mjs.map +0 -1
  46. package/dist/DocsLayout-MBFIB4NO.css +0 -7
  47. package/dist/DocsLayout-MBFIB4NO.css.map +0 -1
  48. package/dist/DocsLayout-OURFYWQE.cjs +0 -3455
  49. package/dist/DocsLayout-OURFYWQE.cjs.map +0 -1
  50. package/dist/JsonSchemaForm-DD7CLRIG.cjs +0 -13
  51. package/dist/JsonSchemaForm-DD7CLRIG.cjs.map +0 -1
  52. package/dist/JsonSchemaForm-XKUIVELK.mjs +0 -4
  53. package/dist/JsonSchemaForm-XKUIVELK.mjs.map +0 -1
  54. package/dist/JsonTree-43PQAJKY.mjs +0 -5
  55. package/dist/JsonTree-43PQAJKY.mjs.map +0 -1
  56. package/dist/JsonTree-MLET23ZA.css +0 -7
  57. package/dist/JsonTree-MLET23ZA.css.map +0 -1
  58. package/dist/JsonTree-X6W5YEVY.cjs +0 -11
  59. package/dist/JsonTree-X6W5YEVY.cjs.map +0 -1
  60. package/dist/LottiePlayer.client-2S7ISJ2S.cjs +0 -168
  61. package/dist/LottiePlayer.client-2S7ISJ2S.cjs.map +0 -1
  62. package/dist/LottiePlayer.client-5LDSSJWS.mjs +0 -161
  63. package/dist/LottiePlayer.client-5LDSSJWS.mjs.map +0 -1
  64. package/dist/MapContainer-AKIPABJK.mjs +0 -4
  65. package/dist/MapContainer-AKIPABJK.mjs.map +0 -1
  66. package/dist/MapContainer-STVDMC36.cjs +0 -17
  67. package/dist/MapContainer-STVDMC36.cjs.map +0 -1
  68. package/dist/Mermaid.client-DDXWXZXY.css +0 -7
  69. package/dist/Mermaid.client-DDXWXZXY.css.map +0 -1
  70. package/dist/Mermaid.client-NL4SVR7F.mjs +0 -481
  71. package/dist/Mermaid.client-NL4SVR7F.mjs.map +0 -1
  72. package/dist/Mermaid.client-NNTI6DFX.cjs +0 -487
  73. package/dist/Mermaid.client-NNTI6DFX.cjs.map +0 -1
  74. package/dist/Player-BRV7XTWR.mjs +0 -4
  75. package/dist/Player-BRV7XTWR.mjs.map +0 -1
  76. package/dist/Player-PM7F7DD7.cjs +0 -13
  77. package/dist/Player-PM7F7DD7.cjs.map +0 -1
  78. package/dist/Player-ZGQKKOWI.css +0 -66
  79. package/dist/Player-ZGQKKOWI.css.map +0 -1
  80. package/dist/PrettyCode.client-GWFAIVFN.css +0 -7
  81. package/dist/PrettyCode.client-GWFAIVFN.css.map +0 -1
  82. package/dist/PrettyCode.client-KOHDVPPN.cjs +0 -285
  83. package/dist/PrettyCode.client-KOHDVPPN.cjs.map +0 -1
  84. package/dist/PrettyCode.client-ZGYGKE7G.mjs +0 -283
  85. package/dist/PrettyCode.client-ZGYGKE7G.mjs.map +0 -1
  86. package/dist/TreeRoot-5COOOSWG.mjs +0 -4
  87. package/dist/TreeRoot-5COOOSWG.mjs.map +0 -1
  88. package/dist/TreeRoot-AABP2J6Y.cjs +0 -19
  89. package/dist/TreeRoot-AABP2J6Y.cjs.map +0 -1
  90. package/dist/chunk-2NG4SXEP.mjs +0 -743
  91. package/dist/chunk-2NG4SXEP.mjs.map +0 -1
  92. package/dist/chunk-4LFB7I5K.cjs +0 -1387
  93. package/dist/chunk-4LFB7I5K.cjs.map +0 -1
  94. package/dist/chunk-5D2OCOPQ.cjs +0 -222
  95. package/dist/chunk-5D2OCOPQ.cjs.map +0 -1
  96. package/dist/chunk-5I5QNGUG.cjs +0 -611
  97. package/dist/chunk-5I5QNGUG.cjs.map +0 -1
  98. package/dist/chunk-6ZX2G25W.mjs +0 -1361
  99. package/dist/chunk-6ZX2G25W.mjs.map +0 -1
  100. package/dist/chunk-76NNDZH6.cjs +0 -1061
  101. package/dist/chunk-76NNDZH6.cjs.map +0 -1
  102. package/dist/chunk-7CWGZPO3.mjs +0 -214
  103. package/dist/chunk-7CWGZPO3.mjs.map +0 -1
  104. package/dist/chunk-7EYHNP3E.cjs +0 -965
  105. package/dist/chunk-7EYHNP3E.cjs.map +0 -1
  106. package/dist/chunk-7IYXZUJO.cjs +0 -769
  107. package/dist/chunk-7IYXZUJO.cjs.map +0 -1
  108. package/dist/chunk-ADEN3UA4.cjs +0 -892
  109. package/dist/chunk-ADEN3UA4.cjs.map +0 -1
  110. package/dist/chunk-B6IR5KSC.mjs +0 -59
  111. package/dist/chunk-B6IR5KSC.mjs.map +0 -1
  112. package/dist/chunk-C6GXVH5J.mjs +0 -338
  113. package/dist/chunk-C6GXVH5J.mjs.map +0 -1
  114. package/dist/chunk-DMX7W4XZ.mjs +0 -1113
  115. package/dist/chunk-DMX7W4XZ.mjs.map +0 -1
  116. package/dist/chunk-ECONRHIG.mjs +0 -212
  117. package/dist/chunk-ECONRHIG.mjs.map +0 -1
  118. package/dist/chunk-FEN5S772.cjs +0 -1227
  119. package/dist/chunk-FEN5S772.cjs.map +0 -1
  120. package/dist/chunk-FP2RLYQZ.cjs +0 -187
  121. package/dist/chunk-FP2RLYQZ.cjs.map +0 -1
  122. package/dist/chunk-FVVF7VCD.cjs +0 -1325
  123. package/dist/chunk-FVVF7VCD.cjs.map +0 -1
  124. package/dist/chunk-GYIO7W7M.mjs +0 -1197
  125. package/dist/chunk-GYIO7W7M.mjs.map +0 -1
  126. package/dist/chunk-KNDLV4PI.cjs +0 -1356
  127. package/dist/chunk-KNDLV4PI.cjs.map +0 -1
  128. package/dist/chunk-KNEQRUBA.mjs +0 -181
  129. package/dist/chunk-KNEQRUBA.mjs.map +0 -1
  130. package/dist/chunk-N2XQF2OL.mjs +0 -14
  131. package/dist/chunk-N4MZYNR4.mjs +0 -1342
  132. package/dist/chunk-N4MZYNR4.mjs.map +0 -1
  133. package/dist/chunk-NTVBIIUD.mjs +0 -1439
  134. package/dist/chunk-NTVBIIUD.mjs.map +0 -1
  135. package/dist/chunk-OBRSGM64.mjs +0 -607
  136. package/dist/chunk-OBRSGM64.mjs.map +0 -1
  137. package/dist/chunk-ODO4GMW7.mjs +0 -79
  138. package/dist/chunk-ODO4GMW7.mjs.map +0 -1
  139. package/dist/chunk-OLISEQHS.cjs +0 -18
  140. package/dist/chunk-PVAX67JG.mjs +0 -1041
  141. package/dist/chunk-PVAX67JG.mjs.map +0 -1
  142. package/dist/chunk-QJ6GTUCO.cjs +0 -81
  143. package/dist/chunk-QJ6GTUCO.cjs.map +0 -1
  144. package/dist/chunk-T3MWM23F.cjs +0 -214
  145. package/dist/chunk-T3MWM23F.cjs.map +0 -1
  146. package/dist/chunk-TBSHZO5R.cjs +0 -1134
  147. package/dist/chunk-TBSHZO5R.cjs.map +0 -1
  148. package/dist/chunk-UNCS5V5F.mjs +0 -887
  149. package/dist/chunk-UNCS5V5F.mjs.map +0 -1
  150. package/dist/chunk-VWQ5WOIL.mjs +0 -2059
  151. package/dist/chunk-VWQ5WOIL.mjs.map +0 -1
  152. package/dist/chunk-W75B7Y6C.cjs +0 -1478
  153. package/dist/chunk-W75B7Y6C.cjs.map +0 -1
  154. package/dist/chunk-Y6UTOBF6.mjs +0 -938
  155. package/dist/chunk-Y6UTOBF6.mjs.map +0 -1
  156. package/dist/chunk-YDPDTOSP.cjs +0 -2061
  157. package/dist/chunk-YDPDTOSP.cjs.map +0 -1
  158. package/dist/chunk-YW5IVWHQ.cjs +0 -346
  159. package/dist/chunk-YW5IVWHQ.cjs.map +0 -1
  160. package/dist/chunk-YXZ6GU7H.cjs +0 -63
  161. package/dist/chunk-YXZ6GU7H.cjs.map +0 -1
  162. package/dist/chunk-ZL7FH4NW.mjs +0 -1274
  163. package/dist/chunk-ZL7FH4NW.mjs.map +0 -1
  164. package/dist/components-EHOGXATG.cjs +0 -22
  165. package/dist/components-EHOGXATG.cjs.map +0 -1
  166. package/dist/components-MQ6DR7TX.cjs +0 -26
  167. package/dist/components-MQ6DR7TX.cjs.map +0 -1
  168. package/dist/components-XRX7QGLB.mjs +0 -5
  169. package/dist/components-XRX7QGLB.mjs.map +0 -1
  170. package/dist/components-YATKRWLH.mjs +0 -5
  171. package/dist/components-YATKRWLH.mjs.map +0 -1
  172. package/dist/index.cjs +0 -3674
  173. package/dist/index.cjs.map +0 -1
  174. package/dist/index.css +0 -234
  175. package/dist/index.css.map +0 -1
  176. package/dist/index.d.cts +0 -4929
  177. package/dist/index.d.ts +0 -4929
  178. package/dist/index.mjs +0 -2912
  179. package/dist/index.mjs.map +0 -1
  180. package/dist/launcher-5Y42OBSN.mjs +0 -6
  181. package/dist/launcher-5Y42OBSN.mjs.map +0 -1
  182. package/dist/launcher-PMW2YB24.cjs +0 -59
  183. package/dist/launcher-PMW2YB24.cjs.map +0 -1
  184. package/src/index.ts +0 -157
@@ -2,151 +2,1380 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var chunkYXZ6GU7H_cjs = require('../chunk-YXZ6GU7H.cjs');
6
- var chunkFVVF7VCD_cjs = require('../chunk-FVVF7VCD.cjs');
7
- require('../chunk-OLISEQHS.cjs');
5
+ var chunkPK6SKIKE_cjs = require('../chunk-PK6SKIKE.cjs');
6
+ var React = require('react');
7
+ var lib = require('@djangocfg/ui-core/lib');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var lucideReact = require('lucide-react');
10
+ var hooks = require('@djangocfg/ui-core/hooks');
8
11
 
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
9
29
 
30
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
10
31
 
11
- Object.defineProperty(exports, "TreeError", {
12
- enumerable: true,
13
- get: function () { return chunkYXZ6GU7H_cjs.TreeError; }
14
- });
15
- Object.defineProperty(exports, "TreeSkeleton", {
16
- enumerable: true,
17
- get: function () { return chunkYXZ6GU7H_cjs.TreeSkeleton; }
18
- });
19
- Object.defineProperty(exports, "createDemoTree", {
20
- enumerable: true,
21
- get: function () { return chunkYXZ6GU7H_cjs.createDemoTree; }
22
- });
23
- Object.defineProperty(exports, "DEFAULT_TREE_APPEARANCE", {
24
- enumerable: true,
25
- get: function () { return chunkFVVF7VCD_cjs.DEFAULT_TREE_APPEARANCE; }
26
- });
27
- Object.defineProperty(exports, "DEFAULT_TREE_LABELS", {
28
- enumerable: true,
29
- get: function () { return chunkFVVF7VCD_cjs.DEFAULT_TREE_LABELS; }
30
- });
31
- Object.defineProperty(exports, "Tree", {
32
- enumerable: true,
33
- get: function () { return chunkFVVF7VCD_cjs.TreeRoot; }
34
- });
35
- Object.defineProperty(exports, "TreeChevron", {
36
- enumerable: true,
37
- get: function () { return chunkFVVF7VCD_cjs.TreeChevron; }
38
- });
39
- Object.defineProperty(exports, "TreeContent", {
40
- enumerable: true,
41
- get: function () { return chunkFVVF7VCD_cjs.TreeContent; }
42
- });
43
- Object.defineProperty(exports, "TreeEmpty", {
44
- enumerable: true,
45
- get: function () { return chunkFVVF7VCD_cjs.TreeEmpty; }
46
- });
47
- Object.defineProperty(exports, "TreeIcon", {
48
- enumerable: true,
49
- get: function () { return chunkFVVF7VCD_cjs.TreeIcon; }
50
- });
51
- Object.defineProperty(exports, "TreeIndentGuides", {
52
- enumerable: true,
53
- get: function () { return chunkFVVF7VCD_cjs.TreeIndentGuides; }
54
- });
55
- Object.defineProperty(exports, "TreeLabel", {
56
- enumerable: true,
57
- get: function () { return chunkFVVF7VCD_cjs.TreeLabel; }
58
- });
59
- Object.defineProperty(exports, "TreeProvider", {
60
- enumerable: true,
61
- get: function () { return chunkFVVF7VCD_cjs.TreeProvider; }
62
- });
63
- Object.defineProperty(exports, "TreeRoot", {
64
- enumerable: true,
65
- get: function () { return chunkFVVF7VCD_cjs.TreeRoot; }
66
- });
67
- Object.defineProperty(exports, "TreeRow", {
68
- enumerable: true,
69
- get: function () { return chunkFVVF7VCD_cjs.TreeRow; }
70
- });
71
- Object.defineProperty(exports, "TreeSearchInput", {
72
- enumerable: true,
73
- get: function () { return chunkFVVF7VCD_cjs.TreeSearchInput; }
74
- });
75
- Object.defineProperty(exports, "appearanceToStyle", {
76
- enumerable: true,
77
- get: function () { return chunkFVVF7VCD_cjs.appearanceToStyle; }
78
- });
79
- Object.defineProperty(exports, "clearTreeState", {
80
- enumerable: true,
81
- get: function () { return chunkFVVF7VCD_cjs.clearTreeState; }
82
- });
83
- Object.defineProperty(exports, "createChildCache", {
84
- enumerable: true,
85
- get: function () { return chunkFVVF7VCD_cjs.createChildCache; }
86
- });
87
- Object.defineProperty(exports, "default", {
88
- enumerable: true,
89
- get: function () { return chunkFVVF7VCD_cjs.TreeRoot_default; }
90
- });
91
- Object.defineProperty(exports, "flattenTree", {
92
- enumerable: true,
93
- get: function () { return chunkFVVF7VCD_cjs.flattenTree; }
94
- });
95
- Object.defineProperty(exports, "loadTreeState", {
96
- enumerable: true,
97
- get: function () { return chunkFVVF7VCD_cjs.loadTreeState; }
98
- });
99
- Object.defineProperty(exports, "resolveAppearance", {
100
- enumerable: true,
101
- get: function () { return chunkFVVF7VCD_cjs.resolveAppearance; }
102
- });
103
- Object.defineProperty(exports, "resolveChildren", {
104
- enumerable: true,
105
- get: function () { return chunkFVVF7VCD_cjs.resolveChildren; }
106
- });
107
- Object.defineProperty(exports, "saveTreeState", {
108
- enumerable: true,
109
- get: function () { return chunkFVVF7VCD_cjs.saveTreeState; }
110
- });
111
- Object.defineProperty(exports, "useTreeActions", {
112
- enumerable: true,
113
- get: function () { return chunkFVVF7VCD_cjs.useTreeActions; }
114
- });
115
- Object.defineProperty(exports, "useTreeContext", {
116
- enumerable: true,
117
- get: function () { return chunkFVVF7VCD_cjs.useTreeContext; }
118
- });
119
- Object.defineProperty(exports, "useTreeExpansion", {
120
- enumerable: true,
121
- get: function () { return chunkFVVF7VCD_cjs.useTreeExpansion; }
122
- });
123
- Object.defineProperty(exports, "useTreeFocus", {
124
- enumerable: true,
125
- get: function () { return chunkFVVF7VCD_cjs.useTreeFocus; }
126
- });
127
- Object.defineProperty(exports, "useTreeKeyboard", {
128
- enumerable: true,
129
- get: function () { return chunkFVVF7VCD_cjs.useTreeKeyboard; }
130
- });
131
- Object.defineProperty(exports, "useTreeLabels", {
132
- enumerable: true,
133
- get: function () { return chunkFVVF7VCD_cjs.useTreeLabels; }
134
- });
135
- Object.defineProperty(exports, "useTreeRows", {
136
- enumerable: true,
137
- get: function () { return chunkFVVF7VCD_cjs.useTreeRows; }
138
- });
139
- Object.defineProperty(exports, "useTreeSearch", {
140
- enumerable: true,
141
- get: function () { return chunkFVVF7VCD_cjs.useTreeSearch; }
142
- });
143
- Object.defineProperty(exports, "useTreeSelection", {
144
- enumerable: true,
145
- get: function () { return chunkFVVF7VCD_cjs.useTreeSelection; }
146
- });
147
- Object.defineProperty(exports, "useTreeTypeAhead", {
148
- enumerable: true,
149
- get: function () { return chunkFVVF7VCD_cjs.useTreeTypeAhead; }
150
- });
32
+ // src/tools/Tree/types.ts
33
+ var DEFAULT_TREE_LABELS = {
34
+ loading: "Loading\u2026",
35
+ empty: "Nothing to show",
36
+ error: "Failed to load",
37
+ searchPlaceholder: "Search\u2026",
38
+ searchMatches: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((n) => `${n} match${n === 1 ? "" : "es"}`, "searchMatches"),
39
+ ariaLabel: "Tree"
40
+ };
41
+
42
+ // src/tools/Tree/data/childCache.ts
43
+ var createChildCache = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name(() => /* @__PURE__ */ new Map(), "createChildCache");
44
+ var resolveChildren = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((cache, node) => {
45
+ if (Array.isArray(node.children)) {
46
+ return { children: node.children, status: "loaded" };
47
+ }
48
+ const entry = cache.get(node.id);
49
+ if (!entry) return { children: null, status: "idle" };
50
+ if (entry.status === "loaded") {
51
+ return { children: entry.children, status: "loaded" };
52
+ }
53
+ return { children: null, status: entry.status, error: entry.error };
54
+ }, "resolveChildren");
55
+
56
+ // src/tools/Tree/data/flatten.ts
57
+ var isNodeFolder = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((node) => {
58
+ if (typeof node.isFolder === "boolean") return node.isFolder;
59
+ return Array.isArray(node.children);
60
+ }, "isNodeFolder");
61
+ function flattenTree({
62
+ roots,
63
+ expandedIds,
64
+ cache,
65
+ filterNode
66
+ }) {
67
+ const out = [];
68
+ const walk = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((nodes, level, parentId) => {
69
+ for (const node of nodes) {
70
+ if (filterNode && !filterNode(node)) continue;
71
+ const isFolder = isNodeFolder(node);
72
+ const isExpanded = expandedIds.has(node.id);
73
+ const resolved = isFolder ? resolveChildren(cache, node) : { children: [], status: "loaded" };
74
+ out.push({
75
+ node,
76
+ level,
77
+ parentId,
78
+ isFolder,
79
+ isExpanded,
80
+ isLoading: resolved.status === "loading",
81
+ hasError: resolved.status === "error"
82
+ });
83
+ if (isFolder && isExpanded && resolved.children) {
84
+ walk(resolved.children, level + 1, node.id);
85
+ }
86
+ }
87
+ }, "walk");
88
+ walk(roots, 0, null);
89
+ return out;
90
+ }
91
+ chunkPK6SKIKE_cjs.__name(flattenTree, "flattenTree");
92
+
93
+ // src/tools/Tree/data/persist.ts
94
+ var KEY_PREFIX = "@djangocfg/tree:";
95
+ var VERSION = 1;
96
+ function safeStorage() {
97
+ if (typeof window === "undefined") return null;
98
+ try {
99
+ return window.localStorage;
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+ chunkPK6SKIKE_cjs.__name(safeStorage, "safeStorage");
105
+ function loadTreeState(key) {
106
+ const storage = safeStorage();
107
+ if (!storage) return null;
108
+ try {
109
+ const raw = storage.getItem(KEY_PREFIX + key);
110
+ if (!raw) return null;
111
+ const parsed = JSON.parse(raw);
112
+ if (parsed.version !== VERSION) return null;
113
+ return {
114
+ expandedItems: Array.isArray(parsed.expandedItems) ? parsed.expandedItems : [],
115
+ selectedItems: Array.isArray(parsed.selectedItems) ? parsed.selectedItems : []
116
+ };
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+ chunkPK6SKIKE_cjs.__name(loadTreeState, "loadTreeState");
122
+ function saveTreeState(key, state) {
123
+ const storage = safeStorage();
124
+ if (!storage) return;
125
+ try {
126
+ const payload = { ...state, version: VERSION };
127
+ storage.setItem(KEY_PREFIX + key, JSON.stringify(payload));
128
+ } catch {
129
+ }
130
+ }
131
+ chunkPK6SKIKE_cjs.__name(saveTreeState, "saveTreeState");
132
+ function clearTreeState(key) {
133
+ const storage = safeStorage();
134
+ if (!storage) return;
135
+ try {
136
+ storage.removeItem(KEY_PREFIX + key);
137
+ } catch {
138
+ }
139
+ }
140
+ chunkPK6SKIKE_cjs.__name(clearTreeState, "clearTreeState");
141
+
142
+ // src/tools/Tree/data/appearance.ts
143
+ var DENSITY_PRESETS = {
144
+ compact: { rowHeight: 24, iconSize: 14, fontSize: 13, gap: 6 },
145
+ cozy: { rowHeight: 28, iconSize: 16, fontSize: 13, gap: 8 },
146
+ comfortable: { rowHeight: 32, iconSize: 16, fontSize: 14, gap: 8 }
147
+ };
148
+ var DEFAULT_TREE_APPEARANCE = {
149
+ density: "cozy",
150
+ ...DENSITY_PRESETS.cozy,
151
+ iconStrokeWidth: 1.5,
152
+ indent: 16,
153
+ accent: "default",
154
+ radius: "sm",
155
+ indentGuideOpacity: 0.4,
156
+ showActiveIndicator: true
157
+ };
158
+ function resolveAppearance(input, outerIndent) {
159
+ if (!input && outerIndent === void 0) return DEFAULT_TREE_APPEARANCE;
160
+ const density = input?.density ?? "cozy";
161
+ const preset = DENSITY_PRESETS[density];
162
+ return {
163
+ density,
164
+ rowHeight: input?.rowHeight ?? preset.rowHeight,
165
+ iconSize: input?.iconSize ?? preset.iconSize,
166
+ iconStrokeWidth: input?.iconStrokeWidth ?? DEFAULT_TREE_APPEARANCE.iconStrokeWidth,
167
+ fontSize: input?.fontSize ?? preset.fontSize,
168
+ gap: input?.gap ?? preset.gap,
169
+ indent: input?.indent ?? outerIndent ?? DEFAULT_TREE_APPEARANCE.indent,
170
+ accent: input?.accent ?? DEFAULT_TREE_APPEARANCE.accent,
171
+ radius: input?.radius ?? DEFAULT_TREE_APPEARANCE.radius,
172
+ indentGuideOpacity: input?.indentGuideOpacity ?? DEFAULT_TREE_APPEARANCE.indentGuideOpacity,
173
+ showActiveIndicator: input?.showActiveIndicator ?? DEFAULT_TREE_APPEARANCE.showActiveIndicator
174
+ };
175
+ }
176
+ chunkPK6SKIKE_cjs.__name(resolveAppearance, "resolveAppearance");
177
+ function appearanceToStyle(a) {
178
+ return {
179
+ ["--tree-row-height"]: `${a.rowHeight}px`,
180
+ ["--tree-icon-size"]: `${a.iconSize}px`,
181
+ ["--tree-icon-stroke"]: a.iconStrokeWidth,
182
+ ["--tree-font-size"]: `${a.fontSize}px`,
183
+ ["--tree-gap"]: `${a.gap}px`,
184
+ ["--tree-indent"]: `${a.indent}px`,
185
+ ["--tree-guide-opacity"]: a.indentGuideOpacity
186
+ };
187
+ }
188
+ chunkPK6SKIKE_cjs.__name(appearanceToStyle, "appearanceToStyle");
189
+ var RADIUS_CLASS = {
190
+ none: "rounded-none",
191
+ sm: "rounded-sm",
192
+ md: "rounded-md"
193
+ };
194
+ function radiusClass(a) {
195
+ return RADIUS_CLASS[a.radius];
196
+ }
197
+ chunkPK6SKIKE_cjs.__name(radiusClass, "radiusClass");
198
+ var HOVER = {
199
+ subtle: "hover:bg-foreground/[.03]",
200
+ default: "hover:bg-foreground/[.06]",
201
+ strong: "hover:bg-foreground/[.09]"
202
+ };
203
+ var FOCUSED_NOT_SELECTED = {
204
+ subtle: "data-[focused=true]:bg-foreground/[.05]",
205
+ default: "data-[focused=true]:bg-foreground/[.08]",
206
+ strong: "data-[focused=true]:bg-foreground/[.12]"
207
+ };
208
+ var SELECTED_INACTIVE = {
209
+ subtle: "data-[selected=true]:bg-foreground/[.06]",
210
+ default: "data-[selected=true]:bg-foreground/[.10]",
211
+ strong: "data-[selected=true]:bg-foreground/[.14]"
212
+ };
213
+ var SELECTED_ACTIVE = {
214
+ subtle: "data-[selected=true]:group-focus-within/tree:bg-primary/10 data-[selected=true]:group-focus-within/tree:text-primary",
215
+ default: "data-[selected=true]:group-focus-within/tree:bg-primary/15 data-[selected=true]:group-focus-within/tree:text-primary",
216
+ strong: "data-[selected=true]:group-focus-within/tree:bg-primary/25 data-[selected=true]:group-focus-within/tree:text-primary"
217
+ };
218
+ function rowStateClasses(a) {
219
+ return [
220
+ HOVER[a.accent],
221
+ FOCUSED_NOT_SELECTED[a.accent],
222
+ SELECTED_INACTIVE[a.accent],
223
+ SELECTED_ACTIVE[a.accent]
224
+ ].join(" ");
225
+ }
226
+ chunkPK6SKIKE_cjs.__name(rowStateClasses, "rowStateClasses");
227
+ var reducer = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((state, action) => {
228
+ switch (action.type) {
229
+ case "expand": {
230
+ if (state.expanded.has(action.id)) return state;
231
+ const next = new Set(state.expanded);
232
+ next.add(action.id);
233
+ return { ...state, expanded: next };
234
+ }
235
+ case "collapse": {
236
+ if (!state.expanded.has(action.id)) return state;
237
+ const next = new Set(state.expanded);
238
+ next.delete(action.id);
239
+ return { ...state, expanded: next };
240
+ }
241
+ case "toggle": {
242
+ const next = new Set(state.expanded);
243
+ if (next.has(action.id)) next.delete(action.id);
244
+ else next.add(action.id);
245
+ return { ...state, expanded: next };
246
+ }
247
+ case "set-expanded":
248
+ return { ...state, expanded: new Set(action.ids) };
249
+ case "select": {
250
+ if (action.mode === "none") return state;
251
+ if (action.mode === "single") {
252
+ return { ...state, selected: /* @__PURE__ */ new Set([action.id]), focused: action.id };
253
+ }
254
+ const next = new Set(state.selected);
255
+ if (next.has(action.id)) next.delete(action.id);
256
+ else next.add(action.id);
257
+ return { ...state, selected: next, focused: action.id };
258
+ }
259
+ case "select-many":
260
+ return { ...state, selected: new Set(action.ids) };
261
+ case "clear-selection":
262
+ return { ...state, selected: /* @__PURE__ */ new Set() };
263
+ case "focus":
264
+ return { ...state, focused: action.id };
265
+ case "set-query":
266
+ return { ...state, query: action.q };
267
+ case "cache-tick":
268
+ return { ...state, cacheTick: state.cacheTick + 1 };
269
+ default:
270
+ return state;
271
+ }
272
+ }, "reducer");
273
+ var TreeContext = React.createContext(null);
274
+ function useTreeContext() {
275
+ const ctx = React__namespace.useContext(TreeContext);
276
+ if (!ctx) {
277
+ throw new Error("useTreeContext must be used inside <TreeProvider>");
278
+ }
279
+ return ctx;
280
+ }
281
+ chunkPK6SKIKE_cjs.__name(useTreeContext, "useTreeContext");
282
+ var setEqualsArr = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((set, arr) => {
283
+ if (set.size !== arr.length) return false;
284
+ for (const id of arr) if (!set.has(id)) return false;
285
+ return true;
286
+ }, "setEqualsArr");
287
+ var collectAllIds = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((roots, cache, out) => {
288
+ for (const node of roots) {
289
+ if (Array.isArray(node.children)) {
290
+ out.push(node.id);
291
+ collectAllIds(node.children, cache, out);
292
+ } else if (node.isFolder) {
293
+ out.push(node.id);
294
+ const entry = cache.get(node.id);
295
+ if (entry?.children) collectAllIds(entry.children, cache, out);
296
+ }
297
+ }
298
+ }, "collectAllIds");
299
+ function TreeProvider(props) {
300
+ const {
301
+ data,
302
+ getItemName,
303
+ loadChildren,
304
+ selectionMode = "single",
305
+ activationMode = "single-click",
306
+ initialExpandedIds,
307
+ initialSelectedIds,
308
+ indent,
309
+ appearance,
310
+ onSelectionChange,
311
+ onExpansionChange,
312
+ onActivate,
313
+ filterNode,
314
+ enableSearch = false,
315
+ showIndentGuides = false,
316
+ renderIcon,
317
+ renderLabel,
318
+ renderActions,
319
+ renderContextMenu,
320
+ labels: labelsOverride,
321
+ persistKey,
322
+ persistSelection = false,
323
+ children
324
+ } = props;
325
+ const labels = React.useMemo(
326
+ () => ({ ...DEFAULT_TREE_LABELS, ...labelsOverride }),
327
+ [labelsOverride]
328
+ );
329
+ const resolvedAppearance = React.useMemo(
330
+ () => resolveAppearance(appearance, indent),
331
+ [appearance, indent]
332
+ );
333
+ const persisted = React.useMemo(
334
+ () => persistKey ? loadTreeState(persistKey) : null,
335
+ [persistKey]
336
+ );
337
+ const [state, dispatch] = React.useReducer(reducer, void 0, () => ({
338
+ expanded: new Set(persisted?.expandedItems ?? initialExpandedIds ?? []),
339
+ selected: new Set(
340
+ (persistSelection ? persisted?.selectedItems : void 0) ?? initialSelectedIds ?? []
341
+ ),
342
+ focused: null,
343
+ query: "",
344
+ cacheTick: 0
345
+ }));
346
+ const cacheRef = React.useRef(createChildCache());
347
+ const inflightRef = React.useRef(/* @__PURE__ */ new Map());
348
+ const fetchChildren = React.useCallback(
349
+ async (node) => {
350
+ if (!loadChildren) return;
351
+ if (Array.isArray(node.children)) return;
352
+ const existing = cacheRef.current.get(node.id);
353
+ if (existing?.status === "loaded" || existing?.status === "loading") return;
354
+ const inflight = inflightRef.current.get(node.id);
355
+ if (inflight) return inflight;
356
+ cacheRef.current.set(node.id, { status: "loading", children: [] });
357
+ dispatch({ type: "cache-tick" });
358
+ const promise = (async () => {
359
+ try {
360
+ const children2 = await loadChildren(node);
361
+ cacheRef.current.set(node.id, { status: "loaded", children: children2 });
362
+ } catch (err) {
363
+ cacheRef.current.set(node.id, {
364
+ status: "error",
365
+ children: [],
366
+ error: err instanceof Error ? err.message : String(err)
367
+ });
368
+ } finally {
369
+ inflightRef.current.delete(node.id);
370
+ dispatch({ type: "cache-tick" });
371
+ }
372
+ })();
373
+ inflightRef.current.set(node.id, promise);
374
+ return promise;
375
+ },
376
+ [loadChildren]
377
+ );
378
+ const nodeById = React.useMemo(() => {
379
+ const map = /* @__PURE__ */ new Map();
380
+ const walk = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((nodes) => {
381
+ for (const n of nodes) {
382
+ map.set(n.id, n);
383
+ if (Array.isArray(n.children)) walk(n.children);
384
+ else {
385
+ const entry = cacheRef.current.get(n.id);
386
+ if (entry?.children) walk(entry.children);
387
+ }
388
+ }
389
+ }, "walk");
390
+ walk(data);
391
+ return map;
392
+ }, [data, state.cacheTick]);
393
+ React.useEffect(() => {
394
+ if (!loadChildren) return;
395
+ for (const id of state.expanded) {
396
+ const node = nodeById.get(id);
397
+ if (!node) continue;
398
+ void fetchChildren(node);
399
+ }
400
+ }, [loadChildren, state.expanded, state.cacheTick, nodeById, fetchChildren]);
401
+ const flatRows = React.useMemo(
402
+ () => flattenTree({
403
+ roots: data,
404
+ expandedIds: state.expanded,
405
+ cache: cacheRef.current,
406
+ filterNode
407
+ }),
408
+ [data, state.expanded, state.cacheTick, filterNode]
409
+ );
410
+ const matchingIds = React.useMemo(() => {
411
+ const set = /* @__PURE__ */ new Set();
412
+ if (!enableSearch || state.query.trim() === "") return set;
413
+ const q = state.query.trim().toLowerCase();
414
+ for (const row of flatRows) {
415
+ if (getItemName(row.node).toLowerCase().includes(q)) {
416
+ set.add(row.node.id);
417
+ }
418
+ }
419
+ return set;
420
+ }, [enableSearch, state.query, flatRows, getItemName]);
421
+ const onSelectionChangeRef = React.useRef(onSelectionChange);
422
+ const onExpansionChangeRef = React.useRef(onExpansionChange);
423
+ const onActivateRef = React.useRef(onActivate);
424
+ onSelectionChangeRef.current = onSelectionChange;
425
+ onExpansionChangeRef.current = onExpansionChange;
426
+ onActivateRef.current = onActivate;
427
+ const lastSelectedArrRef = React.useRef([...state.selected]);
428
+ const lastExpandedArrRef = React.useRef([...state.expanded]);
429
+ React.useEffect(() => {
430
+ const arr = [...state.expanded];
431
+ if (!setEqualsArr(state.expanded, lastExpandedArrRef.current)) {
432
+ lastExpandedArrRef.current = arr;
433
+ onExpansionChangeRef.current?.(arr);
434
+ if (persistKey) {
435
+ saveTreeState(persistKey, {
436
+ expandedItems: arr,
437
+ selectedItems: persistSelection ? [...state.selected] : []
438
+ });
439
+ }
440
+ }
441
+ }, [state.expanded, persistKey, persistSelection, state.selected]);
442
+ React.useEffect(() => {
443
+ const arr = [...state.selected];
444
+ if (!setEqualsArr(state.selected, lastSelectedArrRef.current)) {
445
+ lastSelectedArrRef.current = arr;
446
+ onSelectionChangeRef.current?.(arr);
447
+ if (persistKey && persistSelection) {
448
+ saveTreeState(persistKey, {
449
+ expandedItems: [...state.expanded],
450
+ selectedItems: arr
451
+ });
452
+ }
453
+ }
454
+ }, [state.selected, persistKey, persistSelection, state.expanded]);
455
+ const expand = React.useCallback((id) => dispatch({ type: "expand", id }), []);
456
+ const collapse = React.useCallback((id) => dispatch({ type: "collapse", id }), []);
457
+ const toggle = React.useCallback((id) => dispatch({ type: "toggle", id }), []);
458
+ const expandAll = React.useCallback(() => {
459
+ const ids = [];
460
+ collectAllIds(data, cacheRef.current, ids);
461
+ dispatch({ type: "set-expanded", ids });
462
+ }, [data]);
463
+ const collapseAll = React.useCallback(
464
+ () => dispatch({ type: "set-expanded", ids: [] }),
465
+ []
466
+ );
467
+ const select = React.useCallback(
468
+ (id) => dispatch({ type: "select", id, mode: selectionMode }),
469
+ [selectionMode]
470
+ );
471
+ const setSelectedIds = React.useCallback(
472
+ (ids) => dispatch({ type: "select-many", ids }),
473
+ []
474
+ );
475
+ const clearSelection = React.useCallback(() => dispatch({ type: "clear-selection" }), []);
476
+ const setFocus = React.useCallback(
477
+ (id) => dispatch({ type: "focus", id }),
478
+ []
479
+ );
480
+ const setQuery = React.useCallback((q) => dispatch({ type: "set-query", q }), []);
481
+ const refresh = React.useCallback(
482
+ async (id) => {
483
+ const node = nodeById.get(id);
484
+ if (!node || !loadChildren) return;
485
+ cacheRef.current.delete(id);
486
+ dispatch({ type: "cache-tick" });
487
+ await fetchChildren(node);
488
+ },
489
+ [nodeById, loadChildren, fetchChildren]
490
+ );
491
+ const refreshAll = React.useCallback(async () => {
492
+ cacheRef.current.clear();
493
+ dispatch({ type: "cache-tick" });
494
+ if (!loadChildren) return;
495
+ await Promise.all(
496
+ [...state.expanded].map((id) => {
497
+ const node = nodeById.get(id);
498
+ return node ? fetchChildren(node) : void 0;
499
+ })
500
+ );
501
+ }, [loadChildren, state.expanded, nodeById, fetchChildren]);
502
+ const activate = React.useCallback(
503
+ (node, opts = { preview: false }) => onActivateRef.current?.(node, opts),
504
+ []
505
+ );
506
+ const value = React.useMemo(
507
+ () => ({
508
+ expanded: state.expanded,
509
+ selected: state.selected,
510
+ focused: state.focused,
511
+ query: state.query,
512
+ flatRows,
513
+ matchingIds,
514
+ expand,
515
+ collapse,
516
+ toggle,
517
+ expandAll,
518
+ collapseAll,
519
+ select,
520
+ setSelectedIds,
521
+ clearSelection,
522
+ setFocus,
523
+ setQuery,
524
+ refresh,
525
+ refreshAll,
526
+ activate,
527
+ labels,
528
+ appearance: resolvedAppearance,
529
+ indent: resolvedAppearance.indent,
530
+ selectionMode,
531
+ activationMode,
532
+ enableSearch,
533
+ showIndentGuides,
534
+ getItemName,
535
+ renderIcon,
536
+ renderLabel,
537
+ renderActions,
538
+ renderContextMenu
539
+ }),
540
+ [
541
+ state.expanded,
542
+ state.selected,
543
+ state.focused,
544
+ state.query,
545
+ flatRows,
546
+ matchingIds,
547
+ expand,
548
+ collapse,
549
+ toggle,
550
+ expandAll,
551
+ collapseAll,
552
+ select,
553
+ setSelectedIds,
554
+ clearSelection,
555
+ setFocus,
556
+ setQuery,
557
+ refresh,
558
+ refreshAll,
559
+ activate,
560
+ labels,
561
+ resolvedAppearance,
562
+ selectionMode,
563
+ activationMode,
564
+ enableSearch,
565
+ showIndentGuides,
566
+ getItemName,
567
+ renderIcon,
568
+ renderLabel,
569
+ renderActions,
570
+ renderContextMenu
571
+ ]
572
+ );
573
+ return /* @__PURE__ */ jsxRuntime.jsx(TreeContext.Provider, { value, children });
574
+ }
575
+ chunkPK6SKIKE_cjs.__name(TreeProvider, "TreeProvider");
576
+ function TreeChevronRaw({ isExpanded, isFolder, className }) {
577
+ const { appearance } = useTreeContext();
578
+ const size = { width: "var(--tree-icon-size)", height: "var(--tree-icon-size)" };
579
+ if (!isFolder) {
580
+ return /* @__PURE__ */ jsxRuntime.jsx(
581
+ "span",
582
+ {
583
+ "aria-hidden": true,
584
+ style: size,
585
+ className: lib.cn("inline-block shrink-0", className)
586
+ }
587
+ );
588
+ }
589
+ const Icon = isExpanded ? lucideReact.ChevronDown : lucideReact.ChevronRight;
590
+ return /* @__PURE__ */ jsxRuntime.jsx(
591
+ Icon,
592
+ {
593
+ "aria-hidden": true,
594
+ strokeWidth: appearance.iconStrokeWidth,
595
+ style: size,
596
+ className: lib.cn(
597
+ "shrink-0 text-muted-foreground/70 transition-transform",
598
+ className
599
+ )
600
+ }
601
+ );
602
+ }
603
+ chunkPK6SKIKE_cjs.__name(TreeChevronRaw, "TreeChevronRaw");
604
+ var TreeChevron = React.memo(TreeChevronRaw);
605
+ function TreeIconRaw({ isFolder, isExpanded, className }) {
606
+ const { appearance } = useTreeContext();
607
+ const Icon = isFolder ? isExpanded ? lucideReact.FolderOpen : lucideReact.Folder : lucideReact.File;
608
+ return /* @__PURE__ */ jsxRuntime.jsx(
609
+ Icon,
610
+ {
611
+ "aria-hidden": true,
612
+ strokeWidth: appearance.iconStrokeWidth,
613
+ style: { width: "var(--tree-icon-size)", height: "var(--tree-icon-size)" },
614
+ className: lib.cn(
615
+ "shrink-0",
616
+ isFolder ? "text-foreground/70" : "text-muted-foreground/80",
617
+ className
618
+ )
619
+ }
620
+ );
621
+ }
622
+ chunkPK6SKIKE_cjs.__name(TreeIconRaw, "TreeIconRaw");
623
+ var TreeIcon = React.memo(TreeIconRaw);
624
+ function TreeIndentGuides({ level, indent }) {
625
+ const { appearance } = useTreeContext();
626
+ if (level <= 0) return null;
627
+ return /* @__PURE__ */ jsxRuntime.jsx(
628
+ "span",
629
+ {
630
+ "aria-hidden": true,
631
+ className: "pointer-events-none absolute inset-y-0 left-0",
632
+ style: { width: 8 + level * indent, opacity: appearance.indentGuideOpacity },
633
+ children: Array.from({ length: level }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
634
+ "span",
635
+ {
636
+ className: "absolute inset-y-0 w-px bg-border",
637
+ style: { left: 8 + i * indent + indent / 2 - 0.5 }
638
+ },
639
+ i
640
+ ))
641
+ }
642
+ );
643
+ }
644
+ chunkPK6SKIKE_cjs.__name(TreeIndentGuides, "TreeIndentGuides");
645
+ function TreeLabelRaw({ children, isMatchingSearch, className }) {
646
+ return /* @__PURE__ */ jsxRuntime.jsx(
647
+ "span",
648
+ {
649
+ style: { fontSize: "var(--tree-font-size)" },
650
+ className: lib.cn(
651
+ "truncate leading-tight tracking-[-0.005em]",
652
+ isMatchingSearch && "font-medium text-foreground",
653
+ className
654
+ ),
655
+ children
656
+ }
657
+ );
658
+ }
659
+ chunkPK6SKIKE_cjs.__name(TreeLabelRaw, "TreeLabelRaw");
660
+ var TreeLabel = React.memo(TreeLabelRaw);
661
+ function TreeRowRaw({ row, className }) {
662
+ const ctx = useTreeContext();
663
+ const {
664
+ appearance,
665
+ activationMode,
666
+ showIndentGuides,
667
+ selected,
668
+ focused,
669
+ matchingIds,
670
+ select,
671
+ toggle,
672
+ setFocus,
673
+ activate,
674
+ getItemName,
675
+ renderIcon,
676
+ renderLabel,
677
+ renderActions,
678
+ renderContextMenu
679
+ } = ctx;
680
+ const { node, level, isFolder, isExpanded, isLoading } = row;
681
+ const isSelected = selected.has(node.id);
682
+ const isFocused = focused === node.id;
683
+ const isMatchingSearch = matchingIds.has(node.id);
684
+ const slot = {
685
+ node,
686
+ level,
687
+ isSelected,
688
+ isExpanded,
689
+ isFocused,
690
+ isFolder,
691
+ isLoading,
692
+ isMatchingSearch
693
+ };
694
+ const handleClick = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((e) => {
695
+ if (node.disabled) return;
696
+ setFocus(node.id);
697
+ select(node.id);
698
+ if (isFolder) {
699
+ toggle(node.id);
700
+ } else if (activationMode === "single-click") {
701
+ activate(node, { preview: false });
702
+ } else if (activationMode === "single-click-preview") {
703
+ activate(node, { preview: true });
704
+ }
705
+ e.currentTarget.scrollIntoView?.({ block: "nearest" });
706
+ }, "handleClick");
707
+ const handleDoubleClick = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name(() => {
708
+ if (node.disabled) return;
709
+ if (isFolder) return;
710
+ activate(node, { preview: false });
711
+ }, "handleDoubleClick");
712
+ const trigger = /* @__PURE__ */ jsxRuntime.jsxs(
713
+ "div",
714
+ {
715
+ role: "treeitem",
716
+ "aria-level": level + 1,
717
+ "aria-expanded": isFolder ? isExpanded : void 0,
718
+ "aria-selected": isSelected || void 0,
719
+ "aria-current": isSelected ? "true" : void 0,
720
+ "aria-disabled": node.disabled || void 0,
721
+ "data-tree-row": "",
722
+ "data-id": node.id,
723
+ "data-activation-mode": activationMode,
724
+ "data-selected": isSelected ? "true" : void 0,
725
+ "data-focused": isFocused && !isSelected ? "true" : void 0,
726
+ "data-folder": isFolder || void 0,
727
+ "data-expanded": isExpanded || void 0,
728
+ tabIndex: isFocused ? 0 : -1,
729
+ style: {
730
+ paddingLeft: 6 + level * appearance.indent,
731
+ height: "var(--tree-row-height)",
732
+ gap: "var(--tree-gap)"
733
+ },
734
+ onClick: handleClick,
735
+ onDoubleClick: handleDoubleClick,
736
+ onFocus: () => setFocus(node.id),
737
+ className: lib.cn(
738
+ "group/row relative flex w-full select-none items-center pr-2 text-left",
739
+ "transition-colors outline-none",
740
+ node.disabled ? "cursor-not-allowed" : "cursor-pointer",
741
+ radiusClass(appearance),
742
+ rowStateClasses(appearance),
743
+ "focus-visible:ring-1 focus-visible:ring-ring/50",
744
+ isMatchingSearch && "ring-1 ring-primary/30",
745
+ node.disabled && "opacity-50",
746
+ className
747
+ ),
748
+ children: [
749
+ appearance.showActiveIndicator && isSelected ? /* @__PURE__ */ jsxRuntime.jsx(
750
+ "span",
751
+ {
752
+ "aria-hidden": true,
753
+ className: lib.cn(
754
+ "absolute left-0 top-1 bottom-1 w-0.5 rounded-r-full",
755
+ "bg-foreground/30 group-focus-within/tree:bg-primary"
756
+ )
757
+ }
758
+ ) : null,
759
+ showIndentGuides && level > 0 ? /* @__PURE__ */ jsxRuntime.jsx(TreeIndentGuides, { level, indent: appearance.indent }) : null,
760
+ /* @__PURE__ */ jsxRuntime.jsx(TreeChevron, { isExpanded, isFolder }),
761
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx(
762
+ lucideReact.Loader2,
763
+ {
764
+ "aria-hidden": true,
765
+ strokeWidth: appearance.iconStrokeWidth,
766
+ style: { width: "var(--tree-icon-size)", height: "var(--tree-icon-size)" },
767
+ className: "shrink-0 animate-spin text-muted-foreground/70"
768
+ }
769
+ ) : renderIcon ? renderIcon(slot) : /* @__PURE__ */ jsxRuntime.jsx(TreeIcon, { isFolder, isExpanded }),
770
+ /* @__PURE__ */ jsxRuntime.jsx(
771
+ "span",
772
+ {
773
+ className: "flex min-w-0 flex-1 items-center",
774
+ style: { gap: "var(--tree-gap)" },
775
+ children: renderLabel ? renderLabel(slot) : /* @__PURE__ */ jsxRuntime.jsx(TreeLabel, { isMatchingSearch, children: getItemName(node) })
776
+ }
777
+ ),
778
+ renderActions ? /* @__PURE__ */ jsxRuntime.jsx(
779
+ "span",
780
+ {
781
+ className: "ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100",
782
+ onClick: (e) => e.stopPropagation(),
783
+ children: renderActions(slot)
784
+ }
785
+ ) : null
786
+ ]
787
+ }
788
+ );
789
+ if (renderContextMenu) {
790
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderContextMenu(slot, trigger) });
791
+ }
792
+ return trigger;
793
+ }
794
+ chunkPK6SKIKE_cjs.__name(TreeRowRaw, "TreeRowRaw");
795
+ var TreeRow = React.memo(TreeRowRaw);
796
+ function TreeEmpty({ children, className }) {
797
+ return /* @__PURE__ */ jsxRuntime.jsx(
798
+ "div",
799
+ {
800
+ className: lib.cn(
801
+ "flex h-full min-h-32 items-center justify-center px-4 py-6 text-sm text-muted-foreground",
802
+ className
803
+ ),
804
+ children
805
+ }
806
+ );
807
+ }
808
+ chunkPK6SKIKE_cjs.__name(TreeEmpty, "TreeEmpty");
809
+ function TreeContent({ children, className, ariaLabel }) {
810
+ const { flatRows, labels, selected, focused, matchingIds, appearance } = useTreeContext();
811
+ if (flatRows.length === 0) {
812
+ return /* @__PURE__ */ jsxRuntime.jsx(TreeEmpty, { children: labels.empty });
813
+ }
814
+ return /* @__PURE__ */ jsxRuntime.jsx(
815
+ "div",
816
+ {
817
+ role: "tree",
818
+ "aria-label": ariaLabel ?? labels.ariaLabel,
819
+ className: lib.cn("relative flex flex-col py-1", className),
820
+ style: appearanceToStyle(appearance),
821
+ children: flatRows.map((row) => {
822
+ const slot = {
823
+ node: row.node,
824
+ level: row.level,
825
+ isSelected: selected.has(row.node.id),
826
+ isExpanded: row.isExpanded,
827
+ isFocused: focused === row.node.id,
828
+ isFolder: row.isFolder,
829
+ isLoading: row.isLoading,
830
+ isMatchingSearch: matchingIds.has(row.node.id)
831
+ };
832
+ const node = children ? children(slot) : /* @__PURE__ */ jsxRuntime.jsx(TreeRow, { row });
833
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: node }, row.node.id);
834
+ })
835
+ }
836
+ );
837
+ }
838
+ chunkPK6SKIKE_cjs.__name(TreeContent, "TreeContent");
839
+ function useTreeLabels() {
840
+ return useTreeContext().labels;
841
+ }
842
+ chunkPK6SKIKE_cjs.__name(useTreeLabels, "useTreeLabels");
843
+ function useTreeRows() {
844
+ return useTreeContext().flatRows;
845
+ }
846
+ chunkPK6SKIKE_cjs.__name(useTreeRows, "useTreeRows");
847
+ function useTreeSelection() {
848
+ const ctx = useTreeContext();
849
+ const selectedIds = React.useMemo(() => [...ctx.selected], [ctx.selected]);
850
+ const isSelected = React.useCallback(
851
+ (id) => ctx.selected.has(id),
852
+ [ctx.selected]
853
+ );
854
+ return React.useMemo(
855
+ () => ({
856
+ selectedIds,
857
+ select: ctx.select,
858
+ setSelectedIds: ctx.setSelectedIds,
859
+ clear: ctx.clearSelection,
860
+ isSelected
861
+ }),
862
+ [selectedIds, ctx.select, ctx.setSelectedIds, ctx.clearSelection, isSelected]
863
+ );
864
+ }
865
+ chunkPK6SKIKE_cjs.__name(useTreeSelection, "useTreeSelection");
866
+ function useTreeExpansion() {
867
+ const ctx = useTreeContext();
868
+ const expandedIds = React.useMemo(() => [...ctx.expanded], [ctx.expanded]);
869
+ const isExpanded = React.useCallback(
870
+ (id) => ctx.expanded.has(id),
871
+ [ctx.expanded]
872
+ );
873
+ return React.useMemo(
874
+ () => ({
875
+ expandedIds,
876
+ expand: ctx.expand,
877
+ collapse: ctx.collapse,
878
+ toggle: ctx.toggle,
879
+ expandAll: ctx.expandAll,
880
+ collapseAll: ctx.collapseAll,
881
+ isExpanded
882
+ }),
883
+ [
884
+ expandedIds,
885
+ ctx.expand,
886
+ ctx.collapse,
887
+ ctx.toggle,
888
+ ctx.expandAll,
889
+ ctx.collapseAll,
890
+ isExpanded
891
+ ]
892
+ );
893
+ }
894
+ chunkPK6SKIKE_cjs.__name(useTreeExpansion, "useTreeExpansion");
895
+ function useTreeFocus() {
896
+ const ctx = useTreeContext();
897
+ return React.useMemo(
898
+ () => ({ focusedId: ctx.focused, setFocus: ctx.setFocus }),
899
+ [ctx.focused, ctx.setFocus]
900
+ );
901
+ }
902
+ chunkPK6SKIKE_cjs.__name(useTreeFocus, "useTreeFocus");
903
+ function useTreeSearch() {
904
+ const ctx = useTreeContext();
905
+ return React.useMemo(
906
+ () => ({
907
+ isOpen: ctx.enableSearch,
908
+ query: ctx.query,
909
+ setQuery: ctx.setQuery,
910
+ matchingIds: ctx.matchingIds,
911
+ matchCount: ctx.matchingIds.size
912
+ }),
913
+ [ctx.enableSearch, ctx.query, ctx.setQuery, ctx.matchingIds]
914
+ );
915
+ }
916
+ chunkPK6SKIKE_cjs.__name(useTreeSearch, "useTreeSearch");
917
+ function useTreeActions() {
918
+ const ctx = useTreeContext();
919
+ return React.useMemo(
920
+ () => ({
921
+ expand: ctx.expand,
922
+ collapse: ctx.collapse,
923
+ toggle: ctx.toggle,
924
+ expandAll: ctx.expandAll,
925
+ collapseAll: ctx.collapseAll,
926
+ refresh: ctx.refresh,
927
+ refreshAll: ctx.refreshAll,
928
+ activate: ctx.activate
929
+ }),
930
+ [
931
+ ctx.expand,
932
+ ctx.collapse,
933
+ ctx.toggle,
934
+ ctx.expandAll,
935
+ ctx.collapseAll,
936
+ ctx.refresh,
937
+ ctx.refreshAll,
938
+ ctx.activate
939
+ ]
940
+ );
941
+ }
942
+ chunkPK6SKIKE_cjs.__name(useTreeActions, "useTreeActions");
943
+ function TreeSearchInput({ className, showMatches = true }) {
944
+ const { labels } = useTreeContext();
945
+ const { query, setQuery, matchCount } = useTreeSearch();
946
+ return /* @__PURE__ */ jsxRuntime.jsxs(
947
+ "div",
948
+ {
949
+ className: lib.cn(
950
+ "flex items-center gap-2 rounded-md border border-border bg-background px-2",
951
+ className
952
+ ),
953
+ children: [
954
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { "aria-hidden": true, className: "size-3.5 shrink-0 text-muted-foreground" }),
955
+ /* @__PURE__ */ jsxRuntime.jsx(
956
+ "input",
957
+ {
958
+ type: "search",
959
+ value: query,
960
+ onChange: (e) => setQuery(e.target.value),
961
+ placeholder: labels.searchPlaceholder,
962
+ className: "h-7 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
963
+ }
964
+ ),
965
+ showMatches && query.trim().length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: labels.searchMatches(matchCount) }) : null,
966
+ query.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
967
+ "button",
968
+ {
969
+ type: "button",
970
+ onClick: () => setQuery(""),
971
+ "aria-label": "Clear search",
972
+ className: "shrink-0 rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground",
973
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": true, className: "size-3.5" })
974
+ }
975
+ ) : null
976
+ ]
977
+ }
978
+ );
979
+ }
980
+ chunkPK6SKIKE_cjs.__name(TreeSearchInput, "TreeSearchInput");
981
+ function useTreeKeyboard({
982
+ rows,
983
+ focusedId,
984
+ enabled = true,
985
+ onFocus,
986
+ onSelect,
987
+ onActivate,
988
+ onExpand,
989
+ onCollapse,
990
+ onClearSelection
991
+ }) {
992
+ const rowsRef = React.useRef(rows);
993
+ const focusedIdRef = React.useRef(focusedId);
994
+ rowsRef.current = rows;
995
+ focusedIdRef.current = focusedId;
996
+ const getCurrent = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name(() => {
997
+ const r = rowsRef.current;
998
+ const id = focusedIdRef.current;
999
+ const idx = id ? r.findIndex((x) => x.node.id === id) : -1;
1000
+ return { rows: r, idx, current: idx >= 0 ? r[idx] : null };
1001
+ }, "getCurrent");
1002
+ const refDown = hooks.useHotkey(
1003
+ "down",
1004
+ () => {
1005
+ const { rows: r, idx } = getCurrent();
1006
+ if (r.length === 0) return;
1007
+ const next = r[Math.min(idx + 1, r.length - 1)] ?? r[0];
1008
+ onFocus(next.node.id);
1009
+ },
1010
+ { enabled, preventDefault: true, description: "Next row" }
1011
+ );
1012
+ const refUp = hooks.useHotkey(
1013
+ "up",
1014
+ () => {
1015
+ const { rows: r, idx } = getCurrent();
1016
+ if (r.length === 0) return;
1017
+ const prev = r[Math.max(idx - 1, 0)] ?? r[0];
1018
+ onFocus(prev.node.id);
1019
+ },
1020
+ { enabled, preventDefault: true, description: "Previous row" }
1021
+ );
1022
+ const refHome = hooks.useHotkey(
1023
+ "home",
1024
+ () => {
1025
+ const { rows: r } = getCurrent();
1026
+ if (r.length === 0) return;
1027
+ onFocus(r[0].node.id);
1028
+ },
1029
+ { enabled, preventDefault: true, description: "First row" }
1030
+ );
1031
+ const refEnd = hooks.useHotkey(
1032
+ "end",
1033
+ () => {
1034
+ const { rows: r } = getCurrent();
1035
+ if (r.length === 0) return;
1036
+ onFocus(r[r.length - 1].node.id);
1037
+ },
1038
+ { enabled, preventDefault: true, description: "Last row" }
1039
+ );
1040
+ const refRight = hooks.useHotkey(
1041
+ "right",
1042
+ () => {
1043
+ const { rows: r, idx, current } = getCurrent();
1044
+ if (!current) return;
1045
+ if (current.isFolder && !current.isExpanded) {
1046
+ onExpand(current.node.id);
1047
+ } else if (current.isFolder && current.isExpanded) {
1048
+ const next = r[idx + 1];
1049
+ if (next) onFocus(next.node.id);
1050
+ }
1051
+ },
1052
+ { enabled, preventDefault: true, description: "Expand / first child" }
1053
+ );
1054
+ const refLeft = hooks.useHotkey(
1055
+ "left",
1056
+ () => {
1057
+ const { current } = getCurrent();
1058
+ if (!current) return;
1059
+ if (current.isFolder && current.isExpanded) {
1060
+ onCollapse(current.node.id);
1061
+ } else if (current.parentId) {
1062
+ onFocus(current.parentId);
1063
+ }
1064
+ },
1065
+ { enabled, preventDefault: true, description: "Collapse / parent" }
1066
+ );
1067
+ const refActivate = hooks.useHotkey(
1068
+ ["enter", "space"],
1069
+ () => {
1070
+ const { current } = getCurrent();
1071
+ if (!current) return;
1072
+ onSelect(current.node.id);
1073
+ if (current.isFolder) {
1074
+ if (current.isExpanded) onCollapse(current.node.id);
1075
+ else onExpand(current.node.id);
1076
+ } else {
1077
+ onActivate(current.node.id);
1078
+ }
1079
+ },
1080
+ { enabled, preventDefault: true, description: "Activate / toggle" }
1081
+ );
1082
+ const refEscape = hooks.useHotkey(
1083
+ "escape",
1084
+ () => onClearSelection(),
1085
+ { enabled, preventDefault: true, description: "Clear selection" }
1086
+ );
1087
+ const ref = React.useCallback(
1088
+ (instance) => {
1089
+ refDown(instance);
1090
+ refUp(instance);
1091
+ refHome(instance);
1092
+ refEnd(instance);
1093
+ refRight(instance);
1094
+ refLeft(instance);
1095
+ refActivate(instance);
1096
+ refEscape(instance);
1097
+ },
1098
+ [refDown, refUp, refHome, refEnd, refRight, refLeft, refActivate, refEscape]
1099
+ );
1100
+ return { ref };
1101
+ }
1102
+ chunkPK6SKIKE_cjs.__name(useTreeKeyboard, "useTreeKeyboard");
1103
+ var FLUSH_MS = 600;
1104
+ function useTreeTypeAhead({
1105
+ rows,
1106
+ getItemName,
1107
+ containerRef,
1108
+ onMatch,
1109
+ enabled = true
1110
+ }) {
1111
+ const bufferRef = React.useRef("");
1112
+ const timerRef = React.useRef(null);
1113
+ const rowsRef = React.useRef(rows);
1114
+ const getNameRef = React.useRef(getItemName);
1115
+ const onMatchRef = React.useRef(onMatch);
1116
+ rowsRef.current = rows;
1117
+ getNameRef.current = getItemName;
1118
+ onMatchRef.current = onMatch;
1119
+ React.useEffect(() => {
1120
+ if (!enabled) return;
1121
+ const target = containerRef.current;
1122
+ if (!target) return;
1123
+ const reset = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name(() => {
1124
+ bufferRef.current = "";
1125
+ if (timerRef.current) {
1126
+ clearTimeout(timerRef.current);
1127
+ timerRef.current = null;
1128
+ }
1129
+ }, "reset");
1130
+ const handler = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((e) => {
1131
+ const tag = e.target?.tagName;
1132
+ if (tag === "INPUT" || tag === "TEXTAREA") return;
1133
+ if (e.target?.isContentEditable) return;
1134
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
1135
+ if (e.key === "Escape" || e.key === "Enter" || e.key === "Tab" || e.key.startsWith("Arrow") || e.key === "Home" || e.key === "End" || e.key === "PageUp" || e.key === "PageDown") {
1136
+ reset();
1137
+ return;
1138
+ }
1139
+ if (e.key.length !== 1) return;
1140
+ bufferRef.current += e.key.toLowerCase();
1141
+ if (timerRef.current) clearTimeout(timerRef.current);
1142
+ timerRef.current = setTimeout(reset, FLUSH_MS);
1143
+ const prefix = bufferRef.current;
1144
+ const hit = rowsRef.current.find(
1145
+ (row) => getNameRef.current(row.node).toLowerCase().startsWith(prefix)
1146
+ );
1147
+ if (hit) {
1148
+ e.preventDefault();
1149
+ onMatchRef.current(hit.node.id);
1150
+ }
1151
+ }, "handler");
1152
+ target.addEventListener("keydown", handler);
1153
+ return () => {
1154
+ target.removeEventListener("keydown", handler);
1155
+ reset();
1156
+ };
1157
+ }, [containerRef, enabled]);
1158
+ }
1159
+ chunkPK6SKIKE_cjs.__name(useTreeTypeAhead, "useTreeTypeAhead");
1160
+ function TreeRoot(props) {
1161
+ const {
1162
+ data,
1163
+ getItemName,
1164
+ loadChildren,
1165
+ selectionMode,
1166
+ activationMode,
1167
+ initialExpandedIds,
1168
+ initialSelectedIds,
1169
+ indent,
1170
+ appearance,
1171
+ onSelectionChange,
1172
+ onExpansionChange,
1173
+ onActivate,
1174
+ filterNode,
1175
+ enableSearch = false,
1176
+ enableTypeAhead = true,
1177
+ showIndentGuides = false,
1178
+ renderRow,
1179
+ renderIcon,
1180
+ renderLabel,
1181
+ renderActions,
1182
+ renderContextMenu,
1183
+ labels,
1184
+ persistKey,
1185
+ persistSelection = false,
1186
+ className,
1187
+ style
1188
+ } = props;
1189
+ return /* @__PURE__ */ jsxRuntime.jsx(
1190
+ TreeProvider,
1191
+ {
1192
+ data,
1193
+ getItemName,
1194
+ loadChildren,
1195
+ selectionMode,
1196
+ activationMode,
1197
+ initialExpandedIds,
1198
+ initialSelectedIds,
1199
+ indent,
1200
+ appearance,
1201
+ onSelectionChange,
1202
+ onExpansionChange,
1203
+ onActivate,
1204
+ filterNode,
1205
+ enableSearch,
1206
+ showIndentGuides,
1207
+ renderIcon,
1208
+ renderLabel,
1209
+ renderActions,
1210
+ renderContextMenu,
1211
+ labels,
1212
+ persistKey,
1213
+ persistSelection,
1214
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1215
+ TreeRootShell,
1216
+ {
1217
+ className,
1218
+ style,
1219
+ enableSearch,
1220
+ enableTypeAhead,
1221
+ renderRow
1222
+ }
1223
+ )
1224
+ }
1225
+ );
1226
+ }
1227
+ chunkPK6SKIKE_cjs.__name(TreeRoot, "TreeRoot");
1228
+ function TreeRootShell({
1229
+ className,
1230
+ style,
1231
+ enableSearch,
1232
+ enableTypeAhead,
1233
+ renderRow
1234
+ }) {
1235
+ const containerRef = React.useRef(null);
1236
+ const ctx = useTreeContext();
1237
+ const { ref: keyboardRef } = useTreeKeyboard({
1238
+ rows: ctx.flatRows,
1239
+ focusedId: ctx.focused,
1240
+ onFocus: ctx.setFocus,
1241
+ onSelect: ctx.select,
1242
+ onActivate: /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((id) => {
1243
+ const row = ctx.flatRows.find((r) => r.node.id === id);
1244
+ if (row) ctx.activate(row.node, { preview: false });
1245
+ }, "onActivate"),
1246
+ onExpand: ctx.expand,
1247
+ onCollapse: ctx.collapse,
1248
+ onClearSelection: ctx.clearSelection
1249
+ });
1250
+ const setContainerRef = React.useCallback(
1251
+ (instance) => {
1252
+ containerRef.current = instance;
1253
+ keyboardRef(instance);
1254
+ },
1255
+ [keyboardRef]
1256
+ );
1257
+ const onTypeAheadMatch = React.useCallback(
1258
+ (id) => {
1259
+ ctx.setFocus(id);
1260
+ const el = containerRef.current?.querySelector(
1261
+ `[data-tree-row][data-id="${CSS.escape(id)}"]`
1262
+ );
1263
+ el?.scrollIntoView({ block: "nearest" });
1264
+ },
1265
+ [ctx]
1266
+ );
1267
+ useTreeTypeAhead({
1268
+ rows: ctx.flatRows,
1269
+ getItemName: ctx.getItemName,
1270
+ containerRef,
1271
+ onMatch: onTypeAheadMatch,
1272
+ enabled: enableTypeAhead
1273
+ });
1274
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1275
+ "div",
1276
+ {
1277
+ ref: setContainerRef,
1278
+ tabIndex: 0,
1279
+ className: lib.cn(
1280
+ "group/tree flex h-full w-full flex-col gap-2 outline-none",
1281
+ className
1282
+ ),
1283
+ style: { ...appearanceToStyle(ctx.appearance), ...style },
1284
+ "data-tree-root": "",
1285
+ children: [
1286
+ enableSearch ? /* @__PURE__ */ jsxRuntime.jsx(TreeSearchInput, { className: "mx-2 mt-2" }) : null,
1287
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1 overflow-auto px-1", children: /* @__PURE__ */ jsxRuntime.jsx(TreeContent, { children: renderRow }) })
1288
+ ]
1289
+ }
1290
+ );
1291
+ }
1292
+ chunkPK6SKIKE_cjs.__name(TreeRootShell, "TreeRootShell");
1293
+ var TreeRoot_default = TreeRoot;
1294
+ function TreeSkeleton({ rows = 6, className }) {
1295
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("flex flex-col gap-1 p-2", className), "aria-hidden": true, children: Array.from({ length: rows }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", style: { paddingLeft: i % 3 * 16 }, children: [
1296
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-4 shrink-0 animate-pulse rounded bg-muted" }),
1297
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-4 shrink-0 animate-pulse rounded bg-muted" }),
1298
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "h-3 flex-1 animate-pulse rounded bg-muted" })
1299
+ ] }, i)) });
1300
+ }
1301
+ chunkPK6SKIKE_cjs.__name(TreeSkeleton, "TreeSkeleton");
1302
+ function TreeError({ children, className }) {
1303
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1304
+ "div",
1305
+ {
1306
+ className: lib.cn(
1307
+ "flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",
1308
+ className
1309
+ ),
1310
+ role: "alert",
1311
+ children: [
1312
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { "aria-hidden": true, className: "mt-0.5 size-4 shrink-0" }),
1313
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children })
1314
+ ]
1315
+ }
1316
+ );
1317
+ }
1318
+ chunkPK6SKIKE_cjs.__name(TreeError, "TreeError");
1319
+
1320
+ // src/tools/Tree/data/createDemoTree.ts
1321
+ function createDemoTree({
1322
+ depth = 3,
1323
+ breadth = 4,
1324
+ rootPrefix = "node"
1325
+ } = {}) {
1326
+ const make = /* @__PURE__ */ chunkPK6SKIKE_cjs.__name((id, name, level) => {
1327
+ if (level >= depth) {
1328
+ return { id, data: { name } };
1329
+ }
1330
+ const children = [];
1331
+ for (let i = 0; i < breadth; i++) {
1332
+ const childId = `${id}/${i}`;
1333
+ children.push(make(childId, `${name}-${i}`, level + 1));
1334
+ }
1335
+ return { id, data: { name }, children };
1336
+ }, "make");
1337
+ const roots = [];
1338
+ for (let i = 0; i < breadth; i++) {
1339
+ roots.push(make(`${rootPrefix}-${i}`, `${rootPrefix} ${i}`, 1));
1340
+ }
1341
+ return roots;
1342
+ }
1343
+ chunkPK6SKIKE_cjs.__name(createDemoTree, "createDemoTree");
1344
+
1345
+ exports.DEFAULT_TREE_APPEARANCE = DEFAULT_TREE_APPEARANCE;
1346
+ exports.DEFAULT_TREE_LABELS = DEFAULT_TREE_LABELS;
1347
+ exports.Tree = TreeRoot;
1348
+ exports.TreeChevron = TreeChevron;
1349
+ exports.TreeContent = TreeContent;
1350
+ exports.TreeEmpty = TreeEmpty;
1351
+ exports.TreeError = TreeError;
1352
+ exports.TreeIcon = TreeIcon;
1353
+ exports.TreeIndentGuides = TreeIndentGuides;
1354
+ exports.TreeLabel = TreeLabel;
1355
+ exports.TreeProvider = TreeProvider;
1356
+ exports.TreeRoot = TreeRoot;
1357
+ exports.TreeRow = TreeRow;
1358
+ exports.TreeSearchInput = TreeSearchInput;
1359
+ exports.TreeSkeleton = TreeSkeleton;
1360
+ exports.appearanceToStyle = appearanceToStyle;
1361
+ exports.clearTreeState = clearTreeState;
1362
+ exports.createChildCache = createChildCache;
1363
+ exports.createDemoTree = createDemoTree;
1364
+ exports.default = TreeRoot_default;
1365
+ exports.flattenTree = flattenTree;
1366
+ exports.loadTreeState = loadTreeState;
1367
+ exports.resolveAppearance = resolveAppearance;
1368
+ exports.resolveChildren = resolveChildren;
1369
+ exports.saveTreeState = saveTreeState;
1370
+ exports.useTreeActions = useTreeActions;
1371
+ exports.useTreeContext = useTreeContext;
1372
+ exports.useTreeExpansion = useTreeExpansion;
1373
+ exports.useTreeFocus = useTreeFocus;
1374
+ exports.useTreeKeyboard = useTreeKeyboard;
1375
+ exports.useTreeLabels = useTreeLabels;
1376
+ exports.useTreeRows = useTreeRows;
1377
+ exports.useTreeSearch = useTreeSearch;
1378
+ exports.useTreeSelection = useTreeSelection;
1379
+ exports.useTreeTypeAhead = useTreeTypeAhead;
151
1380
  //# sourceMappingURL=index.cjs.map
152
1381
  //# sourceMappingURL=index.cjs.map