@headless-tree/react 1.3.0 → 1.5.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.
- package/CHANGELOG.md +13 -0
- package/dist/index.js +12 -10
- package/dist/index.mjs +13 -11
- package/package.json +21 -5
- package/readme.md +6 -6
- package/src/use-tree.tsx +19 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @headless-tree/react
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cbeaba6: all state updates (like setSelectedItems) will not propagate while the component is unmounted. This happened before for `tree.setState()` calls directly, but not individual state atoms like `setSelectedItems`. When calling `createTree()` directly (instead of `useTree()`), `tree.setMounted(true)` needs to be called once after mount. No changes are necessary when using the React-based `useTree()` integration. (#158)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 72e714b: all NPM deployments will now publish with provenance
|
|
12
|
+
- 7a7424f: fixed incorrect exports definition in package.json for require/cjs imports (#161)
|
|
13
|
+
|
|
14
|
+
## 1.4.0
|
|
15
|
+
|
|
3
16
|
## 1.3.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -129,18 +129,20 @@ var useTree = (config) => {
|
|
|
129
129
|
() => tree.current.getState()
|
|
130
130
|
);
|
|
131
131
|
(0, import_react2.useEffect)(() => {
|
|
132
|
+
tree.current.setMounted(true);
|
|
132
133
|
tree.current.rebuildTree();
|
|
134
|
+
return () => {
|
|
135
|
+
tree.current.setMounted(false);
|
|
136
|
+
};
|
|
133
137
|
}, [tree]);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}));
|
|
143
|
-
});
|
|
138
|
+
tree.current.setConfig((prev) => __spreadProps(__spreadValues(__spreadValues({}, prev), config), {
|
|
139
|
+
state: __spreadValues(__spreadValues({}, state), config.state),
|
|
140
|
+
setState: (state2) => {
|
|
141
|
+
var _a;
|
|
142
|
+
setState(state2);
|
|
143
|
+
(_a = config.setState) == null ? void 0 : _a.call(config, state2);
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
144
146
|
return tree.current;
|
|
145
147
|
};
|
|
146
148
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -63,7 +63,7 @@ var AssistiveTreeDescription = (_a) => {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
// src/use-tree.tsx
|
|
66
|
-
import { useEffect,
|
|
66
|
+
import { useEffect, useState } from "react";
|
|
67
67
|
import { createTree } from "@headless-tree/core";
|
|
68
68
|
var useTree = (config) => {
|
|
69
69
|
const [tree] = useState(() => ({ current: createTree(config) }));
|
|
@@ -71,18 +71,20 @@ var useTree = (config) => {
|
|
|
71
71
|
() => tree.current.getState()
|
|
72
72
|
);
|
|
73
73
|
useEffect(() => {
|
|
74
|
+
tree.current.setMounted(true);
|
|
74
75
|
tree.current.rebuildTree();
|
|
76
|
+
return () => {
|
|
77
|
+
tree.current.setMounted(false);
|
|
78
|
+
};
|
|
75
79
|
}, [tree]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}));
|
|
85
|
-
});
|
|
80
|
+
tree.current.setConfig((prev) => __spreadProps(__spreadValues(__spreadValues({}, prev), config), {
|
|
81
|
+
state: __spreadValues(__spreadValues({}, state), config.state),
|
|
82
|
+
setState: (state2) => {
|
|
83
|
+
var _a;
|
|
84
|
+
setState(state2);
|
|
85
|
+
(_a = config.setState) == null ? void 0 : _a.call(config, state2);
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
86
88
|
return tree.current;
|
|
87
89
|
};
|
|
88
90
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-tree/react",
|
|
3
|
-
"
|
|
3
|
+
"description": "The definitive tree component for the Web",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"tree",
|
|
6
|
+
"component",
|
|
7
|
+
"web",
|
|
8
|
+
"headless",
|
|
9
|
+
"ui",
|
|
10
|
+
"react",
|
|
11
|
+
"nested",
|
|
12
|
+
"async",
|
|
13
|
+
"checkbox",
|
|
14
|
+
"hook"
|
|
15
|
+
],
|
|
16
|
+
"version": "1.5.0",
|
|
4
17
|
"main": "dist/index.d.ts",
|
|
5
18
|
"module": "dist/index.mjs",
|
|
6
19
|
"types": "dist/index.d.mts",
|
|
@@ -11,8 +24,8 @@
|
|
|
11
24
|
"default": "./dist/index.mjs"
|
|
12
25
|
},
|
|
13
26
|
"require": {
|
|
14
|
-
"types": "./dist/index.
|
|
15
|
-
"default": "./dist/index.
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
16
29
|
}
|
|
17
30
|
},
|
|
18
31
|
"./react17": {
|
|
@@ -21,13 +34,16 @@
|
|
|
21
34
|
"default": "./dist/react17/index.mjs"
|
|
22
35
|
},
|
|
23
36
|
"require": {
|
|
24
|
-
"types": "./dist/react17/index.
|
|
25
|
-
"default": "./dist/react17/index.
|
|
37
|
+
"types": "./dist/react17/index.d.ts",
|
|
38
|
+
"default": "./dist/react17/index.js"
|
|
26
39
|
}
|
|
27
40
|
},
|
|
28
41
|
"./package.json": "./package.json"
|
|
29
42
|
},
|
|
30
43
|
"sideEffects": false,
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"provenance": true
|
|
46
|
+
},
|
|
31
47
|
"scripts": {
|
|
32
48
|
"build": "tsup ./src/index.ts ./src/react17/index.tsx --format esm,cjs --dts",
|
|
33
49
|
"start": "tsup ./src/index.ts --format esm,cjs --dts --watch"
|
package/readme.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://headless-tree.lukasbach.com/)
|
|
4
4
|
[](https://discord.gg/KuZ6EezzVw)
|
|
5
|
-
[](https://bsky.app/profile/lukasbach.bsky.social)
|
|
6
|
+
[](https://x.com/lukasmbach)
|
|
6
7
|
[](https://github.com/sponsors/lukasbach)
|
|
7
8
|
[](https://github.com/lukasbach)
|
|
8
9
|
[](https://www.npmjs.com/package/@headless-tree/core)
|
|
9
10
|
[](https://www.npmjs.com/package/@headless-tree/react)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
Super-easy integration of complex tree components into React. Supports ordered
|
|
12
|
+
Super-easy integration of complex tree components into React. Supports ordered
|
|
13
13
|
and unordered drag-and-drop, extensive keybindings, search, renaming and more.
|
|
14
14
|
Fully customizable and accessible. Headless Tree is the official successor for
|
|
15
15
|
[react-complex-tree](https://github.com/lukasbach/react-complex-tree).
|
|
@@ -18,7 +18,7 @@ It aims to bring the many features of complex tree views, like multi-select,
|
|
|
18
18
|
drag-and-drop, keyboard navigation, tree search, renaming and more, while
|
|
19
19
|
being unopinionated about the styling and rendering of the tree itself.
|
|
20
20
|
Accessibility is ensured by default, and the integration is extremely
|
|
21
|
-
simple and flexible.
|
|
21
|
+
simple and flexible.
|
|
22
22
|
|
|
23
23
|
The interface gives you a flat list of tree nodes
|
|
24
24
|
that you can easily render yourself, which keeps the complexity of the
|
|
@@ -39,7 +39,7 @@ to get an idea of what you can do with it.
|
|
|
39
39
|
> I have collected feedback and fixed any bugs that might arise. I've written
|
|
40
40
|
> [a blog post](https://medium.com/@lukasbach/headless-tree-and-the-future-of-react-complex-tree-fc920700e82a)
|
|
41
41
|
> about the details of the change, and the future of the library.
|
|
42
|
-
>
|
|
42
|
+
>
|
|
43
43
|
> Join
|
|
44
44
|
> [the Discord](https://discord.gg/KuZ6EezzVw) to get involved, and
|
|
45
45
|
> [follow on Bluesky](https://bsky.app/profile/lukasbach.bsky.social) to
|
|
@@ -154,4 +154,4 @@ Then, render your tree based on the tree instance returned from the hook:
|
|
|
154
154
|
```
|
|
155
155
|
|
|
156
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.
|
|
157
|
+
how to use Headless Tree, and how to customize it to your needs.
|
package/src/use-tree.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
import { TreeConfig, TreeState, createTree } from "@headless-tree/core";
|
|
3
3
|
|
|
4
4
|
export const useTree = <T,>(config: TreeConfig<T>) => {
|
|
@@ -8,24 +8,26 @@ export const useTree = <T,>(config: TreeConfig<T>) => {
|
|
|
8
8
|
);
|
|
9
9
|
|
|
10
10
|
useEffect(() => {
|
|
11
|
+
(tree.current as any).setMounted(true);
|
|
11
12
|
tree.current.rebuildTree();
|
|
12
|
-
|
|
13
|
+
return () => {
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
(tree.current as any).setMounted(false);
|
|
16
|
+
};
|
|
17
|
+
}, [tree]);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
state
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
setState
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
}));
|
|
28
|
-
});
|
|
19
|
+
tree.current.setConfig((prev) => ({
|
|
20
|
+
...prev,
|
|
21
|
+
...config,
|
|
22
|
+
state: {
|
|
23
|
+
...state,
|
|
24
|
+
...config.state,
|
|
25
|
+
},
|
|
26
|
+
setState: (state) => {
|
|
27
|
+
setState(state);
|
|
28
|
+
config.setState?.(state);
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
29
31
|
|
|
30
32
|
return tree.current;
|
|
31
33
|
};
|