ink-tree-view 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +7 -3
- package/dist/index.js +12 -6
- package/package.json +5 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# ink-tree-view
|
|
2
2
|
|
|
3
|
-
[](https://github.com/costajohnt/ink-tree-view/actions/workflows/ci.yml)
|
|
4
3
|
[](https://www.npmjs.com/package/ink-tree-view)
|
|
5
|
-
[](https://github.com/costajohnt/ink-tree-view/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/costajohnt/ink-tree-view/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="media/demo.gif" alt="ink-tree-view demo" width="600">
|
|
9
|
+
</p>
|
|
6
10
|
|
|
7
11
|
A tree view component for [Ink](https://github.com/vadimdemedes/ink) (React for CLIs). Display hierarchical data with expand/collapse, keyboard navigation, selection modes, custom rendering, virtual scrolling, and async lazy loading.
|
|
8
12
|
|
|
@@ -376,7 +380,7 @@ Run `npm run build` to compile and `npm run typecheck` to verify types.
|
|
|
376
380
|
|
|
377
381
|
## Changelog
|
|
378
382
|
|
|
379
|
-
See [GitHub Releases](https://github.com/costajohnt/ink-tree-view/releases)
|
|
383
|
+
See [GitHub Releases](https://github.com/costajohnt/ink-tree-view/releases).
|
|
380
384
|
|
|
381
385
|
## License
|
|
382
386
|
|
package/dist/index.js
CHANGED
|
@@ -501,24 +501,30 @@ function useTreeViewState({
|
|
|
501
501
|
});
|
|
502
502
|
setLastData(data);
|
|
503
503
|
}
|
|
504
|
+
const onFocusChangeRef = useRef(onFocusChange);
|
|
505
|
+
onFocusChangeRef.current = onFocusChange;
|
|
506
|
+
const onExpandChangeRef = useRef(onExpandChange);
|
|
507
|
+
onExpandChangeRef.current = onExpandChange;
|
|
508
|
+
const onSelectChangeRef = useRef(onSelectChange);
|
|
509
|
+
onSelectChangeRef.current = onSelectChange;
|
|
504
510
|
const isInitialMount = useRef(true);
|
|
505
511
|
useEffect(() => {
|
|
506
512
|
if (isInitialMount.current) {
|
|
507
513
|
isInitialMount.current = false;
|
|
508
514
|
return;
|
|
509
515
|
}
|
|
510
|
-
if (state.focusedId)
|
|
511
|
-
}, [state.focusedId
|
|
516
|
+
if (state.focusedId) onFocusChangeRef.current?.(state.focusedId);
|
|
517
|
+
}, [state.focusedId]);
|
|
512
518
|
useEffect(() => {
|
|
513
519
|
if (state.expandedIds !== state.previousExpandedIds) {
|
|
514
|
-
|
|
520
|
+
onExpandChangeRef.current?.(state.expandedIds);
|
|
515
521
|
}
|
|
516
|
-
}, [state.expandedIds, state.previousExpandedIds
|
|
522
|
+
}, [state.expandedIds, state.previousExpandedIds]);
|
|
517
523
|
useEffect(() => {
|
|
518
524
|
if (state.selectedIds !== state.previousSelectedIds) {
|
|
519
|
-
|
|
525
|
+
onSelectChangeRef.current?.(state.selectedIds);
|
|
520
526
|
}
|
|
521
|
-
}, [state.selectedIds, state.previousSelectedIds
|
|
527
|
+
}, [state.selectedIds, state.previousSelectedIds]);
|
|
522
528
|
const viewportNodes = useMemo(() => {
|
|
523
529
|
return state.visibleIds.slice(state.viewportFromIndex, state.viewportToIndex).map((id) => {
|
|
524
530
|
const flat = state.nodeMap.get(id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ink-tree-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A tree view component for Ink with expand/collapse, keyboard navigation, and selection",
|
|
5
5
|
"author": "John Costa",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,8 +24,10 @@
|
|
|
24
24
|
"main": "./dist/index.js",
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"exports": {
|
|
27
|
-
"
|
|
28
|
-
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
29
31
|
},
|
|
30
32
|
"files": [
|
|
31
33
|
"dist"
|