https://github.com/afeiship/next-tree
Tree data for next.
https://github.com/afeiship/next-tree
ancestors descendants next tree tree-view
Last synced: 2 months ago
JSON representation
Tree data for next.
- Host: GitHub
- URL: https://github.com/afeiship/next-tree
- Owner: afeiship
- License: mit
- Created: 2019-07-10T09:17:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T13:19:33.000Z (almost 5 years ago)
- Last Synced: 2025-10-17T10:03:01.794Z (9 months ago)
- Topics: ancestors, descendants, next, tree, tree-view
- Language: JavaScript
- Size: 45.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-tree
> Tree data for next.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
npm install -S @jswork/next-tree
```
## apis
| api | params | description |
| ----------- | -------- | --------------------------- |
| children | callback | Find children only on level |
| parent | callback | Find parent only one level |
| descendants | callback | Find descendants recursion |
| ancestors | callback | Find ancestors recursion |
| find | callback | - |
| filter | callback | - |
| search | callback | - |
| table | callback | Create table data |
## usage
```js
import NxTree from '@jswork/next-tree';
const treeData = {
label: '空间',
value: '/admin/space',
children: [
{
label: '空间-子级1',
value: '/admin/space/:id',
children: [
{
label: '空间导出',
value: '/admin/space/:id/export'
}
]
},
{
label: '空间-子级2',
value: '/admin/space2/:id',
children: [
{
label: '空间导出222',
value: '/admin/space/:id/expor2222t'
}
]
}
]
};
const item = NxTree.create(treeData).find((_, item) => item.label === '空间导出222');
const data = NxTree.serialize(item);
// results:
{
label: '空间导出222',
value: '/admin/space/:id/expor2222t',
depth: 2,
independent: true
}
```
## license
Code released under [the MIT license](https://github.com/afeiship/next-tree/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-tree
[version-url]: https://npmjs.org/package/@jswork/next-tree
[license-image]: https://img.shields.io/npm/l/@jswork/next-tree
[license-url]: https://github.com/afeiship/next-tree/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-tree
[size-url]: https://github.com/afeiship/next-tree/blob/master/dist/next-tree.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-tree
[download-url]: https://www.npmjs.com/package/@jswork/next-tree