@react-stately/data 3.11.7-nightly.5042 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -26,7 +26,7 @@ export interface ListData<T> {
26
26
  * Gets an item from the list by key.
27
27
  * @param key - The key of the item to retrieve.
28
28
  */
29
- getItem(key: Key): T;
29
+ getItem(key: Key): T | undefined;
30
30
  /**
31
31
  * Inserts items into the list at the given index.
32
32
  * @param index - The index to insert into.
@@ -110,16 +110,18 @@ export interface AsyncListOptions<T, C> {
110
110
  * An optional function that performs sorting. If not provided,
111
111
  * then `sortDescriptor` is passed to the `load` function.
112
112
  */
113
- sort?: AsyncListLoadFunction<T, C>;
113
+ sort?: AsyncListLoadFunction<T, C, AsyncListLoadOptions<T, C> & {
114
+ sortDescriptor: SortDescriptor;
115
+ }>;
114
116
  }
115
- type AsyncListLoadFunction<T, C> = (state: AsyncListLoadOptions<T, C>) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;
117
+ type AsyncListLoadFunction<T, C, S extends AsyncListLoadOptions<T, C> = AsyncListLoadOptions<T, C>> = (state: S) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;
116
118
  interface AsyncListLoadOptions<T, C> {
117
119
  /** The items currently in the list. */
118
120
  items: T[];
119
121
  /** The keys of the currently selected items in the list. */
120
122
  selectedKeys: Selection;
121
123
  /** The current sort descriptor for the list. */
122
- sortDescriptor: SortDescriptor;
124
+ sortDescriptor?: SortDescriptor;
123
125
  /** An abort signal used to notify the load function that the request has been aborted. */
124
126
  signal: AbortSignal;
125
127
  /** The pagination cursor returned from the last page load. */
@@ -176,11 +178,11 @@ interface TreeNode<T extends object> {
176
178
  /** A unique key for the tree node. */
177
179
  key: Key;
178
180
  /** The key of the parent node. */
179
- parentKey: Key;
181
+ parentKey?: Key | null;
180
182
  /** The value object for the tree node. */
181
183
  value: T;
182
184
  /** Children of the tree node. */
183
- children: TreeNode<T>[];
185
+ children: TreeNode<T>[] | null;
184
186
  }
185
187
  export interface TreeData<T extends object> {
186
188
  /** The root nodes in the tree. */
@@ -193,7 +195,7 @@ export interface TreeData<T extends object> {
193
195
  * Gets a node from the tree by key.
194
196
  * @param key - The key of the item to retrieve.
195
197
  */
196
- getItem(key: Key): TreeNode<T>;
198
+ getItem(key: Key): TreeNode<T> | undefined;
197
199
  /**
198
200
  * Inserts an item into a parent node as a child.
199
201
  * @param parentKey - The key of the parent item to insert into. `null` for the root.
@@ -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,6BAA6B;IAC7B,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,4DAA4D;IAC5D,YAAY,EAAE,SAAS,CAAC;IAExB,8BAA8B;IAC9B,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAEvC,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;IAErB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE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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"}
1
+ {"mappings":";AAeA,6BAA6B,CAAC;IAC5B,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;IACnB,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5C,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC;IAC1B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAA;CAClD;AAED,0BAA0B,CAAC;IACzB,6BAA6B;IAC7B,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,4DAA4D;IAC5D,YAAY,EAAE,SAAS,CAAC;IAExB,8BAA8B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K,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,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7D;;;;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,CA6QlF","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"}
@@ -40,9 +40,10 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
40
40
  abortController: action.abortController
41
41
  };
42
42
  case 'update':
43
+ var _action_updater;
43
44
  return {
44
45
  ...data,
45
- ...action.updater(data)
46
+ ...(_action_updater = action.updater) === null || _action_updater === void 0 ? void 0 : _action_updater.call(action, data)
46
47
  };
47
48
  case 'success':
48
49
  case 'error':
@@ -61,17 +62,17 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
61
62
  if (action.abortController !== data.abortController) return data;
62
63
  var _action_selectedKeys;
63
64
  selectedKeys = (_action_selectedKeys = action.selectedKeys) !== null && _action_selectedKeys !== void 0 ? _action_selectedKeys : data.selectedKeys;
64
- var _action_filterText1, _action_sortDescriptor1;
65
+ var _action_filterText1, _action_items, _action_sortDescriptor1;
65
66
  return {
66
67
  ...data,
67
68
  filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
68
69
  state: 'idle',
69
70
  items: [
70
- ...action.items
71
+ ...(_action_items = action.items) !== null && _action_items !== void 0 ? _action_items : []
71
72
  ],
72
73
  selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),
73
74
  sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
74
- abortController: null,
75
+ abortController: undefined,
75
76
  cursor: action.cursor
76
77
  };
77
78
  case 'error':
@@ -80,15 +81,16 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
80
81
  ...data,
81
82
  state: 'error',
82
83
  error: action.error,
83
- abortController: null
84
+ abortController: undefined
84
85
  };
85
86
  case 'loading':
86
87
  case 'loadingMore':
87
88
  case 'sorting':
88
89
  case 'filtering':
89
- // We're already loading, and another load was triggered at the same time.
90
+ var // We're already loading, and another load was triggered at the same time.
90
91
  // We need to abort the previous load and start a new one.
91
- data.abortController.abort();
92
+ _data_abortController;
93
+ (_data_abortController = data.abortController) === null || _data_abortController === void 0 ? void 0 : _data_abortController.abort();
92
94
  var _action_filterText2;
93
95
  return {
94
96
  ...data,
@@ -99,11 +101,12 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
99
101
  abortController: action.abortController
100
102
  };
101
103
  case 'update':
104
+ var _action_updater1;
102
105
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
103
106
  // Update data but don't abort previous load.
104
107
  return {
105
108
  ...data,
106
- ...action.updater(data)
109
+ ...(_action_updater1 = action.updater) === null || _action_updater1 === void 0 ? void 0 : _action_updater1.call(action, data)
107
110
  };
108
111
  default:
109
112
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
@@ -116,18 +119,18 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
116
119
  ...data.selectedKeys,
117
120
  ...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
118
121
  ]);
119
- var _action_sortDescriptor2;
122
+ var _action_items1, _action_sortDescriptor2;
120
123
  // Append the new items
121
124
  return {
122
125
  ...data,
123
126
  state: 'idle',
124
127
  items: [
125
128
  ...data.items,
126
- ...action.items
129
+ ...(_action_items1 = action.items) !== null && _action_items1 !== void 0 ? _action_items1 : []
127
130
  ],
128
131
  selectedKeys: selectedKeys,
129
132
  sortDescriptor: (_action_sortDescriptor2 = action.sortDescriptor) !== null && _action_sortDescriptor2 !== void 0 ? _action_sortDescriptor2 : data.sortDescriptor,
130
- abortController: null,
133
+ abortController: undefined,
131
134
  cursor: action.cursor
132
135
  };
133
136
  case 'error':
@@ -140,9 +143,10 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
140
143
  case 'loading':
141
144
  case 'sorting':
142
145
  case 'filtering':
143
- // We're already loading more, and another load was triggered at the same time.
146
+ var // We're already loading more, and another load was triggered at the same time.
144
147
  // We need to abort the previous load more and start a new one.
145
- data.abortController.abort();
148
+ _data_abortController1;
149
+ (_data_abortController1 = data.abortController) === null || _data_abortController1 === void 0 ? void 0 : _data_abortController1.abort();
146
150
  var _action_filterText3;
147
151
  return {
148
152
  ...data,
@@ -153,17 +157,19 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
153
157
  abortController: action.abortController
154
158
  };
155
159
  case 'loadingMore':
156
- // If already loading more and another loading more is triggered, abort the new load more since
160
+ var // If already loading more and another loading more is triggered, abort the new load more since
157
161
  // it is a duplicate request since the cursor hasn't been updated.
158
162
  // Do not overwrite the data.abortController
159
- action.abortController.abort();
163
+ _action_abortController;
164
+ (_action_abortController = action.abortController) === null || _action_abortController === void 0 ? void 0 : _action_abortController.abort();
160
165
  return data;
161
166
  case 'update':
167
+ var _action_updater2;
162
168
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
163
169
  // Update data but don't abort previous load.
164
170
  return {
165
171
  ...data,
166
- ...action.updater(data)
172
+ ...(_action_updater2 = action.updater) === null || _action_updater2 === void 0 ? void 0 : _action_updater2.call(action, data)
167
173
  };
168
174
  default:
169
175
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
@@ -176,7 +182,7 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
176
182
  const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = '' } = options;
177
183
  let [data, dispatch] = (0, $9f61J$react.useReducer)($1cb48366e5c5533f$var$reducer, {
178
184
  state: 'idle',
179
- error: null,
185
+ error: undefined,
180
186
  items: [],
181
187
  selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),
182
188
  sortDescriptor: initialSortDescriptor,
@@ -197,7 +203,7 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
197
203
  selectedKeys: data.selectedKeys,
198
204
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
199
205
  signal: abortController.signal,
200
- cursor: action.type === 'loadingMore' ? data.cursor : null,
206
+ cursor: action.type === 'loadingMore' ? data.cursor : undefined,
201
207
  filterText: previousFilterText
202
208
  });
203
209
  var _response_filterText;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAuGD,SAAS,8BAAc,IAA0B,EAAE,MAAoB;IACrE,IAAI;IACJ,OAAQ,KAAK,KAAK;QAChB,KAAK;QACL,KAAK;YACH,OAAQ,OAAO,IAAI;gBACjB,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;wBAGW,oBAII;oBANlB,OAAO;wBACL,GAAG,IAAI;wBACP,YAAY,CAAA,qBAAA,OAAO,UAAU,cAAjB,gCAAA,qBAAqB,KAAK,UAAU;wBAChD,OAAO,OAAO,IAAI;wBAClB,iEAAiE;wBACjE,OAAO,OAAO,IAAI,KAAK,YAAY,EAAE,GAAG,KAAK,KAAK;wBAClD,gBAAgB,CAAA,yBAAA,OAAO,cAAc,cAArB,oCAAA,yBAAyB,KAAK,cAAc;wBAC5D,iBAAiB,OAAO,eAAe;oBACzC;gBACF,KAAK;oBACH,OAAO;wBACL,GAAG,IAAI;wBACP,GAAG,OAAO,OAAO,CAAC,KAAK;oBACzB;gBACF,KAAK;gBACL,KAAK;oBACH,OAAO;gBACT;oBACE,MAAM,IAAI,MAAM,CAAC,gBAAgB,EAAE,OAAO,IAAI,CAAC,YAAY,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC;YAC9E;QACF,KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAQ,OAAO,IAAI;gBACjB,KAAK;oBACH,uDAAuD;oBACvD,wDAAwD;oBACxD,0CAA0C;oBAC1C,IAAI,OAAO,eAAe,KAAK,KAAK,eAAe,EACjD,OAAO;wBAGM;oBAAf,eAAe,CAAA,uBAAA,OAAO,YAAY,cAAnB,kCAAA,uBAAuB,KAAK,YAAY;wBAGzC,qBAII;oBANlB,OAAO;wBACL,GAAG,IAAI;wBACP,YAAY,CAAA,sBAAA,OAAO,UAAU,cAAjB,iCAAA,sBAAq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AE;QACR,IAAI,CAAC,wBAAwB,OAAO,EAAE;YACpC,cAAc;gBAAC,MAAM;YAAS,GAAG;YACjC,wBAAwB,OAAO,GAAG;QACpC;IACF,uDAAuD;IACvD,GAAG,EAAE;IAEL,OAAO;QACL,OAAO,KAAK,KAAK;QACjB,cAAc,KAAK,YAAY;QAC/B,gBAAgB,KAAK,cAAc;QACnC,WAAW,KAAK,KAAK,KAAK,aAAa,KAAK,KAAK,KAAK,iBAAiB,KAAK,KAAK,KAAK,aAAa,KAAK,KAAK,KAAK;QAClH,cAAc,KAAK,KAAK;QACxB,OAAO,KAAK,KAAK;QACjB,YAAY,KAAK,UAAU;QAC3B,SAAQ,GAAQ;YACd,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,CAAA,OAAQ,OAAO,UAAU;QAClD;QACA;YACE,cAAc;gBAAC,MAAM;YAAS,GAAG;QACnC;QACA;YACE,yEAAyE;YACzE,IAAI,KAAK,KAAK,KAAK,iBAAiB,KAAK,KAAK,KAAK,eAAe,KAAK,MAAM,IAAI,MAC/E;YAGF,cAAc;gBAAC,MAAM;YAAa,GAAG;QACvC;QACA,MAAK,cAA8B;YACjC,cAAc;gBAAC,MAAM;gCAAW;YAAc,GAAG,QAAQ;QAC3D;QACA,GAAG,CAAA,GAAA,2CAAgB,EAAE;YAAC,GAAG,OAAO;oBAAE;YAAQ,QAAQ,KAAK,MAAM;QAAA,GAAG,CAAA;YAC9D,SAAS;gBAAC,MAAM;gBAAU,SAAS;YAAE;QACvC,EAAE;QACF,eAAc,UAAkB;YAC9B,cAAc;gBAAC,MAAM;4BAAa;YAAU,GAAG;QACjD;IACF;AACF","sources":["packages/@react-stately/data/src/useAsyncList.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\nimport {createListActions, ListData, ListState} from './useListData';\nimport {Key, LoadingState, Selection, SortDescriptor} from '@react-types/shared';\nimport {useEffect, useReducer, useRef} from 'react';\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<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"],"names":[],"version":3,"file":"useAsyncList.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAuGD,SAAS,8BAAc,IAA0B,EAAE,MAAoB;IACrE,IAAI;IACJ,OAAQ,KAAK,KAAK;QAChB,KAAK;QACL,KAAK;YACH,OAAQ,OAAO,IAAI;gBACjB,KAAK;gBACL,KAAK;gBACL,KAAK;gBACL,KAAK;wBAGW,oBAII;oBANlB,OAAO;wBACL,GAAG,IAAI;wBACP,YAAY,CAAA,qBAAA,OAAO,UAAU,cAAjB,gCAAA,qBAAqB,KAAK,UAAU;wBAChD,OAAO,OAAO,IAAI;wBAClB,iEAAiE;wBACjE,OAAO,OAAO,IAAI,KAAK,YAAY,EAAE,GAAG,KAAK,KAAK;wBAClD,gBAAgB,CAAA,yBAAA,OAAO,cAAc,cAArB,oCAAA,yBAAyB,K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AK,aAAa,KAAK,KAAK,KAAK;QAClH,cAAc,KAAK,KAAK;QACxB,OAAO,KAAK,KAAK;QACjB,YAAY,KAAK,UAAU;QAC3B,SAAQ,GAAQ;YACd,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,CAAA,OAAQ,OAAO,UAAU;QAClD;QACA;YACE,cAAc;gBAAC,MAAM;YAAS,GAAG;QACnC;QACA;YACE,yEAAyE;YACzE,IAAI,KAAK,KAAK,KAAK,iBAAiB,KAAK,KAAK,KAAK,eAAe,KAAK,MAAM,IAAI,MAC/E;YAGF,cAAc;gBAAC,MAAM;YAAa,GAAG;QACvC;QACA,MAAK,cAA8B;YACjC,cAAc;gBAAC,MAAM;gCAAW;YAAc,GAAI,QAAQ;QAC5D;QACA,GAAG,CAAA,GAAA,2CAAgB,EAAE;YAAC,GAAG,OAAO;oBAAE;YAAQ,QAAQ,KAAK,MAAM;QAAA,GAAG,CAAA;YAC9D,SAAS;gBAAC,MAAM;gBAAU,SAAS;YAAE;QACvC,EAAE;QACF,eAAc,UAAkB;YAC9B,cAAc;gBAAC,MAAM;4BAAa;YAAU,GAAG;QACjD;IACF;AACF","sources":["packages/@react-stately/data/src/useAsyncList.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\nimport {createListActions, ListData, ListState} from './useListData';\nimport {Key, LoadingState, Selection, SortDescriptor} from '@react-types/shared';\nimport {useEffect, useReducer, useRef} from 'react';\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, AsyncListLoadOptions<T, C> & {sortDescriptor: SortDescriptor}>\n}\n\ntype AsyncListLoadFunction<T, C, S extends AsyncListLoadOptions<T, C> = AsyncListLoadOptions<T, C>> = (state: S) => 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: undefined,\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: undefined\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: undefined,\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<AsyncListState<T, C>, [Action<T, C>]>(reducer, {\n state: 'idle',\n error: undefined,\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 : undefined,\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 as Error, 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) as AsyncListLoadFunction<T, C>);\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"],"names":[],"version":3,"file":"useAsyncList.main.js.map"}
@@ -34,9 +34,10 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
34
34
  abortController: action.abortController
35
35
  };
36
36
  case 'update':
37
+ var _action_updater;
37
38
  return {
38
39
  ...data,
39
- ...action.updater(data)
40
+ ...(_action_updater = action.updater) === null || _action_updater === void 0 ? void 0 : _action_updater.call(action, data)
40
41
  };
41
42
  case 'success':
42
43
  case 'error':
@@ -55,17 +56,17 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
55
56
  if (action.abortController !== data.abortController) return data;
56
57
  var _action_selectedKeys;
57
58
  selectedKeys = (_action_selectedKeys = action.selectedKeys) !== null && _action_selectedKeys !== void 0 ? _action_selectedKeys : data.selectedKeys;
58
- var _action_filterText1, _action_sortDescriptor1;
59
+ var _action_filterText1, _action_items, _action_sortDescriptor1;
59
60
  return {
60
61
  ...data,
61
62
  filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
62
63
  state: 'idle',
63
64
  items: [
64
- ...action.items
65
+ ...(_action_items = action.items) !== null && _action_items !== void 0 ? _action_items : []
65
66
  ],
66
67
  selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),
67
68
  sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
68
- abortController: null,
69
+ abortController: undefined,
69
70
  cursor: action.cursor
70
71
  };
71
72
  case 'error':
@@ -74,15 +75,16 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
74
75
  ...data,
75
76
  state: 'error',
76
77
  error: action.error,
77
- abortController: null
78
+ abortController: undefined
78
79
  };
79
80
  case 'loading':
80
81
  case 'loadingMore':
81
82
  case 'sorting':
82
83
  case 'filtering':
83
- // We're already loading, and another load was triggered at the same time.
84
+ var // We're already loading, and another load was triggered at the same time.
84
85
  // We need to abort the previous load and start a new one.
85
- data.abortController.abort();
86
+ _data_abortController;
87
+ (_data_abortController = data.abortController) === null || _data_abortController === void 0 ? void 0 : _data_abortController.abort();
86
88
  var _action_filterText2;
87
89
  return {
88
90
  ...data,
@@ -93,11 +95,12 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
93
95
  abortController: action.abortController
94
96
  };
95
97
  case 'update':
98
+ var _action_updater1;
96
99
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
97
100
  // Update data but don't abort previous load.
98
101
  return {
99
102
  ...data,
100
- ...action.updater(data)
103
+ ...(_action_updater1 = action.updater) === null || _action_updater1 === void 0 ? void 0 : _action_updater1.call(action, data)
101
104
  };
102
105
  default:
103
106
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
@@ -110,18 +113,18 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
110
113
  ...data.selectedKeys,
111
114
  ...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
112
115
  ]);
113
- var _action_sortDescriptor2;
116
+ var _action_items1, _action_sortDescriptor2;
114
117
  // Append the new items
115
118
  return {
116
119
  ...data,
117
120
  state: 'idle',
118
121
  items: [
119
122
  ...data.items,
120
- ...action.items
123
+ ...(_action_items1 = action.items) !== null && _action_items1 !== void 0 ? _action_items1 : []
121
124
  ],
122
125
  selectedKeys: selectedKeys,
123
126
  sortDescriptor: (_action_sortDescriptor2 = action.sortDescriptor) !== null && _action_sortDescriptor2 !== void 0 ? _action_sortDescriptor2 : data.sortDescriptor,
124
- abortController: null,
127
+ abortController: undefined,
125
128
  cursor: action.cursor
126
129
  };
127
130
  case 'error':
@@ -134,9 +137,10 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
134
137
  case 'loading':
135
138
  case 'sorting':
136
139
  case 'filtering':
137
- // We're already loading more, and another load was triggered at the same time.
140
+ var // We're already loading more, and another load was triggered at the same time.
138
141
  // We need to abort the previous load more and start a new one.
139
- data.abortController.abort();
142
+ _data_abortController1;
143
+ (_data_abortController1 = data.abortController) === null || _data_abortController1 === void 0 ? void 0 : _data_abortController1.abort();
140
144
  var _action_filterText3;
141
145
  return {
142
146
  ...data,
@@ -147,17 +151,19 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
147
151
  abortController: action.abortController
148
152
  };
149
153
  case 'loadingMore':
150
- // If already loading more and another loading more is triggered, abort the new load more since
154
+ var // If already loading more and another loading more is triggered, abort the new load more since
151
155
  // it is a duplicate request since the cursor hasn't been updated.
152
156
  // Do not overwrite the data.abortController
153
- action.abortController.abort();
157
+ _action_abortController;
158
+ (_action_abortController = action.abortController) === null || _action_abortController === void 0 ? void 0 : _action_abortController.abort();
154
159
  return data;
155
160
  case 'update':
161
+ var _action_updater2;
156
162
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
157
163
  // Update data but don't abort previous load.
158
164
  return {
159
165
  ...data,
160
- ...action.updater(data)
166
+ ...(_action_updater2 = action.updater) === null || _action_updater2 === void 0 ? void 0 : _action_updater2.call(action, data)
161
167
  };
162
168
  default:
163
169
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
@@ -170,7 +176,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
170
176
  const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = '' } = options;
171
177
  let [data, dispatch] = (0, $fh1mr$useReducer)($f86e6c1ec7da6ebb$var$reducer, {
172
178
  state: 'idle',
173
- error: null,
179
+ error: undefined,
174
180
  items: [],
175
181
  selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),
176
182
  sortDescriptor: initialSortDescriptor,
@@ -191,7 +197,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
191
197
  selectedKeys: data.selectedKeys,
192
198
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
193
199
  signal: abortController.signal,
194
- cursor: action.type === 'loadingMore' ? data.cursor : null,
200
+ cursor: action.type === 'loadingMore' ? data.cursor : undefined,
195
201
  filterText: previousFilterText
196
202
  });
197
203
  var _response_filterText;
@@ -34,9 +34,10 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
34
34
  abortController: action.abortController
35
35
  };
36
36
  case 'update':
37
+ var _action_updater;
37
38
  return {
38
39
  ...data,
39
- ...action.updater(data)
40
+ ...(_action_updater = action.updater) === null || _action_updater === void 0 ? void 0 : _action_updater.call(action, data)
40
41
  };
41
42
  case 'success':
42
43
  case 'error':
@@ -55,17 +56,17 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
55
56
  if (action.abortController !== data.abortController) return data;
56
57
  var _action_selectedKeys;
57
58
  selectedKeys = (_action_selectedKeys = action.selectedKeys) !== null && _action_selectedKeys !== void 0 ? _action_selectedKeys : data.selectedKeys;
58
- var _action_filterText1, _action_sortDescriptor1;
59
+ var _action_filterText1, _action_items, _action_sortDescriptor1;
59
60
  return {
60
61
  ...data,
61
62
  filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
62
63
  state: 'idle',
63
64
  items: [
64
- ...action.items
65
+ ...(_action_items = action.items) !== null && _action_items !== void 0 ? _action_items : []
65
66
  ],
66
67
  selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),
67
68
  sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
68
- abortController: null,
69
+ abortController: undefined,
69
70
  cursor: action.cursor
70
71
  };
71
72
  case 'error':
@@ -74,15 +75,16 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
74
75
  ...data,
75
76
  state: 'error',
76
77
  error: action.error,
77
- abortController: null
78
+ abortController: undefined
78
79
  };
79
80
  case 'loading':
80
81
  case 'loadingMore':
81
82
  case 'sorting':
82
83
  case 'filtering':
83
- // We're already loading, and another load was triggered at the same time.
84
+ var // We're already loading, and another load was triggered at the same time.
84
85
  // We need to abort the previous load and start a new one.
85
- data.abortController.abort();
86
+ _data_abortController;
87
+ (_data_abortController = data.abortController) === null || _data_abortController === void 0 ? void 0 : _data_abortController.abort();
86
88
  var _action_filterText2;
87
89
  return {
88
90
  ...data,
@@ -93,11 +95,12 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
93
95
  abortController: action.abortController
94
96
  };
95
97
  case 'update':
98
+ var _action_updater1;
96
99
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
97
100
  // Update data but don't abort previous load.
98
101
  return {
99
102
  ...data,
100
- ...action.updater(data)
103
+ ...(_action_updater1 = action.updater) === null || _action_updater1 === void 0 ? void 0 : _action_updater1.call(action, data)
101
104
  };
102
105
  default:
103
106
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
@@ -110,18 +113,18 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
110
113
  ...data.selectedKeys,
111
114
  ...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
112
115
  ]);
113
- var _action_sortDescriptor2;
116
+ var _action_items1, _action_sortDescriptor2;
114
117
  // Append the new items
115
118
  return {
116
119
  ...data,
117
120
  state: 'idle',
118
121
  items: [
119
122
  ...data.items,
120
- ...action.items
123
+ ...(_action_items1 = action.items) !== null && _action_items1 !== void 0 ? _action_items1 : []
121
124
  ],
122
125
  selectedKeys: selectedKeys,
123
126
  sortDescriptor: (_action_sortDescriptor2 = action.sortDescriptor) !== null && _action_sortDescriptor2 !== void 0 ? _action_sortDescriptor2 : data.sortDescriptor,
124
- abortController: null,
127
+ abortController: undefined,
125
128
  cursor: action.cursor
126
129
  };
127
130
  case 'error':
@@ -134,9 +137,10 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
134
137
  case 'loading':
135
138
  case 'sorting':
136
139
  case 'filtering':
137
- // We're already loading more, and another load was triggered at the same time.
140
+ var // We're already loading more, and another load was triggered at the same time.
138
141
  // We need to abort the previous load more and start a new one.
139
- data.abortController.abort();
142
+ _data_abortController1;
143
+ (_data_abortController1 = data.abortController) === null || _data_abortController1 === void 0 ? void 0 : _data_abortController1.abort();
140
144
  var _action_filterText3;
141
145
  return {
142
146
  ...data,
@@ -147,17 +151,19 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
147
151
  abortController: action.abortController
148
152
  };
149
153
  case 'loadingMore':
150
- // If already loading more and another loading more is triggered, abort the new load more since
154
+ var // If already loading more and another loading more is triggered, abort the new load more since
151
155
  // it is a duplicate request since the cursor hasn't been updated.
152
156
  // Do not overwrite the data.abortController
153
- action.abortController.abort();
157
+ _action_abortController;
158
+ (_action_abortController = action.abortController) === null || _action_abortController === void 0 ? void 0 : _action_abortController.abort();
154
159
  return data;
155
160
  case 'update':
161
+ var _action_updater2;
156
162
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
157
163
  // Update data but don't abort previous load.
158
164
  return {
159
165
  ...data,
160
- ...action.updater(data)
166
+ ...(_action_updater2 = action.updater) === null || _action_updater2 === void 0 ? void 0 : _action_updater2.call(action, data)
161
167
  };
162
168
  default:
163
169
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
@@ -170,7 +176,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
170
176
  const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = '' } = options;
171
177
  let [data, dispatch] = (0, $fh1mr$useReducer)($f86e6c1ec7da6ebb$var$reducer, {
172
178
  state: 'idle',
173
- error: null,
179
+ error: undefined,
174
180
  items: [],
175
181
  selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),
176
182
  sortDescriptor: initialSortDescriptor,
@@ -191,7 +197,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
191
197
  selectedKeys: data.selectedKeys,
192
198
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
193
199
  signal: abortController.signal,
194
- cursor: action.type === 'loadingMore' ? data.cursor : null,
200
+ cursor: action.type === 'loadingMore' ? data.cursor : undefined,
195
201
  filterText: previousFilterText
196
202
  });
197
203
  var _response_filterText;