@usereactify/search 4.4.3 → 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,22 @@
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
+
7
+ ### [4.4.5](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.4...v4.4.5) (2022-08-08)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * rename "additonalComponentHandles" to "additonalComponentIds" ([d2b3fd3](https://bitbucket.org/usereactify/reactify-search-ui/commit/d2b3fd3a829168ca1150540b32d9cd21c07b397f))
13
+
14
+ ### [4.4.4](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.3...v4.4.4) (2022-08-05)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * ignore curation in sensors if it's global curation ([5762c0d](https://bitbucket.org/usereactify/reactify-search-ui/commit/5762c0dc30f2d3eac1ebae71208cc93b190d706f))
20
+
5
21
  ### [4.4.3](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.4.2...v4.4.3) (2022-08-03)
6
22
 
7
23
 
package/dist/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": "4.4.3",
4
+ "version": "4.5.0-beta.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -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: 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) => {
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);
@@ -10,13 +10,13 @@ const useFilters_1 = require("../useFilters");
10
10
  const provider_1 = require("../../provider");
11
11
  const useReactiveReactProp = (currentHandle) => {
12
12
  const filters = (0, useFilters_1.useFilters)();
13
- const { additionalComponentHandles } = (0, provider_1.useContext)();
13
+ const { additionalComponentIds } = (0, provider_1.useContext)();
14
14
  return react_1.default.useMemo(() => {
15
15
  return {
16
16
  and: [
17
17
  "SearchInput",
18
18
  ...sensor_1.SENSOR_IDS,
19
- ...(additionalComponentHandles !== null && additionalComponentHandles !== void 0 ? additionalComponentHandles : []),
19
+ ...(additionalComponentIds !== null && additionalComponentIds !== void 0 ? additionalComponentIds : []),
20
20
  ...filters.map((filter) => filter.handle),
21
21
  ].filter((handle) => handle !== currentHandle),
22
22
  };
@@ -20,7 +20,8 @@ declare type Context = {
20
20
  theme?: Theme;
21
21
  curation?: ConfigCuration;
22
22
  /** Array of additional component IDs managed outside of Reactify Search */
23
- additionalComponentHandles?: string[];
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 = {
@@ -35,7 +36,8 @@ declare type Props = {
35
36
  credentials?: Credentials;
36
37
  theme?: Theme;
37
38
  /** Array of additional component IDs managed outside of Reactify Search */
38
- additionalComponentHandles?: string[];
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
  */
@@ -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, additionalComponentHandles, 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: {
@@ -152,9 +152,10 @@ const ConfiguredProvider = (props) => {
152
152
  setShowInstantSearchResults,
153
153
  theme,
154
154
  curation,
155
- additionalComponentHandles,
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,
@@ -169,9 +170,10 @@ const ConfiguredProvider = (props) => {
169
170
  onRedirect,
170
171
  submitSearch,
171
172
  instantSearch,
172
- additionalComponentHandles,
173
+ additionalComponentIds,
173
174
  showInstantSearchResults,
174
175
  theme,
176
+ fuzziness,
175
177
  ]);
176
178
  react_1.default.useEffect(() => {
177
179
  debug("contextValue", contextValue);
@@ -14,7 +14,7 @@ const SensorCollection = () => {
14
14
  return null;
15
15
  }
16
16
  return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCollection", customQuery: () => {
17
- var _a, _b;
17
+ var _a, _b, _c;
18
18
  return ({
19
19
  query: {
20
20
  bool: {
@@ -33,7 +33,7 @@ const SensorCollection = () => {
33
33
  },
34
34
  ]
35
35
  : []),
36
- ...(((_b = context.curation) === null || _b === void 0 ? void 0 : _b.id)
36
+ ...(((_b = context.curation) === null || _b === void 0 ? void 0 : _b.id) && ((_c = context.curation) === null || _c === void 0 ? void 0 : _c.id) !== "global"
37
37
  ? [
38
38
  {
39
39
  nested: {
@@ -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: 1, 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) => {
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]}`);
@@ -29,7 +29,7 @@ const SensorSearch = () => {
29
29
  const query = {
30
30
  bool: {
31
31
  should: [
32
- ...(((_a = context.curation) === null || _a === void 0 ? void 0 : _a.id)
32
+ ...(((_a = context.curation) === null || _a === void 0 ? void 0 : _a.id) && context.curation.id !== "global"
33
33
  ? [
34
34
  {
35
35
  nested: {
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": "4.4.3",
4
+ "version": "4.5.0-beta.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",