@usereactify/search 3.6.0 → 3.8.0
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/dist/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +5 -1
- package/dist/hooks/reactivesearch/useReactiveDataSearchProps.js +5 -20
- package/dist/result/ResultList.d.ts +1 -0
- package/dist/result/ResultList.js +3 -2
- package/dist/search/SearchInput.d.ts +1 -0
- package/dist/search/SearchInput.js +2 -4
- package/package.json +1 -1
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
declare type Props = {
|
|
2
|
+
[key: string]: any;
|
|
2
3
|
debounce?: number;
|
|
3
4
|
placeholder?: string;
|
|
4
5
|
inputClassName?: string;
|
|
5
6
|
};
|
|
6
7
|
export declare const useReactiveDataSearchProps: (props?: Props) => {
|
|
8
|
+
debounce?: number | undefined;
|
|
9
|
+
placeholder: string;
|
|
10
|
+
inputClassName?: string | undefined;
|
|
11
|
+
type: string;
|
|
7
12
|
showIcon: boolean;
|
|
8
13
|
fuzziness: 0 | 1 | 2 | "AUTO";
|
|
9
14
|
queryFormat: "and" | "or";
|
|
@@ -11,7 +16,6 @@ export declare const useReactiveDataSearchProps: (props?: Props) => {
|
|
|
11
16
|
value: string;
|
|
12
17
|
onKeyUp: (e: any) => void;
|
|
13
18
|
componentId: string;
|
|
14
|
-
placeholder: string;
|
|
15
19
|
dataField: string[];
|
|
16
20
|
fieldWeights: number[];
|
|
17
21
|
onChange: (value: string, triggerQuery: () => {}) => void;
|
|
@@ -45,35 +45,20 @@ const useReactiveDataSearchProps = (props = {}) => {
|
|
|
45
45
|
}, {
|
|
46
46
|
wait: debounce !== null && debounce !== void 0 ? debounce : 300,
|
|
47
47
|
});
|
|
48
|
-
return react_1.default.useMemo(() => ({
|
|
49
|
-
showIcon: false,
|
|
50
|
-
fuzziness: 1,
|
|
51
|
-
queryFormat: "and",
|
|
52
|
-
autosuggest: false,
|
|
53
|
-
value: searchQuery !== null && searchQuery !== void 0 ? searchQuery : "",
|
|
54
|
-
onKeyUp: handleKeyPress,
|
|
55
|
-
componentId: "SearchInput",
|
|
56
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Search for a product...",
|
|
57
|
-
dataField: searchFields.map((field) => field.field),
|
|
58
|
-
fieldWeights: searchFields.map((field) => field.importance),
|
|
59
|
-
onChange: (value, triggerQuery) => {
|
|
48
|
+
return react_1.default.useMemo(() => (Object.assign({ type: "search", showIcon: false, fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchQuery !== null && searchQuery !== void 0 ? searchQuery : "", onKeyUp: handleKeyPress, componentId: "SearchInput", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Search for a product...", dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), onChange: (value, triggerQuery) => {
|
|
60
49
|
setSearchQuery(value);
|
|
61
50
|
if (!!value)
|
|
62
51
|
runDebouncedTriggerQuery(triggerQuery);
|
|
63
52
|
else
|
|
64
53
|
cancelDebouncedTriggerQuery();
|
|
65
|
-
},
|
|
66
|
-
onBlur: () => {
|
|
54
|
+
}, onBlur: () => {
|
|
67
55
|
// requestAnimationFrame ensures that results are still clickable before close
|
|
68
56
|
window.requestAnimationFrame(() => setShowInstantSearchResults(false));
|
|
69
|
-
},
|
|
70
|
-
onFocus: () => {
|
|
57
|
+
}, onFocus: () => {
|
|
71
58
|
setShowInstantSearchResults(true);
|
|
72
|
-
},
|
|
73
|
-
innerClass: {
|
|
59
|
+
}, innerClass: {
|
|
74
60
|
input: inputClassName,
|
|
75
|
-
},
|
|
76
|
-
}), [
|
|
61
|
+
} }, props)), [
|
|
77
62
|
searchQuery,
|
|
78
63
|
handleKeyPress,
|
|
79
64
|
placeholder,
|
|
@@ -23,7 +23,7 @@ const ResultList = (props) => {
|
|
|
23
23
|
};
|
|
24
24
|
exports.ResultList = ResultList;
|
|
25
25
|
const ResultListInner = (props) => {
|
|
26
|
-
const { gridColumns, renderError, renderAfter, renderBefore, renderLoading, listClassName, renderResults, renderNoResults, renderResultCard, renderLoadMoreButton, renderResultCardCallout, reactivesearchResultProps, } = props;
|
|
26
|
+
const { gridGap, gridColumns, renderError, renderAfter, renderBefore, renderLoading, listClassName, renderResults, renderNoResults, renderResultCard, renderLoadMoreButton, renderResultCardCallout, reactivesearchResultProps, } = props;
|
|
27
27
|
const filterStack = (0, hooks_1.useFilterStack)();
|
|
28
28
|
const { instantSearch, searchQuery } = (0, hooks_1.useSearch)();
|
|
29
29
|
const { track } = (0, __1.useAnalytics)();
|
|
@@ -31,8 +31,9 @@ const ResultListInner = (props) => {
|
|
|
31
31
|
typeof reactivesearchResultProps.resultStats.numberOfResults, [reactivesearchResultProps]);
|
|
32
32
|
const styleProp = react_1.default.useMemo(() => ({
|
|
33
33
|
display: "grid",
|
|
34
|
+
gap: `${gridGap !== null && gridGap !== void 0 ? gridGap : "0px"}`,
|
|
34
35
|
gridTemplateColumns: `repeat(${gridColumns !== null && gridColumns !== void 0 ? gridColumns : 4}, minmax(0, 1fr))`,
|
|
35
|
-
}), [gridColumns]);
|
|
36
|
+
}), [gridColumns, gridGap]);
|
|
36
37
|
const resultProps = react_1.default.useMemo(() => (Object.assign(Object.assign({}, reactivesearchResultProps), { products: reactivesearchResultProps.data.filter((document) => elastic_1.ElasticDocumentType.Product === document.type || !document.type), callouts: reactivesearchResultProps.data.filter((document) => elastic_1.ElasticDocumentType.Callout === document.type) })), [reactivesearchResultProps]);
|
|
37
38
|
if (reactivesearchResultProps.error) {
|
|
38
39
|
if (renderError)
|
|
@@ -9,11 +9,9 @@ const DataSearch_1 = __importDefault(require("@appbaseio/reactivesearch/lib/comp
|
|
|
9
9
|
const hooks_1 = require("../hooks");
|
|
10
10
|
const SearchInput = (props) => {
|
|
11
11
|
const { debounce, placeholder, inputClassName } = props;
|
|
12
|
-
const reactiveDataSearchProps = (0, hooks_1.useReactiveDataSearchProps)({
|
|
13
|
-
debounce,
|
|
12
|
+
const reactiveDataSearchProps = (0, hooks_1.useReactiveDataSearchProps)(Object.assign({ debounce,
|
|
14
13
|
placeholder,
|
|
15
|
-
inputClassName,
|
|
16
|
-
});
|
|
14
|
+
inputClassName }, props));
|
|
17
15
|
return react_1.default.createElement(DataSearch_1.default, Object.assign({}, reactiveDataSearchProps));
|
|
18
16
|
};
|
|
19
17
|
exports.SearchInput = SearchInput;
|