@voxel51/voodo 0.0.29 → 0.0.31
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/components/Checkbox/Checkbox.d.ts +3 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.d.ts +69 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -0
- package/dist/components/ContextMenu/index.d.ts +2 -0
- package/dist/components/ContextMenu/index.d.ts.map +1 -0
- package/dist/components/Pill/Pill.d.ts +1 -0
- package/dist/components/Pill/Pill.d.ts.map +1 -1
- package/dist/components/TreeSelect/TreeSelect.d.ts +33 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts.map +1 -0
- package/dist/components/TreeSelect/TreeSelectNode.d.ts +21 -0
- package/dist/components/TreeSelect/TreeSelectNode.d.ts.map +1 -0
- package/dist/components/TreeSelect/TreeSelectPanel.d.ts +21 -0
- package/dist/components/TreeSelect/TreeSelectPanel.d.ts.map +1 -0
- package/dist/components/TreeSelect/TreeSelectSearchInput.d.ts +16 -0
- package/dist/components/TreeSelect/TreeSelectSearchInput.d.ts.map +1 -0
- package/dist/components/TreeSelect/TreeSelectTrigger.d.ts +22 -0
- package/dist/components/TreeSelect/TreeSelectTrigger.d.ts.map +1 -0
- package/dist/components/TreeSelect/index.d.ts +4 -0
- package/dist/components/TreeSelect/index.d.ts.map +1 -0
- package/dist/components/TreeSelect/tree.d.ts +100 -0
- package/dist/components/TreeSelect/tree.d.ts.map +1 -0
- package/dist/components/TreeSelect/types.d.ts +163 -0
- package/dist/components/TreeSelect/types.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7969 -6397
- package/dist/index.js.map +1 -1
- package/dist/util/useTree.d.ts +126 -0
- package/dist/util/useTree.d.ts.map +1 -0
- package/dist/voodo.css +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { ResolvedNode } from '../components/TreeSelect/types';
|
|
3
|
+
export interface UseTreeOptions {
|
|
4
|
+
/** Pre-resolved (and optionally pre-filtered) tree. */
|
|
5
|
+
tree: ResolvedNode;
|
|
6
|
+
/**
|
|
7
|
+
* Set of currently selected paths, used for `aria-selected` and `isSelected`.
|
|
8
|
+
* For single-select, pass a Set with one element. For multi-select, pass
|
|
9
|
+
* all selected paths. The hook is mode-agnostic.
|
|
10
|
+
*/
|
|
11
|
+
selection?: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Paths that must be treated as expanded regardless of user expansion state
|
|
14
|
+
* (e.g. ancestors of a search match).
|
|
15
|
+
*/
|
|
16
|
+
forceOpenPaths?: Set<string>;
|
|
17
|
+
/** Optional id prefix override; defaults to a `useId()` value. */
|
|
18
|
+
idPrefix?: string;
|
|
19
|
+
/** Scroll the active row into view on change. @default true */
|
|
20
|
+
scrollActiveIntoView?: boolean;
|
|
21
|
+
/** Fires on selectable row click and Enter on active selectable row. */
|
|
22
|
+
onSelect?: (path: string) => void;
|
|
23
|
+
/** Fires on Escape key. */
|
|
24
|
+
onEscape?: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* Fires when a branch is newly opened by user interaction
|
|
27
|
+
* (`toggleExpand`, `expand`, or ArrowRight). Does **not** fire for paths
|
|
28
|
+
* opened solely via `forceOpenPaths` (search auto-expand), and fires at
|
|
29
|
+
* most once per path transition from closed → open.
|
|
30
|
+
*/
|
|
31
|
+
onExpand?: (path: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Async load state for lazy branches. Exposed via `getLoadState` so
|
|
34
|
+
* renderers can show spinners / error icons without direct access to the
|
|
35
|
+
* map.
|
|
36
|
+
*/
|
|
37
|
+
loadState?: Map<string, "loading" | "error">;
|
|
38
|
+
/**
|
|
39
|
+
* Branches to expand initially. User can still collapse them.
|
|
40
|
+
* `resetExpansion()` restores this set rather than clearing to empty.
|
|
41
|
+
*
|
|
42
|
+
* - `Set<string>` — explicit branch paths.
|
|
43
|
+
* - `true` — expand every branch in `tree`.
|
|
44
|
+
* - `false` / `undefined` — expand nothing.
|
|
45
|
+
*/
|
|
46
|
+
defaultExpanded?: Set<string> | boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface TreeItemProps {
|
|
49
|
+
id: string;
|
|
50
|
+
role: "treeitem";
|
|
51
|
+
"aria-selected": boolean | undefined;
|
|
52
|
+
"aria-expanded": boolean | undefined;
|
|
53
|
+
"aria-posinset": number;
|
|
54
|
+
"aria-setsize": number;
|
|
55
|
+
tabIndex: -1;
|
|
56
|
+
"data-active": true | undefined;
|
|
57
|
+
onClick: () => void;
|
|
58
|
+
onMouseDown: (e: {
|
|
59
|
+
preventDefault: () => void;
|
|
60
|
+
}) => void;
|
|
61
|
+
onMouseEnter: () => void;
|
|
62
|
+
}
|
|
63
|
+
export interface TreeChevronProps {
|
|
64
|
+
"aria-expanded": boolean;
|
|
65
|
+
"aria-label": string;
|
|
66
|
+
onClick: (e: {
|
|
67
|
+
stopPropagation: () => void;
|
|
68
|
+
preventDefault: () => void;
|
|
69
|
+
}) => void;
|
|
70
|
+
onPointerDown: (e: {
|
|
71
|
+
stopPropagation: () => void;
|
|
72
|
+
preventDefault: () => void;
|
|
73
|
+
}) => void;
|
|
74
|
+
onPointerUp: (e: {
|
|
75
|
+
stopPropagation: () => void;
|
|
76
|
+
preventDefault: () => void;
|
|
77
|
+
}) => void;
|
|
78
|
+
}
|
|
79
|
+
export interface UseTreeReturn {
|
|
80
|
+
/** Flat list of visible nodes in DOM render order. */
|
|
81
|
+
visibleNodes: ResolvedNode[];
|
|
82
|
+
/** Set of explicitly expanded paths (excludes forceOpenPaths). */
|
|
83
|
+
expandedPaths: Set<string>;
|
|
84
|
+
/** Path of the keyboard-active row, or `null`. */
|
|
85
|
+
activePath: string | null;
|
|
86
|
+
/** DOM id of the active row, for `aria-activedescendant`. */
|
|
87
|
+
activeDescendantId: string | undefined;
|
|
88
|
+
/** Toggle a branch open/closed. */
|
|
89
|
+
toggleExpand: (path: string) => void;
|
|
90
|
+
/** Expand a branch (no-op if already open). */
|
|
91
|
+
expand: (path: string) => void;
|
|
92
|
+
/** Collapse a branch (no-op if already closed). */
|
|
93
|
+
collapse: (path: string) => void;
|
|
94
|
+
/** Clear all user-expanded paths. */
|
|
95
|
+
resetExpansion: () => void;
|
|
96
|
+
/** Set the active (keyboard-highlighted) path. */
|
|
97
|
+
setActivePath: (path: string | null) => void;
|
|
98
|
+
/** Spread onto the outer `<div role="treeitem">` wrapper. */
|
|
99
|
+
getItemProps: (node: ResolvedNode) => TreeItemProps;
|
|
100
|
+
/** Spread onto the chevron `<button>`. */
|
|
101
|
+
getChevronProps: (node: ResolvedNode) => TreeChevronProps;
|
|
102
|
+
/** `onKeyDown` handler for the element that holds virtual focus (e.g. search input). */
|
|
103
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
104
|
+
/** Get the DOM id for a given path. */
|
|
105
|
+
rowId: (path: string) => string;
|
|
106
|
+
/** Whether a path is effectively open (expanded or force-open). */
|
|
107
|
+
isOpen: (path: string) => boolean;
|
|
108
|
+
/** Whether a path is the keyboard-active row. */
|
|
109
|
+
isActive: (path: string) => boolean;
|
|
110
|
+
/** Whether a node is the selected value. */
|
|
111
|
+
isSelected: (node: ResolvedNode) => boolean;
|
|
112
|
+
/** Whether any descendant of a node is in the current selection. */
|
|
113
|
+
hasSelectedDescendant: (node: ResolvedNode) => boolean;
|
|
114
|
+
/** Async load state for a path: `"loading"`, `"error"`, or `undefined`. */
|
|
115
|
+
getLoadState: (path: string) => "loading" | "error" | undefined;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Headless hook that manages tree state: expansion, active (keyboard) path,
|
|
119
|
+
* keyboard navigation per WAI-ARIA treeview semantics, ARIA prop generation,
|
|
120
|
+
* and scroll-into-view. Owns no rendering or styling.
|
|
121
|
+
*
|
|
122
|
+
* Designed to be consumed by `TreeSelect` and `TreeSelectNode` but generic
|
|
123
|
+
* enough for any component that renders a tree of `ResolvedNode`s.
|
|
124
|
+
*/
|
|
125
|
+
export declare function useTree(options: UseTreeOptions): UseTreeReturn;
|
|
126
|
+
//# sourceMappingURL=useTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTree.d.ts","sourceRoot":"","sources":["../../src/util/useTree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAOnB,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAMlE,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,IAAI,EAAE,YAAY,CAAC;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB;;;OAGG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC;IAC7C;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;CACzC;AAED,MAAM,WAAW,aAAa;IAC5B,EA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