@synerise/ds-item-picker 1.17.0 → 1.17.2

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