@react-stately/data 3.11.4-nightly.4624 → 3.11.4

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.
@@ -22,39 +22,39 @@ $parcel$export(module.exports, "useAsyncList", () => $1cb48366e5c5533f$export$bc
22
22
  function $1cb48366e5c5533f$var$reducer(data, action) {
23
23
  let selectedKeys;
24
24
  switch(data.state){
25
- case "idle":
26
- case "error":
25
+ case 'idle':
26
+ case 'error':
27
27
  switch(action.type){
28
- case "loading":
29
- case "loadingMore":
30
- case "sorting":
31
- case "filtering":
28
+ case 'loading':
29
+ case 'loadingMore':
30
+ case 'sorting':
31
+ case 'filtering':
32
32
  var _action_filterText, _action_sortDescriptor;
33
33
  return {
34
34
  ...data,
35
35
  filterText: (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText,
36
36
  state: action.type,
37
37
  // Reset items to an empty list if loading, but not when sorting.
38
- items: action.type === "loading" ? [] : data.items,
38
+ items: action.type === 'loading' ? [] : data.items,
39
39
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
40
40
  abortController: action.abortController
41
41
  };
42
- case "update":
42
+ case 'update':
43
43
  return {
44
44
  ...data,
45
45
  ...action.updater(data)
46
46
  };
47
- case "success":
48
- case "error":
47
+ case 'success':
48
+ case 'error':
49
49
  return data;
50
50
  default:
51
51
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
52
52
  }
53
- case "loading":
54
- case "sorting":
55
- case "filtering":
53
+ case 'loading':
54
+ case 'sorting':
55
+ case 'filtering':
56
56
  switch(action.type){
57
- case "success":
57
+ case 'success':
58
58
  // Ignore if there is a newer abortcontroller in state.
59
59
  // This means that multiple requests were going at once.
60
60
  // We want to take only the latest result.
@@ -65,27 +65,27 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
65
65
  return {
66
66
  ...data,
67
67
  filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
68
- state: "idle",
68
+ state: 'idle',
69
69
  items: [
70
70
  ...action.items
71
71
  ],
72
- selectedKeys: selectedKeys === "all" ? "all" : new Set(selectedKeys),
72
+ selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),
73
73
  sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
74
74
  abortController: null,
75
75
  cursor: action.cursor
76
76
  };
77
- case "error":
77
+ case 'error':
78
78
  if (action.abortController !== data.abortController) return data;
79
79
  return {
80
80
  ...data,
81
- state: "error",
81
+ state: 'error',
82
82
  error: action.error,
83
83
  abortController: null
84
84
  };
85
- case "loading":
86
- case "loadingMore":
87
- case "sorting":
88
- case "filtering":
85
+ case 'loading':
86
+ case 'loadingMore':
87
+ case 'sorting':
88
+ case 'filtering':
89
89
  // We're already loading, and another load was triggered at the same time.
90
90
  // We need to abort the previous load and start a new one.
91
91
  data.abortController.abort();
@@ -95,10 +95,10 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
95
95
  filterText: (_action_filterText2 = action.filterText) !== null && _action_filterText2 !== void 0 ? _action_filterText2 : data.filterText,
96
96
  state: action.type,
97
97
  // Reset items to an empty list if loading, but not when sorting.
98
- items: action.type === "loading" ? [] : data.items,
98
+ items: action.type === 'loading' ? [] : data.items,
99
99
  abortController: action.abortController
100
100
  };
101
- case "update":
101
+ case 'update':
102
102
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
103
103
  // Update data but don't abort previous load.
104
104
  return {
@@ -108,11 +108,11 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
108
108
  default:
109
109
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
110
110
  }
111
- case "loadingMore":
111
+ case 'loadingMore':
112
112
  switch(action.type){
113
- case "success":
113
+ case 'success':
114
114
  var _action_selectedKeys1;
115
- selectedKeys = data.selectedKeys === "all" || action.selectedKeys === "all" ? "all" : new Set([
115
+ selectedKeys = data.selectedKeys === 'all' || action.selectedKeys === 'all' ? 'all' : new Set([
116
116
  ...data.selectedKeys,
117
117
  ...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
118
118
  ]);
@@ -120,7 +120,7 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
120
120
  // Append the new items
121
121
  return {
122
122
  ...data,
123
- state: "idle",
123
+ state: 'idle',
124
124
  items: [
125
125
  ...data.items,
126
126
  ...action.items
@@ -130,16 +130,16 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
130
130
  abortController: null,
131
131
  cursor: action.cursor
132
132
  };
133
- case "error":
133
+ case 'error':
134
134
  if (action.abortController !== data.abortController) return data;
135
135
  return {
136
136
  ...data,
137
- state: "error",
137
+ state: 'error',
138
138
  error: action.error
139
139
  };
140
- case "loading":
141
- case "sorting":
142
- case "filtering":
140
+ case 'loading':
141
+ case 'sorting':
142
+ case 'filtering':
143
143
  // We're already loading more, and another load was triggered at the same time.
144
144
  // We need to abort the previous load more and start a new one.
145
145
  data.abortController.abort();
@@ -149,16 +149,16 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
149
149
  filterText: (_action_filterText3 = action.filterText) !== null && _action_filterText3 !== void 0 ? _action_filterText3 : data.filterText,
150
150
  state: action.type,
151
151
  // Reset items to an empty list if loading, but not when sorting.
152
- items: action.type === "loading" ? [] : data.items,
152
+ items: action.type === 'loading' ? [] : data.items,
153
153
  abortController: action.abortController
154
154
  };
155
- case "loadingMore":
155
+ case 'loadingMore':
156
156
  // If already loading more and another loading more is triggered, abort the new load more since
157
157
  // it is a duplicate request since the cursor hasn't been updated.
158
158
  // Do not overwrite the data.abortController
159
159
  action.abortController.abort();
160
160
  return data;
161
- case "update":
161
+ case 'update':
162
162
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
163
163
  // Update data but don't abort previous load.
164
164
  return {
@@ -173,12 +173,12 @@ function $1cb48366e5c5533f$var$reducer(data, action) {
173
173
  }
174
174
  }
175
175
  function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
176
- const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = "" } = options;
176
+ const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = '' } = options;
177
177
  let [data, dispatch] = (0, $9f61J$react.useReducer)($1cb48366e5c5533f$var$reducer, {
178
- state: "idle",
178
+ state: 'idle',
179
179
  error: null,
180
180
  items: [],
181
- selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys),
181
+ selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),
182
182
  sortDescriptor: initialSortDescriptor,
183
183
  filterText: initialFilterText
184
184
  });
@@ -197,25 +197,25 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
197
197
  selectedKeys: data.selectedKeys,
198
198
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
199
199
  signal: abortController.signal,
200
- cursor: action.type === "loadingMore" ? data.cursor : null,
200
+ cursor: action.type === 'loadingMore' ? data.cursor : null,
201
201
  filterText: previousFilterText
202
202
  });
203
203
  var _response_filterText;
204
204
  let filterText = (_response_filterText = response.filterText) !== null && _response_filterText !== void 0 ? _response_filterText : previousFilterText;
205
205
  dispatch({
206
- type: "success",
206
+ type: 'success',
207
207
  ...response,
208
208
  abortController: abortController
209
209
  });
210
210
  // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText
211
211
  // Only do this if not aborted (e.g. user triggers another filter action before load completes)
212
212
  if (filterText && filterText !== previousFilterText && !abortController.signal.aborted) dispatchFetch({
213
- type: "filtering",
213
+ type: 'filtering',
214
214
  filterText: filterText
215
215
  }, load);
216
216
  } catch (e) {
217
217
  dispatch({
218
- type: "error",
218
+ type: 'error',
219
219
  error: e,
220
220
  abortController: abortController
221
221
  });
@@ -225,7 +225,7 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
225
225
  (0, $9f61J$react.useEffect)(()=>{
226
226
  if (!didDispatchInitialFetch.current) {
227
227
  dispatchFetch({
228
- type: "loading"
228
+ type: 'loading'
229
229
  }, load);
230
230
  didDispatchInitialFetch.current = true;
231
231
  }
@@ -235,7 +235,7 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
235
235
  items: data.items,
236
236
  selectedKeys: data.selectedKeys,
237
237
  sortDescriptor: data.sortDescriptor,
238
- isLoading: data.state === "loading" || data.state === "loadingMore" || data.state === "sorting" || data.state === "filtering",
238
+ isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',
239
239
  loadingState: data.state,
240
240
  error: data.error,
241
241
  filterText: data.filterText,
@@ -244,19 +244,19 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
244
244
  },
245
245
  reload () {
246
246
  dispatchFetch({
247
- type: "loading"
247
+ type: 'loading'
248
248
  }, load);
249
249
  },
250
250
  loadMore () {
251
251
  // Ignore if already loading more or if performing server side filtering.
252
- if (data.state === "loadingMore" || data.state === "filtering" || data.cursor == null) return;
252
+ if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) return;
253
253
  dispatchFetch({
254
- type: "loadingMore"
254
+ type: 'loadingMore'
255
255
  }, load);
256
256
  },
257
257
  sort (sortDescriptor) {
258
258
  dispatchFetch({
259
- type: "sorting",
259
+ type: 'sorting',
260
260
  sortDescriptor: sortDescriptor
261
261
  }, sort || load);
262
262
  },
@@ -266,13 +266,13 @@ function $1cb48366e5c5533f$export$bc3384a35de93d66(options) {
266
266
  cursor: data.cursor
267
267
  }, (fn)=>{
268
268
  dispatch({
269
- type: "update",
269
+ type: 'update',
270
270
  updater: fn
271
271
  });
272
272
  }),
273
273
  setFilterText (filterText) {
274
274
  dispatchFetch({
275
- type: "filtering",
275
+ type: 'filtering',
276
276
  filterText: filterText
277
277
  }, load);
278
278
  }
@@ -16,39 +16,39 @@ import {useReducer as $fh1mr$useReducer, useRef as $fh1mr$useRef, useEffect as $
16
16
  function $f86e6c1ec7da6ebb$var$reducer(data, action) {
17
17
  let selectedKeys;
18
18
  switch(data.state){
19
- case "idle":
20
- case "error":
19
+ case 'idle':
20
+ case 'error':
21
21
  switch(action.type){
22
- case "loading":
23
- case "loadingMore":
24
- case "sorting":
25
- case "filtering":
22
+ case 'loading':
23
+ case 'loadingMore':
24
+ case 'sorting':
25
+ case 'filtering':
26
26
  var _action_filterText, _action_sortDescriptor;
27
27
  return {
28
28
  ...data,
29
29
  filterText: (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText,
30
30
  state: action.type,
31
31
  // Reset items to an empty list if loading, but not when sorting.
32
- items: action.type === "loading" ? [] : data.items,
32
+ items: action.type === 'loading' ? [] : data.items,
33
33
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
34
34
  abortController: action.abortController
35
35
  };
36
- case "update":
36
+ case 'update':
37
37
  return {
38
38
  ...data,
39
39
  ...action.updater(data)
40
40
  };
41
- case "success":
42
- case "error":
41
+ case 'success':
42
+ case 'error':
43
43
  return data;
44
44
  default:
45
45
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
46
46
  }
47
- case "loading":
48
- case "sorting":
49
- case "filtering":
47
+ case 'loading':
48
+ case 'sorting':
49
+ case 'filtering':
50
50
  switch(action.type){
51
- case "success":
51
+ case 'success':
52
52
  // Ignore if there is a newer abortcontroller in state.
53
53
  // This means that multiple requests were going at once.
54
54
  // We want to take only the latest result.
@@ -59,27 +59,27 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
59
59
  return {
60
60
  ...data,
61
61
  filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
62
- state: "idle",
62
+ state: 'idle',
63
63
  items: [
64
64
  ...action.items
65
65
  ],
66
- selectedKeys: selectedKeys === "all" ? "all" : new Set(selectedKeys),
66
+ selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),
67
67
  sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
68
68
  abortController: null,
69
69
  cursor: action.cursor
70
70
  };
71
- case "error":
71
+ case 'error':
72
72
  if (action.abortController !== data.abortController) return data;
73
73
  return {
74
74
  ...data,
75
- state: "error",
75
+ state: 'error',
76
76
  error: action.error,
77
77
  abortController: null
78
78
  };
79
- case "loading":
80
- case "loadingMore":
81
- case "sorting":
82
- case "filtering":
79
+ case 'loading':
80
+ case 'loadingMore':
81
+ case 'sorting':
82
+ case 'filtering':
83
83
  // We're already loading, and another load was triggered at the same time.
84
84
  // We need to abort the previous load and start a new one.
85
85
  data.abortController.abort();
@@ -89,10 +89,10 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
89
89
  filterText: (_action_filterText2 = action.filterText) !== null && _action_filterText2 !== void 0 ? _action_filterText2 : data.filterText,
90
90
  state: action.type,
91
91
  // Reset items to an empty list if loading, but not when sorting.
92
- items: action.type === "loading" ? [] : data.items,
92
+ items: action.type === 'loading' ? [] : data.items,
93
93
  abortController: action.abortController
94
94
  };
95
- case "update":
95
+ case 'update':
96
96
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
97
97
  // Update data but don't abort previous load.
98
98
  return {
@@ -102,11 +102,11 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
102
102
  default:
103
103
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
104
104
  }
105
- case "loadingMore":
105
+ case 'loadingMore':
106
106
  switch(action.type){
107
- case "success":
107
+ case 'success':
108
108
  var _action_selectedKeys1;
109
- selectedKeys = data.selectedKeys === "all" || action.selectedKeys === "all" ? "all" : new Set([
109
+ selectedKeys = data.selectedKeys === 'all' || action.selectedKeys === 'all' ? 'all' : new Set([
110
110
  ...data.selectedKeys,
111
111
  ...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
112
112
  ]);
@@ -114,7 +114,7 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
114
114
  // Append the new items
115
115
  return {
116
116
  ...data,
117
- state: "idle",
117
+ state: 'idle',
118
118
  items: [
119
119
  ...data.items,
120
120
  ...action.items
@@ -124,16 +124,16 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
124
124
  abortController: null,
125
125
  cursor: action.cursor
126
126
  };
127
- case "error":
127
+ case 'error':
128
128
  if (action.abortController !== data.abortController) return data;
129
129
  return {
130
130
  ...data,
131
- state: "error",
131
+ state: 'error',
132
132
  error: action.error
133
133
  };
134
- case "loading":
135
- case "sorting":
136
- case "filtering":
134
+ case 'loading':
135
+ case 'sorting':
136
+ case 'filtering':
137
137
  // We're already loading more, and another load was triggered at the same time.
138
138
  // We need to abort the previous load more and start a new one.
139
139
  data.abortController.abort();
@@ -143,16 +143,16 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
143
143
  filterText: (_action_filterText3 = action.filterText) !== null && _action_filterText3 !== void 0 ? _action_filterText3 : data.filterText,
144
144
  state: action.type,
145
145
  // Reset items to an empty list if loading, but not when sorting.
146
- items: action.type === "loading" ? [] : data.items,
146
+ items: action.type === 'loading' ? [] : data.items,
147
147
  abortController: action.abortController
148
148
  };
149
- case "loadingMore":
149
+ case 'loadingMore':
150
150
  // If already loading more and another loading more is triggered, abort the new load more since
151
151
  // it is a duplicate request since the cursor hasn't been updated.
152
152
  // Do not overwrite the data.abortController
153
153
  action.abortController.abort();
154
154
  return data;
155
- case "update":
155
+ case 'update':
156
156
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
157
157
  // Update data but don't abort previous load.
158
158
  return {
@@ -167,12 +167,12 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
167
167
  }
168
168
  }
169
169
  function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
170
- const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = "" } = options;
170
+ const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = '' } = options;
171
171
  let [data, dispatch] = (0, $fh1mr$useReducer)($f86e6c1ec7da6ebb$var$reducer, {
172
- state: "idle",
172
+ state: 'idle',
173
173
  error: null,
174
174
  items: [],
175
- selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys),
175
+ selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),
176
176
  sortDescriptor: initialSortDescriptor,
177
177
  filterText: initialFilterText
178
178
  });
@@ -191,25 +191,25 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
191
191
  selectedKeys: data.selectedKeys,
192
192
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
193
193
  signal: abortController.signal,
194
- cursor: action.type === "loadingMore" ? data.cursor : null,
194
+ cursor: action.type === 'loadingMore' ? data.cursor : null,
195
195
  filterText: previousFilterText
196
196
  });
197
197
  var _response_filterText;
198
198
  let filterText = (_response_filterText = response.filterText) !== null && _response_filterText !== void 0 ? _response_filterText : previousFilterText;
199
199
  dispatch({
200
- type: "success",
200
+ type: 'success',
201
201
  ...response,
202
202
  abortController: abortController
203
203
  });
204
204
  // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText
205
205
  // Only do this if not aborted (e.g. user triggers another filter action before load completes)
206
206
  if (filterText && filterText !== previousFilterText && !abortController.signal.aborted) dispatchFetch({
207
- type: "filtering",
207
+ type: 'filtering',
208
208
  filterText: filterText
209
209
  }, load);
210
210
  } catch (e) {
211
211
  dispatch({
212
- type: "error",
212
+ type: 'error',
213
213
  error: e,
214
214
  abortController: abortController
215
215
  });
@@ -219,7 +219,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
219
219
  (0, $fh1mr$useEffect)(()=>{
220
220
  if (!didDispatchInitialFetch.current) {
221
221
  dispatchFetch({
222
- type: "loading"
222
+ type: 'loading'
223
223
  }, load);
224
224
  didDispatchInitialFetch.current = true;
225
225
  }
@@ -229,7 +229,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
229
229
  items: data.items,
230
230
  selectedKeys: data.selectedKeys,
231
231
  sortDescriptor: data.sortDescriptor,
232
- isLoading: data.state === "loading" || data.state === "loadingMore" || data.state === "sorting" || data.state === "filtering",
232
+ isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',
233
233
  loadingState: data.state,
234
234
  error: data.error,
235
235
  filterText: data.filterText,
@@ -238,19 +238,19 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
238
238
  },
239
239
  reload () {
240
240
  dispatchFetch({
241
- type: "loading"
241
+ type: 'loading'
242
242
  }, load);
243
243
  },
244
244
  loadMore () {
245
245
  // Ignore if already loading more or if performing server side filtering.
246
- if (data.state === "loadingMore" || data.state === "filtering" || data.cursor == null) return;
246
+ if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) return;
247
247
  dispatchFetch({
248
- type: "loadingMore"
248
+ type: 'loadingMore'
249
249
  }, load);
250
250
  },
251
251
  sort (sortDescriptor) {
252
252
  dispatchFetch({
253
- type: "sorting",
253
+ type: 'sorting',
254
254
  sortDescriptor: sortDescriptor
255
255
  }, sort || load);
256
256
  },
@@ -260,13 +260,13 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
260
260
  cursor: data.cursor
261
261
  }, (fn)=>{
262
262
  dispatch({
263
- type: "update",
263
+ type: 'update',
264
264
  updater: fn
265
265
  });
266
266
  }),
267
267
  setFilterText (filterText) {
268
268
  dispatchFetch({
269
- type: "filtering",
269
+ type: 'filtering',
270
270
  filterText: filterText
271
271
  }, load);
272
272
  }
@@ -16,39 +16,39 @@ import {useReducer as $fh1mr$useReducer, useRef as $fh1mr$useRef, useEffect as $
16
16
  function $f86e6c1ec7da6ebb$var$reducer(data, action) {
17
17
  let selectedKeys;
18
18
  switch(data.state){
19
- case "idle":
20
- case "error":
19
+ case 'idle':
20
+ case 'error':
21
21
  switch(action.type){
22
- case "loading":
23
- case "loadingMore":
24
- case "sorting":
25
- case "filtering":
22
+ case 'loading':
23
+ case 'loadingMore':
24
+ case 'sorting':
25
+ case 'filtering':
26
26
  var _action_filterText, _action_sortDescriptor;
27
27
  return {
28
28
  ...data,
29
29
  filterText: (_action_filterText = action.filterText) !== null && _action_filterText !== void 0 ? _action_filterText : data.filterText,
30
30
  state: action.type,
31
31
  // Reset items to an empty list if loading, but not when sorting.
32
- items: action.type === "loading" ? [] : data.items,
32
+ items: action.type === 'loading' ? [] : data.items,
33
33
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
34
34
  abortController: action.abortController
35
35
  };
36
- case "update":
36
+ case 'update':
37
37
  return {
38
38
  ...data,
39
39
  ...action.updater(data)
40
40
  };
41
- case "success":
42
- case "error":
41
+ case 'success':
42
+ case 'error':
43
43
  return data;
44
44
  default:
45
45
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
46
46
  }
47
- case "loading":
48
- case "sorting":
49
- case "filtering":
47
+ case 'loading':
48
+ case 'sorting':
49
+ case 'filtering':
50
50
  switch(action.type){
51
- case "success":
51
+ case 'success':
52
52
  // Ignore if there is a newer abortcontroller in state.
53
53
  // This means that multiple requests were going at once.
54
54
  // We want to take only the latest result.
@@ -59,27 +59,27 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
59
59
  return {
60
60
  ...data,
61
61
  filterText: (_action_filterText1 = action.filterText) !== null && _action_filterText1 !== void 0 ? _action_filterText1 : data.filterText,
62
- state: "idle",
62
+ state: 'idle',
63
63
  items: [
64
64
  ...action.items
65
65
  ],
66
- selectedKeys: selectedKeys === "all" ? "all" : new Set(selectedKeys),
66
+ selectedKeys: selectedKeys === 'all' ? 'all' : new Set(selectedKeys),
67
67
  sortDescriptor: (_action_sortDescriptor1 = action.sortDescriptor) !== null && _action_sortDescriptor1 !== void 0 ? _action_sortDescriptor1 : data.sortDescriptor,
68
68
  abortController: null,
69
69
  cursor: action.cursor
70
70
  };
71
- case "error":
71
+ case 'error':
72
72
  if (action.abortController !== data.abortController) return data;
73
73
  return {
74
74
  ...data,
75
- state: "error",
75
+ state: 'error',
76
76
  error: action.error,
77
77
  abortController: null
78
78
  };
79
- case "loading":
80
- case "loadingMore":
81
- case "sorting":
82
- case "filtering":
79
+ case 'loading':
80
+ case 'loadingMore':
81
+ case 'sorting':
82
+ case 'filtering':
83
83
  // We're already loading, and another load was triggered at the same time.
84
84
  // We need to abort the previous load and start a new one.
85
85
  data.abortController.abort();
@@ -89,10 +89,10 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
89
89
  filterText: (_action_filterText2 = action.filterText) !== null && _action_filterText2 !== void 0 ? _action_filterText2 : data.filterText,
90
90
  state: action.type,
91
91
  // Reset items to an empty list if loading, but not when sorting.
92
- items: action.type === "loading" ? [] : data.items,
92
+ items: action.type === 'loading' ? [] : data.items,
93
93
  abortController: action.abortController
94
94
  };
95
- case "update":
95
+ case 'update':
96
96
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
97
97
  // Update data but don't abort previous load.
98
98
  return {
@@ -102,11 +102,11 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
102
102
  default:
103
103
  throw new Error(`Invalid action "${action.type}" in state "${data.state}"`);
104
104
  }
105
- case "loadingMore":
105
+ case 'loadingMore':
106
106
  switch(action.type){
107
- case "success":
107
+ case 'success':
108
108
  var _action_selectedKeys1;
109
- selectedKeys = data.selectedKeys === "all" || action.selectedKeys === "all" ? "all" : new Set([
109
+ selectedKeys = data.selectedKeys === 'all' || action.selectedKeys === 'all' ? 'all' : new Set([
110
110
  ...data.selectedKeys,
111
111
  ...(_action_selectedKeys1 = action.selectedKeys) !== null && _action_selectedKeys1 !== void 0 ? _action_selectedKeys1 : []
112
112
  ]);
@@ -114,7 +114,7 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
114
114
  // Append the new items
115
115
  return {
116
116
  ...data,
117
- state: "idle",
117
+ state: 'idle',
118
118
  items: [
119
119
  ...data.items,
120
120
  ...action.items
@@ -124,16 +124,16 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
124
124
  abortController: null,
125
125
  cursor: action.cursor
126
126
  };
127
- case "error":
127
+ case 'error':
128
128
  if (action.abortController !== data.abortController) return data;
129
129
  return {
130
130
  ...data,
131
- state: "error",
131
+ state: 'error',
132
132
  error: action.error
133
133
  };
134
- case "loading":
135
- case "sorting":
136
- case "filtering":
134
+ case 'loading':
135
+ case 'sorting':
136
+ case 'filtering':
137
137
  // We're already loading more, and another load was triggered at the same time.
138
138
  // We need to abort the previous load more and start a new one.
139
139
  data.abortController.abort();
@@ -143,16 +143,16 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
143
143
  filterText: (_action_filterText3 = action.filterText) !== null && _action_filterText3 !== void 0 ? _action_filterText3 : data.filterText,
144
144
  state: action.type,
145
145
  // Reset items to an empty list if loading, but not when sorting.
146
- items: action.type === "loading" ? [] : data.items,
146
+ items: action.type === 'loading' ? [] : data.items,
147
147
  abortController: action.abortController
148
148
  };
149
- case "loadingMore":
149
+ case 'loadingMore':
150
150
  // If already loading more and another loading more is triggered, abort the new load more since
151
151
  // it is a duplicate request since the cursor hasn't been updated.
152
152
  // Do not overwrite the data.abortController
153
153
  action.abortController.abort();
154
154
  return data;
155
- case "update":
155
+ case 'update':
156
156
  // We're already loading, and an update happened at the same time (e.g. selectedKey changed).
157
157
  // Update data but don't abort previous load.
158
158
  return {
@@ -167,12 +167,12 @@ function $f86e6c1ec7da6ebb$var$reducer(data, action) {
167
167
  }
168
168
  }
169
169
  function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
170
- const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = "" } = options;
170
+ const { load: load, sort: sort, initialSelectedKeys: initialSelectedKeys, initialSortDescriptor: initialSortDescriptor, getKey: getKey = (item)=>item.id || item.key, initialFilterText: initialFilterText = '' } = options;
171
171
  let [data, dispatch] = (0, $fh1mr$useReducer)($f86e6c1ec7da6ebb$var$reducer, {
172
- state: "idle",
172
+ state: 'idle',
173
173
  error: null,
174
174
  items: [],
175
- selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys),
175
+ selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys),
176
176
  sortDescriptor: initialSortDescriptor,
177
177
  filterText: initialFilterText
178
178
  });
@@ -191,25 +191,25 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
191
191
  selectedKeys: data.selectedKeys,
192
192
  sortDescriptor: (_action_sortDescriptor = action.sortDescriptor) !== null && _action_sortDescriptor !== void 0 ? _action_sortDescriptor : data.sortDescriptor,
193
193
  signal: abortController.signal,
194
- cursor: action.type === "loadingMore" ? data.cursor : null,
194
+ cursor: action.type === 'loadingMore' ? data.cursor : null,
195
195
  filterText: previousFilterText
196
196
  });
197
197
  var _response_filterText;
198
198
  let filterText = (_response_filterText = response.filterText) !== null && _response_filterText !== void 0 ? _response_filterText : previousFilterText;
199
199
  dispatch({
200
- type: "success",
200
+ type: 'success',
201
201
  ...response,
202
202
  abortController: abortController
203
203
  });
204
204
  // Fetch a new filtered list if filterText is updated via `load` response func rather than list.setFilterText
205
205
  // Only do this if not aborted (e.g. user triggers another filter action before load completes)
206
206
  if (filterText && filterText !== previousFilterText && !abortController.signal.aborted) dispatchFetch({
207
- type: "filtering",
207
+ type: 'filtering',
208
208
  filterText: filterText
209
209
  }, load);
210
210
  } catch (e) {
211
211
  dispatch({
212
- type: "error",
212
+ type: 'error',
213
213
  error: e,
214
214
  abortController: abortController
215
215
  });
@@ -219,7 +219,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
219
219
  (0, $fh1mr$useEffect)(()=>{
220
220
  if (!didDispatchInitialFetch.current) {
221
221
  dispatchFetch({
222
- type: "loading"
222
+ type: 'loading'
223
223
  }, load);
224
224
  didDispatchInitialFetch.current = true;
225
225
  }
@@ -229,7 +229,7 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
229
229
  items: data.items,
230
230
  selectedKeys: data.selectedKeys,
231
231
  sortDescriptor: data.sortDescriptor,
232
- isLoading: data.state === "loading" || data.state === "loadingMore" || data.state === "sorting" || data.state === "filtering",
232
+ isLoading: data.state === 'loading' || data.state === 'loadingMore' || data.state === 'sorting' || data.state === 'filtering',
233
233
  loadingState: data.state,
234
234
  error: data.error,
235
235
  filterText: data.filterText,
@@ -238,19 +238,19 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
238
238
  },
239
239
  reload () {
240
240
  dispatchFetch({
241
- type: "loading"
241
+ type: 'loading'
242
242
  }, load);
243
243
  },
244
244
  loadMore () {
245
245
  // Ignore if already loading more or if performing server side filtering.
246
- if (data.state === "loadingMore" || data.state === "filtering" || data.cursor == null) return;
246
+ if (data.state === 'loadingMore' || data.state === 'filtering' || data.cursor == null) return;
247
247
  dispatchFetch({
248
- type: "loadingMore"
248
+ type: 'loadingMore'
249
249
  }, load);
250
250
  },
251
251
  sort (sortDescriptor) {
252
252
  dispatchFetch({
253
- type: "sorting",
253
+ type: 'sorting',
254
254
  sortDescriptor: sortDescriptor
255
255
  }, sort || load);
256
256
  },
@@ -260,13 +260,13 @@ function $f86e6c1ec7da6ebb$export$bc3384a35de93d66(options) {
260
260
  cursor: data.cursor
261
261
  }, (fn)=>{
262
262
  dispatch({
263
- type: "update",
263
+ type: 'update',
264
264
  updater: fn
265
265
  });
266
266
  }),
267
267
  setFilterText (filterText) {
268
268
  dispatchFetch({
269
- type: "filtering",
269
+ type: 'filtering',
270
270
  filterText: filterText
271
271
  }, load);
272
272
  }
@@ -19,11 +19,11 @@ $parcel$export(module.exports, "createListActions", () => $fbc1d750f520c94e$expo
19
19
  * governing permissions and limitations under the License.
20
20
  */
21
21
  function $fbc1d750f520c94e$export$762f73dccccd255d(options) {
22
- let { initialItems: initialItems = [], initialSelectedKeys: initialSelectedKeys, getKey: getKey = (item)=>item.id || item.key, filter: filter, initialFilterText: initialFilterText = "" } = options;
22
+ let { initialItems: initialItems = [], initialSelectedKeys: initialSelectedKeys, getKey: getKey = (item)=>item.id || item.key, filter: filter, initialFilterText: initialFilterText = '' } = options;
23
23
  // Store both items and filteredItems in state so we can go back to the unfiltered list
24
24
  let [state, setState] = (0, $1nAKR$react.useState)({
25
25
  items: initialItems,
26
- selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []),
26
+ selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),
27
27
  filterText: initialFilterText
28
28
  });
29
29
  let filteredItems = (0, $1nAKR$react.useMemo)(()=>filter ? state.items.filter((item)=>filter(item, state.filterText)) : state.items, [
@@ -90,8 +90,8 @@ function $fbc1d750f520c94e$export$79c0c687a5963b0a(opts, dispatch) {
90
90
  dispatch((state)=>{
91
91
  let keySet = new Set(keys);
92
92
  let items = state.items.filter((item)=>!keySet.has(getKey(item)));
93
- let selection = "all";
94
- if (state.selectedKeys !== "all") {
93
+ let selection = 'all';
94
+ if (state.selectedKeys !== 'all') {
95
95
  selection = new Set(state.selectedKeys);
96
96
  for (let key of keys)selection.delete(key);
97
97
  }
@@ -105,7 +105,7 @@ function $fbc1d750f520c94e$export$79c0c687a5963b0a(opts, dispatch) {
105
105
  },
106
106
  removeSelectedItems () {
107
107
  dispatch((state)=>{
108
- if (state.selectedKeys === "all") return {
108
+ if (state.selectedKeys === 'all') return {
109
109
  ...state,
110
110
  items: [],
111
111
  selectedKeys: new Set()
@@ -12,11 +12,11 @@ import {useState as $bc4N1$useState, useMemo as $bc4N1$useMemo} from "react";
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
  function $0d86e9c8f07f9a7b$export$762f73dccccd255d(options) {
15
- let { initialItems: initialItems = [], initialSelectedKeys: initialSelectedKeys, getKey: getKey = (item)=>item.id || item.key, filter: filter, initialFilterText: initialFilterText = "" } = options;
15
+ let { initialItems: initialItems = [], initialSelectedKeys: initialSelectedKeys, getKey: getKey = (item)=>item.id || item.key, filter: filter, initialFilterText: initialFilterText = '' } = options;
16
16
  // Store both items and filteredItems in state so we can go back to the unfiltered list
17
17
  let [state, setState] = (0, $bc4N1$useState)({
18
18
  items: initialItems,
19
- selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []),
19
+ selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),
20
20
  filterText: initialFilterText
21
21
  });
22
22
  let filteredItems = (0, $bc4N1$useMemo)(()=>filter ? state.items.filter((item)=>filter(item, state.filterText)) : state.items, [
@@ -83,8 +83,8 @@ function $0d86e9c8f07f9a7b$export$79c0c687a5963b0a(opts, dispatch) {
83
83
  dispatch((state)=>{
84
84
  let keySet = new Set(keys);
85
85
  let items = state.items.filter((item)=>!keySet.has(getKey(item)));
86
- let selection = "all";
87
- if (state.selectedKeys !== "all") {
86
+ let selection = 'all';
87
+ if (state.selectedKeys !== 'all') {
88
88
  selection = new Set(state.selectedKeys);
89
89
  for (let key of keys)selection.delete(key);
90
90
  }
@@ -98,7 +98,7 @@ function $0d86e9c8f07f9a7b$export$79c0c687a5963b0a(opts, dispatch) {
98
98
  },
99
99
  removeSelectedItems () {
100
100
  dispatch((state)=>{
101
- if (state.selectedKeys === "all") return {
101
+ if (state.selectedKeys === 'all') return {
102
102
  ...state,
103
103
  items: [],
104
104
  selectedKeys: new Set()
@@ -12,11 +12,11 @@ import {useState as $bc4N1$useState, useMemo as $bc4N1$useMemo} from "react";
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
  function $0d86e9c8f07f9a7b$export$762f73dccccd255d(options) {
15
- let { initialItems: initialItems = [], initialSelectedKeys: initialSelectedKeys, getKey: getKey = (item)=>item.id || item.key, filter: filter, initialFilterText: initialFilterText = "" } = options;
15
+ let { initialItems: initialItems = [], initialSelectedKeys: initialSelectedKeys, getKey: getKey = (item)=>item.id || item.key, filter: filter, initialFilterText: initialFilterText = '' } = options;
16
16
  // Store both items and filteredItems in state so we can go back to the unfiltered list
17
17
  let [state, setState] = (0, $bc4N1$useState)({
18
18
  items: initialItems,
19
- selectedKeys: initialSelectedKeys === "all" ? "all" : new Set(initialSelectedKeys || []),
19
+ selectedKeys: initialSelectedKeys === 'all' ? 'all' : new Set(initialSelectedKeys || []),
20
20
  filterText: initialFilterText
21
21
  });
22
22
  let filteredItems = (0, $bc4N1$useMemo)(()=>filter ? state.items.filter((item)=>filter(item, state.filterText)) : state.items, [
@@ -83,8 +83,8 @@ function $0d86e9c8f07f9a7b$export$79c0c687a5963b0a(opts, dispatch) {
83
83
  dispatch((state)=>{
84
84
  let keySet = new Set(keys);
85
85
  let items = state.items.filter((item)=>!keySet.has(getKey(item)));
86
- let selection = "all";
87
- if (state.selectedKeys !== "all") {
86
+ let selection = 'all';
87
+ if (state.selectedKeys !== 'all') {
88
88
  selection = new Set(state.selectedKeys);
89
89
  for (let key of keys)selection.delete(key);
90
90
  }
@@ -98,7 +98,7 @@ function $0d86e9c8f07f9a7b$export$79c0c687a5963b0a(opts, dispatch) {
98
98
  },
99
99
  removeSelectedItems () {
100
100
  dispatch((state)=>{
101
- if (state.selectedKeys === "all") return {
101
+ if (state.selectedKeys === 'all') return {
102
102
  ...state,
103
103
  items: [],
104
104
  selectedKeys: new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/data",
3
- "version": "3.11.4-nightly.4624+d80999e89",
3
+ "version": "3.11.4",
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.2912+d80999e89",
25
+ "@react-types/shared": "^3.23.1",
26
26
  "@swc/helpers": "^0.5.0"
27
27
  },
28
28
  "peerDependencies": {
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "d80999e897b4d4db9fcfb4e9b8fcdc9fdd700882"
34
+ "gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
35
35
  }