@usereactify/search 4.4.5 → 4.5.0-beta.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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [4.5.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.5...v4.5.0-beta.0) (2022-09-06)
|
|
6
|
+
|
|
5
7
|
### [4.4.5](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.4...v4.4.5) (2022-08-08)
|
|
6
8
|
|
|
7
9
|
|
package/dist/package.json
CHANGED
|
@@ -8,6 +8,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const ahooks_1 = require("ahooks");
|
|
9
9
|
const debug = require("debug")("reactify-search:useReactiveDataSearchProps");
|
|
10
10
|
const __1 = require("../");
|
|
11
|
+
const provider_1 = require("../../provider");
|
|
11
12
|
// default field for when zero search fields have been configured in Reactify
|
|
12
13
|
const defaultSearchField = {
|
|
13
14
|
id: "title",
|
|
@@ -16,6 +17,7 @@ const defaultSearchField = {
|
|
|
16
17
|
searchType: "instant_search",
|
|
17
18
|
};
|
|
18
19
|
const useReactiveDataSearchProps = (props = {}) => {
|
|
20
|
+
const context = (0, provider_1.useContext)();
|
|
19
21
|
const { debounce, placeholder, inputClassName } = props;
|
|
20
22
|
react_1.default.useEffect(() => {
|
|
21
23
|
debug("props", props);
|
|
@@ -45,7 +47,7 @@ const useReactiveDataSearchProps = (props = {}) => {
|
|
|
45
47
|
}, {
|
|
46
48
|
wait: debounce !== null && debounce !== void 0 ? debounce : 300,
|
|
47
49
|
});
|
|
48
|
-
return react_1.default.useMemo(() => (Object.assign({ type: "search", showIcon: false, fuzziness:
|
|
50
|
+
return react_1.default.useMemo(() => (Object.assign({ type: "search", showIcon: false, fuzziness: context.fuzziness, 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) => {
|
|
49
51
|
setSearchQuery(value);
|
|
50
52
|
if (!!value)
|
|
51
53
|
runDebouncedTriggerQuery(triggerQuery);
|
package/dist/src/provider.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare type Context = {
|
|
|
21
21
|
curation?: ConfigCuration;
|
|
22
22
|
/** Array of additional component IDs managed outside of Reactify Search */
|
|
23
23
|
additionalComponentIds?: string[];
|
|
24
|
+
fuzziness: 0 | 1 | 2 | "AUTO";
|
|
24
25
|
};
|
|
25
26
|
declare const Context: React.Context<Context | undefined>;
|
|
26
27
|
declare type Props = {
|
|
@@ -36,6 +37,7 @@ declare type Props = {
|
|
|
36
37
|
theme?: Theme;
|
|
37
38
|
/** Array of additional component IDs managed outside of Reactify Search */
|
|
38
39
|
additionalComponentIds?: string[];
|
|
40
|
+
fuzziness?: 0 | 1 | 2 | "AUTO";
|
|
39
41
|
/**
|
|
40
42
|
* Optional render function to display a component when the config is loading.
|
|
41
43
|
*/
|
package/dist/src/provider.js
CHANGED
|
@@ -71,7 +71,7 @@ const Provider = (_a) => {
|
|
|
71
71
|
exports.Provider = Provider;
|
|
72
72
|
const ConfiguredProvider = (props) => {
|
|
73
73
|
var _a, _b;
|
|
74
|
-
const { index, config, children, collection, instantSearch, filterStackHandle, noReactiveBase, shopifyPermanentDomain, additionalComponentIds, onRedirect, } = props;
|
|
74
|
+
const { index, config, children, collection, instantSearch, filterStackHandle, noReactiveBase, shopifyPermanentDomain, additionalComponentIds, fuzziness, onRedirect, } = props;
|
|
75
75
|
const credentials = (_a = props.credentials) !== null && _a !== void 0 ? _a : defaultCredentials;
|
|
76
76
|
const theme = (_b = props.theme) !== null && _b !== void 0 ? _b : {
|
|
77
77
|
typography: {
|
|
@@ -155,6 +155,7 @@ const ConfiguredProvider = (props) => {
|
|
|
155
155
|
additionalComponentIds,
|
|
156
156
|
instantSearch: !!instantSearch,
|
|
157
157
|
showInstantSearchResults: !!showInstantSearchResults && !!searchQuery,
|
|
158
|
+
fuzziness: fuzziness !== null && fuzziness !== void 0 ? fuzziness : 0,
|
|
158
159
|
}), [
|
|
159
160
|
index,
|
|
160
161
|
config,
|
|
@@ -172,6 +173,7 @@ const ConfiguredProvider = (props) => {
|
|
|
172
173
|
additionalComponentIds,
|
|
173
174
|
showInstantSearchResults,
|
|
174
175
|
theme,
|
|
176
|
+
fuzziness,
|
|
175
177
|
]);
|
|
176
178
|
react_1.default.useEffect(() => {
|
|
177
179
|
debug("contextValue", contextValue);
|
|
@@ -18,7 +18,7 @@ const SensorSearch = () => {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
21
|
-
react_1.default.createElement(DataSearch_1.default, { fuzziness:
|
|
21
|
+
react_1.default.createElement(DataSearch_1.default, { fuzziness: context.fuzziness, queryFormat: "and", autosuggest: false, value: searchQuery, componentId: "SensorSearch", style: { display: "none" }, dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), customQuery: (value, props) => {
|
|
22
22
|
var _a;
|
|
23
23
|
const { dataField, fieldWeights } = props;
|
|
24
24
|
const fieldsCrossFields = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
|