@synerise/ds-item-picker 1.16.2 → 1.17.1

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -3
  3. package/dist/ItemPicker.d.ts +5 -5
  4. package/dist/ItemPicker.js +13 -17
  5. package/dist/ItemPicker.styles.d.ts +1 -1
  6. package/dist/ItemPicker.styles.js +6 -3
  7. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.d.ts +2 -2
  8. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.js +58 -99
  9. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.d.ts +7 -7
  10. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.js +22 -19
  11. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.d.ts +4 -4
  12. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.js +1 -1
  13. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.d.ts +2 -2
  14. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.js +89 -152
  15. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.d.ts +8 -8
  16. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.js +1 -1
  17. package/dist/components/ItemPickerList/ItemPickerList.d.ts +5 -5
  18. package/dist/components/ItemPickerList/ItemPickerList.js +199 -258
  19. package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +18 -18
  20. package/dist/components/ItemPickerList/ItemPickerList.styles.js +55 -64
  21. package/dist/components/ItemPickerList/ItemPickerList.types.d.ts +3 -3
  22. package/dist/components/ItemPickerList/ItemPickerList.types.js +1 -1
  23. package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +10 -5
  24. package/dist/components/ItemPickerList/components/EmptyListMessage.js +33 -29
  25. package/dist/components/ItemPickerList/components/ErrorItem.d.ts +1 -1
  26. package/dist/components/ItemPickerList/components/ErrorItem.js +10 -9
  27. package/dist/components/ItemPickerList/components/ErrorMessage.d.ts +2 -2
  28. package/dist/components/ItemPickerList/components/ErrorMessage.js +12 -15
  29. package/dist/components/ItemPickerList/components/InfiniteLoaderItem.d.ts +2 -2
  30. package/dist/components/ItemPickerList/components/InfiniteLoaderItem.js +19 -17
  31. package/dist/components/ItemPickerList/components/ItemPickerListFooter.d.ts +3 -3
  32. package/dist/components/ItemPickerList/components/ItemPickerListFooter.js +21 -20
  33. package/dist/components/ItemPickerList/components/ItemPickerListRow.d.ts +4 -4
  34. package/dist/components/ItemPickerList/components/ItemPickerListRow.js +42 -43
  35. package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.d.ts +1 -1
  36. package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.js +16 -23
  37. package/dist/components/ItemPickerList/components/ListSearchInput.d.ts +4 -4
  38. package/dist/components/ItemPickerList/components/ListSearchInput.js +36 -51
  39. package/dist/components/ItemPickerList/components/LoadingItem.d.ts +1 -1
  40. package/dist/components/ItemPickerList/components/LoadingItem.js +10 -9
  41. package/dist/components/ItemPickerList/components/NoMoreItem.d.ts +1 -1
  42. package/dist/components/ItemPickerList/components/NoMoreItem.js +10 -9
  43. package/dist/components/ItemPickerList/components/index.js +14 -6
  44. package/dist/components/ItemPickerList/constants.d.ts +2 -2
  45. package/dist/components/ItemPickerList/constants.js +47 -26
  46. package/dist/components/ItemPickerList/hooks/index.js +8 -3
  47. package/dist/components/ItemPickerList/hooks/useFlattenFolders.d.ts +2 -2
  48. package/dist/components/ItemPickerList/hooks/useFlattenFolders.js +40 -61
  49. package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +7 -7
  50. package/dist/components/ItemPickerList/hooks/useItemsInSections.js +342 -443
  51. package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.d.ts +5 -5
  52. package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.js +77 -74
  53. package/dist/components/ItemPickerList/hooks/useListHeight.d.ts +2 -2
  54. package/dist/components/ItemPickerList/hooks/useListHeight.js +37 -41
  55. package/dist/components/ItemPickerList/types/renderMode.js +8 -5
  56. package/dist/components/ItemPickerList/utils/actionItemsUtils.d.ts +4 -4
  57. package/dist/components/ItemPickerList/utils/actionItemsUtils.js +92 -92
  58. package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.d.ts +2 -2
  59. package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.js +7 -4
  60. package/dist/components/ItemPickerList/utils/findSectionById.d.ts +1 -1
  61. package/dist/components/ItemPickerList/utils/findSectionById.js +10 -12
  62. package/dist/components/ItemPickerList/utils/getContextAwareActions.d.ts +1 -1
  63. package/dist/components/ItemPickerList/utils/getContextAwareActions.js +19 -15
  64. package/dist/components/ItemPickerList/utils/getSearchByActionItems.d.ts +2 -2
  65. package/dist/components/ItemPickerList/utils/getSearchByActionItems.js +28 -29
  66. package/dist/components/ItemPickerList/utils/index.js +16 -4
  67. package/dist/components/ItemPickerList/utils/isNavKey.d.ts +1 -1
  68. package/dist/components/ItemPickerList/utils/isNavKey.js +6 -3
  69. package/dist/components/ItemPickerList/utils/resolveSectionId.d.ts +2 -2
  70. package/dist/components/ItemPickerList/utils/resolveSectionId.js +15 -9
  71. package/dist/components/ItemPickerList/utils/typeguards.utils.d.ts +5 -5
  72. package/dist/components/ItemPickerList/utils/typeguards.utils.js +23 -14
  73. package/dist/components/ItemPickerNew/ItemPickerNew.d.ts +4 -4
  74. package/dist/components/ItemPickerNew/ItemPickerNew.js +59 -101
  75. package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +18 -16
  76. package/dist/components/ItemPickerNew/ItemPickerNew.types.js +1 -1
  77. package/dist/components/ItemPickerNew/types/actions.types.d.ts +2 -2
  78. package/dist/components/ItemPickerNew/types/actions.types.js +10 -6
  79. package/dist/components/ItemPickerNew/types/baseItemSectionType.types.d.ts +3 -3
  80. package/dist/components/ItemPickerNew/types/baseItemSectionType.types.js +1 -1
  81. package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.d.ts +2 -2
  82. package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.js +1 -1
  83. package/dist/components/ItemPickerTrigger/Trigger.d.ts +5 -5
  84. package/dist/components/ItemPickerTrigger/Trigger.js +71 -111
  85. package/dist/components/ItemPickerTrigger/Trigger.styles.d.ts +12 -12
  86. package/dist/components/ItemPickerTrigger/Trigger.styles.js +70 -93
  87. package/dist/components/ItemPickerTrigger/Trigger.types.d.ts +3 -3
  88. package/dist/components/ItemPickerTrigger/Trigger.types.js +1 -1
  89. package/dist/hooks/useDefaultTexts.d.ts +1 -1
  90. package/dist/hooks/useDefaultTexts.js +116 -117
  91. package/dist/index.js +14 -6
  92. package/dist/modules.d.js +1 -1
  93. package/dist/modules.d.ts +0 -0
  94. package/package.json +25 -25
@@ -1,274 +1,237 @@
1
- var _excluded = ["items", "recents", "sections", "actions", "texts", "isLoading", "selectedItem", "scrollbarProps", "searchBarProps", "showItemsSectionLabel", "onItemSelect", "onRefresh", "containerHeight", "isVisible", "onSectionChange", "containerRef", "includeFooter", "includeSearchBar", "onLoadedData", "isDropdown"];
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
- 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
- import debounce from 'lodash.debounce';
5
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
6
- import { v4 as uuid } from 'uuid';
7
- import { useTheme } from '@synerise/ds-core';
8
- import Dropdown from '@synerise/ds-dropdown';
9
- import Icon, { ArrowLeftM } from '@synerise/ds-icon';
10
- import { ListContextProvider, itemSizes } from '@synerise/ds-list-item';
11
- import { Text } from '@synerise/ds-typography';
12
- import { focusWithArrowKeys, useCombinedRefs, useKeyboardShortcuts, useScrollContain } from '@synerise/ds-utils';
13
- import { useDefaultTexts } from '../../hooks/useDefaultTexts';
14
- import * as S from './ItemPickerList.styles';
15
- import { EmptyListMessage, ErrorMessage, ItemPickerListFooter, ItemPickerListRow, ItemPickerListSkeleton } from './components';
16
- import { ListSearchInput } from './components/ListSearchInput';
17
- import { ITEM_SIZE, LIST_INNER_PADDING, LIST_STYLE, SECTION_HEADER_HEIGHT } from './constants';
18
- import { useItemsInSections, useListHeight } from './hooks';
19
- import { findSectionById, isNavKey, isTitle } from './utils';
20
- var ItemPickerListInner = function ItemPickerListInner(_ref, forwardedRef) {
21
- var items = _ref.items,
22
- recents = _ref.recents,
23
- sections = _ref.sections,
24
- actions = _ref.actions,
25
- texts = _ref.texts,
26
- isLoading = _ref.isLoading,
27
- selectedItem = _ref.selectedItem,
28
- scrollbarProps = _ref.scrollbarProps,
29
- searchBarProps = _ref.searchBarProps,
30
- _ref$showItemsSection = _ref.showItemsSectionLabel,
31
- showItemsSectionLabel = _ref$showItemsSection === void 0 ? true : _ref$showItemsSection,
32
- onItemSelect = _ref.onItemSelect,
33
- onRefresh = _ref.onRefresh,
34
- containerHeight = _ref.containerHeight,
35
- isVisible = _ref.isVisible,
36
- onSectionChange = _ref.onSectionChange,
37
- containerRefProp = _ref.containerRef,
38
- _ref$includeFooter = _ref.includeFooter,
39
- includeFooter = _ref$includeFooter === void 0 ? true : _ref$includeFooter,
40
- _ref$includeSearchBar = _ref.includeSearchBar,
41
- includeSearchBar = _ref$includeSearchBar === void 0 ? true : _ref$includeSearchBar,
42
- onLoadedData = _ref.onLoadedData,
43
- isDropdown = _ref.isDropdown,
44
- htmlAttributes = _objectWithoutPropertiesLoose(_ref, _excluded);
45
- var theme = useTheme();
46
- var _useState = useState(''),
47
- searchQuery = _useState[0],
48
- setSearchQuery = _useState[1];
49
- var listRef = useRef(null);
50
- var scrollBarRef = useRef(null);
51
- var containerRef = useRef(null);
52
- var refs = [containerRef];
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import debounce from "lodash.debounce";
3
+ import { forwardRef, useState, useRef, useCallback, useMemo, useImperativeHandle, useEffect } from "react";
4
+ import { v4 } from "uuid";
5
+ import { useTheme } from "@synerise/ds-core";
6
+ import Dropdown from "@synerise/ds-dropdown";
7
+ import Icon, { ArrowLeftM } from "@synerise/ds-icon";
8
+ import { itemSizes, ListContextProvider } from "@synerise/ds-list-item";
9
+ import { Text } from "@synerise/ds-typography";
10
+ import { useCombinedRefs, useScrollContain, useKeyboardShortcuts, focusWithArrowKeys } from "@synerise/ds-utils";
11
+ import { useDefaultTexts } from "../../hooks/useDefaultTexts.js";
12
+ import { StyledScrollbar, ScrollContent, StyledList, ListContainer, ListWrapper } from "./ItemPickerList.styles.js";
13
+ import { EmptyListMessage } from "./components/EmptyListMessage.js";
14
+ import { ErrorMessage } from "./components/ErrorMessage.js";
15
+ import "@synerise/ds-alert";
16
+ import { ItemPickerListFooter } from "./components/ItemPickerListFooter.js";
17
+ import { ItemPickerListRow } from "./components/ItemPickerListRow.js";
18
+ import { ItemPickerListSkeleton } from "./components/ItemPickerListSkeleton.js";
19
+ import { ListSearchInput } from "./components/ListSearchInput.js";
20
+ import { ITEM_SIZE, LIST_STYLE, SECTION_HEADER_HEIGHT, LIST_INNER_PADDING } from "./constants.js";
21
+ import { useItemsInSections } from "./hooks/useItemsInSections.js";
22
+ import { useListHeight } from "./hooks/useListHeight.js";
23
+ import { isTitle } from "./utils/typeguards.utils.js";
24
+ import { isNavKey } from "./utils/isNavKey.js";
25
+ import { findSectionById } from "./utils/findSectionById.js";
26
+ const ItemPickerListInner = ({
27
+ items,
28
+ recents,
29
+ sections,
30
+ actions,
31
+ texts,
32
+ isLoading,
33
+ selectedItem,
34
+ scrollbarProps,
35
+ searchBarProps,
36
+ showItemsSectionLabel = true,
37
+ onItemSelect,
38
+ onRefresh,
39
+ containerHeight,
40
+ isVisible,
41
+ onSectionChange,
42
+ containerRef: containerRefProp,
43
+ includeFooter = true,
44
+ includeSearchBar = true,
45
+ onLoadedData,
46
+ isDropdown,
47
+ emptyListIcon,
48
+ noResultsIcon,
49
+ emptyStateComponent,
50
+ noResultsComponent,
51
+ ...htmlAttributes
52
+ }, forwardedRef) => {
53
+ const theme = useTheme();
54
+ const [searchQuery, setSearchQuery] = useState("");
55
+ const listRef = useRef(null);
56
+ const scrollBarRef = useRef(null);
57
+ const containerRef = useRef(null);
58
+ const refs = [containerRef];
53
59
  if (containerRefProp) {
54
60
  refs.push(containerRefProp);
55
61
  }
56
- var combinedScrollRef = useCombinedRefs.apply(void 0, refs);
57
- var inputRef = useRef(null);
58
- var changeLocalSearchQueryRef = useRef(null);
59
- var scrollContainRef = useScrollContain();
60
- var allTexts = useDefaultTexts(texts);
61
- var changeSearchQuery = useCallback(function (query) {
62
- changeLocalSearchQueryRef.current == null || changeLocalSearchQueryRef.current(query);
62
+ const combinedScrollRef = useCombinedRefs(...refs);
63
+ const inputRef = useRef(null);
64
+ const changeLocalSearchQueryRef = useRef(null);
65
+ const scrollContainRef = useScrollContain();
66
+ const allTexts = useDefaultTexts(texts);
67
+ const changeSearchQuery = useCallback((query) => {
68
+ changeLocalSearchQueryRef.current?.(query);
63
69
  setSearchQuery(query);
64
70
  }, []);
65
- var debouncedSearchQueryChange = useRef(debounce(function (query) {
71
+ const debouncedSearchQueryChange = useRef(debounce((query) => {
66
72
  changeSearchQuery(query);
67
73
  }, 300)).current;
68
- var classNames = useMemo(function () {
69
- return "ds-item-picker-dropdown ds-item-picker-dropdown-" + uuid();
70
- }, []);
71
- var handleItemSelect = function handleItemSelect(item) {
72
- var section = findSectionById(sections, item.sectionId);
73
- onItemSelect == null || onItemSelect(item, section);
74
+ const classNames = useMemo(() => `ds-item-picker-dropdown ds-item-picker-dropdown-${v4()}`, []);
75
+ const handleItemSelect = (item) => {
76
+ const section = findSectionById(sections, item.sectionId);
77
+ onItemSelect?.(item, section);
74
78
  };
75
- var _useItemsInSections = useItemsInSections({
76
- items: items,
77
- texts: allTexts,
78
- selectedItem: selectedItem,
79
- sections: sections,
80
- recents: recents,
81
- actions: actions,
82
- searchQuery: searchQuery,
83
- handleItemSelect: handleItemSelect,
84
- onSectionChange: onSectionChange,
85
- showItemsSectionLabel: showItemsSectionLabel,
86
- changeSearchQuery: changeSearchQuery,
87
- onLoadedData: onLoadedData
88
- }),
89
- currentSection = _useItemsInSections.currentSection,
90
- resetCurrentSection = _useItemsInSections.resetCurrentSection,
91
- currentPath = _useItemsInSections.currentPath,
92
- goBack = _useItemsInSections.goBack,
93
- mergedItemsList = _useItemsInSections.mergedItemsList,
94
- isLoadingMore = _useItemsInSections.isLoadingMore,
95
- isLoadingMoreError = _useItemsInSections.isLoadingMoreError,
96
- isLoadingItems = _useItemsInSections.isLoading,
97
- isLoadedAll = _useItemsInSections.isLoadedAll,
98
- isLoadingError = _useItemsInSections.isLoadingError,
99
- handleScrollEndReach = _useItemsInSections.handleScrollEndReach,
100
- refreshItems = _useItemsInSections.refreshItems,
101
- refreshEnabled = _useItemsInSections.refreshEnabled,
102
- contentHeight = _useItemsInSections.contentHeight,
103
- searchByParamConfig = _useItemsInSections.searchByParamConfig,
104
- setSearchByParamConfig = _useItemsInSections.setSearchByParamConfig,
105
- searchByAction = _useItemsInSections.searchByAction,
106
- listActions = _useItemsInSections.listActions,
107
- searchInAction = _useItemsInSections.searchInAction,
108
- searchInItem = _useItemsInSections.searchInItem,
109
- canPerformListActions = _useItemsInSections.canPerformListActions,
110
- reloadActiveSection = _useItemsInSections.reloadActiveSection,
111
- activeSectionId = _useItemsInSections.activeSectionId;
112
- useImperativeHandle(forwardedRef, function () {
79
+ const {
80
+ currentSection,
81
+ resetCurrentSection,
82
+ currentPath,
83
+ goBack,
84
+ mergedItemsList,
85
+ isLoadingMore,
86
+ isLoadingMoreError,
87
+ isLoading: isLoadingItems,
88
+ isLoadedAll,
89
+ isLoadingError,
90
+ handleScrollEndReach,
91
+ refreshItems,
92
+ refreshEnabled,
93
+ contentHeight,
94
+ searchByParamConfig,
95
+ setSearchByParamConfig,
96
+ searchByAction,
97
+ listActions,
98
+ searchInAction,
99
+ searchInItem,
100
+ canPerformListActions,
101
+ reloadActiveSection,
102
+ activeSectionId
103
+ } = useItemsInSections({
104
+ items,
105
+ texts: allTexts,
106
+ selectedItem,
107
+ sections,
108
+ recents,
109
+ actions,
110
+ searchQuery,
111
+ handleItemSelect,
112
+ onSectionChange,
113
+ showItemsSectionLabel,
114
+ changeSearchQuery,
115
+ onLoadedData
116
+ });
117
+ useImperativeHandle(forwardedRef, () => {
113
118
  return {
114
- currentSection: currentSection,
115
- activeSectionId: activeSectionId,
116
- reloadActiveSection: reloadActiveSection
119
+ currentSection,
120
+ activeSectionId,
121
+ reloadActiveSection
117
122
  };
118
123
  }, [activeSectionId, currentSection, reloadActiveSection]);
119
- var handleScroll = useCallback(function (_ref2) {
120
- var currentTarget = _ref2.currentTarget;
121
- var scrollTop = currentTarget.scrollTop,
122
- scrollHeight = currentTarget.scrollHeight,
123
- clientHeight = currentTarget.clientHeight;
124
+ const handleScroll = useCallback(({
125
+ currentTarget
126
+ }) => {
127
+ const {
128
+ scrollTop,
129
+ scrollHeight,
130
+ clientHeight
131
+ } = currentTarget;
124
132
  if (listRef.current) {
125
133
  listRef.current.scrollTo(scrollTop);
126
134
  }
127
135
  if (isDropdown && !isVisible) {
128
136
  return;
129
137
  }
130
- var max = scrollHeight - clientHeight;
138
+ const max = scrollHeight - clientHeight;
131
139
  if (scrollTop >= max - 20) {
132
140
  handleScrollEndReach();
133
141
  }
134
142
  }, [handleScrollEndReach, isDropdown, isVisible]);
135
- var focusSearchInput = useCallback(function () {
136
- var _inputRef$current;
137
- (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
143
+ const focusSearchInput = useCallback(() => {
144
+ inputRef.current?.focus();
138
145
  }, []);
139
- var handleKeyDown = function handleKeyDown(event) {
146
+ const handleKeyDown = (event) => {
140
147
  if (isNavKey(event)) {
141
- focusWithArrowKeys(event, classNames.split(' ')[1], function () {
148
+ focusWithArrowKeys(event, classNames.split(" ")[1], () => {
142
149
  focusSearchInput();
143
150
  });
144
151
  }
145
152
  };
146
- var getItemSize = useCallback(function (index) {
147
- var item = mergedItemsList && mergedItemsList[index];
153
+ const getItemSize = useCallback((index) => {
154
+ const item = mergedItemsList && mergedItemsList[index];
148
155
  if (isTitle(item)) {
149
156
  return ITEM_SIZE.title;
150
157
  }
151
158
  return ITEM_SIZE[item.size || itemSizes.DEFAULT];
152
159
  }, [mergedItemsList]);
153
- var itemData = useMemo(function () {
154
- return {
155
- dataSource: mergedItemsList,
156
- classNames: classNames,
157
- getItemSize: getItemSize,
158
- texts: allTexts,
159
- infiniteScroll: {
160
- isLoading: isLoadingMore,
161
- hasMore: !isLoadedAll,
162
- hasError: isLoadingMoreError
163
- }
164
- };
165
- }, [mergedItemsList, classNames, getItemSize, allTexts, isLoadingMore, isLoadedAll, isLoadingMoreError]);
166
- var handleRefresh = onRefresh || refreshItems ? function () {
167
- changeSearchQuery('');
168
- setSearchByParamConfig(undefined);
160
+ const itemData = useMemo(() => ({
161
+ dataSource: mergedItemsList,
162
+ classNames,
163
+ getItemSize,
164
+ texts: allTexts,
165
+ infiniteScroll: {
166
+ isLoading: isLoadingMore,
167
+ hasMore: !isLoadedAll,
168
+ hasError: isLoadingMoreError
169
+ }
170
+ }), [mergedItemsList, classNames, getItemSize, allTexts, isLoadingMore, isLoadedAll, isLoadingMoreError]);
171
+ const handleRefresh = onRefresh || refreshItems ? () => {
172
+ changeSearchQuery("");
173
+ setSearchByParamConfig(void 0);
169
174
  resetCurrentSection();
170
175
  onRefresh && onRefresh();
171
176
  if (refreshItems) {
172
177
  refreshItems();
173
178
  }
174
- } : undefined;
175
- var _ref3 = useListHeight({
176
- heightConfig: containerHeight,
177
- calculatedContentHeight: contentHeight,
178
- containerRef: combinedScrollRef,
179
- includeFooter: includeFooter && !!handleRefresh,
180
- includeSearchBar: includeSearchBar
181
- }) || 0,
182
- outerWrapperHeight = _ref3.outerWrapperHeight,
183
- listWrapperHeight = _ref3.listWrapperHeight,
184
- offsetSpace = _ref3.offsetSpace;
185
- var isActionSection = Boolean(searchByAction || searchInAction || searchInItem);
186
- var isSection = Boolean(currentSection || isActionSection);
187
- var listHeight = (isSection ? listWrapperHeight - SECTION_HEADER_HEIGHT : listWrapperHeight) - LIST_INNER_PADDING;
188
- var clearSearchQuery = function clearSearchQuery() {
189
- changeSearchQuery('');
179
+ } : void 0;
180
+ const {
181
+ outerWrapperHeight,
182
+ listWrapperHeight,
183
+ offsetSpace
184
+ } = useListHeight({
185
+ heightConfig: containerHeight,
186
+ calculatedContentHeight: contentHeight,
187
+ containerRef: combinedScrollRef,
188
+ includeFooter: includeFooter && !!handleRefresh,
189
+ includeSearchBar
190
+ }) || 0;
191
+ const isActionSection = Boolean(searchByAction || searchInAction || searchInItem);
192
+ const isSection = Boolean(currentSection || isActionSection);
193
+ const listHeight = (isSection ? listWrapperHeight - SECTION_HEADER_HEIGHT : listWrapperHeight) - LIST_INNER_PADDING;
194
+ const clearSearchQuery = () => {
195
+ changeSearchQuery("");
190
196
  };
191
- var showMessage = !isLoading && !isLoadingItems && ((mergedItemsList == null ? void 0 : mergedItemsList.length) === 0 || isLoadingError);
192
- var listContent = useMemo(function () {
197
+ const showMessage = !isLoading && !isLoadingItems && (mergedItemsList?.length === 0 || isLoadingError);
198
+ const listContent = useMemo(() => {
193
199
  if (isLoadingError) {
194
- return /*#__PURE__*/React.createElement(ErrorMessage, {
195
- texts: allTexts
196
- });
200
+ return /* @__PURE__ */ jsx(ErrorMessage, { texts: allTexts });
197
201
  }
198
202
  if (isLoading || isLoadingItems) {
199
- return /*#__PURE__*/React.createElement(ItemPickerListSkeleton, {
200
- wrapperHeight: listWrapperHeight
201
- });
203
+ return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight });
202
204
  }
203
- var getSectionLabel = function getSectionLabel() {
204
- var itemsPath = currentPath || [currentSection == null ? void 0 : currentSection.text];
205
- var searchByActionLabel = (searchByAction == null ? void 0 : searchByAction.sectionTitle) || (searchByAction == null ? void 0 : searchByAction.text);
206
- var searchInActionLabel = searchInAction == null ? void 0 : searchInAction.text;
207
- var searchInItemLabel = searchInItem && "" + (searchInAction == null ? void 0 : searchInAction.renderSearchInValueText(searchInItem));
208
- var labelParts = [].concat(itemsPath, [searchInActionLabel, searchInItemLabel, searchByActionLabel]).filter(Boolean).join(' - ');
209
- return /*#__PURE__*/React.createElement(Text, {
210
- ellipsis: {
211
- tooltip: labelParts
212
- }
213
- }, labelParts);
205
+ const getSectionLabel = () => {
206
+ const itemsPath = currentPath || [currentSection?.text];
207
+ const searchByActionLabel = searchByAction?.sectionTitle || searchByAction?.text;
208
+ const searchInActionLabel = searchInAction?.text;
209
+ const searchInItemLabel = searchInItem && `${searchInAction?.renderSearchInValueText(searchInItem)}`;
210
+ const labelParts = [...itemsPath, searchInActionLabel, searchInItemLabel, searchByActionLabel].filter(Boolean).join(" - ");
211
+ return /* @__PURE__ */ jsx(Text, { ellipsis: {
212
+ tooltip: labelParts
213
+ }, children: labelParts });
214
214
  };
215
- return /*#__PURE__*/React.createElement(React.Fragment, null, isSection && /*#__PURE__*/React.createElement(Dropdown.BackAction, {
216
- tooltipProps: {
215
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
216
+ isSection && /* @__PURE__ */ jsx(Dropdown.BackAction, { tooltipProps: {
217
217
  title: allTexts.backTooltip,
218
- shortCuts: ['', /*#__PURE__*/React.createElement(Icon, {
219
- key: "hint-arrow-left",
220
- size: 18,
221
- color: theme.palette.white,
222
- component: /*#__PURE__*/React.createElement(ArrowLeftM, null)
223
- })]
224
- },
225
- label: getSectionLabel(),
226
- onClick: goBack
227
- }), (mergedItemsList == null ? void 0 : mergedItemsList.length) === 0 ? /*#__PURE__*/React.createElement(EmptyListMessage, {
228
- buttonOnClick: function buttonOnClick() {
229
- return resetCurrentSection();
230
- },
231
- listActions: listActions,
232
- hasCurrentSection: isSection,
233
- texts: allTexts,
234
- isActionSection: isActionSection,
235
- currentSection: currentSection
236
- }) : /*#__PURE__*/React.createElement(S.StyledScrollbar, _extends({
237
- withSectionHeader: isSection,
238
- maxHeight: listHeight,
239
- "data-maxheight": listHeight,
240
- onScroll: handleScroll,
241
- absolute: true,
242
- withDnd: false,
243
- ref: scrollBarRef
244
- }, scrollbarProps), /*#__PURE__*/React.createElement(S.ScrollContent, null, /*#__PURE__*/React.createElement(ListContextProvider, null, /*#__PURE__*/React.createElement(S.StyledList, {
245
- width: "100%",
246
- "data-listheight": listHeight,
247
- height: listHeight,
248
- maxHeight: listHeight,
249
- itemCount: mergedItemsList.length,
250
- itemSize: getItemSize,
251
- itemData: itemData,
252
- style: LIST_STYLE,
253
- ref: listRef
254
- }, function (props) {
255
- return ItemPickerListRow(props);
256
- })))));
257
- // eslint-disable-next-line react-hooks/exhaustive-deps
218
+ shortCuts: ["", /* @__PURE__ */ jsx(Icon, { size: 18, color: theme.palette.white, component: /* @__PURE__ */ jsx(ArrowLeftM, {}) }, "hint-arrow-left")]
219
+ }, label: getSectionLabel(), onClick: goBack }),
220
+ mergedItemsList?.length === 0 ? /* @__PURE__ */ jsx(EmptyListMessage, { buttonOnClick: () => resetCurrentSection(), listActions, hasCurrentSection: isSection, texts: allTexts, isActionSection, currentSection, searchQuery, emptyListIcon, noResultsIcon, emptyStateComponent, noResultsComponent }) : /* @__PURE__ */ jsx(StyledScrollbar, { withSectionHeader: isSection, maxHeight: listHeight, "data-maxheight": listHeight, onScroll: handleScroll, absolute: true, withDnd: false, ref: scrollBarRef, ...scrollbarProps, children: /* @__PURE__ */ jsx(ScrollContent, { children: /* @__PURE__ */ jsx(ListContextProvider, { children: /* @__PURE__ */ jsx(StyledList, { width: "100%", "data-listheight": listHeight, height: listHeight, maxHeight: listHeight, itemCount: mergedItemsList.length, itemSize: getItemSize, itemData, style: LIST_STYLE, ref: listRef, children: (props) => ItemPickerListRow(props) }) }) }) })
221
+ ] });
258
222
  }, [allTexts, currentSection, currentPath, getItemSize, handleScroll, isLoading, isLoadingError, isLoadingItems, itemData, listHeight, goBack, mergedItemsList.length, scrollbarProps, searchQuery, listWrapperHeight]);
259
- useEffect(function () {
223
+ useEffect(() => {
260
224
  setTimeout(focusSearchInput, 0);
261
225
  }, [isLoading, isLoadingItems, isLoadingMore, focusSearchInput]);
262
- useEffect(function () {
226
+ useEffect(() => {
263
227
  if (isVisible) {
264
228
  resetCurrentSection();
265
229
  clearSearchQuery();
266
- setSearchByParamConfig(undefined);
230
+ setSearchByParamConfig(void 0);
267
231
  setTimeout(focusSearchInput, 0);
268
232
  }
269
- // eslint-disable-next-line react-hooks/exhaustive-deps
270
233
  }, [isVisible, focusSearchInput]);
271
- useEffect(function () {
234
+ useEffect(() => {
272
235
  if (scrollBarRef.current && listRef.current) {
273
236
  scrollBarRef.current.scrollTo({
274
237
  top: 0
@@ -277,16 +240,15 @@ var ItemPickerListInner = function ItemPickerListInner(_ref, forwardedRef) {
277
240
  setTimeout(focusSearchInput, 0);
278
241
  }
279
242
  }, [searchByAction, searchByParamConfig, searchInAction, searchInItem, currentSection, focusSearchInput]);
280
- useEffect(function () {
243
+ useEffect(() => {
281
244
  listRef.current && listRef.current.resetAfterIndex(0);
282
245
  }, [mergedItemsList]);
283
246
  useKeyboardShortcuts({
284
- ArrowLeft: function ArrowLeft(event) {
285
- var _combinedScrollRef$cu;
286
- if (!((_combinedScrollRef$cu = combinedScrollRef.current) != null && _combinedScrollRef$cu.offsetParent)) {
247
+ ArrowLeft: (event) => {
248
+ if (!combinedScrollRef.current?.offsetParent) {
287
249
  return;
288
250
  }
289
- var isMetaOrCtrlKey = event.metaKey || event.ctrlKey;
251
+ const isMetaOrCtrlKey = event.metaKey || event.ctrlKey;
290
252
  if (isMetaOrCtrlKey) {
291
253
  event.preventDefault();
292
254
  event.stopPropagation();
@@ -294,9 +256,8 @@ var ItemPickerListInner = function ItemPickerListInner(_ref, forwardedRef) {
294
256
  return;
295
257
  }
296
258
  },
297
- Escape: function Escape(event) {
298
- var _combinedScrollRef$cu2;
299
- if (!((_combinedScrollRef$cu2 = combinedScrollRef.current) != null && _combinedScrollRef$cu2.offsetParent)) {
259
+ Escape: (event) => {
260
+ if (!combinedScrollRef.current?.offsetParent) {
300
261
  return;
301
262
  }
302
263
  if (searchQuery) {
@@ -308,40 +269,20 @@ var ItemPickerListInner = function ItemPickerListInner(_ref, forwardedRef) {
308
269
  if (searchByParamConfig) {
309
270
  event.preventDefault();
310
271
  event.stopPropagation();
311
- setSearchByParamConfig(undefined);
272
+ setSearchByParamConfig(void 0);
312
273
  }
313
274
  }
314
275
  });
315
- var containerHeightMode = !containerHeight || typeof containerHeight === 'object' ? 'preset' : containerHeight;
316
- return /*#__PURE__*/React.createElement(S.ListContainer, _extends({
317
- "data-testid": "ds-item-picker-dropdown",
318
- ref: combinedScrollRef,
319
- onKeyDown: handleKeyDown,
320
- containerHeightMode: containerHeightMode,
321
- wrapperHeight: outerWrapperHeight
322
- }, htmlAttributes), includeSearchBar && /*#__PURE__*/React.createElement(ListSearchInput, {
323
- clearSearchQuery: clearSearchQuery,
324
- searchByParamConfig: searchByParamConfig,
325
- setSearchByParamConfig: setSearchByParamConfig,
326
- searchBarProps: searchBarProps,
327
- debouncedChangeSearchQuery: debouncedSearchQueryChange,
328
- inputRef: inputRef,
329
- changeLocalSearchQueryRef: changeLocalSearchQueryRef,
330
- allTexts: allTexts,
331
- canPerformListActions: canPerformListActions
332
- }), /*#__PURE__*/React.createElement(S.ListWrapper, {
333
- "data-testid": "list-wrapper",
334
- ref: scrollContainRef,
335
- wrapperHeight: listWrapperHeight,
336
- centered: showMessage,
337
- offsetSpace: offsetSpace
338
- }, listContent), includeFooter && /*#__PURE__*/React.createElement(ItemPickerListFooter, {
339
- "data-testid": "footer-wrapper",
340
- texts: allTexts,
341
- onRefresh: handleRefresh,
342
- refreshButtonProps: {
276
+ const containerHeightMode = !containerHeight || typeof containerHeight === "object" ? "preset" : containerHeight;
277
+ return /* @__PURE__ */ jsxs(ListContainer, { "data-testid": "ds-item-picker-dropdown", ref: combinedScrollRef, onKeyDown: handleKeyDown, containerHeightMode, wrapperHeight: outerWrapperHeight, ...htmlAttributes, children: [
278
+ includeSearchBar && /* @__PURE__ */ jsx(ListSearchInput, { clearSearchQuery, searchByParamConfig, setSearchByParamConfig, searchBarProps, debouncedChangeSearchQuery: debouncedSearchQueryChange, inputRef, changeLocalSearchQueryRef, allTexts, canPerformListActions }),
279
+ /* @__PURE__ */ jsx(ListWrapper, { "data-testid": "list-wrapper", ref: scrollContainRef, wrapperHeight: listWrapperHeight, centered: showMessage, offsetSpace, children: listContent }),
280
+ includeFooter && /* @__PURE__ */ jsx(ItemPickerListFooter, { "data-testid": "footer-wrapper", texts: allTexts, onRefresh: handleRefresh, refreshButtonProps: {
343
281
  disabled: !refreshEnabled
344
- }
345
- }));
282
+ } })
283
+ ] });
284
+ };
285
+ const ItemPickerList = forwardRef(ItemPickerListInner);
286
+ export {
287
+ ItemPickerList
346
288
  };
347
- export var ItemPickerList = /*#__PURE__*/forwardRef(ItemPickerListInner);
@@ -1,31 +1,31 @@
1
- import { VariableSizeList } from 'react-window';
2
- export declare const ListWrapper: import("styled-components").StyledComponent<"div", any, {
1
+ import { VariableSizeList } from '../../../../../../config/vitest/__mocks__/reactWindowMock.js';
2
+ export declare const ListWrapper: import('styled-components').StyledComponent<"div", any, {
3
3
  wrapperHeight?: number;
4
4
  centered?: boolean;
5
5
  offsetSpace: number;
6
6
  }, never>;
7
- export declare const ListContainer: import("styled-components").StyledComponent<"div", any, {
7
+ export declare const ListContainer: import('styled-components').StyledComponent<"div", any, {
8
8
  containerHeightMode?: "fillSpace" | "fitContent" | "preset";
9
9
  wrapperHeight: string;
10
10
  }, never>;
11
- export declare const SearchWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
12
- export declare const EmptyStates: import("styled-components").StyledComponent<({ size, label, text, button, fontSize, customIcon, className, mode, iconPosition, textAlign, }: import("@synerise/ds-empty-states").EmptyStatesProps) => React.JSX.Element, any, {}, never>;
13
- export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
14
- export declare const FooterWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
15
- export declare const FooterWrapperRight: import("styled-components").StyledComponent<"div", any, {}, never>;
16
- export declare const FooterWrapperLeft: import("styled-components").StyledComponent<"div", any, {}, never>;
17
- export declare const ScrollContent: import("styled-components").StyledComponent<"div", any, {}, never>;
18
- export declare const StyledScrollbar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<(import("@synerise/ds-scrollbar").ScrollbarProps | import("@synerise/ds-scrollbar").VirtualScrollbarProps) & import("react").RefAttributes<HTMLElement>>, any, {
11
+ export declare const SearchWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
12
+ export declare const EmptyStates: import('styled-components').StyledComponent<({ size, label, text, button, fontSize, customIcon, className, mode, iconPosition, textAlign, }: import('@synerise/ds-empty-states').EmptyStatesProps) => React.JSX.Element, any, {}, never>;
13
+ export declare const IconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
14
+ export declare const FooterWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
15
+ export declare const FooterWrapperRight: import('styled-components').StyledComponent<"div", any, {}, never>;
16
+ export declare const FooterWrapperLeft: import('styled-components').StyledComponent<"div", any, {}, never>;
17
+ export declare const ScrollContent: import('styled-components').StyledComponent<"div", any, {}, never>;
18
+ export declare const StyledScrollbar: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<(import('@synerise/ds-scrollbar').ScrollbarProps | import('@synerise/ds-scrollbar').VirtualScrollbarProps) & import('react').RefAttributes<HTMLElement>>, any, {
19
19
  withSectionHeader?: boolean;
20
20
  }, never>;
21
- export declare const StyledList: import("styled-components").StyledComponent<typeof VariableSizeList, any, {
21
+ export declare const StyledList: import('styled-components').StyledComponent<typeof VariableSizeList, any, {
22
22
  maxHeight?: number;
23
23
  }, never>;
24
- export declare const Skeleton: import("styled-components").StyledComponent<({ size, numberOfSkeletons, width, height, className, }: import("@synerise/ds-skeleton").SkeletonProps) => React.JSX.Element, any, {}, never>;
25
- export declare const SkeletonWrapper: import("styled-components").StyledComponent<"div", any, {
24
+ export declare const Skeleton: import('styled-components').StyledComponent<({ size, numberOfSkeletons, width, height, className, }: import('@synerise/ds-skeleton').SkeletonProps) => React.JSX.Element, any, {}, never>;
25
+ export declare const SkeletonWrapper: import('styled-components').StyledComponent<"div", any, {
26
26
  wrapperHeight?: number;
27
27
  }, never>;
28
- export declare const Title: import("styled-components").StyledComponent<"div", any, {}, never>;
29
- export declare const SectionTitleWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
30
- export declare const InfiniteLoaderItemWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
31
- export declare const Loader: import("styled-components").StyledComponent<({ size, label, labelPosition, color, percent, percentFormatter, text, fontSize, mode, className, }: import("@synerise/ds-loader/dist/Loader.types").LoaderProps) => React.JSX.Element, any, {}, never>;
28
+ export declare const Title: import('styled-components').StyledComponent<"div", any, {}, never>;
29
+ export declare const SectionTitleWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
30
+ export declare const InfiniteLoaderItemWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
31
+ export declare const Loader: import('styled-components').StyledComponent<({ size, label, labelPosition, color, percent, percentFormatter, text, fontSize, mode, className, }: import('@synerise/ds-loader/dist/Loader.types').LoaderProps) => React.JSX.Element, any, {}, never>;