@synerise/ds-item-picker 1.3.2 → 1.4.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@1.3.2...@synerise/ds-item-picker@1.4.0) (2025-05-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **item-picker:** add abortController ([85a6b52](https://github.com/Synerise/synerise-design/commit/85a6b522841e6377d57d4fc93b9fc309030f72cc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.3.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@1.3.1...@synerise/ds-item-picker@1.3.2) (2025-05-26)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -48,6 +48,7 @@ export var useItemsInSections = function useItemsInSections(_ref) {
|
|
|
48
48
|
var loadedPage = useRef(FIRST_PAGE);
|
|
49
49
|
var metaRef = useRef({});
|
|
50
50
|
var sectionTotals = useRef({});
|
|
51
|
+
var abortControllerRef = useRef();
|
|
51
52
|
var isFixedItemsList = isItems(items) || isItemsConfig(items);
|
|
52
53
|
var _useState3 = useState(),
|
|
53
54
|
contentHeight = _useState3[0],
|
|
@@ -215,11 +216,12 @@ export var useItemsInSections = function useItemsInSections(_ref) {
|
|
|
215
216
|
return !!(selectedItem && getItemKey(item) === getItemKey(selectedItem));
|
|
216
217
|
}, [getItemKey, selectedItem]);
|
|
217
218
|
var loadItems = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
219
|
+
var _abortControllerRef$c;
|
|
218
220
|
var sectionId, _yield$items$loadItem, _fetchedItems, meta, fetchedItems, requests, results;
|
|
219
221
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
220
222
|
while (1) switch (_context.prev = _context.next) {
|
|
221
223
|
case 0:
|
|
222
|
-
if (!(isFixedItemsList || listActions
|
|
224
|
+
if (!(isFixedItemsList || listActions)) {
|
|
223
225
|
_context.next = 2;
|
|
224
226
|
break;
|
|
225
227
|
}
|
|
@@ -227,21 +229,25 @@ export var useItemsInSections = function useItemsInSections(_ref) {
|
|
|
227
229
|
case 2:
|
|
228
230
|
setIsLoading(true);
|
|
229
231
|
setIsLoadingError(false);
|
|
232
|
+
// eslint-disable-next-line no-unused-expressions
|
|
233
|
+
(_abortControllerRef$c = abortControllerRef.current) == null || _abortControllerRef$c.abort();
|
|
234
|
+
abortControllerRef.current = new AbortController();
|
|
230
235
|
if (!(listRenderingMode === RENDER_MODES.LIST_ITEMS)) {
|
|
231
|
-
_context.next =
|
|
236
|
+
_context.next = 27;
|
|
232
237
|
break;
|
|
233
238
|
}
|
|
234
239
|
sectionId = (currentSection == null ? void 0 : currentSection.id) || 'DEFAULT';
|
|
235
|
-
_context.prev =
|
|
236
|
-
_context.next =
|
|
240
|
+
_context.prev = 8;
|
|
241
|
+
_context.next = 11;
|
|
237
242
|
return items.loadItems({
|
|
238
243
|
page: FIRST_PAGE,
|
|
239
244
|
searchQuery: searchQuery,
|
|
240
245
|
sectionId: sectionId,
|
|
241
246
|
limit: items.limitPerPage || ITEMS_PER_PAGE,
|
|
242
|
-
meta: undefined
|
|
247
|
+
meta: undefined,
|
|
248
|
+
abortController: abortControllerRef.current
|
|
243
249
|
});
|
|
244
|
-
case
|
|
250
|
+
case 11:
|
|
245
251
|
_yield$items$loadItem = _context.sent;
|
|
246
252
|
_fetchedItems = _yield$items$loadItem.items;
|
|
247
253
|
meta = _yield$items$loadItem.meta;
|
|
@@ -250,17 +256,17 @@ export var useItemsInSections = function useItemsInSections(_ref) {
|
|
|
250
256
|
metaRef.current[sectionId] = meta;
|
|
251
257
|
setIsInitialDataLoaded(true);
|
|
252
258
|
setCurrentItems(_fetchedItems);
|
|
253
|
-
_context.next =
|
|
259
|
+
_context.next = 26;
|
|
254
260
|
break;
|
|
255
|
-
case
|
|
256
|
-
_context.prev =
|
|
257
|
-
_context.t0 = _context["catch"](
|
|
261
|
+
case 21:
|
|
262
|
+
_context.prev = 21;
|
|
263
|
+
_context.t0 = _context["catch"](8);
|
|
258
264
|
setIsLoading(false);
|
|
259
265
|
setIsInitialDataLoaded(true);
|
|
260
266
|
setIsLoadingError(true);
|
|
261
|
-
case
|
|
267
|
+
case 26:
|
|
262
268
|
return _context.abrupt("return");
|
|
263
|
-
case
|
|
269
|
+
case 27:
|
|
264
270
|
fetchedItems = [];
|
|
265
271
|
requests = listRenderingMode === RENDER_MODES.LIST_FOLDERS_IN_SECTIONS ? [Promise.resolve()] : currentFolders == null ? void 0 : currentFolders.map(function (folder) {
|
|
266
272
|
return items.loadItems({
|
|
@@ -268,7 +274,8 @@ export var useItemsInSections = function useItemsInSections(_ref) {
|
|
|
268
274
|
searchQuery: searchQuery,
|
|
269
275
|
limit: (items.limitPerSection || ITEMS_PER_SECTION) + 1,
|
|
270
276
|
sectionId: folder.id,
|
|
271
|
-
meta: undefined
|
|
277
|
+
meta: undefined,
|
|
278
|
+
abortController: abortControllerRef.current
|
|
272
279
|
}).then(function (_ref3) {
|
|
273
280
|
var sectionItems = _ref3.items,
|
|
274
281
|
total = _ref3.total,
|
|
@@ -278,47 +285,47 @@ export var useItemsInSections = function useItemsInSections(_ref) {
|
|
|
278
285
|
fetchedItems = [].concat(fetchedItems, sectionItems);
|
|
279
286
|
});
|
|
280
287
|
});
|
|
281
|
-
_context.prev =
|
|
288
|
+
_context.prev = 29;
|
|
282
289
|
if (!requests) {
|
|
283
|
-
_context.next =
|
|
290
|
+
_context.next = 36;
|
|
284
291
|
break;
|
|
285
292
|
}
|
|
286
|
-
_context.next =
|
|
293
|
+
_context.next = 33;
|
|
287
294
|
return Promise.allSettled(requests);
|
|
288
|
-
case
|
|
295
|
+
case 33:
|
|
289
296
|
_context.t1 = _context.sent;
|
|
290
|
-
_context.next =
|
|
297
|
+
_context.next = 37;
|
|
291
298
|
break;
|
|
292
|
-
case
|
|
299
|
+
case 36:
|
|
293
300
|
_context.t1 = [];
|
|
294
|
-
case
|
|
301
|
+
case 37:
|
|
295
302
|
results = _context.t1;
|
|
296
303
|
setIsLoading(false);
|
|
297
304
|
setIsInitialDataLoaded(true);
|
|
298
305
|
if (!results.every(function (result) {
|
|
299
306
|
return result.status === 'fulfilled';
|
|
300
307
|
})) {
|
|
301
|
-
_context.next =
|
|
308
|
+
_context.next = 43;
|
|
302
309
|
break;
|
|
303
310
|
}
|
|
304
311
|
setCurrentItems(fetchedItems);
|
|
305
312
|
return _context.abrupt("return");
|
|
306
|
-
case
|
|
313
|
+
case 43:
|
|
307
314
|
setIsLoadingError(true);
|
|
308
|
-
_context.next =
|
|
315
|
+
_context.next = 51;
|
|
309
316
|
break;
|
|
310
|
-
case
|
|
311
|
-
_context.prev =
|
|
312
|
-
_context.t2 = _context["catch"](
|
|
317
|
+
case 46:
|
|
318
|
+
_context.prev = 46;
|
|
319
|
+
_context.t2 = _context["catch"](29);
|
|
313
320
|
setIsLoading(false);
|
|
314
321
|
setIsInitialDataLoaded(true);
|
|
315
322
|
setIsLoadingError(true);
|
|
316
|
-
case
|
|
323
|
+
case 51:
|
|
317
324
|
case "end":
|
|
318
325
|
return _context.stop();
|
|
319
326
|
}
|
|
320
|
-
}, _callee, null, [[
|
|
321
|
-
})), [currentSection, isFixedItemsList, currentFolders, listRenderingMode,
|
|
327
|
+
}, _callee, null, [[8, 21], [29, 46]]);
|
|
328
|
+
})), [currentSection, isFixedItemsList, currentFolders, listRenderingMode, items, listActions, searchQuery]);
|
|
322
329
|
useEffect(function () {
|
|
323
330
|
if (listActions) {
|
|
324
331
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-item-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "ItemPicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
65
65
|
"styled-components": "^5.3.3"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "2447f7472406c9f7fedc2b695539a76b9bc3d641"
|
|
68
68
|
}
|