@djangocfg/ui-tools 2.1.315 → 2.1.317
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/dist/TreeRoot-R6XVHYQK.mjs +4 -0
- package/dist/{TreeRoot-DO33TIS5.mjs.map → TreeRoot-R6XVHYQK.mjs.map} +1 -1
- package/dist/TreeRoot-RAMQSBMO.cjs +19 -0
- package/dist/{TreeRoot-NJOZ2DMV.cjs.map → TreeRoot-RAMQSBMO.cjs.map} +1 -1
- package/dist/{chunk-MA552EWC.cjs → chunk-44ZTWYAF.cjs} +139 -111
- package/dist/chunk-44ZTWYAF.cjs.map +1 -0
- package/dist/chunk-KR6B3LVY.mjs +59 -0
- package/dist/chunk-KR6B3LVY.mjs.map +1 -0
- package/dist/{chunk-E5BP4IXF.mjs → chunk-NTJL2SXK.mjs} +139 -111
- package/dist/chunk-NTJL2SXK.mjs.map +1 -0
- package/dist/chunk-YXBOAGIM.cjs +63 -0
- package/dist/chunk-YXBOAGIM.cjs.map +1 -0
- package/dist/file-icon/index.cjs +117 -0
- package/dist/file-icon/index.cjs.map +1 -0
- package/dist/file-icon/index.d.cts +69 -0
- package/dist/file-icon/index.d.ts +69 -0
- package/dist/file-icon/index.mjs +112 -0
- package/dist/file-icon/index.mjs.map +1 -0
- package/dist/index.cjs +140 -180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -433
- package/dist/index.d.ts +5 -433
- package/dist/index.mjs +7 -56
- package/dist/index.mjs.map +1 -1
- package/dist/tree/index.cjs +152 -0
- package/dist/tree/index.cjs.map +1 -0
- package/dist/tree/index.d.cts +278 -0
- package/dist/tree/index.d.ts +278 -0
- package/dist/tree/index.mjs +5 -0
- package/dist/tree/index.mjs.map +1 -0
- package/dist/types-Cclwv4Hl.d.cts +198 -0
- package/dist/types-Cclwv4Hl.d.ts +198 -0
- package/package.json +16 -10
- package/src/tools/FileIcon/FileIcon.tsx +91 -0
- package/src/tools/FileIcon/index.ts +9 -0
- package/src/tools/FileIcon/loader.ts +47 -0
- package/src/tools/FileIcon/treeAdapter.tsx +41 -0
- package/src/tools/Tree/README.md +56 -0
- package/src/tools/Tree/Tree.story.tsx +48 -0
- package/src/tools/Tree/TreeRoot.tsx +15 -5
- package/src/tools/Tree/components/TreeRow.tsx +17 -18
- package/src/tools/Tree/context/TreeContext.tsx +10 -2
- package/src/tools/Tree/hooks/useTreeKeyboard.ts +133 -99
- package/src/tools/Tree/index.tsx +2 -0
- package/src/tools/Tree/types.ts +36 -2
- package/dist/TreeRoot-DO33TIS5.mjs +0 -4
- package/dist/TreeRoot-NJOZ2DMV.cjs +0 -19
- package/dist/chunk-E5BP4IXF.mjs.map +0 -1
- package/dist/chunk-MA552EWC.cjs.map +0 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chunkYXBOAGIM_cjs = require('../chunk-YXBOAGIM.cjs');
|
|
6
|
+
var chunk44ZTWYAF_cjs = require('../chunk-44ZTWYAF.cjs');
|
|
7
|
+
require('../chunk-WGEGR3DF.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(exports, "TreeError", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkYXBOAGIM_cjs.TreeError; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "TreeSkeleton", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkYXBOAGIM_cjs.TreeSkeleton; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "createDemoTree", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkYXBOAGIM_cjs.createDemoTree; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "DEFAULT_TREE_APPEARANCE", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunk44ZTWYAF_cjs.DEFAULT_TREE_APPEARANCE; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "DEFAULT_TREE_LABELS", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunk44ZTWYAF_cjs.DEFAULT_TREE_LABELS; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "Tree", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeRoot; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "TreeChevron", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeChevron; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "TreeContent", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeContent; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "TreeEmpty", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeEmpty; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "TreeIcon", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeIcon; }
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "TreeIndentGuides", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeIndentGuides; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "TreeLabel", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeLabel; }
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "TreeProvider", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeProvider; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "TreeRoot", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeRoot; }
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "TreeRow", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeRow; }
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "TreeSearchInput", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeSearchInput; }
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "appearanceToStyle", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () { return chunk44ZTWYAF_cjs.appearanceToStyle; }
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, "clearTreeState", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () { return chunk44ZTWYAF_cjs.clearTreeState; }
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, "createChildCache", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () { return chunk44ZTWYAF_cjs.createChildCache; }
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "default", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () { return chunk44ZTWYAF_cjs.TreeRoot_default; }
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, "flattenTree", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () { return chunk44ZTWYAF_cjs.flattenTree; }
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "loadTreeState", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () { return chunk44ZTWYAF_cjs.loadTreeState; }
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "resolveAppearance", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () { return chunk44ZTWYAF_cjs.resolveAppearance; }
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, "resolveChildren", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () { return chunk44ZTWYAF_cjs.resolveChildren; }
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "saveTreeState", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function () { return chunk44ZTWYAF_cjs.saveTreeState; }
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, "useTreeActions", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeActions; }
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, "useTreeContext", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeContext; }
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, "useTreeExpansion", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeExpansion; }
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(exports, "useTreeFocus", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeFocus; }
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(exports, "useTreeKeyboard", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeKeyboard; }
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "useTreeLabels", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeLabels; }
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(exports, "useTreeRows", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeRows; }
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, "useTreeSearch", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeSearch; }
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, "useTreeSelection", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeSelection; }
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(exports, "useTreeTypeAhead", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function () { return chunk44ZTWYAF_cjs.useTreeTypeAhead; }
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=index.cjs.map
|
|
152
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { b as TreeRootProps, f as TreeItemId, T as TreeNode, F as FlatRow, o as TreeActivateOptions, g as TreeLabels, R as ResolvedAppearance, h as TreeSelectionMode, p as TreeActivationMode, a as TreeRowSlot, e as TreeContextMenuSlot } from '../types-Cclwv4Hl.cjs';
|
|
3
|
+
export { c as DEFAULT_TREE_APPEARANCE, D as DEFAULT_TREE_LABELS, m as TreeAccentIntensity, k as TreeAppearance, l as TreeDensity, j as TreeLoadChildren, n as TreeRadius, i as TreeRowRenderProps, d as appearanceToStyle, r as resolveAppearance } from '../types-Cclwv4Hl.cjs';
|
|
4
|
+
import * as React$1 from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* High-level entry point. Wraps Provider + (optional) search bar + content.
|
|
8
|
+
*
|
|
9
|
+
* For full control, compose with <TreeProvider>, <TreeContent>,
|
|
10
|
+
* <TreeSearchInput>, <TreeRow>, etc. directly from `@djangocfg/ui-tools/tree`.
|
|
11
|
+
*/
|
|
12
|
+
declare function TreeRoot<T>(props: TreeRootProps<T>): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
type ChildEntryStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
15
|
+
interface ChildEntry<T> {
|
|
16
|
+
status: ChildEntryStatus;
|
|
17
|
+
children: TreeNode<T>[];
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
type ChildCache<T> = Map<TreeItemId, ChildEntry<T>>;
|
|
21
|
+
declare const createChildCache: <T>() => ChildCache<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a node's children for the current render.
|
|
24
|
+
*
|
|
25
|
+
* - If the node carries inline `children`, those win (no async fetch).
|
|
26
|
+
* - Otherwise we look in the cache.
|
|
27
|
+
*
|
|
28
|
+
* Returns `null` when nothing is loaded yet (caller may show a skeleton).
|
|
29
|
+
*/
|
|
30
|
+
declare const resolveChildren: <T>(cache: ChildCache<T>, node: TreeNode<T>) => {
|
|
31
|
+
children: TreeNode<T>[] | null;
|
|
32
|
+
status: ChildEntryStatus;
|
|
33
|
+
error?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
interface TreeContextValue<T> {
|
|
37
|
+
expanded: ReadonlySet<TreeItemId>;
|
|
38
|
+
selected: ReadonlySet<TreeItemId>;
|
|
39
|
+
focused: TreeItemId | null;
|
|
40
|
+
query: string;
|
|
41
|
+
flatRows: FlatRow<T>[];
|
|
42
|
+
/** Search-matching node ids (subset of all flatRows). */
|
|
43
|
+
matchingIds: ReadonlySet<TreeItemId>;
|
|
44
|
+
expand: (id: TreeItemId) => void;
|
|
45
|
+
collapse: (id: TreeItemId) => void;
|
|
46
|
+
toggle: (id: TreeItemId) => void;
|
|
47
|
+
expandAll: () => void;
|
|
48
|
+
collapseAll: () => void;
|
|
49
|
+
select: (id: TreeItemId) => void;
|
|
50
|
+
setSelectedIds: (ids: TreeItemId[]) => void;
|
|
51
|
+
clearSelection: () => void;
|
|
52
|
+
setFocus: (id: TreeItemId | null) => void;
|
|
53
|
+
setQuery: (q: string) => void;
|
|
54
|
+
refresh: (id: TreeItemId) => Promise<void>;
|
|
55
|
+
refreshAll: () => Promise<void>;
|
|
56
|
+
activate: (node: TreeNode<T>, opts?: TreeActivateOptions) => void;
|
|
57
|
+
labels: TreeLabels;
|
|
58
|
+
/** Resolved cosmetic config — never null. */
|
|
59
|
+
appearance: ResolvedAppearance;
|
|
60
|
+
/** Convenience alias for `appearance.indent`. */
|
|
61
|
+
indent: number;
|
|
62
|
+
selectionMode: TreeSelectionMode;
|
|
63
|
+
activationMode: TreeActivationMode;
|
|
64
|
+
enableSearch: boolean;
|
|
65
|
+
showIndentGuides: boolean;
|
|
66
|
+
getItemName: (node: TreeNode<T>) => string;
|
|
67
|
+
renderIcon?: TreeRowSlot<T>;
|
|
68
|
+
renderLabel?: TreeRowSlot<T>;
|
|
69
|
+
renderActions?: TreeRowSlot<T>;
|
|
70
|
+
renderContextMenu?: TreeContextMenuSlot<T>;
|
|
71
|
+
}
|
|
72
|
+
declare function useTreeContext<T>(): TreeContextValue<T>;
|
|
73
|
+
interface TreeProviderProps<T> extends Pick<TreeRootProps<T>, 'data' | 'getItemName' | 'loadChildren' | 'selectionMode' | 'activationMode' | 'initialExpandedIds' | 'initialSelectedIds' | 'indent' | 'appearance' | 'onSelectionChange' | 'onExpansionChange' | 'onActivate' | 'enableSearch' | 'showIndentGuides' | 'renderIcon' | 'renderLabel' | 'renderActions' | 'renderContextMenu' | 'labels' | 'persistKey' | 'persistSelection'> {
|
|
74
|
+
children: React$1.ReactNode;
|
|
75
|
+
}
|
|
76
|
+
declare function TreeProvider<T>(props: TreeProviderProps<T>): react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
declare function useTreeLabels(): TreeLabels;
|
|
79
|
+
declare function useTreeRows<T>(): FlatRow<T>[];
|
|
80
|
+
declare function useTreeSelection<T>(): {
|
|
81
|
+
selectedIds: string[];
|
|
82
|
+
select: (id: TreeItemId) => void;
|
|
83
|
+
setSelectedIds: (ids: TreeItemId[]) => void;
|
|
84
|
+
clear: () => void;
|
|
85
|
+
isSelected: (id: TreeItemId) => boolean;
|
|
86
|
+
};
|
|
87
|
+
declare function useTreeExpansion<T>(): {
|
|
88
|
+
expandedIds: string[];
|
|
89
|
+
expand: (id: TreeItemId) => void;
|
|
90
|
+
collapse: (id: TreeItemId) => void;
|
|
91
|
+
toggle: (id: TreeItemId) => void;
|
|
92
|
+
expandAll: () => void;
|
|
93
|
+
collapseAll: () => void;
|
|
94
|
+
isExpanded: (id: TreeItemId) => boolean;
|
|
95
|
+
};
|
|
96
|
+
declare function useTreeFocus<T>(): {
|
|
97
|
+
focusedId: string;
|
|
98
|
+
setFocus: (id: TreeItemId | null) => void;
|
|
99
|
+
};
|
|
100
|
+
declare function useTreeSearch<T>(): {
|
|
101
|
+
isOpen: boolean;
|
|
102
|
+
query: string;
|
|
103
|
+
setQuery: (q: string) => void;
|
|
104
|
+
matchingIds: ReadonlySet<string>;
|
|
105
|
+
matchCount: number;
|
|
106
|
+
};
|
|
107
|
+
declare function useTreeActions<T>(): {
|
|
108
|
+
expand: (id: TreeItemId) => void;
|
|
109
|
+
collapse: (id: TreeItemId) => void;
|
|
110
|
+
toggle: (id: TreeItemId) => void;
|
|
111
|
+
expandAll: () => void;
|
|
112
|
+
collapseAll: () => void;
|
|
113
|
+
refresh: (id: TreeItemId) => Promise<void>;
|
|
114
|
+
refreshAll: () => Promise<void>;
|
|
115
|
+
activate: (node: TreeNode<T>, opts?: TreeActivateOptions) => void;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
interface UseTreeTypeAheadOptions<T> {
|
|
119
|
+
/** Visible flat rows in render order. */
|
|
120
|
+
rows: FlatRow<T>[];
|
|
121
|
+
/** How to read the displayed name of a node (matched case-insensitively). */
|
|
122
|
+
getItemName: (node: TreeNode<T>) => string;
|
|
123
|
+
/** Element receiving keydown events. */
|
|
124
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
125
|
+
/** Called with the matched node id so the consumer can focus / scroll. */
|
|
126
|
+
onMatch: (id: string) => void;
|
|
127
|
+
/** Disable without removing the call site. */
|
|
128
|
+
enabled?: boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Type-ahead jump (Finder / VSCode style).
|
|
132
|
+
*
|
|
133
|
+
* Builds a rolling buffer of printable keys (within ~600 ms of each other)
|
|
134
|
+
* and notifies the consumer of the first row whose name starts with that
|
|
135
|
+
* prefix. Resets on Esc / Enter / navigation keys / timeout.
|
|
136
|
+
*/
|
|
137
|
+
declare function useTreeTypeAhead<T>({ rows, getItemName, containerRef, onMatch, enabled, }: UseTreeTypeAheadOptions<T>): void;
|
|
138
|
+
|
|
139
|
+
interface UseTreeKeyboardOptions<T> {
|
|
140
|
+
rows: FlatRow<T>[];
|
|
141
|
+
focusedId: TreeItemId | null;
|
|
142
|
+
enabled?: boolean;
|
|
143
|
+
onFocus: (id: TreeItemId) => void;
|
|
144
|
+
onSelect: (id: TreeItemId) => void;
|
|
145
|
+
onActivate: (id: TreeItemId) => void;
|
|
146
|
+
onExpand: (id: TreeItemId) => void;
|
|
147
|
+
onCollapse: (id: TreeItemId) => void;
|
|
148
|
+
onClearSelection: () => void;
|
|
149
|
+
}
|
|
150
|
+
interface UseTreeKeyboardReturn {
|
|
151
|
+
/** Attach to the tree container. Hotkeys only fire when focus is inside. */
|
|
152
|
+
ref: (instance: HTMLElement | null) => void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Standard tree keyboard navigation, scoped to the container ref.
|
|
156
|
+
*
|
|
157
|
+
* - ↑ / ↓ : prev / next visible row
|
|
158
|
+
* - Home / End : first / last visible row
|
|
159
|
+
* - → : expand folder; if already expanded, jump to first child
|
|
160
|
+
* - ← : collapse folder; if already collapsed (or leaf), jump to parent
|
|
161
|
+
* - Enter / Space : activate (folder => toggle, leaf => onActivate)
|
|
162
|
+
* - Esc : clear selection
|
|
163
|
+
*
|
|
164
|
+
* Built on `useHotkey` (react-hotkeys-hook) — focus gating is automatic; no
|
|
165
|
+
* manual `addEventListener` or `data-scope` juggling.
|
|
166
|
+
*/
|
|
167
|
+
declare function useTreeKeyboard<T>({ rows, focusedId, enabled, onFocus, onSelect, onActivate, onExpand, onCollapse, onClearSelection, }: UseTreeKeyboardOptions<T>): UseTreeKeyboardReturn;
|
|
168
|
+
|
|
169
|
+
interface TreeChevronProps {
|
|
170
|
+
isExpanded: boolean;
|
|
171
|
+
isFolder: boolean;
|
|
172
|
+
className?: string;
|
|
173
|
+
}
|
|
174
|
+
declare function TreeChevron({ isExpanded, isFolder, className }: TreeChevronProps): react_jsx_runtime.JSX.Element;
|
|
175
|
+
|
|
176
|
+
interface TreeIconProps {
|
|
177
|
+
isFolder: boolean;
|
|
178
|
+
isExpanded: boolean;
|
|
179
|
+
className?: string;
|
|
180
|
+
}
|
|
181
|
+
declare function TreeIcon({ isFolder, isExpanded, className }: TreeIconProps): react_jsx_runtime.JSX.Element;
|
|
182
|
+
|
|
183
|
+
interface TreeLabelProps {
|
|
184
|
+
children: React.ReactNode;
|
|
185
|
+
isMatchingSearch?: boolean;
|
|
186
|
+
className?: string;
|
|
187
|
+
}
|
|
188
|
+
declare function TreeLabel({ children, isMatchingSearch, className }: TreeLabelProps): react_jsx_runtime.JSX.Element;
|
|
189
|
+
|
|
190
|
+
interface TreeRowProps<T> {
|
|
191
|
+
row: FlatRow<T>;
|
|
192
|
+
className?: string;
|
|
193
|
+
}
|
|
194
|
+
declare function TreeRow<T>({ row, className }: TreeRowProps<T>): react_jsx_runtime.JSX.Element;
|
|
195
|
+
|
|
196
|
+
interface TreeContentProps<T> {
|
|
197
|
+
/** Custom row renderer; falls back to <TreeRow />. */
|
|
198
|
+
children?: TreeRowSlot<T>;
|
|
199
|
+
className?: string;
|
|
200
|
+
/** Override aria-label for the container. */
|
|
201
|
+
ariaLabel?: string;
|
|
202
|
+
}
|
|
203
|
+
declare function TreeContent<T>({ children, className, ariaLabel }: TreeContentProps<T>): react_jsx_runtime.JSX.Element;
|
|
204
|
+
|
|
205
|
+
interface TreeSearchInputProps {
|
|
206
|
+
className?: string;
|
|
207
|
+
showMatches?: boolean;
|
|
208
|
+
}
|
|
209
|
+
declare function TreeSearchInput({ className, showMatches }: TreeSearchInputProps): react_jsx_runtime.JSX.Element;
|
|
210
|
+
|
|
211
|
+
interface TreeEmptyProps {
|
|
212
|
+
children: React.ReactNode;
|
|
213
|
+
className?: string;
|
|
214
|
+
}
|
|
215
|
+
declare function TreeEmpty({ children, className }: TreeEmptyProps): react_jsx_runtime.JSX.Element;
|
|
216
|
+
|
|
217
|
+
interface TreeSkeletonProps {
|
|
218
|
+
rows?: number;
|
|
219
|
+
className?: string;
|
|
220
|
+
}
|
|
221
|
+
declare function TreeSkeleton({ rows, className }: TreeSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
222
|
+
|
|
223
|
+
interface TreeErrorProps {
|
|
224
|
+
children: React.ReactNode;
|
|
225
|
+
className?: string;
|
|
226
|
+
}
|
|
227
|
+
declare function TreeError({ children, className }: TreeErrorProps): react_jsx_runtime.JSX.Element;
|
|
228
|
+
|
|
229
|
+
interface TreeIndentGuidesProps {
|
|
230
|
+
level: number;
|
|
231
|
+
indent: number;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Vertical guide lines under nested rows. Renders one absolute-positioned
|
|
235
|
+
* 1px column per ancestor level. Decorative — `aria-hidden` and
|
|
236
|
+
* pointer-events disabled. Opacity comes from the tree appearance.
|
|
237
|
+
*/
|
|
238
|
+
declare function TreeIndentGuides({ level, indent }: TreeIndentGuidesProps): react_jsx_runtime.JSX.Element;
|
|
239
|
+
|
|
240
|
+
interface FlattenInput<T> {
|
|
241
|
+
roots: TreeNode<T>[];
|
|
242
|
+
expandedIds: ReadonlySet<TreeItemId>;
|
|
243
|
+
cache: ChildCache<T>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Walk the tree top-to-bottom and produce a flat list of visible rows.
|
|
247
|
+
*
|
|
248
|
+
* Visibility rule: a child row appears only when every ancestor is in
|
|
249
|
+
* `expandedIds`. The output is ordered exactly as it should render,
|
|
250
|
+
* which keeps keyboard navigation (next/prev row) trivial.
|
|
251
|
+
*/
|
|
252
|
+
declare function flattenTree<T>({ roots, expandedIds, cache }: FlattenInput<T>): FlatRow<T>[];
|
|
253
|
+
|
|
254
|
+
interface PersistedTreeState {
|
|
255
|
+
expandedItems: TreeItemId[];
|
|
256
|
+
selectedItems: TreeItemId[];
|
|
257
|
+
}
|
|
258
|
+
declare function loadTreeState(key: string): PersistedTreeState | null;
|
|
259
|
+
declare function saveTreeState(key: string, state: PersistedTreeState): void;
|
|
260
|
+
declare function clearTreeState(key: string): void;
|
|
261
|
+
|
|
262
|
+
interface DemoNode {
|
|
263
|
+
name: string;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Build a deterministic synthetic tree for stories and tests.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* const data = createDemoTree({ depth: 4, breadth: 3 });
|
|
270
|
+
* <TreeRoot data={data} getItemName={(n) => n.data.name} />
|
|
271
|
+
*/
|
|
272
|
+
declare function createDemoTree({ depth, breadth, rootPrefix, }?: {
|
|
273
|
+
depth?: number;
|
|
274
|
+
breadth?: number;
|
|
275
|
+
rootPrefix?: string;
|
|
276
|
+
}): TreeNode<DemoNode>[];
|
|
277
|
+
|
|
278
|
+
export { type ChildCache, type ChildEntry, type ChildEntryStatus, type DemoNode, FlatRow, type FlattenInput, type PersistedTreeState, ResolvedAppearance, TreeRoot as Tree, TreeActivateOptions, TreeActivationMode, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuSlot, type TreeContextValue, TreeEmpty, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, TreeLabels, TreeNode, TreeProvider, type TreeProviderProps, TreeRoot, TreeRootProps, TreeRow, type TreeRowProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, flattenTree, loadTreeState, resolveChildren, saveTreeState, useTreeActions, useTreeContext, useTreeExpansion, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };
|