@synerise/ds-item-picker 1.6.2 → 1.7.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.7.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@1.6.2...@synerise/ds-item-picker@1.7.0) (2025-07-04)
7
+
8
+
9
+ ### Features
10
+
11
+ * **item-picker:** add onLoadedItems prop ([4a848a9](https://github.com/Synerise/synerise-design/commit/4a848a9cd2b00e8f1f440478f321ad3c06214089))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [1.6.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@1.6.1...@synerise/ds-item-picker@1.6.2) (2025-07-01)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-item-picker
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import type { BaseItemType, BaseSectionType } from '../ItemPickerNew/ItemPickerNew.types';
3
3
  import type { ItemPickerListProps } from './ItemPickerList.types';
4
- export declare const ItemPickerList: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items, recents, sections, actions, texts, isLoading, selectedItem, scrollbarProps, searchBarProps, showItemsSectionLabel, onItemSelect, onRefresh, containerHeight, isVisible, onSectionChange, containerRef: forwardedRef, includeFooter, includeSearchBar, ...htmlAttributes }: ItemPickerListProps<ItemType, SectionType>) => React.JSX.Element;
4
+ export declare const ItemPickerList: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items, recents, sections, actions, texts, isLoading, selectedItem, scrollbarProps, searchBarProps, showItemsSectionLabel, onItemSelect, onRefresh, containerHeight, isVisible, onSectionChange, containerRef: forwardedRef, includeFooter, includeSearchBar, onLoadedData, ...htmlAttributes }: ItemPickerListProps<ItemType, SectionType>) => React.JSX.Element;
5
5
  export default ItemPickerList;
@@ -1,4 +1,4 @@
1
- var _excluded = ["items", "recents", "sections", "actions", "texts", "isLoading", "selectedItem", "scrollbarProps", "searchBarProps", "showItemsSectionLabel", "onItemSelect", "onRefresh", "containerHeight", "isVisible", "onSectionChange", "containerRef", "includeFooter", "includeSearchBar"];
1
+ var _excluded = ["items", "recents", "sections", "actions", "texts", "isLoading", "selectedItem", "scrollbarProps", "searchBarProps", "showItemsSectionLabel", "onItemSelect", "onRefresh", "containerHeight", "isVisible", "onSectionChange", "containerRef", "includeFooter", "includeSearchBar", "onLoadedData"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import { debounce } from 'lodash';
@@ -39,6 +39,7 @@ export var ItemPickerList = function ItemPickerList(_ref) {
39
39
  includeFooter = _ref$includeFooter === void 0 ? true : _ref$includeFooter,
40
40
  _ref$includeSearchBar = _ref.includeSearchBar,
41
41
  includeSearchBar = _ref$includeSearchBar === void 0 ? true : _ref$includeSearchBar,
42
+ onLoadedData = _ref.onLoadedData,
42
43
  htmlAttributes = _objectWithoutPropertiesLoose(_ref, _excluded);
43
44
  var theme = useTheme();
44
45
  var _useState = useState(''),
@@ -81,7 +82,8 @@ export var ItemPickerList = function ItemPickerList(_ref) {
81
82
  handleItemSelect: handleItemSelect,
82
83
  onSectionChange: onSectionChange,
83
84
  showItemsSectionLabel: showItemsSectionLabel,
84
- changeSearchQuery: changeSearchQuery
85
+ changeSearchQuery: changeSearchQuery,
86
+ onLoadedData: onLoadedData
85
87
  }),
86
88
  currentSection = _useItemsInSections.currentSection,
87
89
  resetCurrentSection = _useItemsInSections.resetCurrentSection,
@@ -3,7 +3,7 @@ import type { ListItemProps } from '@synerise/ds-list-item';
3
3
  import type { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
4
4
  import type { SearchBarProps } from '@synerise/ds-search-bar';
5
5
  import type { WithHTMLAttributes } from '@synerise/ds-utils';
6
- import type { ActionType, BaseItemType, BaseSectionType, BaseSectionTypeWithFolders, ContainerHeightType, ItemLoaderConfig, ItemsConfig } from '../ItemPickerNew/ItemPickerNew.types';
6
+ import type { ActionType, BaseItemType, BaseSectionType, BaseSectionTypeWithFolders, ContainerHeightType, ItemLoaderConfig, ItemsConfig, OnLoadedData } from '../ItemPickerNew/ItemPickerNew.types';
7
7
  type TextsAsReactNode = 'basicSearchPlaceholder' | 'searchPlaceholder' | 'refreshButtonLabel' | 'showMoreResultsLabel' | 'noItems' | 'noResults' | 'noResultsInSection' | 'searchAllFoldersButtonLabel' | 'recentsSectionLabel' | 'actionsSectionLabel' | 'resultsSectionLabel' | 'noActions' | 'itemsSectionLabel' | 'infiniteScrollLoadingMore' | 'infiniteScrollLoadingError' | 'errorMessageTitle' | 'errorMessageDetails' | 'backTooltip' | 'clearSearchTooltip' | 'infiniteScrollAllLoaded';
8
8
  export type ItemPickerListTexts = {
9
9
  [key in TextsAsReactNode]: ReactNode;
@@ -31,6 +31,7 @@ export type ItemPickerListProps<ItemType extends BaseItemType, SectionType exten
31
31
  containerRef?: Ref<HTMLDivElement>;
32
32
  includeSearchBar?: boolean;
33
33
  includeFooter?: boolean;
34
+ onLoadedData?: OnLoadedData;
34
35
  }>;
35
36
  export type TitleListItemProps = Omit<ListItemProps, 'type'> & {
36
37
  type: 'title';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders, SearchActionType, SearchParamConfig } from '../../ItemPickerNew/ItemPickerNew.types';
2
+ import type { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders, OnLoadedData, SearchActionType, SearchParamConfig } from '../../ItemPickerNew/ItemPickerNew.types';
3
3
  import type { ItemPickerListProps, ItemPickerListTexts } from '../ItemPickerList.types';
4
4
  type ItemsInSectionsType<ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined> = {
5
5
  items: ItemPickerListProps<ItemType, SectionType>['items'];
@@ -14,8 +14,9 @@ type ItemsInSectionsType<ItemType extends BaseItemType, SectionType extends Base
14
14
  getItemKey?: (item: ItemType) => string | number;
15
15
  showItemsSectionLabel: boolean;
16
16
  changeSearchQuery: (query: string) => void;
17
+ onLoadedData?: OnLoadedData;
17
18
  };
18
- export declare const useItemsInSections: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items, texts, selectedItem, sections, recents, actions, searchQuery, handleItemSelect, onSectionChange, getItemKey, showItemsSectionLabel, changeSearchQuery, }: ItemsInSectionsType<ItemType, SectionType>) => {
19
+ export declare const useItemsInSections: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items, texts, selectedItem, sections, recents, actions, searchQuery, handleItemSelect, onSectionChange, getItemKey, showItemsSectionLabel, changeSearchQuery, onLoadedData, }: ItemsInSectionsType<ItemType, SectionType>) => {
19
20
  currentSection: BaseSectionType | SectionType | undefined;
20
21
  currentPath: import("react").ReactNode[] | undefined;
21
22
  goBack: () => void;
@@ -4,6 +4,7 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
4
4
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { itemSizes } from '@synerise/ds-list-item';
6
6
  import { FIRST_PAGE, GET_ITEM_KEY, ITEMS_PER_PAGE, ITEMS_PER_SECTION, ITEMS_PER_SECTION_IN_SEARCH, ITEM_SIZE, SECTION_HEADER_HEIGHT } from '../constants';
7
+ import { RENDER_MODES } from '../types/renderMode';
7
8
  import { isItems, isItemsConfig, isWithOutSections } from '../utils';
8
9
  import { getSearchActionItems } from '../utils/getSearchActionItems';
9
10
  import { useFlattenFolders } from './useFlattenFolders';
@@ -13,11 +14,6 @@ var getSectionHeight = function getSectionHeight(itemsCount, withTitle) {
13
14
  var titleHeight = withTitle && itemsCount ? ITEM_SIZE.title : 0;
14
15
  return itemsHeight + titleHeight;
15
16
  };
16
- var RENDER_MODES = {
17
- LIST_ITEMS_IN_SECTIONS: 'ITEMS_IN_SECTIONS',
18
- LIST_FOLDERS_IN_SECTIONS: 'LIST_FOLDERS_IN_SECTION',
19
- LIST_ITEMS: 'LIST_ITEMS'
20
- };
21
17
  export var useItemsInSections = function useItemsInSections(_ref) {
22
18
  var items = _ref.items,
23
19
  texts = _ref.texts,
@@ -31,7 +27,8 @@ export var useItemsInSections = function useItemsInSections(_ref) {
31
27
  _ref$getItemKey = _ref.getItemKey,
32
28
  getItemKey = _ref$getItemKey === void 0 ? GET_ITEM_KEY : _ref$getItemKey,
33
29
  showItemsSectionLabel = _ref.showItemsSectionLabel,
34
- changeSearchQuery = _ref.changeSearchQuery;
30
+ changeSearchQuery = _ref.changeSearchQuery,
31
+ onLoadedData = _ref.onLoadedData;
35
32
  var _useState = useState(),
36
33
  currentSection = _useState[0],
37
34
  setCurrentSection = _useState[1];
@@ -249,7 +246,7 @@ export var useItemsInSections = function useItemsInSections(_ref) {
249
246
  currentRequestId = crypto.randomUUID();
250
247
  requestIdRef.current = currentRequestId;
251
248
  if (!(listRenderingMode === RENDER_MODES.LIST_ITEMS)) {
252
- _context.next = 29;
249
+ _context.next = 30;
253
250
  break;
254
251
  }
255
252
  sectionId = (currentSection == null ? void 0 : currentSection.id) || 'DEFAULT';
@@ -277,26 +274,32 @@ export var useItemsInSections = function useItemsInSections(_ref) {
277
274
  setIsLoading(false);
278
275
  loadedPage.current = FIRST_PAGE;
279
276
  metaRef.current[sectionId] = meta;
277
+ onLoadedData == null || onLoadedData({
278
+ sectionId: sectionId,
279
+ meta: meta,
280
+ renderMode: listRenderingMode
281
+ });
280
282
  setIsInitialDataLoaded(true);
281
283
  setCurrentItems(_fetchedItems);
282
- _context.next = 28;
284
+ _context.next = 29;
283
285
  break;
284
- case 23:
285
- _context.prev = 23;
286
+ case 24:
287
+ _context.prev = 24;
286
288
  _context.t0 = _context["catch"](8);
287
289
  setIsLoading(false);
288
290
  setIsInitialDataLoaded(true);
289
291
  setIsLoadingError(true);
290
- case 28:
291
- return _context.abrupt("return");
292
292
  case 29:
293
+ return _context.abrupt("return");
294
+ case 30:
293
295
  fetchedItems = [];
294
296
  requests = listRenderingMode === RENDER_MODES.LIST_FOLDERS_IN_SECTIONS ? [Promise.resolve()] : currentFolders == null ? void 0 : currentFolders.map(function (folder) {
297
+ var sectionId = folder.id;
295
298
  return items.loadItems({
296
299
  page: FIRST_PAGE,
297
300
  searchQuery: searchQuery,
298
301
  limit: (items.limitPerSection || ITEMS_PER_SECTION) + 1,
299
- sectionId: folder.id,
302
+ sectionId: sectionId,
300
303
  meta: undefined,
301
304
  abortController: abortControllerRef.current,
302
305
  searchKey: searchParamConfig == null ? void 0 : searchParamConfig.paramKey
@@ -304,58 +307,63 @@ export var useItemsInSections = function useItemsInSections(_ref) {
304
307
  var sectionItems = _ref3.items,
305
308
  total = _ref3.total,
306
309
  meta = _ref3.meta;
310
+ onLoadedData == null || onLoadedData({
311
+ sectionId: sectionId,
312
+ meta: meta,
313
+ renderMode: listRenderingMode
314
+ });
307
315
  metaRef.current[folder.id] = meta;
308
316
  sectionTotals.current[folder.id] = total;
309
317
  fetchedItems = [].concat(fetchedItems, sectionItems);
310
318
  });
311
319
  });
312
- _context.prev = 31;
320
+ _context.prev = 32;
313
321
  if (!requests) {
314
- _context.next = 38;
322
+ _context.next = 39;
315
323
  break;
316
324
  }
317
- _context.next = 35;
325
+ _context.next = 36;
318
326
  return Promise.allSettled(requests);
319
- case 35:
327
+ case 36:
320
328
  _context.t1 = _context.sent;
321
- _context.next = 39;
329
+ _context.next = 40;
322
330
  break;
323
- case 38:
324
- _context.t1 = [];
325
331
  case 39:
332
+ _context.t1 = [];
333
+ case 40:
326
334
  results = _context.t1;
327
335
  if (!(currentRequestId !== requestIdRef.current)) {
328
- _context.next = 42;
336
+ _context.next = 43;
329
337
  break;
330
338
  }
331
339
  return _context.abrupt("return");
332
- case 42:
340
+ case 43:
333
341
  setIsLoading(false);
334
342
  setIsInitialDataLoaded(true);
335
343
  if (!results.every(function (result) {
336
344
  return result.status === 'fulfilled';
337
345
  })) {
338
- _context.next = 47;
346
+ _context.next = 48;
339
347
  break;
340
348
  }
341
349
  setCurrentItems(fetchedItems);
342
350
  return _context.abrupt("return");
343
- case 47:
351
+ case 48:
344
352
  setIsLoadingError(true);
345
- _context.next = 55;
353
+ _context.next = 56;
346
354
  break;
347
- case 50:
348
- _context.prev = 50;
349
- _context.t2 = _context["catch"](31);
355
+ case 51:
356
+ _context.prev = 51;
357
+ _context.t2 = _context["catch"](32);
350
358
  setIsLoading(false);
351
359
  setIsInitialDataLoaded(true);
352
360
  setIsLoadingError(true);
353
- case 55:
361
+ case 56:
354
362
  case "end":
355
363
  return _context.stop();
356
364
  }
357
- }, _callee, null, [[8, 23], [31, 50]]);
358
- })), [searchParamConfig, currentSection, isFixedItemsList, currentFolders, listRenderingMode, items, listActions, searchQuery, searchActionSection]);
365
+ }, _callee, null, [[8, 24], [32, 51]]);
366
+ })), [searchParamConfig, currentSection, isFixedItemsList, currentFolders, listRenderingMode, items, listActions, searchQuery, searchActionSection, onLoadedData]);
359
367
  useEffect(function () {
360
368
  if (listActions) {
361
369
  return;
@@ -0,0 +1,6 @@
1
+ export declare const RENDER_MODES: {
2
+ readonly LIST_ITEMS_IN_SECTIONS: "ITEMS_IN_SECTIONS";
3
+ readonly LIST_FOLDERS_IN_SECTIONS: "LIST_FOLDERS_IN_SECTION";
4
+ readonly LIST_ITEMS: "LIST_ITEMS";
5
+ };
6
+ export type RenderMode = (typeof RENDER_MODES)[keyof typeof RENDER_MODES];
@@ -0,0 +1,5 @@
1
+ export var RENDER_MODES = {
2
+ LIST_ITEMS_IN_SECTIONS: 'ITEMS_IN_SECTIONS',
3
+ LIST_FOLDERS_IN_SECTIONS: 'LIST_FOLDERS_IN_SECTION',
4
+ LIST_ITEMS: 'LIST_ITEMS'
5
+ };
@@ -5,6 +5,7 @@ import type { InformationCardProps } from '@synerise/ds-information-card';
5
5
  import type { ListItemProps } from '@synerise/ds-list-item';
6
6
  import type { WithHTMLAttributes } from '@synerise/ds-utils';
7
7
  import type { ItemPickerListProps, ItemPickerListTexts } from '../ItemPickerList/ItemPickerList.types';
8
+ import type { RenderMode } from '../ItemPickerList/types/renderMode';
8
9
  import type { ItemPickerTriggerProps, ItemPickerTriggerTexts } from '../ItemPickerTrigger/Trigger.types';
9
10
  type HeightConfig = {
10
11
  defaultHeight: number;
@@ -40,6 +41,9 @@ export type LoaderProps = {
40
41
  abortController?: AbortController;
41
42
  searchKey?: string;
42
43
  };
44
+ export type OnLoadedData = (options: Pick<LoaderProps, 'sectionId' | 'meta'> & {
45
+ renderMode: RenderMode;
46
+ }) => void;
43
47
  export type ItemLoaderConfig<ItemType extends BaseItemType> = {
44
48
  limitPerPage?: number;
45
49
  limitPerSection?: number;
@@ -83,6 +87,7 @@ export type ItemPickerProps<ItemType extends BaseItemType, SectionType extends B
83
87
  onChange?: (item: ItemType) => void;
84
88
  onFocus?: () => void;
85
89
  onBlur?: () => void;
90
+ onLoadedData?: OnLoadedData;
86
91
  dropdownProps?: Partial<DropdownProps>;
87
92
  } & Pick<ItemPickerListProps<ItemType, SectionType>, 'items' | 'actions' | 'recents' | 'sections' | 'isLoading' | 'onRefresh' | 'onSectionChange' | 'containerHeight' | 'showItemsSectionLabel' | 'noResultsIcon' | 'emptyListIcon' | 'selectedItem' | 'getItemHeight' | 'scrollbarProps' | 'searchBarProps' | 'includeFooter' | 'includeSearchBar'>> & FormFieldCommonProps & Partial<Pick<ItemPickerTriggerProps, 'placeholder' | 'placeholderIcon' | 'onClear'>>;
88
93
  export type SearchConfig = {
package/dist/index.d.ts CHANGED
@@ -5,4 +5,4 @@ export { default as ItemPickerTrigger } from './components/ItemPickerTrigger/Tri
5
5
  export { ItemPickerList } from './components/ItemPickerList/ItemPickerList';
6
6
  export { ItemPickerNew } from './components/ItemPickerNew/ItemPickerNew';
7
7
  export type { ItemPickerListProps, ItemPickerListTexts, ItemSelectHandler, } from './components/ItemPickerList/ItemPickerList.types';
8
- export type { ItemPickerProps as ItemPickerPropsNew, ItemLoaderConfig, BaseSectionTypeWithFolders, BaseItemType, ItemLoaderResponse, LoaderProps, } from './components/ItemPickerNew/ItemPickerNew.types';
8
+ export type { ItemPickerProps as ItemPickerPropsNew, ItemLoaderConfig, BaseSectionTypeWithFolders, BaseItemType, ItemLoaderResponse, LoaderProps, OnLoadedData, } from './components/ItemPickerNew/ItemPickerNew.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-item-picker",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "description": "ItemPicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -42,7 +42,7 @@
42
42
  "@synerise/ds-flag": "^1.0.2",
43
43
  "@synerise/ds-form-field": "^1.1.8",
44
44
  "@synerise/ds-icon": "^1.5.4",
45
- "@synerise/ds-information-card": "^1.0.18",
45
+ "@synerise/ds-information-card": "^1.0.19",
46
46
  "@synerise/ds-list-item": "^1.0.13",
47
47
  "@synerise/ds-loader": "^1.0.6",
48
48
  "@synerise/ds-popconfirm": "^1.0.14",
@@ -64,5 +64,5 @@
64
64
  "react-intl": ">=3.12.0 <= 6.8",
65
65
  "styled-components": "^5.3.3"
66
66
  },
67
- "gitHead": "4512641033ba3581a3df208143c547fcfed45895"
67
+ "gitHead": "2161bdb04f3db0f79b7d0465ce6b41121f1543ef"
68
68
  }