npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@itihon/file-tree-view

v0.2.1

Published

File tree view component based on Web Components API

Readme

file-tree-view

License Build Status NPM Package Code Coverage semantic-release

File tree view web component with drag-and-drop feature.

🕑 Developing...

Install

npm install @itihon/file-tree-view

Use

import { fileTreeView } from 'file-tree-view'
// TODO: describe usage

In HTML

<script type="module" src="/path/to/file-tree-view.js"></script>

<file-tree-view id="file_explorer">
  <ftv-folder name="folder1" expanded>
      <ftv-file name="file1"></ftv-file>
      <ftv-folder name="folder2" expanded>
          <ftv-file name="file3"></ftv-file>
          <ftv-file name="file4"></ftv-file>
          <ftv-folder name="folder3"></ftv-folder>
      </ftv-folder>
      <ftv-folder name="folder4">
          <ftv-file name="file5"></ftv-file>
          <ftv-file name="file6"></ftv-file>
          <ftv-folder name="folder5"></ftv-folder>
      </ftv-folder>
  </ftv-folder>
</file-tree-view>

In JS or TS

Create an instance and add to DOM:

import FileTreeView from "@itihon/file-tree-view";

const fileTree = new FileTreeFiew();

document.body.append(fileTree);

or get a reference to an existing instance:

const fileTree = document.getElementById('file_explorer');

API

class FileTreeView

export default class FileTreeView extends HTMLElement  {
  addContent(content: FTVFile | FTVFolder): void;
  addNode(path: string, name: string, type: 'file' | 'folder'): void;
  getNodeByPath(path: string): FTVFile | FTVFolder | null;
  getSelectedItem(): FTVFolder | FTVFile | null;
  load(tree: FolderNode, root?: FolderOrFileTreeView, withRootNode?: boolean, sort?: boolean): void;
  removeNode(path: string): void;
}

class FTVFile

export default class FTVFile extends FTVNode  {
  deselect(): void;
  getContainingFolder(): FTVFolder | null;
  getName(): string;
  getNode: () => T | null;
  getRelativePath(): string;
  getTreeViewContainer(): FileTreeView | null;
  isFocused(): boolean;
  isFolder(): this is FTVFolder;
  isSelected(): boolean;
  select(): void;
  setName(name: string): void;
  toggleSelected(): void;
}

class FTVFolder

export default class FTVFolder extends FTVNode  {
  addContent(content?: FTVFile | FTVFolder | Array<FTVFile | FTVFolder> | []): void;
  clearContent(): void;
  collapse(): void;
  deselect(): void;
  expand(): void;
  get length(): number;
  getContainingFolder(): FTVFolder | null;
  getContent(): FTVRef<FTVNode>;
  getName(): string;
  getNode: () => T | null;
  getRelativePath(): string;
  getTreeViewContainer(): FileTreeView | null;
  isExpanded(): boolean;
  isFocused(): boolean;
  isFolder(): this is FTVFolder;
  isSelected(): boolean;
  select(): void;
  setName(name: string): void;
  toggleExpanded(): void;
  toggleSelected(): void;
}

Tree state

scroll
focus

Folder state

name
selected
expanded/collapsed
hovered
hint displayed
context menu displayed

File state

name
selected
hovered
hint displayed
context menu displayed

Events

fileTree.addEventListener('expand', (e) => {
  const folder = e.target;
  // ...
});

fileTree.addEventListener('collapse', (e) => {
  const folder = e.target;
  // ...
});

Instance methods

fileTree.load(/* from file system, from JSON */);
fileTree.createFile(path, fileName);
fileTree.createFolder(path, folderName);
fileTree.cut();
fileTree.copy();
fileTree.copyPath();
fileTree.paste();
fileTree.rename();
fileTree.delete();

Instance properties

fileTree.selectedItems

Features

  • [ ] make it a general tree view component, not a file tree view
  • [ ] themes
  • [x] tab control
  • [x] keyboard navigation: [x]up, [x]down, [x]left, [x]right, [x]Home, [x]End, Tabindex for main container
  • [x] hover indication
  • [ ] multiple selection
  • [ ] hint tooltip
  • [ ] aria
  • [ ] drag and drop
  • [ ] context menu
  • [ ] icons for specific file types
  • [x] loading the first level of file system, and then loading every additional folder level by clicking on it (possible with the expande/collabse events)
  • [ ] fs adapter that reflects file system state
  • [ ] sorting on [x]load, on [ ]adding content, on [ ]file/folder creation
  • [x] remember expanded child folders when a parent folder gets cleared

Issues

Refactor

  • [ ] Change type "folder" to "directory" to follow File system API convention
  • [ ] Consider changing isExpanded() method to getter. It may allow to check an instance if is folder or file.

Related

TODO

Acknowledgments

TODO

TODO

  • the remembering expanded folders feature
    • probably should be deactivatable
    • when adding nodes with methods addNode(), addContent() probably should be optional