@usereactify/search 3.7.0-beta.0 → 3.7.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.
|
@@ -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,
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usereactify/search",
|
|
3
3
|
"description": "React UI library for Reactify Search",
|
|
4
|
-
"version": "3.7.0
|
|
4
|
+
"version": "3.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"react-intersection-observer": "9.1.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@appbaseio/reactivesearch": "^3.
|
|
39
|
+
"@appbaseio/reactivesearch": "^3.16.1",
|
|
40
40
|
"react": "^17.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@appbaseio/reactivesearch": "
|
|
43
|
+
"@appbaseio/reactivesearch": "3.24.3",
|
|
44
44
|
"@commitlint/cli": "13.2.0",
|
|
45
45
|
"@commitlint/config-conventional": "13.2.0",
|
|
46
46
|
"@storybook/addon-actions": "6.3.10",
|