@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.
- package/CHANGELOG.md +8 -0
- package/dist/ItemPicker.d.ts +5 -5
- package/dist/ItemPicker.js +13 -17
- package/dist/ItemPicker.styles.d.ts +1 -1
- package/dist/ItemPicker.styles.js +6 -3
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.d.ts +2 -2
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.js +58 -99
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.d.ts +7 -7
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.js +22 -19
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.d.ts +4 -4
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.js +1 -1
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.d.ts +2 -2
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.js +89 -152
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.d.ts +8 -8
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.js +1 -1
- package/dist/components/ItemPickerList/ItemPickerList.d.ts +4 -4
- package/dist/components/ItemPickerList/ItemPickerList.js +199 -267
- package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +18 -18
- package/dist/components/ItemPickerList/ItemPickerList.styles.js +55 -64
- package/dist/components/ItemPickerList/ItemPickerList.types.d.ts +3 -3
- package/dist/components/ItemPickerList/ItemPickerList.types.js +1 -1
- package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +3 -3
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +27 -40
- package/dist/components/ItemPickerList/components/ErrorItem.d.ts +1 -1
- package/dist/components/ItemPickerList/components/ErrorItem.js +10 -9
- package/dist/components/ItemPickerList/components/ErrorMessage.d.ts +2 -2
- package/dist/components/ItemPickerList/components/ErrorMessage.js +12 -15
- package/dist/components/ItemPickerList/components/InfiniteLoaderItem.d.ts +2 -2
- package/dist/components/ItemPickerList/components/InfiniteLoaderItem.js +19 -17
- package/dist/components/ItemPickerList/components/ItemPickerListFooter.d.ts +3 -3
- package/dist/components/ItemPickerList/components/ItemPickerListFooter.js +21 -20
- package/dist/components/ItemPickerList/components/ItemPickerListRow.d.ts +4 -4
- package/dist/components/ItemPickerList/components/ItemPickerListRow.js +42 -43
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.d.ts +1 -1
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.js +16 -23
- package/dist/components/ItemPickerList/components/ListSearchInput.d.ts +4 -4
- package/dist/components/ItemPickerList/components/ListSearchInput.js +36 -51
- package/dist/components/ItemPickerList/components/LoadingItem.d.ts +1 -1
- package/dist/components/ItemPickerList/components/LoadingItem.js +10 -9
- package/dist/components/ItemPickerList/components/NoMoreItem.d.ts +1 -1
- package/dist/components/ItemPickerList/components/NoMoreItem.js +10 -9
- package/dist/components/ItemPickerList/components/index.js +14 -6
- package/dist/components/ItemPickerList/constants.d.ts +2 -2
- package/dist/components/ItemPickerList/constants.js +47 -26
- package/dist/components/ItemPickerList/hooks/index.js +8 -3
- package/dist/components/ItemPickerList/hooks/useFlattenFolders.d.ts +2 -2
- package/dist/components/ItemPickerList/hooks/useFlattenFolders.js +40 -61
- package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +7 -7
- package/dist/components/ItemPickerList/hooks/useItemsInSections.js +342 -443
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.d.ts +5 -5
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.js +77 -74
- package/dist/components/ItemPickerList/hooks/useListHeight.d.ts +2 -2
- package/dist/components/ItemPickerList/hooks/useListHeight.js +37 -41
- package/dist/components/ItemPickerList/types/renderMode.js +8 -5
- package/dist/components/ItemPickerList/utils/actionItemsUtils.d.ts +4 -4
- package/dist/components/ItemPickerList/utils/actionItemsUtils.js +92 -92
- package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.d.ts +2 -2
- package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.js +7 -4
- package/dist/components/ItemPickerList/utils/findSectionById.d.ts +1 -1
- package/dist/components/ItemPickerList/utils/findSectionById.js +10 -12
- package/dist/components/ItemPickerList/utils/getContextAwareActions.d.ts +1 -1
- package/dist/components/ItemPickerList/utils/getContextAwareActions.js +19 -15
- package/dist/components/ItemPickerList/utils/getSearchByActionItems.d.ts +2 -2
- package/dist/components/ItemPickerList/utils/getSearchByActionItems.js +28 -29
- package/dist/components/ItemPickerList/utils/index.js +16 -4
- package/dist/components/ItemPickerList/utils/isNavKey.d.ts +1 -1
- package/dist/components/ItemPickerList/utils/isNavKey.js +6 -3
- package/dist/components/ItemPickerList/utils/resolveSectionId.d.ts +2 -2
- package/dist/components/ItemPickerList/utils/resolveSectionId.js +15 -9
- package/dist/components/ItemPickerList/utils/typeguards.utils.d.ts +5 -5
- package/dist/components/ItemPickerList/utils/typeguards.utils.js +23 -14
- package/dist/components/ItemPickerNew/ItemPickerNew.d.ts +4 -4
- package/dist/components/ItemPickerNew/ItemPickerNew.js +55 -100
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +13 -13
- package/dist/components/ItemPickerNew/ItemPickerNew.types.js +1 -1
- package/dist/components/ItemPickerNew/types/actions.types.d.ts +2 -2
- package/dist/components/ItemPickerNew/types/actions.types.js +10 -6
- package/dist/components/ItemPickerNew/types/baseItemSectionType.types.d.ts +3 -3
- package/dist/components/ItemPickerNew/types/baseItemSectionType.types.js +1 -1
- package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.d.ts +1 -1
- package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.js +1 -1
- package/dist/components/ItemPickerTrigger/Trigger.d.ts +5 -5
- package/dist/components/ItemPickerTrigger/Trigger.js +71 -111
- package/dist/components/ItemPickerTrigger/Trigger.styles.d.ts +12 -12
- package/dist/components/ItemPickerTrigger/Trigger.styles.js +70 -93
- package/dist/components/ItemPickerTrigger/Trigger.types.d.ts +3 -3
- package/dist/components/ItemPickerTrigger/Trigger.types.js +1 -1
- package/dist/hooks/useDefaultTexts.d.ts +1 -1
- package/dist/hooks/useDefaultTexts.js +116 -121
- package/dist/index.js +14 -6
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +25 -25
|
@@ -1,283 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
changeLocalSearchQueryRef.current
|
|
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
|
-
|
|
71
|
+
const debouncedSearchQueryChange = useRef(debounce((query) => {
|
|
70
72
|
changeSearchQuery(query);
|
|
71
73
|
}, 300)).current;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
119
|
-
activeSectionId
|
|
120
|
-
reloadActiveSection
|
|
119
|
+
currentSection,
|
|
120
|
+
activeSectionId,
|
|
121
|
+
reloadActiveSection
|
|
121
122
|
};
|
|
122
123
|
}, [activeSectionId, currentSection, reloadActiveSection]);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
138
|
+
const max = scrollHeight - clientHeight;
|
|
135
139
|
if (scrollTop >= max - 20) {
|
|
136
140
|
handleScrollEndReach();
|
|
137
141
|
}
|
|
138
142
|
}, [handleScrollEndReach, isDropdown, isVisible]);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
143
|
+
const focusSearchInput = useCallback(() => {
|
|
144
|
+
inputRef.current?.focus();
|
|
142
145
|
}, []);
|
|
143
|
-
|
|
146
|
+
const handleKeyDown = (event) => {
|
|
144
147
|
if (isNavKey(event)) {
|
|
145
|
-
focusWithArrowKeys(event, classNames.split(
|
|
148
|
+
focusWithArrowKeys(event, classNames.split(" ")[1], () => {
|
|
146
149
|
focusSearchInput();
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
};
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
} :
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
+
const showMessage = !isLoading && !isLoadingItems && (mergedItemsList?.length === 0 || isLoadingError);
|
|
198
|
+
const listContent = useMemo(() => {
|
|
197
199
|
if (isLoadingError) {
|
|
198
|
-
return
|
|
199
|
-
texts: allTexts
|
|
200
|
-
});
|
|
200
|
+
return /* @__PURE__ */ jsx(ErrorMessage, { texts: allTexts });
|
|
201
201
|
}
|
|
202
202
|
if (isLoading || isLoadingItems) {
|
|
203
|
-
return
|
|
204
|
-
wrapperHeight: listWrapperHeight
|
|
205
|
-
});
|
|
203
|
+
return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight });
|
|
206
204
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return
|
|
214
|
-
|
|
215
|
-
|
|
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
|
|
220
|
-
tooltipProps: {
|
|
215
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
216
|
+
isSection && /* @__PURE__ */ jsx(Dropdown.BackAction, { tooltipProps: {
|
|
221
217
|
title: allTexts.backTooltip,
|
|
222
|
-
shortCuts: [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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(
|
|
223
|
+
useEffect(() => {
|
|
269
224
|
setTimeout(focusSearchInput, 0);
|
|
270
225
|
}, [isLoading, isLoadingItems, isLoadingMore, focusSearchInput]);
|
|
271
|
-
useEffect(
|
|
226
|
+
useEffect(() => {
|
|
272
227
|
if (isVisible) {
|
|
273
228
|
resetCurrentSection();
|
|
274
229
|
clearSearchQuery();
|
|
275
|
-
setSearchByParamConfig(
|
|
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(
|
|
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(
|
|
243
|
+
useEffect(() => {
|
|
290
244
|
listRef.current && listRef.current.resetAfterIndex(0);
|
|
291
245
|
}, [mergedItemsList]);
|
|
292
246
|
useKeyboardShortcuts({
|
|
293
|
-
ArrowLeft:
|
|
294
|
-
|
|
295
|
-
if (!((_combinedScrollRef$cu = combinedScrollRef.current) != null && _combinedScrollRef$cu.offsetParent)) {
|
|
247
|
+
ArrowLeft: (event) => {
|
|
248
|
+
if (!combinedScrollRef.current?.offsetParent) {
|
|
296
249
|
return;
|
|
297
250
|
}
|
|
298
|
-
|
|
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:
|
|
307
|
-
|
|
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(
|
|
272
|
+
setSearchByParamConfig(void 0);
|
|
321
273
|
}
|
|
322
274
|
}
|
|
323
275
|
});
|
|
324
|
-
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
ref:
|
|
328
|
-
|
|
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 '
|
|
2
|
-
export declare const ListWrapper: import(
|
|
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(
|
|
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(
|
|
12
|
-
export declare const EmptyStates: import(
|
|
13
|
-
export declare const IconWrapper: import(
|
|
14
|
-
export declare const FooterWrapper: import(
|
|
15
|
-
export declare const FooterWrapperRight: import(
|
|
16
|
-
export declare const FooterWrapperLeft: import(
|
|
17
|
-
export declare const ScrollContent: import(
|
|
18
|
-
export declare const StyledScrollbar: import(
|
|
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(
|
|
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(
|
|
25
|
-
export declare const SkeletonWrapper: import(
|
|
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(
|
|
29
|
-
export declare const SectionTitleWrapper: import(
|
|
30
|
-
export declare const InfiniteLoaderItemWrapper: import(
|
|
31
|
-
export declare const Loader: import(
|
|
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>;
|