@react-stately/data 3.15.2 → 3.16.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/dist/import.mjs +4 -4
- package/dist/main.js +6 -6
- package/dist/main.js.map +1 -1
- package/dist/module.js +4 -4
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +6 -0
- package/package.json +17 -13
- package/src/index.ts +6 -6
- package/dist/types.d.ts +0 -276
- package/dist/types.d.ts.map +0 -1
- package/dist/useAsyncList.main.js +0 -290
- package/dist/useAsyncList.main.js.map +0 -1
- package/dist/useAsyncList.mjs +0 -285
- package/dist/useAsyncList.module.js +0 -285
- package/dist/useAsyncList.module.js.map +0 -1
- package/dist/useListData.main.js +0 -256
- package/dist/useListData.main.js.map +0 -1
- package/dist/useListData.mjs +0 -250
- package/dist/useListData.module.js +0 -250
- package/dist/useListData.module.js.map +0 -1
- package/dist/useTreeData.main.js +0 -342
- package/dist/useTreeData.main.js.map +0 -1
- package/dist/useTreeData.mjs +0 -337
- package/dist/useTreeData.module.js +0 -337
- package/dist/useTreeData.module.js.map +0 -1
- package/src/useAsyncList.ts +0 -358
- package/src/useListData.ts +0 -430
- package/src/useTreeData.ts +0 -540
package/dist/import.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {useAsyncList as $
|
|
2
|
-
import {useTreeData as $
|
|
3
|
-
import {useListData as $
|
|
1
|
+
import {useAsyncList as $c024390cb0176da8$re_export$useAsyncList} from "react-stately/useAsyncList";
|
|
2
|
+
import {useTreeData as $c024390cb0176da8$re_export$useTreeData} from "react-stately/useTreeData";
|
|
3
|
+
import {useListData as $c024390cb0176da8$re_export$useListData} from "react-stately/useListData";
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -17,5 +17,5 @@ import {useListData as $0d86e9c8f07f9a7b$export$762f73dccccd255d} from "./useLis
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
export {$
|
|
20
|
+
export {$c024390cb0176da8$re_export$useAsyncList as useAsyncList, $c024390cb0176da8$re_export$useTreeData as useTreeData, $c024390cb0176da8$re_export$useListData as useListData};
|
|
21
21
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
1
|
+
var $6Xc97$reactstatelyuseAsyncList = require("react-stately/useAsyncList");
|
|
2
|
+
var $6Xc97$reactstatelyuseTreeData = require("react-stately/useTreeData");
|
|
3
|
+
var $6Xc97$reactstatelyuseListData = require("react-stately/useListData");
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function $parcel$export(e, n, v, s) {
|
|
7
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
$parcel$export(module.exports, "useAsyncList", ()
|
|
11
|
-
$parcel$export(module.exports, "useTreeData", ()
|
|
12
|
-
$parcel$export(module.exports, "useListData", ()
|
|
10
|
+
$parcel$export(module.exports, "useAsyncList", function () { return $6Xc97$reactstatelyuseAsyncList.useAsyncList; });
|
|
11
|
+
$parcel$export(module.exports, "useTreeData", function () { return $6Xc97$reactstatelyuseTreeData.useTreeData; });
|
|
12
|
+
$parcel$export(module.exports, "useListData", function () { return $6Xc97$reactstatelyuseListData.useListData; });
|
|
13
13
|
/*
|
|
14
14
|
* Copyright 2020 Adobe. All rights reserved.
|
|
15
15
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/data/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useAsyncList} from '
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/data/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useAsyncList} from 'react-stately/useAsyncList';\n\nexport {useTreeData} from 'react-stately/useTreeData';\nexport {useListData} from 'react-stately/useListData';\nexport type {ListOptions, ListData} from 'react-stately/useListData';\nexport type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from 'react-stately/useAsyncList';\nexport type {TreeOptions, TreeData} from 'react-stately/useTreeData';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {useAsyncList as $
|
|
2
|
-
import {useTreeData as $
|
|
3
|
-
import {useListData as $
|
|
1
|
+
import {useAsyncList as $c024390cb0176da8$re_export$useAsyncList} from "react-stately/useAsyncList";
|
|
2
|
+
import {useTreeData as $c024390cb0176da8$re_export$useTreeData} from "react-stately/useTreeData";
|
|
3
|
+
import {useListData as $c024390cb0176da8$re_export$useListData} from "react-stately/useListData";
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -17,5 +17,5 @@ import {useListData as $0d86e9c8f07f9a7b$export$762f73dccccd255d} from "./useLis
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
export {$
|
|
20
|
+
export {$c024390cb0176da8$re_export$useAsyncList as useAsyncList, $c024390cb0176da8$re_export$useTreeData as useTreeData, $c024390cb0176da8$re_export$useListData as useListData};
|
|
21
21
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/data/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useAsyncList} from '
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/data/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useAsyncList} from 'react-stately/useAsyncList';\n\nexport {useTreeData} from 'react-stately/useTreeData';\nexport {useListData} from 'react-stately/useListData';\nexport type {ListOptions, ListData} from 'react-stately/useListData';\nexport type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from 'react-stately/useAsyncList';\nexport type {TreeOptions, TreeData} from 'react-stately/useTreeData';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useAsyncList } from 'react-stately/useAsyncList';
|
|
2
|
+
export { useTreeData } from 'react-stately/useTreeData';
|
|
3
|
+
export { useListData } from 'react-stately/useListData';
|
|
4
|
+
export type { ListOptions, ListData } from 'react-stately/useListData';
|
|
5
|
+
export type { AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate } from 'react-stately/useAsyncList';
|
|
6
|
+
export type { TreeOptions, TreeData } from 'react-stately/useTreeData';
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/data",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"./dist/types.d.ts",
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/types/src/index.d.ts",
|
|
12
|
+
"import": "./dist/import.mjs",
|
|
13
|
+
"require": "./dist/main.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
|
-
"types": "dist/types.d.ts",
|
|
17
|
+
"types": "dist/types/src/index.d.ts",
|
|
18
18
|
"source": "src/index.ts",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
@@ -26,14 +26,18 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
29
|
+
"@swc/helpers": "^0.5.0",
|
|
30
|
+
"react-stately": "3.46.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
33
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
34
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
38
|
},
|
|
38
|
-
"
|
|
39
|
+
"targets": {
|
|
40
|
+
"types": false
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
39
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export {useAsyncList} from '
|
|
14
|
-
export {useTreeData} from './useTreeData';
|
|
15
|
-
export {useListData} from './useListData';
|
|
13
|
+
export {useAsyncList} from 'react-stately/useAsyncList';
|
|
16
14
|
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export type {
|
|
15
|
+
export {useTreeData} from 'react-stately/useTreeData';
|
|
16
|
+
export {useListData} from 'react-stately/useListData';
|
|
17
|
+
export type {ListOptions, ListData} from 'react-stately/useListData';
|
|
18
|
+
export type {AsyncListOptions, AsyncListData, AsyncListLoadFunction, AsyncListLoadOptions, AsyncListStateUpdate} from 'react-stately/useAsyncList';
|
|
19
|
+
export type {TreeOptions, TreeData} from 'react-stately/useTreeData';
|
package/dist/types.d.ts
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { Key, Selection, LoadingState, SortDescriptor } from "@react-types/shared";
|
|
2
|
-
export interface ListOptions<T> {
|
|
3
|
-
/** Initial items in the list. */
|
|
4
|
-
initialItems?: T[];
|
|
5
|
-
/** The keys for the initially selected items. */
|
|
6
|
-
initialSelectedKeys?: 'all' | Iterable<Key>;
|
|
7
|
-
/** The initial text to filter the list by. */
|
|
8
|
-
initialFilterText?: string;
|
|
9
|
-
/** A function that returns a unique key for an item object. */
|
|
10
|
-
getKey?: (item: T) => Key;
|
|
11
|
-
/** A function that returns whether a item matches the current filter text. */
|
|
12
|
-
filter?: (item: T, filterText: string) => boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface ListData<T> {
|
|
15
|
-
/** The items in the list. */
|
|
16
|
-
items: T[];
|
|
17
|
-
/** The keys of the currently selected items in the list. */
|
|
18
|
-
selectedKeys: Selection;
|
|
19
|
-
/** Sets the selected keys. */
|
|
20
|
-
setSelectedKeys(keys: Selection): void;
|
|
21
|
-
/** Adds the given keys to the current selected keys. */
|
|
22
|
-
addKeysToSelection(keys: Selection): void;
|
|
23
|
-
/** Removes the given keys from the current selected keys. */
|
|
24
|
-
removeKeysFromSelection(keys: Selection): void;
|
|
25
|
-
/** The current filter text. */
|
|
26
|
-
filterText: string;
|
|
27
|
-
/** Sets the filter text. */
|
|
28
|
-
setFilterText(filterText: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* Gets an item from the list by key.
|
|
31
|
-
* @param key - The key of the item to retrieve.
|
|
32
|
-
*/
|
|
33
|
-
getItem(key: Key): T | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Inserts items into the list at the given index.
|
|
36
|
-
* @param index - The index to insert into.
|
|
37
|
-
* @param values - The values to insert.
|
|
38
|
-
*/
|
|
39
|
-
insert(index: number, ...values: T[]): void;
|
|
40
|
-
/**
|
|
41
|
-
* Inserts items into the list before the item at the given key.
|
|
42
|
-
* @param key - The key of the item to insert before.
|
|
43
|
-
* @param values - The values to insert.
|
|
44
|
-
*/
|
|
45
|
-
insertBefore(key: Key, ...values: T[]): void;
|
|
46
|
-
/**
|
|
47
|
-
* Inserts items into the list after the item at the given key.
|
|
48
|
-
* @param key - The key of the item to insert after.
|
|
49
|
-
* @param values - The values to insert.
|
|
50
|
-
*/
|
|
51
|
-
insertAfter(key: Key, ...values: T[]): void;
|
|
52
|
-
/**
|
|
53
|
-
* Appends items to the list.
|
|
54
|
-
* @param values - The values to insert.
|
|
55
|
-
*/
|
|
56
|
-
append(...values: T[]): void;
|
|
57
|
-
/**
|
|
58
|
-
* Prepends items to the list.
|
|
59
|
-
* @param value - The value to insert.
|
|
60
|
-
*/
|
|
61
|
-
prepend(...values: T[]): void;
|
|
62
|
-
/**
|
|
63
|
-
* Removes items from the list by their keys.
|
|
64
|
-
* @param keys - The keys of the item to remove.
|
|
65
|
-
*/
|
|
66
|
-
remove(...keys: Key[]): void;
|
|
67
|
-
/**
|
|
68
|
-
* Removes all items from the list that are currently
|
|
69
|
-
* in the set of selected items.
|
|
70
|
-
*/
|
|
71
|
-
removeSelectedItems(): void;
|
|
72
|
-
/**
|
|
73
|
-
* Moves an item within the list.
|
|
74
|
-
* @param key - The key of the item to move.
|
|
75
|
-
* @param toIndex - The index to move the item to.
|
|
76
|
-
*/
|
|
77
|
-
move(key: Key, toIndex: number): void;
|
|
78
|
-
/**
|
|
79
|
-
* Moves one or more items before a given key.
|
|
80
|
-
* @param key - The key of the item to move the items before.
|
|
81
|
-
* @param keys - The keys of the items to move.
|
|
82
|
-
*/
|
|
83
|
-
moveBefore(key: Key, keys: Iterable<Key>): void;
|
|
84
|
-
/**
|
|
85
|
-
* Moves one or more items after a given key.
|
|
86
|
-
* @param key - The key of the item to move the items after.
|
|
87
|
-
* @param keys - The keys of the items to move.
|
|
88
|
-
*/
|
|
89
|
-
moveAfter(key: Key, keys: Iterable<Key>): void;
|
|
90
|
-
/**
|
|
91
|
-
* Updates an item in the list.
|
|
92
|
-
* @param key - The key of the item to update.
|
|
93
|
-
* @param newValue - The new value for the item, or a function that returns the new value based on the previous value.
|
|
94
|
-
*/
|
|
95
|
-
update(key: Key, newValue: T | ((prev: T) => T)): void;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Manages state for an immutable list data structure, and provides convenience methods to
|
|
99
|
-
* update the data over time.
|
|
100
|
-
*/
|
|
101
|
-
export function useListData<T>(options: ListOptions<T>): ListData<T>;
|
|
102
|
-
export interface AsyncListOptions<T, C> {
|
|
103
|
-
/** The keys for the initially selected items. */
|
|
104
|
-
initialSelectedKeys?: Iterable<Key>;
|
|
105
|
-
/** The initial sort descriptor. */
|
|
106
|
-
initialSortDescriptor?: SortDescriptor;
|
|
107
|
-
/** The initial filter text. */
|
|
108
|
-
initialFilterText?: string;
|
|
109
|
-
/** A function that returns a unique key for an item object. */
|
|
110
|
-
getKey?: (item: T) => Key;
|
|
111
|
-
/** A function that loads the data for the items in the list. */
|
|
112
|
-
load: AsyncListLoadFunction<T, C>;
|
|
113
|
-
/**
|
|
114
|
-
* An optional function that performs sorting. If not provided,
|
|
115
|
-
* then `sortDescriptor` is passed to the `load` function.
|
|
116
|
-
*/
|
|
117
|
-
sort?: AsyncListLoadFunction<T, C, AsyncListLoadOptions<T, C> & {
|
|
118
|
-
sortDescriptor: SortDescriptor;
|
|
119
|
-
}>;
|
|
120
|
-
}
|
|
121
|
-
type AsyncListLoadFunction<T, C, S extends AsyncListLoadOptions<T, C> = AsyncListLoadOptions<T, C>> = (state: S) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;
|
|
122
|
-
interface AsyncListLoadOptions<T, C> {
|
|
123
|
-
/** The items currently in the list. */
|
|
124
|
-
items: T[];
|
|
125
|
-
/** The keys of the currently selected items in the list. */
|
|
126
|
-
selectedKeys: Selection;
|
|
127
|
-
/** The current sort descriptor for the list. */
|
|
128
|
-
sortDescriptor?: SortDescriptor;
|
|
129
|
-
/** An abort signal used to notify the load function that the request has been aborted. */
|
|
130
|
-
signal: AbortSignal;
|
|
131
|
-
/** The pagination cursor returned from the last page load. */
|
|
132
|
-
cursor?: C;
|
|
133
|
-
/** The current filter text used to perform server side filtering. */
|
|
134
|
-
filterText?: string;
|
|
135
|
-
/** The current loading state of the list. */
|
|
136
|
-
loadingState?: LoadingState;
|
|
137
|
-
}
|
|
138
|
-
interface AsyncListStateUpdate<T, C> {
|
|
139
|
-
/** The new items to append to the list. */
|
|
140
|
-
items: Iterable<T>;
|
|
141
|
-
/** The keys to add to the selection. */
|
|
142
|
-
selectedKeys?: Iterable<Key>;
|
|
143
|
-
/** The sort descriptor to set. */
|
|
144
|
-
sortDescriptor?: SortDescriptor;
|
|
145
|
-
/** The pagination cursor to be used for the next page load. */
|
|
146
|
-
cursor?: C;
|
|
147
|
-
/** The updated filter text for the list. */
|
|
148
|
-
filterText?: string;
|
|
149
|
-
}
|
|
150
|
-
export interface AsyncListData<T> extends ListData<T> {
|
|
151
|
-
/** Whether data is currently being loaded. */
|
|
152
|
-
isLoading: boolean;
|
|
153
|
-
/** If loading data failed, then this contains the error that occurred. */
|
|
154
|
-
error?: Error;
|
|
155
|
-
/** The current sort descriptor for the list. */
|
|
156
|
-
sortDescriptor?: SortDescriptor;
|
|
157
|
-
/** Reloads the data in the list. */
|
|
158
|
-
reload(): void;
|
|
159
|
-
/** Loads the next page of data in the list. */
|
|
160
|
-
loadMore(): void;
|
|
161
|
-
/** Triggers sorting for the list. */
|
|
162
|
-
sort(descriptor: SortDescriptor): void;
|
|
163
|
-
/** The current loading state for the list. */
|
|
164
|
-
loadingState: LoadingState;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Manages state for an immutable async loaded list data structure, and provides convenience methods to
|
|
168
|
-
* update the data over time. Manages loading and error states, pagination, and sorting.
|
|
169
|
-
*/
|
|
170
|
-
export function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T>;
|
|
171
|
-
export interface TreeOptions<T extends object> {
|
|
172
|
-
/** Initial root items in the tree. */
|
|
173
|
-
initialItems?: T[];
|
|
174
|
-
/** The keys for the initially selected items. */
|
|
175
|
-
initialSelectedKeys?: Iterable<Key>;
|
|
176
|
-
/** A function that returns a unique key for an item object. */
|
|
177
|
-
getKey?: (item: T) => Key;
|
|
178
|
-
/** A function that returns the children for an item object. */
|
|
179
|
-
getChildren?: (item: T) => T[];
|
|
180
|
-
}
|
|
181
|
-
interface TreeNode<T extends object> {
|
|
182
|
-
/** A unique key for the tree node. */
|
|
183
|
-
key: Key;
|
|
184
|
-
/** The key of the parent node. */
|
|
185
|
-
parentKey?: Key | null;
|
|
186
|
-
/** The value object for the tree node. */
|
|
187
|
-
value: T;
|
|
188
|
-
/** Children of the tree node. */
|
|
189
|
-
children: TreeNode<T>[] | null;
|
|
190
|
-
}
|
|
191
|
-
export interface TreeData<T extends object> {
|
|
192
|
-
/** The root nodes in the tree. */
|
|
193
|
-
items: TreeNode<T>[];
|
|
194
|
-
/** The keys of the currently selected items in the tree. */
|
|
195
|
-
selectedKeys: Set<Key>;
|
|
196
|
-
/** Sets the selected keys. */
|
|
197
|
-
setSelectedKeys(keys: Set<Key>): void;
|
|
198
|
-
/**
|
|
199
|
-
* Gets a node from the tree by key.
|
|
200
|
-
* @param key - The key of the item to retrieve.
|
|
201
|
-
*/
|
|
202
|
-
getItem(key: Key): TreeNode<T> | undefined;
|
|
203
|
-
/**
|
|
204
|
-
* Inserts an item into a parent node as a child.
|
|
205
|
-
* @param parentKey - The key of the parent item to insert into. `null` for the root.
|
|
206
|
-
* @param index - The index within the parent to insert into.
|
|
207
|
-
* @param value - The value to insert.
|
|
208
|
-
*/
|
|
209
|
-
insert(parentKey: Key | null, index: number, ...values: T[]): void;
|
|
210
|
-
/**
|
|
211
|
-
* Inserts items into the list before the item at the given key.
|
|
212
|
-
* @param key - The key of the item to insert before.
|
|
213
|
-
* @param values - The values to insert.
|
|
214
|
-
*/
|
|
215
|
-
insertBefore(key: Key, ...values: T[]): void;
|
|
216
|
-
/**
|
|
217
|
-
* Inserts items into the list after the item at the given key.
|
|
218
|
-
* @param key - The key of the item to insert after.
|
|
219
|
-
* @param values - The values to insert.
|
|
220
|
-
*/
|
|
221
|
-
insertAfter(key: Key, ...values: T[]): void;
|
|
222
|
-
/**
|
|
223
|
-
* Appends an item into a parent node as a child.
|
|
224
|
-
* @param parentKey - The key of the parent item to insert into. `null` for the root.
|
|
225
|
-
* @param value - The value to insert.
|
|
226
|
-
*/
|
|
227
|
-
append(parentKey: Key | null, ...values: T[]): void;
|
|
228
|
-
/**
|
|
229
|
-
* Prepends an item into a parent node as a child.
|
|
230
|
-
* @param parentKey - The key of the parent item to insert into. `null` for the root.
|
|
231
|
-
* @param value - The value to insert.
|
|
232
|
-
*/
|
|
233
|
-
prepend(parentKey: Key | null, ...value: T[]): void;
|
|
234
|
-
/**
|
|
235
|
-
* Removes an item from the tree by its key.
|
|
236
|
-
* @param key - The key of the item to remove.
|
|
237
|
-
*/
|
|
238
|
-
remove(...keys: Key[]): void;
|
|
239
|
-
/**
|
|
240
|
-
* Removes all items from the tree that are currently
|
|
241
|
-
* in the set of selected items.
|
|
242
|
-
*/
|
|
243
|
-
removeSelectedItems(): void;
|
|
244
|
-
/**
|
|
245
|
-
* Moves an item within the tree.
|
|
246
|
-
* @param key - The key of the item to move.
|
|
247
|
-
* @param toParentKey - The key of the new parent to insert into. `null` for the root.
|
|
248
|
-
* @param index - The index within the new parent to insert at.
|
|
249
|
-
*/
|
|
250
|
-
move(key: Key, toParentKey: Key | null, index: number): void;
|
|
251
|
-
/**
|
|
252
|
-
* Moves one or more items before a given key.
|
|
253
|
-
* @param key - The key of the item to move the items before.
|
|
254
|
-
* @param keys - The keys of the items to move.
|
|
255
|
-
*/
|
|
256
|
-
moveBefore(key: Key, keys: Iterable<Key>): void;
|
|
257
|
-
/**
|
|
258
|
-
* Moves one or more items after a given key.
|
|
259
|
-
* @param key - The key of the item to move the items after.
|
|
260
|
-
* @param keys - The keys of the items to move.
|
|
261
|
-
*/
|
|
262
|
-
moveAfter(key: Key, keys: Iterable<Key>): void;
|
|
263
|
-
/**
|
|
264
|
-
* Updates an item in the tree.
|
|
265
|
-
* @param key - The key of the item to update.
|
|
266
|
-
* @param newValue - The new value for the item.
|
|
267
|
-
*/
|
|
268
|
-
update(key: Key, newValue: T): void;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Manages state for an immutable tree data structure, and provides convenience methods to
|
|
272
|
-
* update the data over time.
|
|
273
|
-
*/
|
|
274
|
-
export function useTreeData<T extends object>(options: TreeOptions<T>): TreeData<T>;
|
|
275
|
-
|
|
276
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAeA,6BAA6B,CAAC;IAC5B,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;IACnB,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5C,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC;IAC1B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAA;CAClD;AAED,0BAA0B,CAAC;IACzB,6BAA6B;IAC7B,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,4DAA4D;IAC5D,YAAY,EAAE,SAAS,CAAC;IAExB,8BAA8B;IAC9B,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAEvC,wDAAwD;IACxD,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAE1C,6DAA6D;IAC7D,uBAAuB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAE/C,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,aAAa,CAAC,UAAU,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AAG,EAAE,GAAG,IAAI,CAAC;IAE7B;;;OAGG;IACH,mBAAmB,IAAI,IAAI,CAAC;IAE5B;;;;;OAKG;IACH,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7D;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAEhD;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAE/C;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAA;CACpC;AAOD;;;GAGG;AACH,4BAA4B,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CA6SlF","sources":["packages/@react-stately/data/src/packages/@react-stately/data/src/useListData.ts","packages/@react-stately/data/src/packages/@react-stately/data/src/useAsyncList.ts","packages/@react-stately/data/src/packages/@react-stately/data/src/useTreeData.ts","packages/@react-stately/data/src/packages/@react-stately/data/src/index.ts","packages/@react-stately/data/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useAsyncList} from './useAsyncList';\nexport {useTreeData} from './useTreeData';\nexport {useListData} from './useListData';\n\nexport type {ListOptions, ListData} from './useListData';\nexport type {AsyncListOptions, AsyncListData} from './useAsyncList';\nexport type {TreeOptions, TreeData} from './useTreeData';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|