Inspire Tree
Inspired Javascript Tree
README
Inspire Tree
Inspire Tree is a performance-driven UI tree component. This core library is "headless" (just an API, no DOM) but we do provide a DOM rendering library. We also have some basic example implementations in other popular libraries/frameworks: AngularJS, Angular2, React, and Inferno.
- API Docs
8.0 Overhaul & Modernization
Progress is currently underway to completely overhaul this repository for typescript support, monorepo design, better deployments, better tests, etc.
I have no plans to overhaul the API, only to modernize the code and improve it.
I don't have a timeline.
Features:
- Detailed and fluent API.
- Typescript Support.
- Events everywhere.
- Load data directly, via promises, or callbacks.
- Load child nodes directly or dynamically (or a mix of both).
- Tri-state checkboxes (optional).
- Multiselect (optional).
- Inline editing (optional).
- Search by plain string, RegExp, custom matcher, or external resources (optional).
- Sorting (optional).
- AMD and CommonJS support (RequireJS, Node/Webpack).
- Supports multiple instances on a single page.
- API methods to simplify moving nodes between instances.
- Solid coverage by automated tests.
Installation
- Yarn: yarn add --dev inspire-tree or
- NPM npm install --save-dev inspire-tree
If you're using InspireTree in a browser environment, and are not using a module bundler like
Webpack, Browserify, rollup, etc, you'll need to ensure lodash is available.
Usage
At the very least you must provide data source
- ```js
- var tree = new InspireTree({
- data: [{
- text: 'A node'
- }]
- });
- ```
Node objects must have at least a text property. Additional properties are listed below in "Node Configuration".
Usage with Inspire Tree DOM
If you're using our DOM rendering, you need to pass in two arguments: the tree instance, and a DOM target (css selector):
- ```js
- new InspireTreeDOM(tree, {
- target: '.tree'
- });
- ```
For more information regarding InspireTreeDOM, see the README.
Data Loading and Initialization Errors
InspireTree will try to load nodes on initialization. If an error occurs, it
will be caught in a promise that's cached as tree._loader.promise. This allows you to track the promise returned,
which can't be returned from the InspireTree constructor. This behavior may change in future major releases.
Any calls to load-related methods can use the returned promise normally.