@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.
- package/CHANGELOG.md +14 -0
- package/README.md +2 -3
- 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 +5 -5
- package/dist/components/ItemPickerList/ItemPickerList.js +199 -258
- 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 +10 -5
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +33 -29
- 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 +59 -101
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +18 -16
- 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 +2 -2
- 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 -117
- 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,274 +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
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
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);
|
|
63
69
|
setSearchQuery(query);
|
|
64
70
|
}, []);
|
|
65
|
-
|
|
71
|
+
const debouncedSearchQueryChange = useRef(debounce((query) => {
|
|
66
72
|
changeSearchQuery(query);
|
|
67
73
|
}, 300)).current;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
|
115
|
-
activeSectionId
|
|
116
|
-
reloadActiveSection
|
|
119
|
+
currentSection,
|
|
120
|
+
activeSectionId,
|
|
121
|
+
reloadActiveSection
|
|
117
122
|
};
|
|
118
123
|
}, [activeSectionId, currentSection, reloadActiveSection]);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
138
|
+
const max = scrollHeight - clientHeight;
|
|
131
139
|
if (scrollTop >= max - 20) {
|
|
132
140
|
handleScrollEndReach();
|
|
133
141
|
}
|
|
134
142
|
}, [handleScrollEndReach, isDropdown, isVisible]);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
143
|
+
const focusSearchInput = useCallback(() => {
|
|
144
|
+
inputRef.current?.focus();
|
|
138
145
|
}, []);
|
|
139
|
-
|
|
146
|
+
const handleKeyDown = (event) => {
|
|
140
147
|
if (isNavKey(event)) {
|
|
141
|
-
focusWithArrowKeys(event, classNames.split(
|
|
148
|
+
focusWithArrowKeys(event, classNames.split(" ")[1], () => {
|
|
142
149
|
focusSearchInput();
|
|
143
150
|
});
|
|
144
151
|
}
|
|
145
152
|
};
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
} :
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
192
|
-
|
|
197
|
+
const showMessage = !isLoading && !isLoadingItems && (mergedItemsList?.length === 0 || isLoadingError);
|
|
198
|
+
const listContent = useMemo(() => {
|
|
193
199
|
if (isLoadingError) {
|
|
194
|
-
return
|
|
195
|
-
texts: allTexts
|
|
196
|
-
});
|
|
200
|
+
return /* @__PURE__ */ jsx(ErrorMessage, { texts: allTexts });
|
|
197
201
|
}
|
|
198
202
|
if (isLoading || isLoadingItems) {
|
|
199
|
-
return
|
|
200
|
-
wrapperHeight: listWrapperHeight
|
|
201
|
-
});
|
|
203
|
+
return /* @__PURE__ */ jsx(ItemPickerListSkeleton, { wrapperHeight: listWrapperHeight });
|
|
202
204
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
|
|
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
|
|
216
|
-
tooltipProps: {
|
|
215
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
216
|
+
isSection && /* @__PURE__ */ jsx(Dropdown.BackAction, { tooltipProps: {
|
|
217
217
|
title: allTexts.backTooltip,
|
|
218
|
-
shortCuts: [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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(
|
|
223
|
+
useEffect(() => {
|
|
260
224
|
setTimeout(focusSearchInput, 0);
|
|
261
225
|
}, [isLoading, isLoadingItems, isLoadingMore, focusSearchInput]);
|
|
262
|
-
useEffect(
|
|
226
|
+
useEffect(() => {
|
|
263
227
|
if (isVisible) {
|
|
264
228
|
resetCurrentSection();
|
|
265
229
|
clearSearchQuery();
|
|
266
|
-
setSearchByParamConfig(
|
|
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(
|
|
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(
|
|
243
|
+
useEffect(() => {
|
|
281
244
|
listRef.current && listRef.current.resetAfterIndex(0);
|
|
282
245
|
}, [mergedItemsList]);
|
|
283
246
|
useKeyboardShortcuts({
|
|
284
|
-
ArrowLeft:
|
|
285
|
-
|
|
286
|
-
if (!((_combinedScrollRef$cu = combinedScrollRef.current) != null && _combinedScrollRef$cu.offsetParent)) {
|
|
247
|
+
ArrowLeft: (event) => {
|
|
248
|
+
if (!combinedScrollRef.current?.offsetParent) {
|
|
287
249
|
return;
|
|
288
250
|
}
|
|
289
|
-
|
|
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:
|
|
298
|
-
|
|
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(
|
|
272
|
+
setSearchByParamConfig(void 0);
|
|
312
273
|
}
|
|
313
274
|
}
|
|
314
275
|
});
|
|
315
|
-
|
|
316
|
-
return
|
|
317
|
-
|
|
318
|
-
ref:
|
|
319
|
-
|
|
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 '
|
|
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>;
|