Socket
Book a DemoInstallSign in
Socket

ink-tree-select

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink-tree-select

Directory tree select component for ink

2.3.1
latest
Source
npmnpm
Version published
Weekly downloads
13
333.33%
Maintainers
1
Weekly downloads
 
Created
Source

ink-tree-select NPM version NPM monthly downloads NPM total downloads

Tree select component built for ink

Please consider following this project's author, Sina Bayandorian, and consider starring the project to show your :heart: and support.

Table of Contents

Demo GIF

Installation

npm i ink-tree-select

Usage

// * index.tsx
// * visit the components section if you need further customization

import { render, Text } from 'ink';
import React, { useState } from 'react';
import { TreeSelect } from 'ink-tree-select';

const App = () => {
  const [selectedPath, setSelectedPath] = useState<string>('');
  const selectHandler = (path: string) => setSelectedPath(path);

  return (
    <>
      <TreeSelect root='./' onSelect={selectHandler} />
      {selectedPath.length > 0 && <Text>{selectedPath}</Text>}
    </>
  );
};

render(<App />);

Components

<TreeSelect />

TypeDefaultDescription
rootstringRoot directory to scan
onChange(activePath: string) => void;Triggers on every selected path change
onSelect(selectedPath: string) => void;Triggers once user hits Enter
optionsTreeSelectOptions{ }

TreeSelectOptions

type TreeSelectOptions = Partial<{
  // * directories to ignore - read https://www.npmjs.com/package/fast-glob#ignore
  ignore: string[];
  rootAlias: string; // defaults to '.' - tree's root
  previewColor: Color; // path preview text color
  indicatorColor: Color; // ● color
}>;

<VirtualTreeSelect />

Accepts a custom tree instead of a directory to scan

TypeDefaultDescription
treeTreeCustom directory tree
onChange(activePath: string) => void;Triggers on every selected path change
onSelect(selectedPath: string) => void;Triggers once user hits Enter
optionsVirtualTreeSelectOptions{ }

Tree

type Tree = { name: string; fullPath: string; branches: Tree[]; dir?: boolean };

VirtualTreeSelectOptions

type VirtualTreeSelectOptions = Partial<{
  previewColor: Color; // path preview text color
  indicatorColor: Color; // ● color
}>;

<MultiTreeSelect />

TypeDefaultDescription
rootstringRoot directory to scan
onChange(activePath: string, selectedPaths: string[]) => void;Triggers on every selected path change
onSelect(selectedPaths: string[]) => void;Triggers once user hits Enter
optionsTreeSelectOptions{ }

TreeSelectOptions

type TreeSelectOptions = Partial<{
  // * directories to ignore - read https://www.npmjs.com/package/fast-glob#ignore
  ignore: string[];
  rootAlias: string; // defaults to '.' - tree's root
  previewColor: Color; // path preview text color
  indicatorColor: Color; // ● color
}>;

<MultiVirtualTreeSelect />

Accepts a custom tree instead of a directory to scan

TypeDefaultDescription
treeTreeCustom directory tree
onChange(activePath: string, selectedPaths: string[]) => void;Triggers on every selected path change
onSelect(selectedPaths: string[]) => void;Triggers once user hits Enter
optionsVirtualTreeSelectOptions{ }

Tree

type Tree = { name: string; fullPath: string; branches: Tree[]; dir?: boolean };

VirtualTreeSelectOptions

type MultiVirtualTreeSelectOptions = Partial<{
  previewColor: Color; // path preview text color
  indicatorColor: Color; // (*) color
}>;

Keywords

cli

FAQs

Package last updated on 03 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.