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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024-2026 John Costa
3
+ Copyright (c) 2026 John Costa
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # ink-tree-view
2
2
 
3
- [![CI](https://github.com/costajohnt/ink-tree-view/actions/workflows/ci.yml/badge.svg)](https://github.com/costajohnt/ink-tree-view/actions/workflows/ci.yml)
4
3
  [![npm version](https://img.shields.io/npm/v/ink-tree-view)](https://www.npmjs.com/package/ink-tree-view)
5
- [![license](https://img.shields.io/npm/l/ink-tree-view)](https://github.com/costajohnt/ink-tree-view/blob/main/LICENSE)
4
+ [![CI](https://github.com/costajohnt/ink-tree-view/actions/workflows/ci.yml/badge.svg)](https://github.com/costajohnt/ink-tree-view/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/npm/l/ink-tree-view)](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) for a list of changes.
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) onFocusChange?.(state.focusedId);
511
- }, [state.focusedId, onFocusChange]);
516
+ if (state.focusedId) onFocusChangeRef.current?.(state.focusedId);
517
+ }, [state.focusedId]);
512
518
  useEffect(() => {
513
519
  if (state.expandedIds !== state.previousExpandedIds) {
514
- onExpandChange?.(state.expandedIds);
520
+ onExpandChangeRef.current?.(state.expandedIds);
515
521
  }
516
- }, [state.expandedIds, state.previousExpandedIds, onExpandChange]);
522
+ }, [state.expandedIds, state.previousExpandedIds]);
517
523
  useEffect(() => {
518
524
  if (state.selectedIds !== state.previousSelectedIds) {
519
- onSelectChange?.(state.selectedIds);
525
+ onSelectChangeRef.current?.(state.selectedIds);
520
526
  }
521
- }, [state.selectedIds, state.previousSelectedIds, onSelectChange]);
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.0",
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
- "types": "./dist/index.d.ts",
28
- "default": "./dist/index.js"
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "default": "./dist/index.js"
30
+ }
29
31
  },
30
32
  "files": [
31
33
  "dist"