@headless-tree/react 1.0.1 → 1.1.0

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.json +1 -1
  3. package/readme.md +0 -157
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @headless-tree/react
2
2
 
3
+ ## 1.1.0
4
+
3
5
  ## 1.0.1
4
6
 
5
7
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-tree/react",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "main": "lib/cjs/index.js",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/esm/index.d.ts",
package/readme.md DELETED
@@ -1,157 +0,0 @@
1
- ![Headless Tree](./packages/docs/static/img/banner-github.png)
2
-
3
- [![Documentation](https://img.shields.io/badge/docs-1e1f22?style=flat)](https://headless-tree.lukasbach.com/)
4
- [![Chat on Discord](https://img.shields.io/badge/discord-4c57d9?style=flat&logo=discord&logoColor=ffffff)](https://discord.gg/KuZ6EezzVw)
5
- [![Follow on BLuesky](https://img.shields.io/badge/bluesky-0285FF?style=flat&logo=bluesky&logoColor=ffffff)](https://bsky.app/profile/lukasbach.bsky.social)
6
- [![Support on Github Sponsors](https://img.shields.io/badge/sponsor-EA4AAA?style=flat&logo=githubsponsors&logoColor=ffffff)](https://github.com/sponsors/lukasbach)
7
- [![Follow on Github](https://img.shields.io/badge/follow-181717?style=flat&logo=github&logoColor=ffffff)](https://github.com/lukasbach)
8
- [![NPM Core package](https://img.shields.io/badge/core-CB3837?style=flat&logo=npm&logoColor=ffffff)](https://www.npmjs.com/package/@headless-tree/core)
9
- [![NPM React package](https://img.shields.io/badge/react-CB3837?style=flat&logo=npm&logoColor=ffffff)](https://www.npmjs.com/package/@headless-tree/react)
10
-
11
-
12
- Super-easy integration of complex tree components into React. Supports ordered
13
- and unordered drag-and-drop, extensive keybindings, search, renaming and more.
14
- Fully customizable and accessible. Headless Tree is the official successor for
15
- [react-complex-tree](https://github.com/lukasbach/react-complex-tree).
16
-
17
- It aims to bring the many features of complex tree views, like multi-select,
18
- drag-and-drop, keyboard navigation, tree search, renaming and more, while
19
- being unopinionated about the styling and rendering of the tree itself.
20
- Accessibility is ensured by default, and the integration is extremely
21
- simple and flexible.
22
-
23
- The interface gives you a flat list of tree nodes
24
- that you can easily render yourself, which keeps the complexity of the
25
- code low and allows you to customize the tree to your needs. This flat
26
- structure also allows you to virtualize the tree with any virtualization
27
- library you want. The library automatically provides the necessary
28
- aria tags to emulate a nested tree structure, so that accessibility
29
- requirements are met despite the flat structure.
30
-
31
- Dive into [the Get Started page](https://headless-tree.lukasbach.com/getstarted)
32
- to find out how to use Headless Tree, or have a look at
33
- [the samples on the Headless Tree Homepage](https://headless-tree.lukasbach.com/#demogrid)
34
- to get an idea of what you can do with it.
35
-
36
- > [!TIP]
37
- > Headless Tree is now available as Beta! The library is mostly stable and
38
- > production ready, and will be generally released within two months, once
39
- > I have collected feedback and fixed any bugs that might arise. I've written
40
- > [a blog post](https://medium.com/@lukasbach/headless-tree-and-the-future-of-react-complex-tree-fc920700e82a)
41
- > about the details of the change, and the future of the library.
42
- >
43
- > Join
44
- > [the Discord](https://discord.gg/KuZ6EezzVw) to get involved, and
45
- > [follow on Bluesky](https://bsky.app/profile/lukasbach.bsky.social) to
46
- > stay up to date.
47
-
48
- ## Features
49
-
50
- - [Simple Interface](https://headless-tree.lukasbach.com/?demo=0#demogrid): Easy integration in React with full customizability of DOM
51
- - [Drag and Drop](https://headless-tree.lukasbach.com/?demo=1#demogrid): Powerful ordered drag-and-drop, that can interact with external drag events
52
- - [Scalable](https://headless-tree.lukasbach.com/?demo=2#demogrid): Headless Tree remains performant even with large trees
53
- - [Virtualization Support](https://headless-tree.lukasbach.com/?demo=3#demogrid): Compatible with common virtualization library to support 100k+ items
54
- - [Hotkeys!](https://headless-tree.lukasbach.com/?demo=4#demogrid): Lots of hotkeys, fully customizable
55
- - [Search Support](https://headless-tree.lukasbach.com/?demo=5#demogrid): Typeahead anywhere in the tree to quickly search the entire tree
56
- - [Rename items](https://headless-tree.lukasbach.com/?demo=6#demogrid): Optionally allow users to rename items inside the tree
57
- - [Manage State](https://headless-tree.lukasbach.com/?demo=7#demogrid): Let Headless Tree manage tree state internally, or manage any part of it yourself
58
- - [Customize Behavior](https://headless-tree.lukasbach.com/?demo=8#demogrid): Easily overwrite internal behavior like requiring double clicks on items to expand
59
- - [Customize Logic](https://headless-tree.lukasbach.com/?demo=9#demogrid): Overwrite or expand any internal behavior of Headless Tree
60
- - [Async Data Support](https://headless-tree.lukasbach.com/?demo=10#demogrid): Use synchronous or asynchronous data sources for your tree. Headless Tree comes with optional caching for async data
61
- - Free of dependencies
62
- - Or check out [this comprehensive playground](https://headless-tree.lukasbach.com/?demo=11#demogrid) that has most of the capabilities enabled.
63
-
64
- ## Bundle Size
65
-
66
- Headless Tree exports individual features in a tree-shaking-friendly
67
- way, allowing you to only include what you need to keep your bundle size
68
- small. Listed bundle sizes are based on min+gzipped bundles, and are
69
- based on the Bundlephobia report as of Headless Tree v0.0.15.
70
-
71
- | Feature | Bundle Size |
72
- |------------------------|-------------|
73
- | Tree Core | 3.1kB |
74
- | Sync Data Loader | 0.8kB |
75
- | Async Data Loader | 1.4kB |
76
- | Selections | 1.1kB |
77
- | Drag and Drop | 2.8kB |
78
- | Keyboard Drag and Drop | 2.7kB |
79
- | Hotkeys | 0.8kB |
80
- | Tree Search | 1.3kB |
81
- | Renaming | 0.9kB |
82
- | Expand All | 0.7kB |
83
- | React Bindings | 0.4kB |
84
-
85
- Total bundle size is 9.5kB plus 0.4kB for the React bindings. Note that
86
- the sum of features is bigger than the total bundle size, because several
87
- features share code. Tree-shaking will ensure that the minimum amount of
88
- code is included in your bundle.
89
-
90
- ## Get Started
91
-
92
- > [!TIP]
93
- > You can find a comprehensive [get-started guide](https://headless-tree.lukasbach.com/getstarted)
94
- > on the documentation homepage. The following gives a brief overview.
95
-
96
- Install Headless Tree via npm:
97
-
98
- ```bash
99
- npm install @headless-tree/core @headless-tree/react
100
- ```
101
-
102
- In your react component, call the `useTree` hook from `@headless-tree/react` with the configuration of
103
- your tree:
104
-
105
- ```tsx
106
- import {
107
- hotkeysCoreFeature,
108
- selectionFeature,
109
- syncDataLoaderFeature,
110
- } from "@headless-tree/core";
111
- import { useTree } from "@headless-tree/react";
112
-
113
- const tree = useTree<string>({
114
- initialState: { expandedItems: ["folder-1"] },
115
- rootItemId: "folder",
116
- getItemName: (item) => item.getItemData(),
117
- isItemFolder: (item) => !item.getItemData().endsWith("item"),
118
- dataLoader: {
119
- getItem: (itemId) => itemId,
120
- getChildren: (itemId) => [
121
- `${itemId}-folder`,
122
- `${itemId}-1-item`,
123
- `${itemId}-2-item`,
124
- ],
125
- },
126
- indent: 20,
127
- features: [syncDataLoaderFeature, selectionFeature, hotkeysCoreFeature],
128
- });
129
- ```
130
-
131
- Then, render your tree based on the tree instance returned from the hook:
132
-
133
- ```tsx
134
- <div {...tree.getContainerProps()} className="tree">
135
- {tree.getItems().map((item) => (
136
- <button
137
- {...item.getProps()}
138
- key={item.getId()}
139
- style={{ paddingLeft: `${item.getItemMeta().level * 20}px` }}
140
- >
141
- <div
142
- className={cx("treeitem", {
143
- focused: item.isFocused(),
144
- expanded: item.isExpanded(),
145
- selected: item.isSelected(),
146
- folder: item.isFolder(),
147
- })}
148
- >
149
- {item.getItemName()}
150
- </div>
151
- </button>
152
- ))}
153
- </div>
154
- ```
155
-
156
- Read on in the [get started guide](https://headless-tree.lukasbach.com/getstarted) to learn more about
157
- how to use Headless Tree, and how to customize it to your needs.