@usereactify/search 3.4.0 → 3.4.3

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.
@@ -21,8 +21,12 @@ const useLiveConfig = (shopifyPermanentDomain) => {
21
21
  // synchronously returns cached and non-expired config from session storage
22
22
  const cachedConfig = react_1.default.useMemo(() => {
23
23
  var _a;
24
+ if (typeof window === "undefined") {
25
+ return;
26
+ }
24
27
  // skip checking cache if url search param "nocache" is set
25
- const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !== null;
28
+ const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !==
29
+ null;
26
30
  if (skipCache) {
27
31
  debug("skipping cache");
28
32
  return;
@@ -1,5 +1,5 @@
1
1
  export declare const useSort: () => {
2
- sortOption: import("..").ConfigSort;
2
+ sortOption: import("..").ConfigSort | undefined;
3
3
  sortOptions: import("..").ConfigSort[];
4
4
  setSortOption: (sortOptionId: string) => void;
5
5
  };
@@ -5,7 +5,7 @@ declare type Context = {
5
5
  config: Config;
6
6
  configLoading: boolean;
7
7
  shopifyPermanentDomain: string;
8
- sortOption: ConfigSort;
8
+ sortOption: ConfigSort | undefined;
9
9
  sortOptions: ConfigSort[];
10
10
  searchQuery?: string;
11
11
  filterStack?: ConfigFilter;
@@ -11,9 +11,10 @@ const SensorSearch = () => {
11
11
  const { fields } = (0, hooks_1.useConfig)();
12
12
  const { searchQuery } = (0, hooks_1.useSearch)();
13
13
  // ignore search fields only set for instant search
14
- const searchFields = react_1.default.useMemo(() => fields.filter((field) => ["always_search", "search_page"].includes(field.searchType)), []);
15
- if (!searchQuery)
14
+ const searchFields = react_1.default.useMemo(() => fields.filter((field) => ["always_search", "search_page"].includes(field.searchType)), [fields]);
15
+ if (!searchQuery || !searchFields.length) {
16
16
  return null;
17
+ }
17
18
  return (react_1.default.createElement(react_1.default.Fragment, null,
18
19
  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) => {
19
20
  const { dataField, fieldWeights } = props;
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.4.0",
4
+ "version": "3.4.3",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",