@react-stately/data 3.9.3-nightly.3940 → 3.9.3-nightly.3943
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 +8 -4
- package/dist/main.js +7 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -4
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/useAsyncList.ts +6 -2
package/dist/import.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useReducer as $d70Aq$useReducer, useEffect as $d70Aq$useEffect, useState as $d70Aq$useState, useMemo as $d70Aq$useMemo} from "react";
|
|
1
|
+
import {useReducer as $d70Aq$useReducer, useRef as $d70Aq$useRef, useEffect as $d70Aq$useEffect, useState as $d70Aq$useState, useMemo as $d70Aq$useMemo} from "react";
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -433,10 +433,14 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
};
|
|
436
|
+
let didDispatchInitialFetch = (0, $d70Aq$useRef)(false);
|
|
436
437
|
(0, $d70Aq$useEffect)(()=>{
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
if (!didDispatchInitialFetch.current) {
|
|
439
|
+
dispatchFetch({
|
|
440
|
+
type: "loading"
|
|
441
|
+
}, load);
|
|
442
|
+
didDispatchInitialFetch.current = true;
|
|
443
|
+
}
|
|
440
444
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
441
445
|
}, []);
|
|
442
446
|
return {
|
package/dist/main.js
CHANGED
|
@@ -440,10 +440,14 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
|
|
|
440
440
|
});
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
|
+
let didDispatchInitialFetch = (0, $kdbv0$react.useRef)(false);
|
|
443
444
|
(0, $kdbv0$react.useEffect)(()=>{
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
if (!didDispatchInitialFetch.current) {
|
|
446
|
+
dispatchFetch({
|
|
447
|
+
type: "loading"
|
|
448
|
+
}, load);
|
|
449
|
+
didDispatchInitialFetch.current = true;
|
|
450
|
+
}
|
|
447
451
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
448
452
|
}, []);
|
|
449
453
|
return {
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AA8HO,SAAS,0CAAe,OAAuB,EAAe;IACnE,IAAI,gBACF,eAAe,EAAE,wBACjB,oBAAmB,UACnB,SAAS,CAAC,OAAc,KAAK,EAAE,IAAI,KAAK,GAAG,WAC3C,OAAM,qBACN,oBAAoB,KACrB,GAAG;IAEJ,uFAAuF;IACvF,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAQ,AAAD,EAAgB;QAC7C,OAAO;QACP,cAAc,wBAAwB,QAAQ,QAAQ,IAAI,IAAI,uBAAuB,EAAE,CAAC;QACxF,YAAY;IACd;IAEA,IAAI,gBAAgB,CAAA,GAAA,oBAAM,EACxB,IAAM,SAAS,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA,OAAQ,OAAO,MAAM,MAAM,UAAU,KAAK,MAAM,KAAK,EACvF;QAAC,MAAM,KAAK;QAAE,MAAM,UAAU;QAAE;KAAO;IAEzC,OAAO;QACL,GAAG,KAAK;QACR,OAAO;QACP,GAAG,0CAAkB;oBAAC;QAAM,GAAG,SAAS;QACxC,SAAQ,GAAQ,EAAE;YAChB,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA,OAAQ,OAAO,UAAU;QACnD;IACF;AACF;AAEO,SAAS,0CAAwB,IAA6B,EAAE,QAAkE,EAA0E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aAAa,CAAA,aAAe,CAAA;wBACnD,KAAK,WAAW,GAAG;wBACnB,WAAW,WAAW,SAAS;wBAC/B,OAAO,WAAW,KAAK;wBACvB,UAAU;+BACL,WAAW,QAAQ,CAAC,KAAK,CAAC,GAAG;4BAChC;+BACG,WAAW,QAAQ,CAAC,KAAK,CAAC;yBAC9B;oBACH,CAAA;YACF;QACF;QACA,QAAO,MAAW,EAAE,QAAW,EAAE;YAC/B,SAAS,CAAA,QAAS,WAAW,OAAO,QAAQ,CAAA,UAAW;oBACrD,IAAI,OAAoB;wBACtB,KAAK,QAAQ,GAAG;wBAChB,WAAW,QAAQ,SAAS;wBAC5B,OAAO;wBACP,UAAU,IAAI;oBAChB;oBAEA,KAAK,QAAQ,GAAG,UAAU,YAAY,WAAW,KAAK,GAAG;oBACzD,OAAO;gBACT;QACF;IACF;AACF;","sources":["packages/@react-stately/data/src/index.ts","packages/@react-stately/data/src/useAsyncList.ts","packages/@react-stately/data/src/useListData.ts","packages/@react-stately/data/src/useTreeData.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 './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","/*\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\nimport {createListActions, ListData, ListState} from './useListData';\nimport {Key, Reducer, useEffect, useReducer} from 'react';\nimport {LoadingState, Selection, SortDescriptor} from '@react-types/shared';\n\nexport interface AsyncListOptions<T, C> {\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** The initial sort descriptor. */\n initialSortDescriptor?: SortDescriptor,\n /** The initial filter text. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that loads the data for the items in the list. */\n load: AsyncListLoadFunction<T, C>,\n /**\n * An optional function that performs sorting. If not provided,\n * then `sortDescriptor` is passed to the `load` function.\n */\n sort?: AsyncListLoadFunction<T, C>\n}\n\ntype AsyncListLoadFunction<T, C> = (state: AsyncListLoadOptions<T, C>) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;\n\ninterface AsyncListLoadOptions<T, C> {\n /** The items currently in the list. */\n items: T[],\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n /** The current sort descriptor for the list. */\n sortDescriptor: SortDescriptor,\n /** An abort signal used to notify the load function that the request has been aborted. */\n signal: AbortSignal,\n /** The pagination cursor returned from the last page load. */\n cursor?: C,\n /** The current filter text used to perform server side filtering. */\n filterText?: string,\n /** The current loading state of the list. */\n loadingState?: LoadingState\n}\n\ninterface AsyncListStateUpdate<T, C> {\n /** The new items to append to the list. */\n items: Iterable<T>,\n /** The keys to add to the selection. */\n selectedKeys?: Iterable<Key>,\n /** The sort descriptor to set. */\n sortDescriptor?: SortDescriptor,\n /** The pagination cursor to be used for the next page load. */\n cursor?: C,\n /** The updated filter text for the list. */\n filterText?: string\n}\n\ninterface AsyncListState<T, C> extends ListState<T> {\n state: LoadingState,\n items: T[],\n // disabledKeys?: Iterable<Key>,\n selectedKeys: Selection,\n // selectedKey?: Key,\n // expandedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n cursor?: C\n}\n\ntype ActionType = 'success' | 'error' | 'loading' | 'loadingMore' | 'sorting' | 'update' | 'filtering';\ninterface Action<T, C> {\n type: ActionType,\n items?: Iterable<T>,\n selectedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n updater?: (state: ListState<T>) => ListState<T>,\n cursor?: C,\n filterText?: string\n}\n\nexport interface AsyncListData<T> extends ListData<T> {\n /** Whether data is currently being loaded. */\n isLoading: boolean,\n /** If loading data failed, then this contains the error that occurred. */\n error?: Error,\n // disabledKeys?: Set<Key>,\n // selectedKey?: Key,\n // expandedKeys?: Set<Key>,\n /** The current sort descriptor for the list. */\n sortDescriptor?: SortDescriptor,\n\n /** Reloads the data in the list. */\n reload(): void,\n /** Loads the next page of data in the list. */\n loadMore(): void,\n /** Triggers sorting for the list. */\n sort(descriptor: SortDescriptor): void,\n /** The current loading state for the list. */\n loadingState: LoadingState\n}\n\nfunction reducer<T, C>(data: AsyncListState<T, C>, action: Action<T, C>): AsyncListState<T, C> {\n let selectedKeys;\n switch (data.state) {\n case 'idle':\n case 'error':\n switch (action.type) {\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: action.abortController\n };\n case 'update':\n return {\n ...data,\n ...action.updater(data)\n };\n case 'success':\n case 'error':\n return data;\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loading':\n case 'sorting':\n case 'filtering':\n switch (action.type) {\n case 'success':\n // Ignore if there is a newer abortcontroller in state.\n // This means that multiple requests were going at once.\n // We want to take only the latest result.\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n selectedKeys = action.selectedKeys ?? data.selectedKeys;\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: 'idle',\n items: [...action.items],\n selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error,\n abortController: null\n };\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n // We're already loading, and another load was triggered at the same time.\n // We need to abort the previous load and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loadingMore':\n switch (action.type) {\n case 'success':\n selectedKeys = (data.selectedKeys === 'all' || action.selectedKeys === 'all')\n ? 'all'\n : new Set([...data.selectedKeys, ...(action.selectedKeys ?? [])]);\n // Append the new items\n return {\n ...data,\n state: 'idle',\n items: [...data.items, ...action.items],\n selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error\n };\n case 'loading':\n case 'sorting':\n case 'filtering':\n // We're already loading more, and another load was triggered at the same time.\n // We need to abort the previous load more and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'loadingMore':\n // If already loading more and another loading more is triggered, abort the new load more since\n // it is a duplicate request since the cursor hasn't been updated.\n // Do not overwrite the data.abortController\n action.abortController.abort();\n\n return data;\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n default:\n throw new Error(`Invalid state \"${data.state}\"`);\n }\n}\n\n/**\n * Manages state for an immutable async loaded list data structure, and provides convenience methods to\n * update the data over time. Manages loading and error states, pagination, and sorting.\n */\nexport function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T> {\n const {\n load,\n sort,\n initialSelectedKeys,\n initialSortDescriptor,\n getKey = (item: any) => item.id || item.key,\n initialFilterText = ''\n } = options;\n\n let [data, dispatch] = useReducer<Reducer<AsyncListState<T, C>, Action<T, C>>>(reducer, {\n state: 'idle',\n error: null,\n items: [],\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),\n sortDescriptor: initialSortDescriptor,\n filterText: initialFilterText\n });\n\n const dispatchFetch = async (action: Action<T, C>, fn: AsyncListLoadFunction<T, C>) => {\n let abortController = new AbortController();\n try {\n dispatch({...action, abortController});\n let previousFilterText = action.filterText ?? data.filterText;\n\n let response = await fn({\n items: data.items.slice(),\n selectedKeys: data.selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n signal: abortController.signal,\n cursor: action.type === 'loadingMore' ? data.cursor : null,\n filterText: previousFilterText\n });\n\n let filterText = response.filterText ?? previousFilterText;\n dispatch({type: 'success', ...response, abortController});\n\n // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText\n // Only do this if not aborted (e.g. user triggers another filter action before load completes)\n if (filterText && (filterText !== previousFilterText) && !abortController.signal.aborted) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n } catch (e) {\n dispatch({type: 'error', error: e, abortController});\n }\n };\n\n useEffect(() => {\n dispatchFetch({type: 'loading'}, load);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {\n items: data.items,\n selectedKeys: data.selectedKeys,\n sortDescriptor: data.sortDescriptor,\n isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',\n loadingState: data.state,\n error: data.error,\n filterText: data.filterText,\n getItem(key: Key) {\n return data.items.find(item => getKey(item) === key);\n },\n reload() {\n dispatchFetch({type: 'loading'}, load);\n },\n loadMore() {\n // Ignore if already loading more or if performing server side filtering.\n if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) {\n return;\n }\n\n dispatchFetch({type: 'loadingMore'}, load);\n },\n sort(sortDescriptor: SortDescriptor) {\n dispatchFetch({type: 'sorting', sortDescriptor}, sort || load);\n },\n ...createListActions({...options, getKey, cursor: data.cursor}, fn => {\n dispatch({type: 'update', updater: fn});\n }),\n setFilterText(filterText: string) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\nimport {Selection} from '@react-types/shared';\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: 'all' | Iterable<Key>,\n /** The initial text to filter the list by. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns whether a item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n items: T[],\n\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void,\n\n /** The current filter text. */\n filterText: string,\n\n /** Sets the filter text. */\n setFilterText(filterText: string): void,\n\n /**\n * Gets an item from the list by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): T,\n\n /**\n * Inserts items into the list at the given index.\n * @param index - The index to insert into.\n * @param values - The values to insert.\n */\n insert(index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends items to the list.\n * @param values - The values to insert.\n */\n append(...values: T[]): void,\n\n /**\n * Prepends items to the list.\n * @param value - The value to insert.\n */\n prepend(...values: T[]): void,\n\n /**\n * Removes items from the list by their keys.\n * @param keys - The keys of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the list that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the list.\n * @param key - The key of the item to move.\n * @param toIndex - The index to move the item to.\n */\n move(key: Key, toIndex: number): void,\n\n /**\n * Moves one or more items before a given key.\n * @param key - The key of the item to move the items before.\n * @param keys - The keys of the items to move.\n */\n moveBefore(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Moves one or more items after a given key.\n * @param key - The key of the item to move the items after.\n * @param keys - The keys of the items to move.\n */\n moveAfter(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Updates an item in the list.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\nexport interface ListState<T> {\n items: T[],\n selectedKeys: Selection,\n filterText: string\n}\n\ninterface CreateListOptions<T, C> extends ListOptions<T> {\n cursor?: C\n}\n\n/**\n * Manages state for an immutable list data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useListData<T>(options: ListOptions<T>): ListData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n filter,\n initialFilterText = ''\n } = options;\n\n // Store both items and filteredItems in state so we can go back to the unfiltered list\n let [state, setState] = useState<ListState<T>>({\n items: initialItems,\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),\n filterText: initialFilterText\n });\n\n let filteredItems = useMemo(\n () => filter ? state.items.filter(item => filter(item, state.filterText)) : state.items,\n [state.items, state.filterText, filter]);\n\n return {\n ...state,\n items: filteredItems,\n ...createListActions({getKey}, setState),\n getItem(key: Key) {\n return state.items.find(item => getKey(item) === key);\n }\n };\n}\n\nexport function createListActions<T, C>(opts: CreateListOptions<T, C>, dispatch: (updater: (state: ListState<T>) => ListState<T>) => void): Omit<ListData<T>, 'items' | 'selectedKeys' | 'getItem' | 'filterText'> {\n let {cursor, getKey} = opts;\n return {\n setSelectedKeys(selectedKeys: Selection) {\n dispatch(state => ({\n ...state,\n selectedKeys\n }));\n },\n setFilterText(filterText: string) {\n dispatch(state => ({\n ...state,\n filterText\n }));\n },\n insert(index: number, ...values: T[]) {\n dispatch(state => insert(state, index, ...values));\n },\n insertBefore(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index, ...values);\n });\n },\n insertAfter(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index + 1, ...values);\n });\n },\n prepend(...values: T[]) {\n dispatch(state => insert(state, 0, ...values));\n },\n append(...values: T[]) {\n dispatch(state => insert(state, state.items.length, ...values));\n },\n remove(...keys: Key[]) {\n dispatch(state => {\n let keySet = new Set(keys);\n let items = state.items.filter(item => !keySet.has(getKey(item)));\n\n let selection: Selection = 'all';\n if (state.selectedKeys !== 'all') {\n selection = new Set(state.selectedKeys);\n for (let key of keys) {\n selection.delete(key);\n }\n }\n if (cursor == null && items.length === 0) {\n selection = new Set();\n }\n\n return {\n ...state,\n items,\n selectedKeys: selection\n };\n });\n },\n removeSelectedItems() {\n dispatch(state => {\n if (state.selectedKeys === 'all') {\n return {\n ...state,\n items: [],\n selectedKeys: new Set()\n };\n }\n\n let selectedKeys = state.selectedKeys;\n let items = state.items.filter(item => !selectedKeys.has(getKey(item)));\n return {\n ...state,\n items,\n selectedKeys: new Set()\n };\n });\n },\n move(key: Key, toIndex: number) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n let copy = state.items.slice();\n let [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return {\n ...state,\n items: copy\n };\n });\n },\n moveBefore(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n // Find indices of keys to move. Sort them so that the order in the list is retained.\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex);\n });\n },\n moveAfter(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex + 1);\n });\n },\n update(key: Key, newValue: T) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n newValue,\n ...state.items.slice(index + 1)\n ]\n };\n });\n }\n };\n}\n\nfunction insert<T>(state: ListState<T>, index: number, ...values: T[]): ListState<T> {\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n ...values,\n ...state.items.slice(index)\n ]\n };\n}\n\nfunction move<T>(state: ListState<T>, indices: number[], toIndex: number): ListState<T> {\n // Shift the target down by the number of items being moved from before the target\n toIndex -= indices.filter(index => index < toIndex).length;\n\n let moves = indices.map(from => ({\n from,\n to: toIndex++\n }));\n\n // Shift later from indices down if they have a larger index\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i].from;\n for (let j = i; j < moves.length; j++) {\n let b = moves[j].from;\n\n if (b > a) {\n moves[j].from--;\n }\n }\n }\n\n // Interleave the moves so they can be applied one by one rather than all at once\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i];\n for (let j = moves.length - 1; j > i; j--) {\n let b = moves[j];\n\n if (b.from < a.to) {\n a.to++;\n } else {\n b.from++;\n }\n }\n }\n\n let copy = state.items.slice();\n for (let move of moves) {\n let [item] = copy.splice(move.from, 1);\n copy.splice(move.to, 0, item);\n }\n\n return {\n ...state,\n items: copy\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\n\nexport interface TreeOptions<T extends object> {\n /** Initial root items in the tree. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns the children for an item object. */\n getChildren?: (item: T) => T[]\n}\n\ninterface TreeNode<T extends object> {\n /** A unique key for the tree node. */\n key: Key,\n /** The key of the parent node. */\n parentKey: Key,\n /** The value object for the tree node. */\n value: T,\n /** Children of the tree node. */\n children: TreeNode<T>[]\n}\n\nexport interface TreeData<T extends object> {\n /** The root nodes in the tree. */\n items: TreeNode<T>[],\n\n /** The keys of the currently selected items in the tree. */\n selectedKeys: Set<Key>,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Set<Key>): void,\n\n /**\n * Gets a node from the tree by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): TreeNode<T>,\n\n /**\n * Inserts an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param index - The index within the parent to insert into.\n * @param value - The value to insert.\n */\n insert(parentKey: Key | null, index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n append(parentKey: Key | null, ...values: T[]): void,\n\n /**\n * Prepends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n prepend(parentKey: Key | null, ...value: T[]): void,\n\n /**\n * Removes an item from the tree by its key.\n * @param key - The key of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the tree that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the tree.\n * @param key - The key of the item to move.\n * @param toParentKey - The key of the new parent to insert into.\n * @param index - The index within the new parent to insert at.\n */\n move(key: Key, toParentKey: Key, index: number): void,\n\n /**\n * Updates an item in the tree.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\n/**\n * Manages state for an immutable tree data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useTreeData<T extends object>(options: TreeOptions<T>): TreeData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n getChildren = (item: any) => item.children\n } = options;\n let map = useMemo(() => new Map<Key, TreeNode<T>>(), []);\n\n // We only want to compute this on initial render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n let initialNodes = useMemo(() => buildTree(initialItems), []);\n let [items, setItems] = useState(initialNodes);\n let [selectedKeys, setSelectedKeys] = useState(new Set<Key>(initialSelectedKeys || []));\n\n function buildTree(initialItems: T[] = [], parentKey?: Key | null) {\n return initialItems.map(item => {\n let node: TreeNode<T> = {\n key: getKey(item),\n parentKey: parentKey,\n value: item,\n children: null\n };\n\n node.children = buildTree(getChildren(item), node.key);\n map.set(node.key, node);\n return node;\n });\n }\n\n function updateTree(items: TreeNode<T>[], key: Key, update: (node: TreeNode<T>) => TreeNode<T>) {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n // Create a new node. If null, then delete the node, otherwise replace.\n let newNode = update(node);\n if (newNode == null) {\n deleteNode(node);\n } else {\n addNode(newNode);\n }\n\n // Walk up the tree and update each parent to refer to the new chilren.\n while (node.parentKey) {\n let nextParent = map.get(node.parentKey);\n let copy: TreeNode<T> = {\n key: nextParent.key,\n parentKey: nextParent.parentKey,\n value: nextParent.value,\n children: null\n };\n\n let children = nextParent.children;\n if (newNode == null) {\n children = children.filter(c => c !== node);\n }\n\n copy.children = children.map(child => {\n if (child === node) {\n return newNode;\n }\n\n return child;\n });\n\n map.set(copy.key, copy);\n\n newNode = copy;\n node = nextParent;\n }\n\n if (newNode == null) {\n items = items.filter(c => c !== node);\n }\n\n return items.map(item => {\n if (item === node) {\n return newNode;\n }\n\n return item;\n });\n }\n\n function addNode(node: TreeNode<T>) {\n map.set(node.key, node);\n for (let child of node.children) {\n addNode(child);\n }\n }\n\n function deleteNode(node: TreeNode<T>) {\n map.delete(node.key);\n for (let child of node.children) {\n deleteNode(child);\n }\n }\n\n return {\n items,\n selectedKeys,\n setSelectedKeys,\n getItem(key: Key) {\n return map.get(key);\n },\n insert(parentKey: Key | null, index: number, ...values: T[]) {\n setItems(items => {\n let nodes = buildTree(values, parentKey);\n\n // If parentKey is null, insert into the root.\n if (parentKey == null) {\n return [\n ...items.slice(0, index),\n ...nodes,\n ...items.slice(index)\n ];\n }\n\n // Otherwise, update the parent node and its ancestors.\n return updateTree(items, parentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n ...nodes,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n insertBefore(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index, ...values);\n },\n insertAfter(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index + 1, ...values);\n },\n prepend(parentKey: Key | null, ...values: T[]) {\n this.insert(parentKey, 0, ...values);\n },\n append(parentKey: Key | null, ...values: T[]) {\n if (parentKey == null) {\n this.insert(null, items.length, ...values);\n } else {\n let parentNode = map.get(parentKey);\n if (!parentNode) {\n return;\n }\n\n this.insert(parentKey, parentNode.children.length, ...values);\n }\n },\n remove(...keys: Key[]) {\n let newItems = items;\n for (let key of keys) {\n newItems = updateTree(newItems, key, () => null);\n }\n\n setItems(newItems);\n\n let selection = new Set(selectedKeys);\n for (let key of selectedKeys) {\n if (!map.has(key)) {\n selection.delete(key);\n }\n }\n\n setSelectedKeys(selection);\n },\n removeSelectedItems() {\n this.remove(...selectedKeys);\n },\n move(key: Key, toParentKey: Key, index: number) {\n setItems(items => {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n items = updateTree(items, key, () => null);\n\n const movedNode = {\n ...node,\n parentKey: toParentKey\n };\n\n return updateTree(items, toParentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n movedNode,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n update(oldKey: Key, newValue: T) {\n setItems(items => updateTree(items, oldKey, oldNode => {\n let node: TreeNode<T> = {\n key: oldNode.key,\n parentKey: oldNode.parentKey,\n value: newValue,\n children: null\n };\n\n node.children = buildTree(getChildren(newValue), node.key);\n return node;\n }));\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AA8HO,SAAS,0CAAe,OAAuB,EAAe;IACnE,IAAI,gBACF,eAAe,EAAE,wBACjB,oBAAmB,UACnB,SAAS,CAAC,OAAc,KAAK,EAAE,IAAI,KAAK,GAAG,WAC3C,OAAM,qBACN,oBAAoB,KACrB,GAAG;IAEJ,uFAAuF;IACvF,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAQ,AAAD,EAAgB;QAC7C,OAAO;QACP,cAAc,wBAAwB,QAAQ,QAAQ,IAAI,IAAI,uBAAuB,EAAE,CAAC;QACxF,YAAY;IACd;IAEA,IAAI,gBAAgB,CAAA,GAAA,oBAAM,EACxB,IAAM,SAAS,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA,OAAQ,OAAO,MAAM,MAAM,UAAU,KAAK,MAAM,KAAK,EACvF;QAAC,MAAM,KAAK;QAAE,MAAM,UAAU;QAAE;KAAO;IAEzC,OAAO;QACL,GAAG,KAAK;QACR,OAAO;QACP,GAAG,0CAAkB;oBAAC;QAAM,GAAG,SAAS;QACxC,SAAQ,GAAQ,EAAE;YAChB,OAAO,MAAM,KAAK,CAAC,IA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,KAAa,EAAE;YAC9C,SAAS,CAAA,QAAS;gBAChB,IAAI,OAAO,IAAI,GAAG,CAAC;gBACnB,IAAI,CAAC,MACH,OAAO;gBAGT,QAAQ,WAAW,OAAO,KAAK,IAAM,IAAI;gBAEzC,MAAM,YAAY;oBAChB,GAAG,IAAI;oBACP,WAAW;gBACb;gBAEA,OAAO,WAAW,OAAO,aAAa,CAAA,aAAe,CAAA;wBACnD,KAAK,WAAW,GAAG;wBACnB,WAAW,WAAW,SAAS;wBAC/B,OAAO,WAAW,KAAK;wBACvB,UAAU;+BACL,WAAW,QAAQ,CAAC,KAAK,CAAC,GAAG;4BAChC;+BACG,WAAW,QAAQ,CAAC,KAAK,CAAC;yBAC9B;oBACH,CAAA;YACF;QACF;QACA,QAAO,MAAW,EAAE,QAAW,EAAE;YAC/B,SAAS,CAAA,QAAS,WAAW,OAAO,QAAQ,CAAA,UAAW;oBACrD,IAAI,OAAoB;wBACtB,KAAK,QAAQ,GAAG;wBAChB,WAAW,QAAQ,SAAS;wBAC5B,OAAO;wBACP,UAAU,IAAI;oBAChB;oBAEA,KAAK,QAAQ,GAAG,UAAU,YAAY,WAAW,KAAK,GAAG;oBACzD,OAAO;gBACT;QACF;IACF;AACF;","sources":["packages/@react-stately/data/src/index.ts","packages/@react-stately/data/src/useAsyncList.ts","packages/@react-stately/data/src/useListData.ts","packages/@react-stately/data/src/useTreeData.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 './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","/*\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\nimport {createListActions, ListData, ListState} from './useListData';\nimport {Key, Reducer, useEffect, useReducer, useRef} from 'react';\nimport {LoadingState, Selection, SortDescriptor} from '@react-types/shared';\n\nexport interface AsyncListOptions<T, C> {\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** The initial sort descriptor. */\n initialSortDescriptor?: SortDescriptor,\n /** The initial filter text. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that loads the data for the items in the list. */\n load: AsyncListLoadFunction<T, C>,\n /**\n * An optional function that performs sorting. If not provided,\n * then `sortDescriptor` is passed to the `load` function.\n */\n sort?: AsyncListLoadFunction<T, C>\n}\n\ntype AsyncListLoadFunction<T, C> = (state: AsyncListLoadOptions<T, C>) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;\n\ninterface AsyncListLoadOptions<T, C> {\n /** The items currently in the list. */\n items: T[],\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n /** The current sort descriptor for the list. */\n sortDescriptor: SortDescriptor,\n /** An abort signal used to notify the load function that the request has been aborted. */\n signal: AbortSignal,\n /** The pagination cursor returned from the last page load. */\n cursor?: C,\n /** The current filter text used to perform server side filtering. */\n filterText?: string,\n /** The current loading state of the list. */\n loadingState?: LoadingState\n}\n\ninterface AsyncListStateUpdate<T, C> {\n /** The new items to append to the list. */\n items: Iterable<T>,\n /** The keys to add to the selection. */\n selectedKeys?: Iterable<Key>,\n /** The sort descriptor to set. */\n sortDescriptor?: SortDescriptor,\n /** The pagination cursor to be used for the next page load. */\n cursor?: C,\n /** The updated filter text for the list. */\n filterText?: string\n}\n\ninterface AsyncListState<T, C> extends ListState<T> {\n state: LoadingState,\n items: T[],\n // disabledKeys?: Iterable<Key>,\n selectedKeys: Selection,\n // selectedKey?: Key,\n // expandedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n cursor?: C\n}\n\ntype ActionType = 'success' | 'error' | 'loading' | 'loadingMore' | 'sorting' | 'update' | 'filtering';\ninterface Action<T, C> {\n type: ActionType,\n items?: Iterable<T>,\n selectedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n updater?: (state: ListState<T>) => ListState<T>,\n cursor?: C,\n filterText?: string\n}\n\nexport interface AsyncListData<T> extends ListData<T> {\n /** Whether data is currently being loaded. */\n isLoading: boolean,\n /** If loading data failed, then this contains the error that occurred. */\n error?: Error,\n // disabledKeys?: Set<Key>,\n // selectedKey?: Key,\n // expandedKeys?: Set<Key>,\n /** The current sort descriptor for the list. */\n sortDescriptor?: SortDescriptor,\n\n /** Reloads the data in the list. */\n reload(): void,\n /** Loads the next page of data in the list. */\n loadMore(): void,\n /** Triggers sorting for the list. */\n sort(descriptor: SortDescriptor): void,\n /** The current loading state for the list. */\n loadingState: LoadingState\n}\n\nfunction reducer<T, C>(data: AsyncListState<T, C>, action: Action<T, C>): AsyncListState<T, C> {\n let selectedKeys;\n switch (data.state) {\n case 'idle':\n case 'error':\n switch (action.type) {\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: action.abortController\n };\n case 'update':\n return {\n ...data,\n ...action.updater(data)\n };\n case 'success':\n case 'error':\n return data;\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loading':\n case 'sorting':\n case 'filtering':\n switch (action.type) {\n case 'success':\n // Ignore if there is a newer abortcontroller in state.\n // This means that multiple requests were going at once.\n // We want to take only the latest result.\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n selectedKeys = action.selectedKeys ?? data.selectedKeys;\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: 'idle',\n items: [...action.items],\n selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error,\n abortController: null\n };\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n // We're already loading, and another load was triggered at the same time.\n // We need to abort the previous load and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loadingMore':\n switch (action.type) {\n case 'success':\n selectedKeys = (data.selectedKeys === 'all' || action.selectedKeys === 'all')\n ? 'all'\n : new Set([...data.selectedKeys, ...(action.selectedKeys ?? [])]);\n // Append the new items\n return {\n ...data,\n state: 'idle',\n items: [...data.items, ...action.items],\n selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error\n };\n case 'loading':\n case 'sorting':\n case 'filtering':\n // We're already loading more, and another load was triggered at the same time.\n // We need to abort the previous load more and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'loadingMore':\n // If already loading more and another loading more is triggered, abort the new load more since\n // it is a duplicate request since the cursor hasn't been updated.\n // Do not overwrite the data.abortController\n action.abortController.abort();\n\n return data;\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n default:\n throw new Error(`Invalid state \"${data.state}\"`);\n }\n}\n\n/**\n * Manages state for an immutable async loaded list data structure, and provides convenience methods to\n * update the data over time. Manages loading and error states, pagination, and sorting.\n */\nexport function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T> {\n const {\n load,\n sort,\n initialSelectedKeys,\n initialSortDescriptor,\n getKey = (item: any) => item.id || item.key,\n initialFilterText = ''\n } = options;\n\n let [data, dispatch] = useReducer<Reducer<AsyncListState<T, C>, Action<T, C>>>(reducer, {\n state: 'idle',\n error: null,\n items: [],\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),\n sortDescriptor: initialSortDescriptor,\n filterText: initialFilterText\n });\n\n const dispatchFetch = async (action: Action<T, C>, fn: AsyncListLoadFunction<T, C>) => {\n let abortController = new AbortController();\n try {\n dispatch({...action, abortController});\n let previousFilterText = action.filterText ?? data.filterText;\n\n let response = await fn({\n items: data.items.slice(),\n selectedKeys: data.selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n signal: abortController.signal,\n cursor: action.type === 'loadingMore' ? data.cursor : null,\n filterText: previousFilterText\n });\n\n let filterText = response.filterText ?? previousFilterText;\n dispatch({type: 'success', ...response, abortController});\n\n // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText\n // Only do this if not aborted (e.g. user triggers another filter action before load completes)\n if (filterText && (filterText !== previousFilterText) && !abortController.signal.aborted) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n } catch (e) {\n dispatch({type: 'error', error: e, abortController});\n }\n };\n\n let didDispatchInitialFetch = useRef(false);\n useEffect(() => {\n if (!didDispatchInitialFetch.current) {\n dispatchFetch({type: 'loading'}, load);\n didDispatchInitialFetch.current = true;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {\n items: data.items,\n selectedKeys: data.selectedKeys,\n sortDescriptor: data.sortDescriptor,\n isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',\n loadingState: data.state,\n error: data.error,\n filterText: data.filterText,\n getItem(key: Key) {\n return data.items.find(item => getKey(item) === key);\n },\n reload() {\n dispatchFetch({type: 'loading'}, load);\n },\n loadMore() {\n // Ignore if already loading more or if performing server side filtering.\n if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) {\n return;\n }\n\n dispatchFetch({type: 'loadingMore'}, load);\n },\n sort(sortDescriptor: SortDescriptor) {\n dispatchFetch({type: 'sorting', sortDescriptor}, sort || load);\n },\n ...createListActions({...options, getKey, cursor: data.cursor}, fn => {\n dispatch({type: 'update', updater: fn});\n }),\n setFilterText(filterText: string) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\nimport {Selection} from '@react-types/shared';\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: 'all' | Iterable<Key>,\n /** The initial text to filter the list by. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns whether a item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n items: T[],\n\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void,\n\n /** The current filter text. */\n filterText: string,\n\n /** Sets the filter text. */\n setFilterText(filterText: string): void,\n\n /**\n * Gets an item from the list by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): T,\n\n /**\n * Inserts items into the list at the given index.\n * @param index - The index to insert into.\n * @param values - The values to insert.\n */\n insert(index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends items to the list.\n * @param values - The values to insert.\n */\n append(...values: T[]): void,\n\n /**\n * Prepends items to the list.\n * @param value - The value to insert.\n */\n prepend(...values: T[]): void,\n\n /**\n * Removes items from the list by their keys.\n * @param keys - The keys of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the list that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the list.\n * @param key - The key of the item to move.\n * @param toIndex - The index to move the item to.\n */\n move(key: Key, toIndex: number): void,\n\n /**\n * Moves one or more items before a given key.\n * @param key - The key of the item to move the items before.\n * @param keys - The keys of the items to move.\n */\n moveBefore(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Moves one or more items after a given key.\n * @param key - The key of the item to move the items after.\n * @param keys - The keys of the items to move.\n */\n moveAfter(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Updates an item in the list.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\nexport interface ListState<T> {\n items: T[],\n selectedKeys: Selection,\n filterText: string\n}\n\ninterface CreateListOptions<T, C> extends ListOptions<T> {\n cursor?: C\n}\n\n/**\n * Manages state for an immutable list data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useListData<T>(options: ListOptions<T>): ListData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n filter,\n initialFilterText = ''\n } = options;\n\n // Store both items and filteredItems in state so we can go back to the unfiltered list\n let [state, setState] = useState<ListState<T>>({\n items: initialItems,\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),\n filterText: initialFilterText\n });\n\n let filteredItems = useMemo(\n () => filter ? state.items.filter(item => filter(item, state.filterText)) : state.items,\n [state.items, state.filterText, filter]);\n\n return {\n ...state,\n items: filteredItems,\n ...createListActions({getKey}, setState),\n getItem(key: Key) {\n return state.items.find(item => getKey(item) === key);\n }\n };\n}\n\nexport function createListActions<T, C>(opts: CreateListOptions<T, C>, dispatch: (updater: (state: ListState<T>) => ListState<T>) => void): Omit<ListData<T>, 'items' | 'selectedKeys' | 'getItem' | 'filterText'> {\n let {cursor, getKey} = opts;\n return {\n setSelectedKeys(selectedKeys: Selection) {\n dispatch(state => ({\n ...state,\n selectedKeys\n }));\n },\n setFilterText(filterText: string) {\n dispatch(state => ({\n ...state,\n filterText\n }));\n },\n insert(index: number, ...values: T[]) {\n dispatch(state => insert(state, index, ...values));\n },\n insertBefore(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index, ...values);\n });\n },\n insertAfter(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index + 1, ...values);\n });\n },\n prepend(...values: T[]) {\n dispatch(state => insert(state, 0, ...values));\n },\n append(...values: T[]) {\n dispatch(state => insert(state, state.items.length, ...values));\n },\n remove(...keys: Key[]) {\n dispatch(state => {\n let keySet = new Set(keys);\n let items = state.items.filter(item => !keySet.has(getKey(item)));\n\n let selection: Selection = 'all';\n if (state.selectedKeys !== 'all') {\n selection = new Set(state.selectedKeys);\n for (let key of keys) {\n selection.delete(key);\n }\n }\n if (cursor == null && items.length === 0) {\n selection = new Set();\n }\n\n return {\n ...state,\n items,\n selectedKeys: selection\n };\n });\n },\n removeSelectedItems() {\n dispatch(state => {\n if (state.selectedKeys === 'all') {\n return {\n ...state,\n items: [],\n selectedKeys: new Set()\n };\n }\n\n let selectedKeys = state.selectedKeys;\n let items = state.items.filter(item => !selectedKeys.has(getKey(item)));\n return {\n ...state,\n items,\n selectedKeys: new Set()\n };\n });\n },\n move(key: Key, toIndex: number) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n let copy = state.items.slice();\n let [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return {\n ...state,\n items: copy\n };\n });\n },\n moveBefore(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n // Find indices of keys to move. Sort them so that the order in the list is retained.\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex);\n });\n },\n moveAfter(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex + 1);\n });\n },\n update(key: Key, newValue: T) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n newValue,\n ...state.items.slice(index + 1)\n ]\n };\n });\n }\n };\n}\n\nfunction insert<T>(state: ListState<T>, index: number, ...values: T[]): ListState<T> {\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n ...values,\n ...state.items.slice(index)\n ]\n };\n}\n\nfunction move<T>(state: ListState<T>, indices: number[], toIndex: number): ListState<T> {\n // Shift the target down by the number of items being moved from before the target\n toIndex -= indices.filter(index => index < toIndex).length;\n\n let moves = indices.map(from => ({\n from,\n to: toIndex++\n }));\n\n // Shift later from indices down if they have a larger index\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i].from;\n for (let j = i; j < moves.length; j++) {\n let b = moves[j].from;\n\n if (b > a) {\n moves[j].from--;\n }\n }\n }\n\n // Interleave the moves so they can be applied one by one rather than all at once\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i];\n for (let j = moves.length - 1; j > i; j--) {\n let b = moves[j];\n\n if (b.from < a.to) {\n a.to++;\n } else {\n b.from++;\n }\n }\n }\n\n let copy = state.items.slice();\n for (let move of moves) {\n let [item] = copy.splice(move.from, 1);\n copy.splice(move.to, 0, item);\n }\n\n return {\n ...state,\n items: copy\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\n\nexport interface TreeOptions<T extends object> {\n /** Initial root items in the tree. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns the children for an item object. */\n getChildren?: (item: T) => T[]\n}\n\ninterface TreeNode<T extends object> {\n /** A unique key for the tree node. */\n key: Key,\n /** The key of the parent node. */\n parentKey: Key,\n /** The value object for the tree node. */\n value: T,\n /** Children of the tree node. */\n children: TreeNode<T>[]\n}\n\nexport interface TreeData<T extends object> {\n /** The root nodes in the tree. */\n items: TreeNode<T>[],\n\n /** The keys of the currently selected items in the tree. */\n selectedKeys: Set<Key>,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Set<Key>): void,\n\n /**\n * Gets a node from the tree by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): TreeNode<T>,\n\n /**\n * Inserts an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param index - The index within the parent to insert into.\n * @param value - The value to insert.\n */\n insert(parentKey: Key | null, index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n append(parentKey: Key | null, ...values: T[]): void,\n\n /**\n * Prepends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n prepend(parentKey: Key | null, ...value: T[]): void,\n\n /**\n * Removes an item from the tree by its key.\n * @param key - The key of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the tree that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the tree.\n * @param key - The key of the item to move.\n * @param toParentKey - The key of the new parent to insert into.\n * @param index - The index within the new parent to insert at.\n */\n move(key: Key, toParentKey: Key, index: number): void,\n\n /**\n * Updates an item in the tree.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\n/**\n * Manages state for an immutable tree data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useTreeData<T extends object>(options: TreeOptions<T>): TreeData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n getChildren = (item: any) => item.children\n } = options;\n let map = useMemo(() => new Map<Key, TreeNode<T>>(), []);\n\n // We only want to compute this on initial render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n let initialNodes = useMemo(() => buildTree(initialItems), []);\n let [items, setItems] = useState(initialNodes);\n let [selectedKeys, setSelectedKeys] = useState(new Set<Key>(initialSelectedKeys || []));\n\n function buildTree(initialItems: T[] = [], parentKey?: Key | null) {\n return initialItems.map(item => {\n let node: TreeNode<T> = {\n key: getKey(item),\n parentKey: parentKey,\n value: item,\n children: null\n };\n\n node.children = buildTree(getChildren(item), node.key);\n map.set(node.key, node);\n return node;\n });\n }\n\n function updateTree(items: TreeNode<T>[], key: Key, update: (node: TreeNode<T>) => TreeNode<T>) {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n // Create a new node. If null, then delete the node, otherwise replace.\n let newNode = update(node);\n if (newNode == null) {\n deleteNode(node);\n } else {\n addNode(newNode);\n }\n\n // Walk up the tree and update each parent to refer to the new chilren.\n while (node.parentKey) {\n let nextParent = map.get(node.parentKey);\n let copy: TreeNode<T> = {\n key: nextParent.key,\n parentKey: nextParent.parentKey,\n value: nextParent.value,\n children: null\n };\n\n let children = nextParent.children;\n if (newNode == null) {\n children = children.filter(c => c !== node);\n }\n\n copy.children = children.map(child => {\n if (child === node) {\n return newNode;\n }\n\n return child;\n });\n\n map.set(copy.key, copy);\n\n newNode = copy;\n node = nextParent;\n }\n\n if (newNode == null) {\n items = items.filter(c => c !== node);\n }\n\n return items.map(item => {\n if (item === node) {\n return newNode;\n }\n\n return item;\n });\n }\n\n function addNode(node: TreeNode<T>) {\n map.set(node.key, node);\n for (let child of node.children) {\n addNode(child);\n }\n }\n\n function deleteNode(node: TreeNode<T>) {\n map.delete(node.key);\n for (let child of node.children) {\n deleteNode(child);\n }\n }\n\n return {\n items,\n selectedKeys,\n setSelectedKeys,\n getItem(key: Key) {\n return map.get(key);\n },\n insert(parentKey: Key | null, index: number, ...values: T[]) {\n setItems(items => {\n let nodes = buildTree(values, parentKey);\n\n // If parentKey is null, insert into the root.\n if (parentKey == null) {\n return [\n ...items.slice(0, index),\n ...nodes,\n ...items.slice(index)\n ];\n }\n\n // Otherwise, update the parent node and its ancestors.\n return updateTree(items, parentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n ...nodes,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n insertBefore(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index, ...values);\n },\n insertAfter(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index + 1, ...values);\n },\n prepend(parentKey: Key | null, ...values: T[]) {\n this.insert(parentKey, 0, ...values);\n },\n append(parentKey: Key | null, ...values: T[]) {\n if (parentKey == null) {\n this.insert(null, items.length, ...values);\n } else {\n let parentNode = map.get(parentKey);\n if (!parentNode) {\n return;\n }\n\n this.insert(parentKey, parentNode.children.length, ...values);\n }\n },\n remove(...keys: Key[]) {\n let newItems = items;\n for (let key of keys) {\n newItems = updateTree(newItems, key, () => null);\n }\n\n setItems(newItems);\n\n let selection = new Set(selectedKeys);\n for (let key of selectedKeys) {\n if (!map.has(key)) {\n selection.delete(key);\n }\n }\n\n setSelectedKeys(selection);\n },\n removeSelectedItems() {\n this.remove(...selectedKeys);\n },\n move(key: Key, toParentKey: Key, index: number) {\n setItems(items => {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n items = updateTree(items, key, () => null);\n\n const movedNode = {\n ...node,\n parentKey: toParentKey\n };\n\n return updateTree(items, toParentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n movedNode,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n update(oldKey: Key, newValue: T) {\n setItems(items => updateTree(items, oldKey, oldNode => {\n let node: TreeNode<T> = {\n key: oldNode.key,\n parentKey: oldNode.parentKey,\n value: newValue,\n children: null\n };\n\n node.children = buildTree(getChildren(newValue), node.key);\n return node;\n }));\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useReducer as $d70Aq$useReducer, useEffect as $d70Aq$useEffect, useState as $d70Aq$useState, useMemo as $d70Aq$useMemo} from "react";
|
|
1
|
+
import {useReducer as $d70Aq$useReducer, useRef as $d70Aq$useRef, useEffect as $d70Aq$useEffect, useState as $d70Aq$useState, useMemo as $d70Aq$useMemo} from "react";
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -433,10 +433,14 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
};
|
|
436
|
+
let didDispatchInitialFetch = (0, $d70Aq$useRef)(false);
|
|
436
437
|
(0, $d70Aq$useEffect)(()=>{
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
if (!didDispatchInitialFetch.current) {
|
|
439
|
+
dispatchFetch({
|
|
440
|
+
type: "loading"
|
|
441
|
+
}, load);
|
|
442
|
+
didDispatchInitialFetch.current = true;
|
|
443
|
+
}
|
|
440
444
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
441
445
|
}, []);
|
|
442
446
|
return {
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AA8HO,SAAS,0CAAe,OAAuB,EAAe;IACnE,IAAI,gBACF,eAAe,EAAE,wBACjB,oBAAmB,UACnB,SAAS,CAAC,OAAc,KAAK,EAAE,IAAI,KAAK,GAAG,WAC3C,OAAM,qBACN,oBAAoB,KACrB,GAAG;IAEJ,uFAAuF;IACvF,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAgB;QAC7C,OAAO;QACP,cAAc,wBAAwB,QAAQ,QAAQ,IAAI,IAAI,uBAAuB,EAAE,CAAC;QACxF,YAAY;IACd;IAEA,IAAI,gBAAgB,CAAA,GAAA,cAAM,EACxB,IAAM,SAAS,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA,OAAQ,OAAO,MAAM,MAAM,UAAU,KAAK,MAAM,KAAK,EACvF;QAAC,MAAM,KAAK;QAAE,MAAM,UAAU;QAAE;KAAO;IAEzC,OAAO;QACL,GAAG,KAAK;QACR,OAAO;QACP,GAAG,0CAAkB;oBAAC;QAAM,GAAG,SAAS;QACxC,SAAQ,GAAQ,EAAE;YAChB,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA,OAAQ,OAAO,UAAU;QACnD;IACF;AACF;AAEO,SAAS,0CAAwB,IAA6B,EAAE,QAAkE,EAA0E;IACjN,IAAI,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CAAA;wBACnD,KAAK,WAAW,GAAG;wBACnB,WAAW,WAAW,SAAS;wBAC/B,OAAO,WAAW,KAAK;wBACvB,UAAU;+BACL,WAAW,QAAQ,CAAC,KAAK,CAAC,GAAG;4BAChC;+BACG,WAAW,QAAQ,CAAC,KAAK,CAAC;yBAC9B;oBACH,CAAA;YACF;QACF;QACA,QAAO,MAAW,EAAE,QAAW,EAAE;YAC/B,SAAS,CAAA,QAAS,WAAW,OAAO,QAAQ,CAAA,UAAW;oBACrD,IAAI,OAAoB;wBACtB,KAAK,QAAQ,GAAG;wBAChB,WAAW,QAAQ,SAAS;wBAC5B,OAAO;wBACP,UAAU,IAAI;oBAChB;oBAEA,KAAK,QAAQ,GAAG,UAAU,YAAY,WAAW,KAAK,GAAG;oBACzD,OAAO;gBACT;QACF;IACF;AACF;","sources":["packages/@react-stately/data/src/index.ts","packages/@react-stately/data/src/useAsyncList.ts","packages/@react-stately/data/src/useListData.ts","packages/@react-stately/data/src/useTreeData.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 './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","/*\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\nimport {createListActions, ListData, ListState} from './useListData';\nimport {Key, Reducer, useEffect, useReducer} from 'react';\nimport {LoadingState, Selection, SortDescriptor} from '@react-types/shared';\n\nexport interface AsyncListOptions<T, C> {\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** The initial sort descriptor. */\n initialSortDescriptor?: SortDescriptor,\n /** The initial filter text. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that loads the data for the items in the list. */\n load: AsyncListLoadFunction<T, C>,\n /**\n * An optional function that performs sorting. If not provided,\n * then `sortDescriptor` is passed to the `load` function.\n */\n sort?: AsyncListLoadFunction<T, C>\n}\n\ntype AsyncListLoadFunction<T, C> = (state: AsyncListLoadOptions<T, C>) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;\n\ninterface AsyncListLoadOptions<T, C> {\n /** The items currently in the list. */\n items: T[],\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n /** The current sort descriptor for the list. */\n sortDescriptor: SortDescriptor,\n /** An abort signal used to notify the load function that the request has been aborted. */\n signal: AbortSignal,\n /** The pagination cursor returned from the last page load. */\n cursor?: C,\n /** The current filter text used to perform server side filtering. */\n filterText?: string,\n /** The current loading state of the list. */\n loadingState?: LoadingState\n}\n\ninterface AsyncListStateUpdate<T, C> {\n /** The new items to append to the list. */\n items: Iterable<T>,\n /** The keys to add to the selection. */\n selectedKeys?: Iterable<Key>,\n /** The sort descriptor to set. */\n sortDescriptor?: SortDescriptor,\n /** The pagination cursor to be used for the next page load. */\n cursor?: C,\n /** The updated filter text for the list. */\n filterText?: string\n}\n\ninterface AsyncListState<T, C> extends ListState<T> {\n state: LoadingState,\n items: T[],\n // disabledKeys?: Iterable<Key>,\n selectedKeys: Selection,\n // selectedKey?: Key,\n // expandedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n cursor?: C\n}\n\ntype ActionType = 'success' | 'error' | 'loading' | 'loadingMore' | 'sorting' | 'update' | 'filtering';\ninterface Action<T, C> {\n type: ActionType,\n items?: Iterable<T>,\n selectedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n updater?: (state: ListState<T>) => ListState<T>,\n cursor?: C,\n filterText?: string\n}\n\nexport interface AsyncListData<T> extends ListData<T> {\n /** Whether data is currently being loaded. */\n isLoading: boolean,\n /** If loading data failed, then this contains the error that occurred. */\n error?: Error,\n // disabledKeys?: Set<Key>,\n // selectedKey?: Key,\n // expandedKeys?: Set<Key>,\n /** The current sort descriptor for the list. */\n sortDescriptor?: SortDescriptor,\n\n /** Reloads the data in the list. */\n reload(): void,\n /** Loads the next page of data in the list. */\n loadMore(): void,\n /** Triggers sorting for the list. */\n sort(descriptor: SortDescriptor): void,\n /** The current loading state for the list. */\n loadingState: LoadingState\n}\n\nfunction reducer<T, C>(data: AsyncListState<T, C>, action: Action<T, C>): AsyncListState<T, C> {\n let selectedKeys;\n switch (data.state) {\n case 'idle':\n case 'error':\n switch (action.type) {\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: action.abortController\n };\n case 'update':\n return {\n ...data,\n ...action.updater(data)\n };\n case 'success':\n case 'error':\n return data;\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loading':\n case 'sorting':\n case 'filtering':\n switch (action.type) {\n case 'success':\n // Ignore if there is a newer abortcontroller in state.\n // This means that multiple requests were going at once.\n // We want to take only the latest result.\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n selectedKeys = action.selectedKeys ?? data.selectedKeys;\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: 'idle',\n items: [...action.items],\n selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error,\n abortController: null\n };\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n // We're already loading, and another load was triggered at the same time.\n // We need to abort the previous load and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loadingMore':\n switch (action.type) {\n case 'success':\n selectedKeys = (data.selectedKeys === 'all' || action.selectedKeys === 'all')\n ? 'all'\n : new Set([...data.selectedKeys, ...(action.selectedKeys ?? [])]);\n // Append the new items\n return {\n ...data,\n state: 'idle',\n items: [...data.items, ...action.items],\n selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error\n };\n case 'loading':\n case 'sorting':\n case 'filtering':\n // We're already loading more, and another load was triggered at the same time.\n // We need to abort the previous load more and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'loadingMore':\n // If already loading more and another loading more is triggered, abort the new load more since\n // it is a duplicate request since the cursor hasn't been updated.\n // Do not overwrite the data.abortController\n action.abortController.abort();\n\n return data;\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n default:\n throw new Error(`Invalid state \"${data.state}\"`);\n }\n}\n\n/**\n * Manages state for an immutable async loaded list data structure, and provides convenience methods to\n * update the data over time. Manages loading and error states, pagination, and sorting.\n */\nexport function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T> {\n const {\n load,\n sort,\n initialSelectedKeys,\n initialSortDescriptor,\n getKey = (item: any) => item.id || item.key,\n initialFilterText = ''\n } = options;\n\n let [data, dispatch] = useReducer<Reducer<AsyncListState<T, C>, Action<T, C>>>(reducer, {\n state: 'idle',\n error: null,\n items: [],\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),\n sortDescriptor: initialSortDescriptor,\n filterText: initialFilterText\n });\n\n const dispatchFetch = async (action: Action<T, C>, fn: AsyncListLoadFunction<T, C>) => {\n let abortController = new AbortController();\n try {\n dispatch({...action, abortController});\n let previousFilterText = action.filterText ?? data.filterText;\n\n let response = await fn({\n items: data.items.slice(),\n selectedKeys: data.selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n signal: abortController.signal,\n cursor: action.type === 'loadingMore' ? data.cursor : null,\n filterText: previousFilterText\n });\n\n let filterText = response.filterText ?? previousFilterText;\n dispatch({type: 'success', ...response, abortController});\n\n // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText\n // Only do this if not aborted (e.g. user triggers another filter action before load completes)\n if (filterText && (filterText !== previousFilterText) && !abortController.signal.aborted) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n } catch (e) {\n dispatch({type: 'error', error: e, abortController});\n }\n };\n\n useEffect(() => {\n dispatchFetch({type: 'loading'}, load);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {\n items: data.items,\n selectedKeys: data.selectedKeys,\n sortDescriptor: data.sortDescriptor,\n isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',\n loadingState: data.state,\n error: data.error,\n filterText: data.filterText,\n getItem(key: Key) {\n return data.items.find(item => getKey(item) === key);\n },\n reload() {\n dispatchFetch({type: 'loading'}, load);\n },\n loadMore() {\n // Ignore if already loading more or if performing server side filtering.\n if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) {\n return;\n }\n\n dispatchFetch({type: 'loadingMore'}, load);\n },\n sort(sortDescriptor: SortDescriptor) {\n dispatchFetch({type: 'sorting', sortDescriptor}, sort || load);\n },\n ...createListActions({...options, getKey, cursor: data.cursor}, fn => {\n dispatch({type: 'update', updater: fn});\n }),\n setFilterText(filterText: string) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\nimport {Selection} from '@react-types/shared';\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: 'all' | Iterable<Key>,\n /** The initial text to filter the list by. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns whether a item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n items: T[],\n\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void,\n\n /** The current filter text. */\n filterText: string,\n\n /** Sets the filter text. */\n setFilterText(filterText: string): void,\n\n /**\n * Gets an item from the list by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): T,\n\n /**\n * Inserts items into the list at the given index.\n * @param index - The index to insert into.\n * @param values - The values to insert.\n */\n insert(index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends items to the list.\n * @param values - The values to insert.\n */\n append(...values: T[]): void,\n\n /**\n * Prepends items to the list.\n * @param value - The value to insert.\n */\n prepend(...values: T[]): void,\n\n /**\n * Removes items from the list by their keys.\n * @param keys - The keys of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the list that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the list.\n * @param key - The key of the item to move.\n * @param toIndex - The index to move the item to.\n */\n move(key: Key, toIndex: number): void,\n\n /**\n * Moves one or more items before a given key.\n * @param key - The key of the item to move the items before.\n * @param keys - The keys of the items to move.\n */\n moveBefore(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Moves one or more items after a given key.\n * @param key - The key of the item to move the items after.\n * @param keys - The keys of the items to move.\n */\n moveAfter(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Updates an item in the list.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\nexport interface ListState<T> {\n items: T[],\n selectedKeys: Selection,\n filterText: string\n}\n\ninterface CreateListOptions<T, C> extends ListOptions<T> {\n cursor?: C\n}\n\n/**\n * Manages state for an immutable list data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useListData<T>(options: ListOptions<T>): ListData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n filter,\n initialFilterText = ''\n } = options;\n\n // Store both items and filteredItems in state so we can go back to the unfiltered list\n let [state, setState] = useState<ListState<T>>({\n items: initialItems,\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),\n filterText: initialFilterText\n });\n\n let filteredItems = useMemo(\n () => filter ? state.items.filter(item => filter(item, state.filterText)) : state.items,\n [state.items, state.filterText, filter]);\n\n return {\n ...state,\n items: filteredItems,\n ...createListActions({getKey}, setState),\n getItem(key: Key) {\n return state.items.find(item => getKey(item) === key);\n }\n };\n}\n\nexport function createListActions<T, C>(opts: CreateListOptions<T, C>, dispatch: (updater: (state: ListState<T>) => ListState<T>) => void): Omit<ListData<T>, 'items' | 'selectedKeys' | 'getItem' | 'filterText'> {\n let {cursor, getKey} = opts;\n return {\n setSelectedKeys(selectedKeys: Selection) {\n dispatch(state => ({\n ...state,\n selectedKeys\n }));\n },\n setFilterText(filterText: string) {\n dispatch(state => ({\n ...state,\n filterText\n }));\n },\n insert(index: number, ...values: T[]) {\n dispatch(state => insert(state, index, ...values));\n },\n insertBefore(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index, ...values);\n });\n },\n insertAfter(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index + 1, ...values);\n });\n },\n prepend(...values: T[]) {\n dispatch(state => insert(state, 0, ...values));\n },\n append(...values: T[]) {\n dispatch(state => insert(state, state.items.length, ...values));\n },\n remove(...keys: Key[]) {\n dispatch(state => {\n let keySet = new Set(keys);\n let items = state.items.filter(item => !keySet.has(getKey(item)));\n\n let selection: Selection = 'all';\n if (state.selectedKeys !== 'all') {\n selection = new Set(state.selectedKeys);\n for (let key of keys) {\n selection.delete(key);\n }\n }\n if (cursor == null && items.length === 0) {\n selection = new Set();\n }\n\n return {\n ...state,\n items,\n selectedKeys: selection\n };\n });\n },\n removeSelectedItems() {\n dispatch(state => {\n if (state.selectedKeys === 'all') {\n return {\n ...state,\n items: [],\n selectedKeys: new Set()\n };\n }\n\n let selectedKeys = state.selectedKeys;\n let items = state.items.filter(item => !selectedKeys.has(getKey(item)));\n return {\n ...state,\n items,\n selectedKeys: new Set()\n };\n });\n },\n move(key: Key, toIndex: number) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n let copy = state.items.slice();\n let [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return {\n ...state,\n items: copy\n };\n });\n },\n moveBefore(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n // Find indices of keys to move. Sort them so that the order in the list is retained.\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex);\n });\n },\n moveAfter(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex + 1);\n });\n },\n update(key: Key, newValue: T) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n newValue,\n ...state.items.slice(index + 1)\n ]\n };\n });\n }\n };\n}\n\nfunction insert<T>(state: ListState<T>, index: number, ...values: T[]): ListState<T> {\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n ...values,\n ...state.items.slice(index)\n ]\n };\n}\n\nfunction move<T>(state: ListState<T>, indices: number[], toIndex: number): ListState<T> {\n // Shift the target down by the number of items being moved from before the target\n toIndex -= indices.filter(index => index < toIndex).length;\n\n let moves = indices.map(from => ({\n from,\n to: toIndex++\n }));\n\n // Shift later from indices down if they have a larger index\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i].from;\n for (let j = i; j < moves.length; j++) {\n let b = moves[j].from;\n\n if (b > a) {\n moves[j].from--;\n }\n }\n }\n\n // Interleave the moves so they can be applied one by one rather than all at once\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i];\n for (let j = moves.length - 1; j > i; j--) {\n let b = moves[j];\n\n if (b.from < a.to) {\n a.to++;\n } else {\n b.from++;\n }\n }\n }\n\n let copy = state.items.slice();\n for (let move of moves) {\n let [item] = copy.splice(move.from, 1);\n copy.splice(move.to, 0, item);\n }\n\n return {\n ...state,\n items: copy\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\n\nexport interface TreeOptions<T extends object> {\n /** Initial root items in the tree. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns the children for an item object. */\n getChildren?: (item: T) => T[]\n}\n\ninterface TreeNode<T extends object> {\n /** A unique key for the tree node. */\n key: Key,\n /** The key of the parent node. */\n parentKey: Key,\n /** The value object for the tree node. */\n value: T,\n /** Children of the tree node. */\n children: TreeNode<T>[]\n}\n\nexport interface TreeData<T extends object> {\n /** The root nodes in the tree. */\n items: TreeNode<T>[],\n\n /** The keys of the currently selected items in the tree. */\n selectedKeys: Set<Key>,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Set<Key>): void,\n\n /**\n * Gets a node from the tree by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): TreeNode<T>,\n\n /**\n * Inserts an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param index - The index within the parent to insert into.\n * @param value - The value to insert.\n */\n insert(parentKey: Key | null, index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n append(parentKey: Key | null, ...values: T[]): void,\n\n /**\n * Prepends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n prepend(parentKey: Key | null, ...value: T[]): void,\n\n /**\n * Removes an item from the tree by its key.\n * @param key - The key of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the tree that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the tree.\n * @param key - The key of the item to move.\n * @param toParentKey - The key of the new parent to insert into.\n * @param index - The index within the new parent to insert at.\n */\n move(key: Key, toParentKey: Key, index: number): void,\n\n /**\n * Updates an item in the tree.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\n/**\n * Manages state for an immutable tree data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useTreeData<T extends object>(options: TreeOptions<T>): TreeData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n getChildren = (item: any) => item.children\n } = options;\n let map = useMemo(() => new Map<Key, TreeNode<T>>(), []);\n\n // We only want to compute this on initial render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n let initialNodes = useMemo(() => buildTree(initialItems), []);\n let [items, setItems] = useState(initialNodes);\n let [selectedKeys, setSelectedKeys] = useState(new Set<Key>(initialSelectedKeys || []));\n\n function buildTree(initialItems: T[] = [], parentKey?: Key | null) {\n return initialItems.map(item => {\n let node: TreeNode<T> = {\n key: getKey(item),\n parentKey: parentKey,\n value: item,\n children: null\n };\n\n node.children = buildTree(getChildren(item), node.key);\n map.set(node.key, node);\n return node;\n });\n }\n\n function updateTree(items: TreeNode<T>[], key: Key, update: (node: TreeNode<T>) => TreeNode<T>) {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n // Create a new node. If null, then delete the node, otherwise replace.\n let newNode = update(node);\n if (newNode == null) {\n deleteNode(node);\n } else {\n addNode(newNode);\n }\n\n // Walk up the tree and update each parent to refer to the new chilren.\n while (node.parentKey) {\n let nextParent = map.get(node.parentKey);\n let copy: TreeNode<T> = {\n key: nextParent.key,\n parentKey: nextParent.parentKey,\n value: nextParent.value,\n children: null\n };\n\n let children = nextParent.children;\n if (newNode == null) {\n children = children.filter(c => c !== node);\n }\n\n copy.children = children.map(child => {\n if (child === node) {\n return newNode;\n }\n\n return child;\n });\n\n map.set(copy.key, copy);\n\n newNode = copy;\n node = nextParent;\n }\n\n if (newNode == null) {\n items = items.filter(c => c !== node);\n }\n\n return items.map(item => {\n if (item === node) {\n return newNode;\n }\n\n return item;\n });\n }\n\n function addNode(node: TreeNode<T>) {\n map.set(node.key, node);\n for (let child of node.children) {\n addNode(child);\n }\n }\n\n function deleteNode(node: TreeNode<T>) {\n map.delete(node.key);\n for (let child of node.children) {\n deleteNode(child);\n }\n }\n\n return {\n items,\n selectedKeys,\n setSelectedKeys,\n getItem(key: Key) {\n return map.get(key);\n },\n insert(parentKey: Key | null, index: number, ...values: T[]) {\n setItems(items => {\n let nodes = buildTree(values, parentKey);\n\n // If parentKey is null, insert into the root.\n if (parentKey == null) {\n return [\n ...items.slice(0, index),\n ...nodes,\n ...items.slice(index)\n ];\n }\n\n // Otherwise, update the parent node and its ancestors.\n return updateTree(items, parentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n ...nodes,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n insertBefore(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index, ...values);\n },\n insertAfter(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index + 1, ...values);\n },\n prepend(parentKey: Key | null, ...values: T[]) {\n this.insert(parentKey, 0, ...values);\n },\n append(parentKey: Key | null, ...values: T[]) {\n if (parentKey == null) {\n this.insert(null, items.length, ...values);\n } else {\n let parentNode = map.get(parentKey);\n if (!parentNode) {\n return;\n }\n\n this.insert(parentKey, parentNode.children.length, ...values);\n }\n },\n remove(...keys: Key[]) {\n let newItems = items;\n for (let key of keys) {\n newItems = updateTree(newItems, key, () => null);\n }\n\n setItems(newItems);\n\n let selection = new Set(selectedKeys);\n for (let key of selectedKeys) {\n if (!map.has(key)) {\n selection.delete(key);\n }\n }\n\n setSelectedKeys(selection);\n },\n removeSelectedItems() {\n this.remove(...selectedKeys);\n },\n move(key: Key, toParentKey: Key, index: number) {\n setItems(items => {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n items = updateTree(items, key, () => null);\n\n const movedNode = {\n ...node,\n parentKey: toParentKey\n };\n\n return updateTree(items, toParentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n movedNode,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n update(oldKey: Key, newValue: T) {\n setItems(items => updateTree(items, oldKey, oldNode => {\n let node: TreeNode<T> = {\n key: oldNode.key,\n parentKey: oldNode.parentKey,\n value: newValue,\n children: null\n };\n\n node.children = buildTree(getChildren(newValue), node.key);\n return node;\n }));\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;AA8HO,SAAS,0CAAe,OAAuB,EAAe;IACnE,IAAI,gBACF,eAAe,EAAE,wBACjB,oBAAmB,UACnB,SAAS,CAAC,OAAc,KAAK,EAAE,IAAI,KAAK,GAAG,WAC3C,OAAM,qBACN,oBAAoB,KACrB,GAAG;IAEJ,uFAAuF;IACvF,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAgB;QAC7C,OAAO;QACP,cAAc,wBAAwB,QAAQ,QAAQ,IAAI,IAAI,uBAAuB,EAAE,CAAC;QACxF,YAAY;IACd;IAEA,IAAI,gBAAgB,CAAA,GAAA,cAAM,EACxB,IAAM,SAAS,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA,OAAQ,OAAO,MAAM,MAAM,UAAU,KAAK,MAAM,KAAK,EACvF;QAAC,MAAM,KAAK;QAAE,MAAM,UAAU;QAAE;KAAO;IAEzC,OAAO;QACL,GAAG,KAAK;QACR,OAAO;QACP,GAAG,0CAAkB;oBAAC;QAAM,GAAG,SAAS;QACxC,SAAQ,GAAQ,EAAE;YAChB,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA,OAAQ,OAAO,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AS;gBAChB,IAAI,OAAO,IAAI,GAAG,CAAC;gBACnB,IAAI,CAAC,MACH,OAAO;gBAGT,QAAQ,WAAW,OAAO,KAAK,IAAM,IAAI;gBAEzC,MAAM,YAAY;oBAChB,GAAG,IAAI;oBACP,WAAW;gBACb;gBAEA,OAAO,WAAW,OAAO,aAAa,CAAA,aAAe,CAAA;wBACnD,KAAK,WAAW,GAAG;wBACnB,WAAW,WAAW,SAAS;wBAC/B,OAAO,WAAW,KAAK;wBACvB,UAAU;+BACL,WAAW,QAAQ,CAAC,KAAK,CAAC,GAAG;4BAChC;+BACG,WAAW,QAAQ,CAAC,KAAK,CAAC;yBAC9B;oBACH,CAAA;YACF;QACF;QACA,QAAO,MAAW,EAAE,QAAW,EAAE;YAC/B,SAAS,CAAA,QAAS,WAAW,OAAO,QAAQ,CAAA,UAAW;oBACrD,IAAI,OAAoB;wBACtB,KAAK,QAAQ,GAAG;wBAChB,WAAW,QAAQ,SAAS;wBAC5B,OAAO;wBACP,UAAU,IAAI;oBAChB;oBAEA,KAAK,QAAQ,GAAG,UAAU,YAAY,WAAW,KAAK,GAAG;oBACzD,OAAO;gBACT;QACF;IACF;AACF;","sources":["packages/@react-stately/data/src/index.ts","packages/@react-stately/data/src/useAsyncList.ts","packages/@react-stately/data/src/useListData.ts","packages/@react-stately/data/src/useTreeData.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 './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","/*\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\nimport {createListActions, ListData, ListState} from './useListData';\nimport {Key, Reducer, useEffect, useReducer, useRef} from 'react';\nimport {LoadingState, Selection, SortDescriptor} from '@react-types/shared';\n\nexport interface AsyncListOptions<T, C> {\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** The initial sort descriptor. */\n initialSortDescriptor?: SortDescriptor,\n /** The initial filter text. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that loads the data for the items in the list. */\n load: AsyncListLoadFunction<T, C>,\n /**\n * An optional function that performs sorting. If not provided,\n * then `sortDescriptor` is passed to the `load` function.\n */\n sort?: AsyncListLoadFunction<T, C>\n}\n\ntype AsyncListLoadFunction<T, C> = (state: AsyncListLoadOptions<T, C>) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;\n\ninterface AsyncListLoadOptions<T, C> {\n /** The items currently in the list. */\n items: T[],\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n /** The current sort descriptor for the list. */\n sortDescriptor: SortDescriptor,\n /** An abort signal used to notify the load function that the request has been aborted. */\n signal: AbortSignal,\n /** The pagination cursor returned from the last page load. */\n cursor?: C,\n /** The current filter text used to perform server side filtering. */\n filterText?: string,\n /** The current loading state of the list. */\n loadingState?: LoadingState\n}\n\ninterface AsyncListStateUpdate<T, C> {\n /** The new items to append to the list. */\n items: Iterable<T>,\n /** The keys to add to the selection. */\n selectedKeys?: Iterable<Key>,\n /** The sort descriptor to set. */\n sortDescriptor?: SortDescriptor,\n /** The pagination cursor to be used for the next page load. */\n cursor?: C,\n /** The updated filter text for the list. */\n filterText?: string\n}\n\ninterface AsyncListState<T, C> extends ListState<T> {\n state: LoadingState,\n items: T[],\n // disabledKeys?: Iterable<Key>,\n selectedKeys: Selection,\n // selectedKey?: Key,\n // expandedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n cursor?: C\n}\n\ntype ActionType = 'success' | 'error' | 'loading' | 'loadingMore' | 'sorting' | 'update' | 'filtering';\ninterface Action<T, C> {\n type: ActionType,\n items?: Iterable<T>,\n selectedKeys?: Iterable<Key>,\n sortDescriptor?: SortDescriptor,\n error?: Error,\n abortController?: AbortController,\n updater?: (state: ListState<T>) => ListState<T>,\n cursor?: C,\n filterText?: string\n}\n\nexport interface AsyncListData<T> extends ListData<T> {\n /** Whether data is currently being loaded. */\n isLoading: boolean,\n /** If loading data failed, then this contains the error that occurred. */\n error?: Error,\n // disabledKeys?: Set<Key>,\n // selectedKey?: Key,\n // expandedKeys?: Set<Key>,\n /** The current sort descriptor for the list. */\n sortDescriptor?: SortDescriptor,\n\n /** Reloads the data in the list. */\n reload(): void,\n /** Loads the next page of data in the list. */\n loadMore(): void,\n /** Triggers sorting for the list. */\n sort(descriptor: SortDescriptor): void,\n /** The current loading state for the list. */\n loadingState: LoadingState\n}\n\nfunction reducer<T, C>(data: AsyncListState<T, C>, action: Action<T, C>): AsyncListState<T, C> {\n let selectedKeys;\n switch (data.state) {\n case 'idle':\n case 'error':\n switch (action.type) {\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: action.abortController\n };\n case 'update':\n return {\n ...data,\n ...action.updater(data)\n };\n case 'success':\n case 'error':\n return data;\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loading':\n case 'sorting':\n case 'filtering':\n switch (action.type) {\n case 'success':\n // Ignore if there is a newer abortcontroller in state.\n // This means that multiple requests were going at once.\n // We want to take only the latest result.\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n selectedKeys = action.selectedKeys ?? data.selectedKeys;\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: 'idle',\n items: [...action.items],\n selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error,\n abortController: null\n };\n case 'loading':\n case 'loadingMore':\n case 'sorting':\n case 'filtering':\n // We're already loading, and another load was triggered at the same time.\n // We need to abort the previous load and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n case 'loadingMore':\n switch (action.type) {\n case 'success':\n selectedKeys = (data.selectedKeys === 'all' || action.selectedKeys === 'all')\n ? 'all'\n : new Set([...data.selectedKeys, ...(action.selectedKeys ?? [])]);\n // Append the new items\n return {\n ...data,\n state: 'idle',\n items: [...data.items, ...action.items],\n selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n abortController: null,\n cursor: action.cursor\n };\n case 'error':\n if (action.abortController !== data.abortController) {\n return data;\n }\n\n return {\n ...data,\n state: 'error',\n error: action.error\n };\n case 'loading':\n case 'sorting':\n case 'filtering':\n // We're already loading more, and another load was triggered at the same time.\n // We need to abort the previous load more and start a new one.\n data.abortController.abort();\n return {\n ...data,\n filterText: action.filterText ?? data.filterText,\n state: action.type,\n // Reset items to an empty list if loading, but not when sorting.\n items: action.type === 'loading' ? [] : data.items,\n abortController: action.abortController\n };\n case 'loadingMore':\n // If already loading more and another loading more is triggered, abort the new load more since\n // it is a duplicate request since the cursor hasn't been updated.\n // Do not overwrite the data.abortController\n action.abortController.abort();\n\n return data;\n case 'update':\n // We're already loading, and an update happened at the same time (e.g. selectedKey changed).\n // Update data but don't abort previous load.\n return {\n ...data,\n ...action.updater(data)\n };\n default:\n throw new Error(`Invalid action \"${action.type}\" in state \"${data.state}\"`);\n }\n default:\n throw new Error(`Invalid state \"${data.state}\"`);\n }\n}\n\n/**\n * Manages state for an immutable async loaded list data structure, and provides convenience methods to\n * update the data over time. Manages loading and error states, pagination, and sorting.\n */\nexport function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T> {\n const {\n load,\n sort,\n initialSelectedKeys,\n initialSortDescriptor,\n getKey = (item: any) => item.id || item.key,\n initialFilterText = ''\n } = options;\n\n let [data, dispatch] = useReducer<Reducer<AsyncListState<T, C>, Action<T, C>>>(reducer, {\n state: 'idle',\n error: null,\n items: [],\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),\n sortDescriptor: initialSortDescriptor,\n filterText: initialFilterText\n });\n\n const dispatchFetch = async (action: Action<T, C>, fn: AsyncListLoadFunction<T, C>) => {\n let abortController = new AbortController();\n try {\n dispatch({...action, abortController});\n let previousFilterText = action.filterText ?? data.filterText;\n\n let response = await fn({\n items: data.items.slice(),\n selectedKeys: data.selectedKeys,\n sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,\n signal: abortController.signal,\n cursor: action.type === 'loadingMore' ? data.cursor : null,\n filterText: previousFilterText\n });\n\n let filterText = response.filterText ?? previousFilterText;\n dispatch({type: 'success', ...response, abortController});\n\n // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText\n // Only do this if not aborted (e.g. user triggers another filter action before load completes)\n if (filterText && (filterText !== previousFilterText) && !abortController.signal.aborted) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n } catch (e) {\n dispatch({type: 'error', error: e, abortController});\n }\n };\n\n let didDispatchInitialFetch = useRef(false);\n useEffect(() => {\n if (!didDispatchInitialFetch.current) {\n dispatchFetch({type: 'loading'}, load);\n didDispatchInitialFetch.current = true;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {\n items: data.items,\n selectedKeys: data.selectedKeys,\n sortDescriptor: data.sortDescriptor,\n isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',\n loadingState: data.state,\n error: data.error,\n filterText: data.filterText,\n getItem(key: Key) {\n return data.items.find(item => getKey(item) === key);\n },\n reload() {\n dispatchFetch({type: 'loading'}, load);\n },\n loadMore() {\n // Ignore if already loading more or if performing server side filtering.\n if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) {\n return;\n }\n\n dispatchFetch({type: 'loadingMore'}, load);\n },\n sort(sortDescriptor: SortDescriptor) {\n dispatchFetch({type: 'sorting', sortDescriptor}, sort || load);\n },\n ...createListActions({...options, getKey, cursor: data.cursor}, fn => {\n dispatch({type: 'update', updater: fn});\n }),\n setFilterText(filterText: string) {\n dispatchFetch({type: 'filtering', filterText}, load);\n }\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\nimport {Selection} from '@react-types/shared';\n\nexport interface ListOptions<T> {\n /** Initial items in the list. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: 'all' | Iterable<Key>,\n /** The initial text to filter the list by. */\n initialFilterText?: string,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns whether a item matches the current filter text. */\n filter?: (item: T, filterText: string) => boolean\n}\n\nexport interface ListData<T> {\n /** The items in the list. */\n items: T[],\n\n /** The keys of the currently selected items in the list. */\n selectedKeys: Selection,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Selection): void,\n\n /** The current filter text. */\n filterText: string,\n\n /** Sets the filter text. */\n setFilterText(filterText: string): void,\n\n /**\n * Gets an item from the list by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): T,\n\n /**\n * Inserts items into the list at the given index.\n * @param index - The index to insert into.\n * @param values - The values to insert.\n */\n insert(index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends items to the list.\n * @param values - The values to insert.\n */\n append(...values: T[]): void,\n\n /**\n * Prepends items to the list.\n * @param value - The value to insert.\n */\n prepend(...values: T[]): void,\n\n /**\n * Removes items from the list by their keys.\n * @param keys - The keys of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the list that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the list.\n * @param key - The key of the item to move.\n * @param toIndex - The index to move the item to.\n */\n move(key: Key, toIndex: number): void,\n\n /**\n * Moves one or more items before a given key.\n * @param key - The key of the item to move the items before.\n * @param keys - The keys of the items to move.\n */\n moveBefore(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Moves one or more items after a given key.\n * @param key - The key of the item to move the items after.\n * @param keys - The keys of the items to move.\n */\n moveAfter(key: Key, keys: Iterable<Key>): void,\n\n /**\n * Updates an item in the list.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\nexport interface ListState<T> {\n items: T[],\n selectedKeys: Selection,\n filterText: string\n}\n\ninterface CreateListOptions<T, C> extends ListOptions<T> {\n cursor?: C\n}\n\n/**\n * Manages state for an immutable list data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useListData<T>(options: ListOptions<T>): ListData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n filter,\n initialFilterText = ''\n } = options;\n\n // Store both items and filteredItems in state so we can go back to the unfiltered list\n let [state, setState] = useState<ListState<T>>({\n items: initialItems,\n selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),\n filterText: initialFilterText\n });\n\n let filteredItems = useMemo(\n () => filter ? state.items.filter(item => filter(item, state.filterText)) : state.items,\n [state.items, state.filterText, filter]);\n\n return {\n ...state,\n items: filteredItems,\n ...createListActions({getKey}, setState),\n getItem(key: Key) {\n return state.items.find(item => getKey(item) === key);\n }\n };\n}\n\nexport function createListActions<T, C>(opts: CreateListOptions<T, C>, dispatch: (updater: (state: ListState<T>) => ListState<T>) => void): Omit<ListData<T>, 'items' | 'selectedKeys' | 'getItem' | 'filterText'> {\n let {cursor, getKey} = opts;\n return {\n setSelectedKeys(selectedKeys: Selection) {\n dispatch(state => ({\n ...state,\n selectedKeys\n }));\n },\n setFilterText(filterText: string) {\n dispatch(state => ({\n ...state,\n filterText\n }));\n },\n insert(index: number, ...values: T[]) {\n dispatch(state => insert(state, index, ...values));\n },\n insertBefore(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index, ...values);\n });\n },\n insertAfter(key: Key, ...values: T[]) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n if (state.items.length === 0) {\n index = 0;\n } else {\n return state;\n }\n }\n\n return insert(state, index + 1, ...values);\n });\n },\n prepend(...values: T[]) {\n dispatch(state => insert(state, 0, ...values));\n },\n append(...values: T[]) {\n dispatch(state => insert(state, state.items.length, ...values));\n },\n remove(...keys: Key[]) {\n dispatch(state => {\n let keySet = new Set(keys);\n let items = state.items.filter(item => !keySet.has(getKey(item)));\n\n let selection: Selection = 'all';\n if (state.selectedKeys !== 'all') {\n selection = new Set(state.selectedKeys);\n for (let key of keys) {\n selection.delete(key);\n }\n }\n if (cursor == null && items.length === 0) {\n selection = new Set();\n }\n\n return {\n ...state,\n items,\n selectedKeys: selection\n };\n });\n },\n removeSelectedItems() {\n dispatch(state => {\n if (state.selectedKeys === 'all') {\n return {\n ...state,\n items: [],\n selectedKeys: new Set()\n };\n }\n\n let selectedKeys = state.selectedKeys;\n let items = state.items.filter(item => !selectedKeys.has(getKey(item)));\n return {\n ...state,\n items,\n selectedKeys: new Set()\n };\n });\n },\n move(key: Key, toIndex: number) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n let copy = state.items.slice();\n let [item] = copy.splice(index, 1);\n copy.splice(toIndex, 0, item);\n return {\n ...state,\n items: copy\n };\n });\n },\n moveBefore(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n // Find indices of keys to move. Sort them so that the order in the list is retained.\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex);\n });\n },\n moveAfter(key: Key, keys: Iterable<Key>) {\n dispatch(state => {\n let toIndex = state.items.findIndex(item => getKey(item) === key);\n if (toIndex === -1) {\n return state;\n }\n\n let keyArray = Array.isArray(keys) ? keys : [...keys];\n let indices = keyArray.map(key => state.items.findIndex(item => getKey(item) === key)).sort();\n return move(state, indices, toIndex + 1);\n });\n },\n update(key: Key, newValue: T) {\n dispatch(state => {\n let index = state.items.findIndex(item => getKey(item) === key);\n if (index === -1) {\n return state;\n }\n\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n newValue,\n ...state.items.slice(index + 1)\n ]\n };\n });\n }\n };\n}\n\nfunction insert<T>(state: ListState<T>, index: number, ...values: T[]): ListState<T> {\n return {\n ...state,\n items: [\n ...state.items.slice(0, index),\n ...values,\n ...state.items.slice(index)\n ]\n };\n}\n\nfunction move<T>(state: ListState<T>, indices: number[], toIndex: number): ListState<T> {\n // Shift the target down by the number of items being moved from before the target\n toIndex -= indices.filter(index => index < toIndex).length;\n\n let moves = indices.map(from => ({\n from,\n to: toIndex++\n }));\n\n // Shift later from indices down if they have a larger index\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i].from;\n for (let j = i; j < moves.length; j++) {\n let b = moves[j].from;\n\n if (b > a) {\n moves[j].from--;\n }\n }\n }\n\n // Interleave the moves so they can be applied one by one rather than all at once\n for (let i = 0; i < moves.length; i++) {\n let a = moves[i];\n for (let j = moves.length - 1; j > i; j--) {\n let b = moves[j];\n\n if (b.from < a.to) {\n a.to++;\n } else {\n b.from++;\n }\n }\n }\n\n let copy = state.items.slice();\n for (let move of moves) {\n let [item] = copy.splice(move.from, 1);\n copy.splice(move.to, 0, item);\n }\n\n return {\n ...state,\n items: copy\n };\n}\n","/*\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\nimport {Key, useMemo, useState} from 'react';\n\nexport interface TreeOptions<T extends object> {\n /** Initial root items in the tree. */\n initialItems?: T[],\n /** The keys for the initially selected items. */\n initialSelectedKeys?: Iterable<Key>,\n /** A function that returns a unique key for an item object. */\n getKey?: (item: T) => Key,\n /** A function that returns the children for an item object. */\n getChildren?: (item: T) => T[]\n}\n\ninterface TreeNode<T extends object> {\n /** A unique key for the tree node. */\n key: Key,\n /** The key of the parent node. */\n parentKey: Key,\n /** The value object for the tree node. */\n value: T,\n /** Children of the tree node. */\n children: TreeNode<T>[]\n}\n\nexport interface TreeData<T extends object> {\n /** The root nodes in the tree. */\n items: TreeNode<T>[],\n\n /** The keys of the currently selected items in the tree. */\n selectedKeys: Set<Key>,\n\n /** Sets the selected keys. */\n setSelectedKeys(keys: Set<Key>): void,\n\n /**\n * Gets a node from the tree by key.\n * @param key - The key of the item to retrieve.\n */\n getItem(key: Key): TreeNode<T>,\n\n /**\n * Inserts an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param index - The index within the parent to insert into.\n * @param value - The value to insert.\n */\n insert(parentKey: Key | null, index: number, ...values: T[]): void,\n\n /**\n * Inserts items into the list before the item at the given key.\n * @param key - The key of the item to insert before.\n * @param values - The values to insert.\n */\n insertBefore(key: Key, ...values: T[]): void,\n\n /**\n * Inserts items into the list after the item at the given key.\n * @param key - The key of the item to insert after.\n * @param values - The values to insert.\n */\n insertAfter(key: Key, ...values: T[]): void,\n\n /**\n * Appends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n append(parentKey: Key | null, ...values: T[]): void,\n\n /**\n * Prepends an item into a parent node as a child.\n * @param parentKey - The key of the parent item to insert into. `null` for the root.\n * @param value - The value to insert.\n */\n prepend(parentKey: Key | null, ...value: T[]): void,\n\n /**\n * Removes an item from the tree by its key.\n * @param key - The key of the item to remove.\n */\n remove(...keys: Key[]): void,\n\n /**\n * Removes all items from the tree that are currently\n * in the set of selected items.\n */\n removeSelectedItems(): void,\n\n /**\n * Moves an item within the tree.\n * @param key - The key of the item to move.\n * @param toParentKey - The key of the new parent to insert into.\n * @param index - The index within the new parent to insert at.\n */\n move(key: Key, toParentKey: Key, index: number): void,\n\n /**\n * Updates an item in the tree.\n * @param key - The key of the item to update.\n * @param newValue - The new value for the item.\n */\n update(key: Key, newValue: T): void\n}\n\n/**\n * Manages state for an immutable tree data structure, and provides convenience methods to\n * update the data over time.\n */\nexport function useTreeData<T extends object>(options: TreeOptions<T>): TreeData<T> {\n let {\n initialItems = [],\n initialSelectedKeys,\n getKey = (item: any) => item.id || item.key,\n getChildren = (item: any) => item.children\n } = options;\n let map = useMemo(() => new Map<Key, TreeNode<T>>(), []);\n\n // We only want to compute this on initial render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n let initialNodes = useMemo(() => buildTree(initialItems), []);\n let [items, setItems] = useState(initialNodes);\n let [selectedKeys, setSelectedKeys] = useState(new Set<Key>(initialSelectedKeys || []));\n\n function buildTree(initialItems: T[] = [], parentKey?: Key | null) {\n return initialItems.map(item => {\n let node: TreeNode<T> = {\n key: getKey(item),\n parentKey: parentKey,\n value: item,\n children: null\n };\n\n node.children = buildTree(getChildren(item), node.key);\n map.set(node.key, node);\n return node;\n });\n }\n\n function updateTree(items: TreeNode<T>[], key: Key, update: (node: TreeNode<T>) => TreeNode<T>) {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n // Create a new node. If null, then delete the node, otherwise replace.\n let newNode = update(node);\n if (newNode == null) {\n deleteNode(node);\n } else {\n addNode(newNode);\n }\n\n // Walk up the tree and update each parent to refer to the new chilren.\n while (node.parentKey) {\n let nextParent = map.get(node.parentKey);\n let copy: TreeNode<T> = {\n key: nextParent.key,\n parentKey: nextParent.parentKey,\n value: nextParent.value,\n children: null\n };\n\n let children = nextParent.children;\n if (newNode == null) {\n children = children.filter(c => c !== node);\n }\n\n copy.children = children.map(child => {\n if (child === node) {\n return newNode;\n }\n\n return child;\n });\n\n map.set(copy.key, copy);\n\n newNode = copy;\n node = nextParent;\n }\n\n if (newNode == null) {\n items = items.filter(c => c !== node);\n }\n\n return items.map(item => {\n if (item === node) {\n return newNode;\n }\n\n return item;\n });\n }\n\n function addNode(node: TreeNode<T>) {\n map.set(node.key, node);\n for (let child of node.children) {\n addNode(child);\n }\n }\n\n function deleteNode(node: TreeNode<T>) {\n map.delete(node.key);\n for (let child of node.children) {\n deleteNode(child);\n }\n }\n\n return {\n items,\n selectedKeys,\n setSelectedKeys,\n getItem(key: Key) {\n return map.get(key);\n },\n insert(parentKey: Key | null, index: number, ...values: T[]) {\n setItems(items => {\n let nodes = buildTree(values, parentKey);\n\n // If parentKey is null, insert into the root.\n if (parentKey == null) {\n return [\n ...items.slice(0, index),\n ...nodes,\n ...items.slice(index)\n ];\n }\n\n // Otherwise, update the parent node and its ancestors.\n return updateTree(items, parentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n ...nodes,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n insertBefore(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index, ...values);\n },\n insertAfter(key: Key, ...values: T[]): void {\n let node = map.get(key);\n if (!node) {\n return;\n }\n\n let parentNode = map.get(node.parentKey);\n let nodes = parentNode ? parentNode.children : items;\n let index = nodes.indexOf(node);\n this.insert(parentNode?.key, index + 1, ...values);\n },\n prepend(parentKey: Key | null, ...values: T[]) {\n this.insert(parentKey, 0, ...values);\n },\n append(parentKey: Key | null, ...values: T[]) {\n if (parentKey == null) {\n this.insert(null, items.length, ...values);\n } else {\n let parentNode = map.get(parentKey);\n if (!parentNode) {\n return;\n }\n\n this.insert(parentKey, parentNode.children.length, ...values);\n }\n },\n remove(...keys: Key[]) {\n let newItems = items;\n for (let key of keys) {\n newItems = updateTree(newItems, key, () => null);\n }\n\n setItems(newItems);\n\n let selection = new Set(selectedKeys);\n for (let key of selectedKeys) {\n if (!map.has(key)) {\n selection.delete(key);\n }\n }\n\n setSelectedKeys(selection);\n },\n removeSelectedItems() {\n this.remove(...selectedKeys);\n },\n move(key: Key, toParentKey: Key, index: number) {\n setItems(items => {\n let node = map.get(key);\n if (!node) {\n return items;\n }\n\n items = updateTree(items, key, () => null);\n\n const movedNode = {\n ...node,\n parentKey: toParentKey\n };\n\n return updateTree(items, toParentKey, parentNode => ({\n key: parentNode.key,\n parentKey: parentNode.parentKey,\n value: parentNode.value,\n children: [\n ...parentNode.children.slice(0, index),\n movedNode,\n ...parentNode.children.slice(index)\n ]\n }));\n });\n },\n update(oldKey: Key, newValue: T) {\n setItems(items => updateTree(items, oldKey, oldNode => {\n let node: TreeNode<T> = {\n key: oldNode.key,\n parentKey: oldNode.parentKey,\n value: newValue,\n children: null\n };\n\n node.children = buildTree(getChildren(newValue), node.key);\n return node;\n }));\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,6BA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,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IAEpD;;;OAGG;IACH,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE7B;;;OAGG;IACH,mBAAmB,IAAI,IAAI,CAAC;IAE5B;;;;;OAKG;IACH,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtD;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAA;CACpC;AAED;;;GAGG;AACH,4BAA4B,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAsOlF","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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/data",
|
|
3
|
-
"version": "3.9.3-nightly.
|
|
3
|
+
"version": "3.9.3-nightly.3943+06e63d3ae",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-types/shared": "3.0.0-nightly.2241+06e63d3ae",
|
|
26
26
|
"@swc/helpers": "^0.4.14"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "06e63d3ae7898b8cd81fdb6fa87b763faf2054bf"
|
|
35
35
|
}
|
package/src/useAsyncList.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {createListActions, ListData, ListState} from './useListData';
|
|
14
|
-
import {Key, Reducer, useEffect, useReducer} from 'react';
|
|
14
|
+
import {Key, Reducer, useEffect, useReducer, useRef} from 'react';
|
|
15
15
|
import {LoadingState, Selection, SortDescriptor} from '@react-types/shared';
|
|
16
16
|
|
|
17
17
|
export interface AsyncListOptions<T, C> {
|
|
@@ -313,8 +313,12 @@ export function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): As
|
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
315
|
|
|
316
|
+
let didDispatchInitialFetch = useRef(false);
|
|
316
317
|
useEffect(() => {
|
|
317
|
-
|
|
318
|
+
if (!didDispatchInitialFetch.current) {
|
|
319
|
+
dispatchFetch({type: 'loading'}, load);
|
|
320
|
+
didDispatchInitialFetch.current = true;
|
|
321
|
+
}
|
|
318
322
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
319
323
|
}, []);
|
|
320
324
|
|