@synerise/ds-search 1.5.9 → 1.5.10
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 +4 -0
- package/dist/Elements/SearchButton/SearchButton.d.ts +2 -2
- package/dist/Elements/SearchButton/SearchButton.js +16 -28
- package/dist/Elements/SearchButton/SearchButton.types.js +1 -1
- package/dist/Elements/SearchHeader/SearchHeader.d.ts +2 -2
- package/dist/Elements/SearchHeader/SearchHeader.js +15 -15
- package/dist/Elements/SearchHeader/SearchHeader.types.js +1 -1
- package/dist/Elements/SearchInput/SearchInput.d.ts +2 -2
- package/dist/Elements/SearchInput/SearchInput.js +74 -117
- package/dist/Elements/SearchInput/SearchInput.types.d.ts +3 -3
- package/dist/Elements/SearchInput/SearchInput.types.js +1 -1
- package/dist/Elements/SearchItems/SearchItems.d.ts +2 -2
- package/dist/Elements/SearchItems/SearchItems.js +54 -58
- package/dist/Elements/SearchItems/SearchItems.types.d.ts +1 -1
- package/dist/Elements/SearchItems/SearchItems.types.js +1 -1
- package/dist/Elements/SearchRenderer/SearchRenderer.d.ts +1 -1
- package/dist/Elements/SearchRenderer/SearchRenderer.js +22 -33
- package/dist/Elements/SearchRenderer/SearchRenderer.types.d.ts +2 -2
- package/dist/Elements/SearchRenderer/SearchRenderer.types.js +1 -1
- package/dist/Elements/index.js +12 -4
- package/dist/Elements/utils/searchUtils.d.ts +1 -1
- package/dist/Elements/utils/searchUtils.js +16 -17
- package/dist/Search.d.ts +2 -3
- package/dist/Search.js +145 -230
- package/dist/Search.styles.d.ts +15 -15
- package/dist/Search.styles.js +59 -62
- package/dist/Search.types.d.ts +4 -4
- package/dist/Search.types.js +8 -7
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/const.js +16 -7
- package/dist/index.js +14 -2
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +11 -11
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { LIST_HEADER_HEIGHT } from
|
|
2
|
-
|
|
3
|
-
return data && data.filter(
|
|
4
|
-
return String(el[elementTextLookupKey]).toLowerCase().includes(value.toLocaleLowerCase());
|
|
5
|
-
}) || [];
|
|
1
|
+
import { LIST_HEADER_HEIGHT } from "../../const.js";
|
|
2
|
+
const getAllElementsFiltered = (data, value, elementTextLookupKey) => {
|
|
3
|
+
return data && data.filter((el) => String(el[elementTextLookupKey]).toLowerCase().includes(value.toLocaleLowerCase())) || [];
|
|
6
4
|
};
|
|
7
|
-
|
|
8
|
-
return !!data && data.some(
|
|
9
|
-
return String(el[elementTextLookupKey]).toLowerCase().includes(currentValue.toLocaleLowerCase());
|
|
10
|
-
}) || false;
|
|
5
|
+
const hasSomeElementFiltered = (data, currentValue, elementTextLookupKey) => {
|
|
6
|
+
return !!data && data.some((el) => String(el[elementTextLookupKey]).toLowerCase().includes(currentValue.toLocaleLowerCase())) || false;
|
|
11
7
|
};
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const hasSomeElement = (data) => !!data && data.length > 0;
|
|
9
|
+
const getParametersScrollTop = ({
|
|
10
|
+
scrollTop,
|
|
11
|
+
rowHeight,
|
|
12
|
+
recent
|
|
13
|
+
}) => scrollTop - LIST_HEADER_HEIGHT - (hasSomeElement(recent) ? recent.length * rowHeight : 0);
|
|
14
|
+
export {
|
|
15
|
+
getAllElementsFiltered,
|
|
16
|
+
getParametersScrollTop,
|
|
17
|
+
hasSomeElement,
|
|
18
|
+
hasSomeElementFiltered
|
|
14
19
|
};
|
|
15
|
-
export var getParametersScrollTop = function getParametersScrollTop(_ref) {
|
|
16
|
-
var scrollTop = _ref.scrollTop,
|
|
17
|
-
rowHeight = _ref.rowHeight,
|
|
18
|
-
recent = _ref.recent;
|
|
19
|
-
return scrollTop - LIST_HEADER_HEIGHT - (hasSomeElement(recent) ? recent.length * rowHeight : 0);
|
|
20
|
-
};
|
package/dist/Search.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import './style/index.less';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AnyObject, SearchProps } from './Search.types';
|
|
4
3
|
export declare function Search<T extends AnyObject, U extends AnyObject, S extends AnyObject>({ divider, dropdownMaxHeight, width, searchWidth, style, dropdownWidth, recent, suggestions, parameters, value, textLookupConfig, hideLabel, parameterValue, onParameterValueChange, alwaysExpanded, onClear, onValueChange, filterLookupKey, recentDisplayProps, parametersDisplayProps, suggestionsDisplayProps, placeholder, clearTooltip, disableInput, inputProps, searchTooltipProps, }: SearchProps<T, U, S>): React.JSX.Element;
|
|
5
4
|
export default Search;
|
package/dist/Search.js
CHANGED
|
@@ -1,154 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import Scrollbar from
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useEffect } from "react";
|
|
3
|
+
import Scrollbar from "@synerise/ds-scrollbar";
|
|
4
|
+
import { useOnClickOutside, focusWithArrowKeys } from "@synerise/ds-utils";
|
|
5
|
+
import SearchInput from "./Elements/SearchInput/SearchInput.js";
|
|
6
|
+
import "@synerise/ds-icon";
|
|
7
|
+
import "@synerise/ds-tooltip/dist/Tooltip";
|
|
8
|
+
import { SearchWrapper, SearchDropdownWrapper, SearchDropdownContent } from "./Search.styles.js";
|
|
9
|
+
import "react-window";
|
|
10
|
+
import "@synerise/ds-list-item";
|
|
11
|
+
import "@synerise/ds-menu";
|
|
12
|
+
import "@synerise/ds-button";
|
|
13
|
+
import SearchRenderer from "./Elements/SearchRenderer/SearchRenderer.js";
|
|
14
|
+
import { getAllElementsFiltered, hasSomeElement, getParametersScrollTop, hasSomeElementFiltered } from "./Elements/utils/searchUtils.js";
|
|
15
|
+
import { SelectResultDataKeys } from "./Search.types.js";
|
|
16
|
+
import { MENU_WIDTH_OFFSET, SCROLLBAR_HEIGHT_OFFSET, INPUT_EXPAND_ANIMATION_DURATION } from "./const.js";
|
|
11
17
|
import "./style/index.css";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (parameterValue) {
|
|
43
|
-
var _ref2;
|
|
44
|
-
var found = parameters.find(function (param) {
|
|
45
|
-
return param[textLookupConfig.parameters] === parameterValue;
|
|
46
|
-
});
|
|
47
|
-
return (_ref2 = found) != null ? _ref2 : null;
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}),
|
|
51
|
-
label = _useState[0],
|
|
52
|
-
setLabel = _useState[1];
|
|
53
|
-
var _useState2 = useState(parameters),
|
|
54
|
-
filteredParameters = _useState2[0],
|
|
55
|
-
setFilteredParameters = _useState2[1];
|
|
56
|
-
var _useState3 = useState(recent),
|
|
57
|
-
filteredRecent = _useState3[0],
|
|
58
|
-
setFilteredRecent = _useState3[1];
|
|
59
|
-
var _useState4 = useState(suggestions != null ? suggestions : null),
|
|
60
|
-
filteredSuggestions = _useState4[0],
|
|
61
|
-
setFilteredSuggestions = _useState4[1];
|
|
62
|
-
var _useState5 = useState(false),
|
|
63
|
-
isListVisible = _useState5[0],
|
|
64
|
-
setIsListVisible = _useState5[1];
|
|
65
|
-
var _useState6 = useState(false),
|
|
66
|
-
isResultChosen = _useState6[0],
|
|
67
|
-
setIsResultChosen = _useState6[1];
|
|
68
|
-
var _useState7 = useState(false),
|
|
69
|
-
toggleInputTrigger = _useState7[0],
|
|
70
|
-
setToggleInputTrigger = _useState7[1];
|
|
71
|
-
var _useState8 = useState(false),
|
|
72
|
-
focusInputTrigger = _useState8[0],
|
|
73
|
-
setFocusInputTrigger = _useState8[1];
|
|
74
|
-
var _useState9 = useState(0),
|
|
75
|
-
scrollbarScrollTop = _useState9[0],
|
|
76
|
-
setScrollbarScrollTop = _useState9[1];
|
|
77
|
-
var _useState0 = useState(true),
|
|
78
|
-
moveCursorToEnd = _useState0[0],
|
|
79
|
-
setMoveCursorToEnd = _useState0[1];
|
|
80
|
-
var _useState1 = useState(width || searchWidth ? (width || searchWidth) - MENU_WIDTH_OFFSET : 0),
|
|
81
|
-
itemsListWidth = _useState1[0],
|
|
82
|
-
setItemsListWidth = _useState1[1];
|
|
83
|
-
useEffect(function () {
|
|
18
|
+
function Search({
|
|
19
|
+
divider,
|
|
20
|
+
dropdownMaxHeight,
|
|
21
|
+
width,
|
|
22
|
+
searchWidth,
|
|
23
|
+
style,
|
|
24
|
+
dropdownWidth,
|
|
25
|
+
recent,
|
|
26
|
+
suggestions = null,
|
|
27
|
+
parameters,
|
|
28
|
+
value,
|
|
29
|
+
textLookupConfig,
|
|
30
|
+
hideLabel,
|
|
31
|
+
parameterValue,
|
|
32
|
+
onParameterValueChange,
|
|
33
|
+
alwaysExpanded,
|
|
34
|
+
onClear,
|
|
35
|
+
onValueChange,
|
|
36
|
+
filterLookupKey,
|
|
37
|
+
recentDisplayProps,
|
|
38
|
+
parametersDisplayProps,
|
|
39
|
+
suggestionsDisplayProps,
|
|
40
|
+
placeholder,
|
|
41
|
+
clearTooltip,
|
|
42
|
+
disableInput,
|
|
43
|
+
inputProps,
|
|
44
|
+
searchTooltipProps
|
|
45
|
+
}) {
|
|
46
|
+
const wrapperRef = useRef(null);
|
|
47
|
+
const [label, setLabel] = useState(() => {
|
|
84
48
|
if (parameterValue) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
49
|
+
const found = parameters.find((param) => param[textLookupConfig.parameters] === parameterValue);
|
|
50
|
+
return found ?? null;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
});
|
|
54
|
+
const [filteredParameters, setFilteredParameters] = useState(parameters);
|
|
55
|
+
const [filteredRecent, setFilteredRecent] = useState(recent);
|
|
56
|
+
const [filteredSuggestions, setFilteredSuggestions] = useState(suggestions ?? null);
|
|
57
|
+
const [isListVisible, setIsListVisible] = useState(false);
|
|
58
|
+
const [isResultChosen, setIsResultChosen] = useState(false);
|
|
59
|
+
const [toggleInputTrigger, setToggleInputTrigger] = useState(false);
|
|
60
|
+
const [focusInputTrigger, setFocusInputTrigger] = useState(false);
|
|
61
|
+
const [scrollbarScrollTop, setScrollbarScrollTop] = useState(0);
|
|
62
|
+
const [moveCursorToEnd, setMoveCursorToEnd] = useState(true);
|
|
63
|
+
const [itemsListWidth, setItemsListWidth] = useState(width || searchWidth ? (width || searchWidth) - MENU_WIDTH_OFFSET : 0);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (parameterValue) {
|
|
66
|
+
const found = parameters.find((param) => param[textLookupConfig.parameters] === parameterValue);
|
|
67
|
+
setLabel(found ?? null);
|
|
90
68
|
} else {
|
|
91
69
|
setLabel(null);
|
|
92
70
|
}
|
|
93
71
|
}, [parameterValue, parameters, textLookupConfig.parameters]);
|
|
94
|
-
useEffect(
|
|
72
|
+
useEffect(() => {
|
|
95
73
|
setFilteredRecent(getAllElementsFiltered(recent, value, textLookupConfig.recent));
|
|
96
74
|
}, [recent, value, textLookupConfig.recent]);
|
|
97
|
-
useEffect(
|
|
75
|
+
useEffect(() => {
|
|
98
76
|
setFilteredParameters(parameterValue ? parameters : getAllElementsFiltered(parameters, value, textLookupConfig.parameters));
|
|
99
77
|
}, [parameters, value, parameterValue, textLookupConfig.parameters]);
|
|
100
|
-
useEffect(
|
|
78
|
+
useEffect(() => {
|
|
101
79
|
if (suggestions) {
|
|
102
80
|
setFilteredSuggestions(getAllElementsFiltered(suggestions, value, textLookupConfig.suggestions));
|
|
103
81
|
} else {
|
|
104
82
|
setFilteredSuggestions(null);
|
|
105
83
|
}
|
|
106
84
|
}, [suggestions, value, textLookupConfig.suggestions]);
|
|
107
|
-
useEffect(
|
|
108
|
-
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const newWidth = (width || searchWidth || 0) - MENU_WIDTH_OFFSET;
|
|
109
87
|
setItemsListWidth(Math.max(0, newWidth));
|
|
110
88
|
}, [width, searchWidth]);
|
|
111
|
-
useEffect(
|
|
89
|
+
useEffect(() => {
|
|
112
90
|
if (hideLabel) {
|
|
113
91
|
setLabel(null);
|
|
114
92
|
setIsResultChosen(false);
|
|
115
93
|
}
|
|
116
94
|
}, [hideLabel]);
|
|
117
|
-
useEffect(
|
|
95
|
+
useEffect(() => {
|
|
118
96
|
if (!value) {
|
|
119
97
|
setIsResultChosen(false);
|
|
120
98
|
}
|
|
121
99
|
}, [value]);
|
|
122
|
-
|
|
123
|
-
|
|
100
|
+
const handleScroll = (event) => {
|
|
101
|
+
const scrollTop = event.currentTarget.scrollTop;
|
|
124
102
|
setScrollbarScrollTop(scrollTop);
|
|
125
103
|
};
|
|
126
|
-
|
|
127
|
-
focusWithArrowKeys(event,
|
|
128
|
-
setFocusInputTrigger(
|
|
129
|
-
return !prev;
|
|
130
|
-
});
|
|
104
|
+
const handleKeyDownWrapper = (event) => {
|
|
105
|
+
focusWithArrowKeys(event, "ds-search-item", () => {
|
|
106
|
+
setFocusInputTrigger((prev) => !prev);
|
|
131
107
|
});
|
|
132
108
|
};
|
|
133
|
-
|
|
134
|
-
setFocusInputTrigger(
|
|
135
|
-
return !prev;
|
|
136
|
-
});
|
|
109
|
+
const handleDropdownClick = () => {
|
|
110
|
+
setFocusInputTrigger((prev) => !prev);
|
|
137
111
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (event.key ===
|
|
112
|
+
const mergedWidth = searchWidth !== void 0 ? searchWidth : width;
|
|
113
|
+
const onKeyDown = (event) => {
|
|
114
|
+
if (event.key === "Backspace" && value === "" && isOpen) {
|
|
141
115
|
setLabel(null);
|
|
142
116
|
setFilteredRecent(recent);
|
|
143
|
-
onParameterValueChange
|
|
117
|
+
onParameterValueChange?.("", null);
|
|
144
118
|
return;
|
|
145
119
|
}
|
|
146
|
-
if (event.key ===
|
|
120
|
+
if (event.key === "Enter" && isOpen) {
|
|
147
121
|
setIsResultChosen(!!value);
|
|
148
122
|
}
|
|
149
123
|
setMoveCursorToEnd(false);
|
|
150
124
|
};
|
|
151
|
-
|
|
125
|
+
const getSearchWrapperWidth = () => {
|
|
152
126
|
if (width) {
|
|
153
127
|
return width - MENU_WIDTH_OFFSET;
|
|
154
128
|
}
|
|
@@ -157,173 +131,114 @@ export function Search(_ref) {
|
|
|
157
131
|
}
|
|
158
132
|
return 0;
|
|
159
133
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
setIsOpen = _useState10[1];
|
|
163
|
-
useOnClickOutside(wrapperRef, function () {
|
|
134
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
135
|
+
useOnClickOutside(wrapperRef, () => {
|
|
164
136
|
if (isOpen && !value && !label && !alwaysExpanded) {
|
|
165
|
-
setToggleInputTrigger(
|
|
166
|
-
return !prev;
|
|
167
|
-
});
|
|
137
|
+
setToggleInputTrigger((prev) => !prev);
|
|
168
138
|
}
|
|
169
139
|
setIsOpen(false);
|
|
170
140
|
setIsListVisible(false);
|
|
171
141
|
setScrollbarScrollTop(0);
|
|
172
142
|
});
|
|
173
|
-
|
|
174
|
-
onClear
|
|
143
|
+
const handleClearValue = () => {
|
|
144
|
+
onClear?.();
|
|
175
145
|
setLabel(null);
|
|
176
146
|
setFilteredRecent(recent);
|
|
177
147
|
setFilteredParameters(parameters);
|
|
178
|
-
setFilteredSuggestions(suggestions
|
|
148
|
+
setFilteredSuggestions(suggestions ?? null);
|
|
179
149
|
setIsResultChosen(false);
|
|
180
150
|
};
|
|
181
|
-
|
|
182
|
-
onValueChange
|
|
151
|
+
const handleChange = (currentValue) => {
|
|
152
|
+
onValueChange?.(currentValue);
|
|
183
153
|
if (parameterValue) {
|
|
184
|
-
|
|
154
|
+
const matchingSuggestions = getAllElementsFiltered(suggestions ?? [], currentValue, textLookupConfig.suggestions);
|
|
185
155
|
setFilteredSuggestions(matchingSuggestions);
|
|
186
156
|
setIsResultChosen(false);
|
|
187
157
|
setIsListVisible(matchingSuggestions.length > 0);
|
|
188
158
|
} else {
|
|
189
|
-
|
|
190
|
-
|
|
159
|
+
const matchingRecent = getAllElementsFiltered(recent, currentValue, textLookupConfig.recent);
|
|
160
|
+
const matchingParameters = getAllElementsFiltered(parameters, currentValue, textLookupConfig.parameters);
|
|
191
161
|
setFilteredParameters(matchingParameters);
|
|
192
162
|
setFilteredRecent(matchingRecent);
|
|
193
163
|
setIsResultChosen(false);
|
|
194
164
|
setIsListVisible(matchingRecent.length > 0 || matchingParameters.length > 0);
|
|
195
165
|
}
|
|
196
166
|
};
|
|
197
|
-
|
|
167
|
+
const isListItemRendered = () => {
|
|
198
168
|
if (parameterValue) {
|
|
199
169
|
return hasSomeElementFiltered(suggestions, value, textLookupConfig.suggestions);
|
|
200
170
|
} else {
|
|
201
|
-
|
|
202
|
-
|
|
171
|
+
const anyRecentItem = hasSomeElementFiltered(recent, value, textLookupConfig.recent);
|
|
172
|
+
const anyFilter = hasSomeElementFiltered(parameters, value, textLookupConfig.parameters);
|
|
203
173
|
return anyRecentItem || anyFilter;
|
|
204
174
|
}
|
|
205
175
|
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
onValueChange
|
|
176
|
+
const selectResult = (item, dataKey) => {
|
|
177
|
+
const newValue = item[textLookupConfig[dataKey]];
|
|
178
|
+
onValueChange?.(newValue);
|
|
209
179
|
setIsResultChosen(true);
|
|
210
180
|
setMoveCursorToEnd(true);
|
|
211
181
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
onValueChange
|
|
182
|
+
const selectFilter = (item) => {
|
|
183
|
+
const paramKey = textLookupConfig.parameters;
|
|
184
|
+
const paramValue = item[paramKey];
|
|
185
|
+
onValueChange?.("");
|
|
216
186
|
setLabel(item);
|
|
217
|
-
setFocusInputTrigger(
|
|
218
|
-
return !prev;
|
|
219
|
-
});
|
|
187
|
+
setFocusInputTrigger((prev) => !prev);
|
|
220
188
|
setMoveCursorToEnd(true);
|
|
221
189
|
if (filterLookupKey && item[filterLookupKey]) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
onValueChange
|
|
225
|
-
onParameterValueChange
|
|
190
|
+
const inputValue = item[paramKey];
|
|
191
|
+
const filterValue = item[filterLookupKey];
|
|
192
|
+
onValueChange?.(inputValue);
|
|
193
|
+
onParameterValueChange?.(filterValue, item);
|
|
226
194
|
setIsResultChosen(true);
|
|
227
195
|
} else {
|
|
228
|
-
onParameterValueChange
|
|
196
|
+
onParameterValueChange?.(paramValue, item);
|
|
229
197
|
}
|
|
230
198
|
};
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
199
|
+
const widthDropdownSearch = dropdownWidth ? dropdownWidth - MENU_WIDTH_OFFSET : itemsListWidth;
|
|
200
|
+
const shouldRenderRecent = Boolean(recent && !label && hasSomeElement(filteredRecent));
|
|
201
|
+
const shouldRenderParameters = Boolean(parameters && !label && hasSomeElement(filteredParameters));
|
|
202
|
+
const shouldRenderSuggestions = Boolean(suggestions && suggestionsDisplayProps && parameterValue && !isResultChosen && filteredSuggestions && hasSomeElement(filteredSuggestions));
|
|
203
|
+
const renderInputWrapper = () => {
|
|
204
|
+
const handleInputClick = () => {
|
|
237
205
|
setIsOpen(true);
|
|
238
206
|
setIsListVisible(true);
|
|
239
207
|
setItemsListWidth(getSearchWrapperWidth());
|
|
240
208
|
};
|
|
241
|
-
|
|
209
|
+
const handleToggle = (toggle) => {
|
|
242
210
|
setIsOpen(toggle);
|
|
243
211
|
setIsListVisible(toggle);
|
|
244
|
-
setTimeout(
|
|
212
|
+
setTimeout(() => {
|
|
245
213
|
setItemsListWidth(getSearchWrapperWidth());
|
|
246
214
|
}, INPUT_EXPAND_ANIMATION_DURATION);
|
|
247
215
|
};
|
|
248
|
-
|
|
249
|
-
setFocusInputTrigger(
|
|
250
|
-
return !prev;
|
|
251
|
-
});
|
|
216
|
+
const handleButtonClick = () => {
|
|
217
|
+
setFocusInputTrigger((prev) => !prev);
|
|
252
218
|
};
|
|
253
|
-
return
|
|
254
|
-
alwaysHighlight: true,
|
|
255
|
-
clearTooltip: clearTooltip,
|
|
256
|
-
searchTooltipProps: searchTooltipProps,
|
|
257
|
-
filterLookupKey: filterLookupKey,
|
|
258
|
-
textLookupKey: String(textLookupConfig.parameters),
|
|
259
|
-
filterLabel: label,
|
|
260
|
-
focusTrigger: focusInputTrigger,
|
|
261
|
-
onButtonClick: handleButtonClick,
|
|
262
|
-
onChange: handleChange,
|
|
263
|
-
onClear: handleClearValue,
|
|
264
|
-
onClick: handleInputClick,
|
|
265
|
-
onKeyDown: onKeyDown,
|
|
266
|
-
onToggle: handleToggle,
|
|
267
|
-
placeholder: placeholder,
|
|
268
|
-
toggleTrigger: toggleInputTrigger,
|
|
269
|
-
value: value,
|
|
270
|
-
moveCursorToEnd: moveCursorToEnd,
|
|
271
|
-
disableInput: disableInput,
|
|
272
|
-
inputProps: inputProps,
|
|
273
|
-
alwaysExpanded: alwaysExpanded,
|
|
274
|
-
closeOnClickOutside: !alwaysExpanded && !isListVisible && !value && !label
|
|
275
|
-
});
|
|
219
|
+
return /* @__PURE__ */ jsx(SearchInput, { alwaysHighlight: true, clearTooltip, searchTooltipProps, filterLookupKey, textLookupKey: String(textLookupConfig.parameters), filterLabel: label, focusTrigger: focusInputTrigger, onButtonClick: handleButtonClick, onChange: handleChange, onClear: handleClearValue, onClick: handleInputClick, onKeyDown, onToggle: handleToggle, placeholder, toggleTrigger: toggleInputTrigger, value, moveCursorToEnd, disableInput, inputProps, alwaysExpanded, closeOnClickOutside: !alwaysExpanded && !isListVisible && !value && !label });
|
|
276
220
|
};
|
|
277
|
-
return
|
|
278
|
-
|
|
279
|
-
className: "
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
absolute: true,
|
|
292
|
-
maxHeight: dropdownMaxHeight - SCROLLBAR_HEIGHT_OFFSET,
|
|
293
|
-
onScroll: handleScroll
|
|
294
|
-
}, shouldRenderRecent && /*#__PURE__*/React.createElement(SearchRenderer, _extends({
|
|
295
|
-
data: filteredRecent,
|
|
296
|
-
highlight: value,
|
|
297
|
-
width: widthDropdownSearch,
|
|
298
|
-
onItemClick: function onItemClick(item) {
|
|
299
|
-
return selectResult(item, SelectResultDataKeys.RECENT);
|
|
300
|
-
}
|
|
301
|
-
}, recentDisplayProps)), !!(filteredParameters != null && filteredParameters.length) && !!(filteredRecent != null && filteredRecent.length) && !label && divider, shouldRenderParameters && /*#__PURE__*/React.createElement(SearchRenderer, _extends({
|
|
302
|
-
data: filteredParameters,
|
|
303
|
-
highlight: value,
|
|
304
|
-
width: widthDropdownSearch,
|
|
305
|
-
height: dropdownMaxHeight,
|
|
306
|
-
listProps: _extends({
|
|
307
|
-
scrollTop: getParametersScrollTop({
|
|
221
|
+
return /* @__PURE__ */ jsxs(SearchWrapper, { ref: wrapperRef, className: "SearchWrapper", inputOpen: isOpen, $width: mergedWidth, onKeyDown: handleKeyDownWrapper, style, children: [
|
|
222
|
+
renderInputWrapper(),
|
|
223
|
+
isListVisible && /* @__PURE__ */ jsx(SearchDropdownWrapper, { dropdownWidth, onClick: handleDropdownClick, children: /* @__PURE__ */ jsx(SearchDropdownContent, { maxHeight: dropdownMaxHeight, className: isOpen && !isResultChosen && isListItemRendered() ? "search-list-open" : "", children: /* @__PURE__ */ jsxs(Scrollbar, { absolute: true, maxHeight: dropdownMaxHeight - SCROLLBAR_HEIGHT_OFFSET, onScroll: handleScroll, children: [
|
|
224
|
+
shouldRenderRecent && /* @__PURE__ */ jsx(SearchRenderer, { data: filteredRecent, highlight: value, width: widthDropdownSearch, onItemClick: (item) => selectResult(item, SelectResultDataKeys.RECENT), ...recentDisplayProps }),
|
|
225
|
+
!!filteredParameters?.length && !!filteredRecent?.length && !label && divider,
|
|
226
|
+
shouldRenderParameters && /* @__PURE__ */ jsx(SearchRenderer, { data: filteredParameters, highlight: value, width: widthDropdownSearch, height: dropdownMaxHeight, listProps: {
|
|
227
|
+
scrollTop: getParametersScrollTop({
|
|
228
|
+
scrollTop: scrollbarScrollTop,
|
|
229
|
+
recent: filteredRecent,
|
|
230
|
+
rowHeight: recentDisplayProps.rowHeight
|
|
231
|
+
}),
|
|
232
|
+
...parametersDisplayProps.listProps || {}
|
|
233
|
+
}, onItemClick: (item) => selectFilter(item), ...parametersDisplayProps }),
|
|
234
|
+
shouldRenderSuggestions && /* @__PURE__ */ jsx(SearchRenderer, { data: filteredSuggestions || [], highlight: value, width: widthDropdownSearch, height: dropdownMaxHeight, listProps: {
|
|
308
235
|
scrollTop: scrollbarScrollTop,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
onItemClick: function onItemClick(item) {
|
|
314
|
-
return selectFilter(item);
|
|
315
|
-
}
|
|
316
|
-
}, parametersDisplayProps)), shouldRenderSuggestions && /*#__PURE__*/React.createElement(SearchRenderer, _extends({
|
|
317
|
-
data: filteredSuggestions || [],
|
|
318
|
-
highlight: value,
|
|
319
|
-
width: widthDropdownSearch,
|
|
320
|
-
height: dropdownMaxHeight,
|
|
321
|
-
listProps: _extends({
|
|
322
|
-
scrollTop: scrollbarScrollTop
|
|
323
|
-
}, (suggestionsDisplayProps == null ? void 0 : suggestionsDisplayProps.listProps) || {}),
|
|
324
|
-
onItemClick: function onItemClick(item) {
|
|
325
|
-
return selectResult(item, SelectResultDataKeys.SUGGESTIONS);
|
|
326
|
-
}
|
|
327
|
-
}, suggestionsDisplayProps))))));
|
|
236
|
+
...suggestionsDisplayProps?.listProps || {}
|
|
237
|
+
}, onItemClick: (item) => selectResult(item, SelectResultDataKeys.SUGGESTIONS), ...suggestionsDisplayProps })
|
|
238
|
+
] }) }) })
|
|
239
|
+
] });
|
|
328
240
|
}
|
|
329
|
-
export
|
|
241
|
+
export {
|
|
242
|
+
Search,
|
|
243
|
+
Search as default
|
|
244
|
+
};
|
package/dist/Search.styles.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
export declare const openDropdownAnimation: import(
|
|
2
|
-
export declare const SearchInputWrapper: import(
|
|
3
|
-
export declare const SearchWrapper: import(
|
|
1
|
+
export declare const openDropdownAnimation: import('styled-components').Keyframes;
|
|
2
|
+
export declare const SearchInputWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const SearchWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
4
4
|
$width?: number;
|
|
5
5
|
inputOpen?: boolean;
|
|
6
6
|
}, never>;
|
|
7
|
-
export declare const LeftSide: import(
|
|
7
|
+
export declare const LeftSide: import('styled-components').StyledComponent<"span", any, {
|
|
8
8
|
isOpen: boolean;
|
|
9
9
|
}, never>;
|
|
10
|
-
export declare const Filter: import(
|
|
11
|
-
export declare const Icon: import(
|
|
12
|
-
export declare const Label: import(
|
|
13
|
-
export declare const SearchButton: import(
|
|
10
|
+
export declare const Filter: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const Icon: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const Label: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
13
|
+
export declare const SearchButton: import('styled-components').StyledComponent<"div", any, {
|
|
14
14
|
isOpen: boolean;
|
|
15
15
|
clickable?: boolean;
|
|
16
16
|
inputFocused?: boolean;
|
|
17
17
|
}, never>;
|
|
18
|
-
export declare const SearchInner: import(
|
|
18
|
+
export declare const SearchInner: import('styled-components').StyledComponent<"div", any, {
|
|
19
19
|
hasValue: boolean;
|
|
20
20
|
alwaysHighlight?: boolean;
|
|
21
21
|
}, never>;
|
|
22
|
-
export declare const SearchInputContent: import(
|
|
22
|
+
export declare const SearchInputContent: import('styled-components').StyledComponent<"div", any, {
|
|
23
23
|
offset: number;
|
|
24
24
|
filterLabel: object | null | undefined;
|
|
25
25
|
}, never>;
|
|
26
|
-
export declare const ClearButton: import(
|
|
27
|
-
export declare const SearchDropdownContent: import(
|
|
26
|
+
export declare const ClearButton: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
27
|
+
export declare const SearchDropdownContent: import('styled-components').StyledComponent<"div", any, {
|
|
28
28
|
isOpen?: boolean;
|
|
29
29
|
maxHeight: number;
|
|
30
30
|
}, never>;
|
|
31
|
-
export declare const MenuHeader: import(
|
|
32
|
-
export declare const HeaderIconWrapper: import(
|
|
33
|
-
export declare const SearchDropdownWrapper: import(
|
|
31
|
+
export declare const MenuHeader: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
32
|
+
export declare const HeaderIconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
33
|
+
export declare const SearchDropdownWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
34
34
|
dropdownWidth?: number;
|
|
35
35
|
}, never>;
|