react-arborist 2.1.0 → 2.1.1
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/dist/hooks/use-simple-tree.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/tree-api.d.ts +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types/tree-props.d.ts +4 -4
- package/package.json +1 -1
- package/src/data/create-root.ts +1 -1
- package/src/hooks/use-simple-tree.ts +1 -1
- package/src/types/tree-props.ts +4 -4
|
@@ -6,8 +6,8 @@ import { ListOnScrollProps } from "react-window";
|
|
|
6
6
|
import { NodeApi } from "../interfaces/node-api";
|
|
7
7
|
import { OpenMap } from "../state/open-slice";
|
|
8
8
|
export interface TreeProps<T> {
|
|
9
|
-
data?: T[];
|
|
10
|
-
initialData?: T[];
|
|
9
|
+
data?: readonly T[];
|
|
10
|
+
initialData?: readonly T[];
|
|
11
11
|
onCreate?: handlers.CreateHandler<T>;
|
|
12
12
|
onMove?: handlers.MoveHandler<T>;
|
|
13
13
|
onRename?: handlers.RenameHandler<T>;
|
|
@@ -18,7 +18,7 @@ export interface TreeProps<T> {
|
|
|
18
18
|
renderCursor?: ElementType<renderers.CursorProps>;
|
|
19
19
|
renderContainer?: ElementType<{}>;
|
|
20
20
|
rowHeight?: number;
|
|
21
|
-
width?: number;
|
|
21
|
+
width?: number | string;
|
|
22
22
|
height?: number;
|
|
23
23
|
indent?: number;
|
|
24
24
|
paddingTop?: number;
|
|
@@ -28,7 +28,7 @@ export interface TreeProps<T> {
|
|
|
28
28
|
selectionFollowsFocus?: boolean;
|
|
29
29
|
disableDrag?: string | boolean | BoolFunc<T>;
|
|
30
30
|
disableDrop?: string | boolean | BoolFunc<T>;
|
|
31
|
-
childrenAccessor?: string | ((d: T) => T[]);
|
|
31
|
+
childrenAccessor?: string | ((d: T) => T[] | null);
|
|
32
32
|
idAccessor?: string | ((d: T) => string);
|
|
33
33
|
onActivate?: (node: NodeApi<T>) => void;
|
|
34
34
|
onSelect?: (nodes: NodeApi<T>[]) => void;
|
package/package.json
CHANGED
package/src/data/create-root.ts
CHANGED
|
@@ -44,7 +44,7 @@ export function createRoot<T>(tree: TreeApi<T>): NodeApi<T> {
|
|
|
44
44
|
rowIndex: null,
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
const data: T[] = tree.props.data ?? [];
|
|
47
|
+
const data: readonly T[] = tree.props.data ?? [];
|
|
48
48
|
|
|
49
49
|
root.children = data.map((child) => {
|
|
50
50
|
return visitSelfAndChildren(child, 0, root);
|
|
@@ -16,7 +16,7 @@ export type SimpleTreeData = {
|
|
|
16
16
|
|
|
17
17
|
let nextId = 0;
|
|
18
18
|
|
|
19
|
-
export function useSimpleTree<T>(initialData: T[]) {
|
|
19
|
+
export function useSimpleTree<T>(initialData: readonly T[]) {
|
|
20
20
|
const [data, setData] = useState(initialData);
|
|
21
21
|
const tree = useMemo(
|
|
22
22
|
() =>
|
package/src/types/tree-props.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { OpenMap, OpenSlice } from "../state/open-slice";
|
|
|
8
8
|
|
|
9
9
|
export interface TreeProps<T> {
|
|
10
10
|
/* Data Options */
|
|
11
|
-
data?: T[];
|
|
12
|
-
initialData?: T[];
|
|
11
|
+
data?: readonly T[];
|
|
12
|
+
initialData?: readonly T[];
|
|
13
13
|
|
|
14
14
|
/* Data Handlers */
|
|
15
15
|
onCreate?: handlers.CreateHandler<T>;
|
|
@@ -26,7 +26,7 @@ export interface TreeProps<T> {
|
|
|
26
26
|
|
|
27
27
|
/* Sizes */
|
|
28
28
|
rowHeight?: number;
|
|
29
|
-
width?: number;
|
|
29
|
+
width?: number | string;
|
|
30
30
|
height?: number;
|
|
31
31
|
indent?: number;
|
|
32
32
|
paddingTop?: number;
|
|
@@ -38,7 +38,7 @@ export interface TreeProps<T> {
|
|
|
38
38
|
selectionFollowsFocus?: boolean;
|
|
39
39
|
disableDrag?: string | boolean | BoolFunc<T>;
|
|
40
40
|
disableDrop?: string | boolean | BoolFunc<T>;
|
|
41
|
-
childrenAccessor?: string | ((d: T) => T[]);
|
|
41
|
+
childrenAccessor?: string | ((d: T) => T[] | null);
|
|
42
42
|
idAccessor?: string | ((d: T) => string);
|
|
43
43
|
|
|
44
44
|
/* Event Handlers */
|