@usereactify/search 5.0.0-beta.12 → 5.0.0-beta.15

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.
Files changed (214) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +3 -21
  3. package/dist/package.json +1 -1
  4. package/dist/src/components/ClearAll/ClearAll.d.ts +8 -0
  5. package/dist/src/components/ClearAll/ClearAll.js +29 -0
  6. package/dist/src/components/ClearAll/ClearAll.js.map +1 -0
  7. package/dist/src/components/ClearAll/index.d.ts +1 -0
  8. package/dist/src/components/{ReactifySearchBase → ClearAll}/index.js +1 -1
  9. package/dist/src/components/ClearAll/index.js.map +1 -0
  10. package/dist/src/components/CustomComponent/CustomComponent.d.ts +4 -0
  11. package/dist/src/components/CustomComponent/CustomComponent.js +13 -0
  12. package/dist/src/components/CustomComponent/CustomComponent.js.map +1 -0
  13. package/dist/src/components/CustomComponent/index.d.ts +1 -0
  14. package/dist/src/components/CustomComponent/index.js +14 -0
  15. package/dist/src/components/CustomComponent/index.js.map +1 -0
  16. package/dist/src/components/Example/ExampleClearAll.d.ts +4 -0
  17. package/dist/src/components/Example/ExampleClearAll.js +12 -0
  18. package/dist/src/components/Example/ExampleClearAll.js.map +1 -0
  19. package/dist/src/components/Example/ExampleCustomComponent.d.ts +2 -0
  20. package/dist/src/components/Example/ExampleCustomComponent.js +36 -0
  21. package/dist/src/components/Example/ExampleCustomComponent.js.map +1 -0
  22. package/dist/src/components/Example/ExampleFilterList.d.ts +5 -0
  23. package/dist/src/components/Example/ExampleFilterList.js +80 -9
  24. package/dist/src/components/Example/ExampleFilterList.js.map +1 -1
  25. package/dist/src/components/Example/ExampleFilterRange.js +6 -11
  26. package/dist/src/components/Example/ExampleFilterRange.js.map +1 -1
  27. package/dist/src/components/Example/ExampleFilterSlider.js +8 -9
  28. package/dist/src/components/Example/ExampleFilterSlider.js.map +1 -1
  29. package/dist/src/components/Example/ExampleFilters.d.ts +4 -0
  30. package/dist/src/components/Example/{ExampleFilterStack.js → ExampleFilters.js} +5 -5
  31. package/dist/src/components/Example/ExampleFilters.js.map +1 -0
  32. package/dist/src/components/Example/ExampleFiltersActive.d.ts +4 -0
  33. package/dist/src/components/Example/ExampleFiltersActive.js +23 -0
  34. package/dist/src/components/Example/ExampleFiltersActive.js.map +1 -0
  35. package/dist/src/components/Example/ExampleHookUseFilters.d.ts +2 -0
  36. package/dist/src/components/Example/ExampleHookUseFilters.js +20 -0
  37. package/dist/src/components/Example/ExampleHookUseFilters.js.map +1 -0
  38. package/dist/src/components/Example/ExampleHookUseSearch.d.ts +2 -0
  39. package/dist/src/components/Example/ExampleHookUseSearch.js +22 -0
  40. package/dist/src/components/Example/ExampleHookUseSearch.js.map +1 -0
  41. package/dist/src/components/Example/ExampleHookUseSortBy.d.ts +2 -0
  42. package/dist/src/components/Example/ExampleHookUseSortBy.js +18 -0
  43. package/dist/src/components/Example/ExampleHookUseSortBy.js.map +1 -0
  44. package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.d.ts +2 -0
  45. package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js +27 -0
  46. package/dist/src/components/Example/ExampleReactiveSearchProviderCollection.js.map +1 -0
  47. package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.d.ts +2 -0
  48. package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js +27 -0
  49. package/dist/src/components/Example/ExampleReactiveSearchProviderInstantSearch.js.map +1 -0
  50. package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.d.ts +2 -0
  51. package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js +27 -0
  52. package/dist/src/components/Example/ExampleReactiveSearchProviderSearch.js.map +1 -0
  53. package/dist/src/components/Example/ExampleResults.d.ts +2 -0
  54. package/dist/src/components/Example/ExampleResults.js +38 -0
  55. package/dist/src/components/Example/ExampleResults.js.map +1 -0
  56. package/dist/src/components/Example/ExampleSearch.d.ts +4 -0
  57. package/dist/src/components/Example/ExampleSearch.js +20 -0
  58. package/dist/src/components/Example/ExampleSearch.js.map +1 -0
  59. package/dist/src/components/Example/ExampleSortBy.d.ts +4 -0
  60. package/dist/src/components/Example/{ExampleSortby.js → ExampleSortBy.js} +4 -4
  61. package/dist/src/components/Example/ExampleSortBy.js.map +1 -0
  62. package/dist/src/components/Example/ExampleStats.d.ts +4 -0
  63. package/dist/src/components/Example/ExampleStats.js +15 -0
  64. package/dist/src/components/Example/ExampleStats.js.map +1 -0
  65. package/dist/src/components/Example/index.d.ts +12 -2
  66. package/dist/src/components/Example/index.js +12 -2
  67. package/dist/src/components/Example/index.js.map +1 -1
  68. package/dist/src/components/Filter/Filter.d.ts +9 -6
  69. package/dist/src/components/Filter/Filter.js +22 -10
  70. package/dist/src/components/Filter/Filter.js.map +1 -1
  71. package/dist/src/components/Filter/Filters.d.ts +7 -0
  72. package/dist/src/components/Filter/Filters.js +17 -0
  73. package/dist/src/components/Filter/Filters.js.map +1 -0
  74. package/dist/src/components/Filter/FiltersActive.d.ts +16 -0
  75. package/dist/src/components/Filter/FiltersActive.js +36 -0
  76. package/dist/src/components/Filter/FiltersActive.js.map +1 -0
  77. package/dist/src/components/Filter/index.d.ts +2 -1
  78. package/dist/src/components/Filter/index.js +2 -1
  79. package/dist/src/components/Filter/index.js.map +1 -1
  80. package/dist/src/components/{ReactifySearchBase/ReactifySearchBase.d.ts → ReactifySearchProvider/ReactifySearchProvider.d.ts} +6 -10
  81. package/dist/src/components/{ReactifySearchBase/ReactifySearchBase.js → ReactifySearchProvider/ReactifySearchProvider.js} +21 -22
  82. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -0
  83. package/dist/src/components/ReactifySearchProvider/index.d.ts +1 -0
  84. package/dist/src/components/ReactifySearchProvider/index.js +14 -0
  85. package/dist/src/components/ReactifySearchProvider/index.js.map +1 -0
  86. package/dist/src/components/Result/ResultCardCallout.d.ts +2 -4
  87. package/dist/src/components/Result/ResultCardCallout.js.map +1 -1
  88. package/dist/src/components/Result/ResultCardProduct.d.ts +2 -5
  89. package/dist/src/components/Result/ResultCardProduct.js.map +1 -1
  90. package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +2 -2
  91. package/dist/src/components/Result/ResultPaginationLoadMore.js +1 -1
  92. package/dist/src/components/Result/ResultPaginationLoadMore.js.map +1 -1
  93. package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +2 -2
  94. package/dist/src/components/Result/ResultPaginationNextPrev.js +1 -1
  95. package/dist/src/components/Result/ResultPaginationNextPrev.js.map +1 -1
  96. package/dist/src/components/Result/ResultPaginationNumbered.d.ts +2 -2
  97. package/dist/src/components/Result/ResultPaginationNumbered.js +1 -1
  98. package/dist/src/components/Result/ResultPaginationNumbered.js.map +1 -1
  99. package/dist/src/components/Result/{ResultStack.d.ts → Results.d.ts} +21 -13
  100. package/dist/src/components/Result/{ResultStack.js → Results.js} +44 -27
  101. package/dist/src/components/Result/Results.js.map +1 -0
  102. package/dist/src/components/Result/index.d.ts +1 -1
  103. package/dist/src/components/Result/index.js +1 -1
  104. package/dist/src/components/Result/index.js.map +1 -1
  105. package/dist/src/components/Search/Search.d.ts +7 -0
  106. package/dist/src/components/Search/Search.js +17 -0
  107. package/dist/src/components/Search/Search.js.map +1 -0
  108. package/dist/src/components/Search/index.d.ts +1 -1
  109. package/dist/src/components/Search/index.js +1 -1
  110. package/dist/src/components/Search/index.js.map +1 -1
  111. package/dist/src/components/Sensor/SensorCollection.js +2 -2
  112. package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
  113. package/dist/src/components/Sensor/SensorInventoryAvailable.js +1 -1
  114. package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
  115. package/dist/src/components/Sensor/SensorSearch.js +7 -3
  116. package/dist/src/components/Sensor/SensorSearch.js.map +1 -1
  117. package/dist/src/components/Sensor/SensorSort.js +13 -13
  118. package/dist/src/components/Sensor/SensorSort.js.map +1 -1
  119. package/dist/src/components/Sensor/Sensors.d.ts +3 -0
  120. package/dist/src/components/Sensor/{SensorStack.js → Sensors.js} +4 -4
  121. package/dist/src/components/Sensor/Sensors.js.map +1 -0
  122. package/dist/src/components/Sensor/index.d.ts +1 -1
  123. package/dist/src/components/Sensor/index.js +1 -1
  124. package/dist/src/components/Sensor/index.js.map +1 -1
  125. package/dist/src/components/SortBy/SortBy.d.ts +7 -0
  126. package/dist/src/components/SortBy/SortBy.js +17 -0
  127. package/dist/src/components/SortBy/SortBy.js.map +1 -0
  128. package/dist/src/components/SortBy/index.d.ts +1 -0
  129. package/dist/src/components/{Sortby → SortBy}/index.js +1 -1
  130. package/dist/src/components/{Sortby → SortBy}/index.js.map +1 -1
  131. package/dist/src/components/Stats/Stats.d.ts +22 -0
  132. package/dist/src/components/Stats/Stats.js +15 -0
  133. package/dist/src/components/Stats/Stats.js.map +1 -0
  134. package/dist/src/components/Stats/index.d.ts +1 -0
  135. package/dist/src/components/Stats/index.js +14 -0
  136. package/dist/src/components/Stats/index.js.map +1 -0
  137. package/dist/src/components/index.d.ts +5 -2
  138. package/dist/src/components/index.js +5 -2
  139. package/dist/src/components/index.js.map +1 -1
  140. package/dist/src/hooks/index.d.ts +4 -3
  141. package/dist/src/hooks/index.js +4 -3
  142. package/dist/src/hooks/index.js.map +1 -1
  143. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +10 -10
  144. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js.map +1 -1
  145. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +6 -1
  146. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +12 -1
  147. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +1 -1
  148. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +5 -0
  149. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +9 -2
  150. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +1 -1
  151. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +4 -4
  152. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +1 -1
  153. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js +1 -1
  154. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +1 -1
  155. package/dist/src/hooks/useConfig.js +1 -1
  156. package/dist/src/hooks/useConfig.js.map +1 -1
  157. package/dist/src/hooks/useCuration.js +4 -8
  158. package/dist/src/hooks/useCuration.js.map +1 -1
  159. package/dist/src/hooks/useFilterListProps.d.ts +3 -2
  160. package/dist/src/hooks/useFilterListProps.js +37 -7
  161. package/dist/src/hooks/useFilterListProps.js.map +1 -1
  162. package/dist/src/hooks/useFilterRangeProps.d.ts +11 -0
  163. package/dist/src/hooks/useFilterRangeProps.js +53 -0
  164. package/dist/src/hooks/useFilterRangeProps.js.map +1 -0
  165. package/dist/src/hooks/useFilterSliderProps.d.ts +12 -0
  166. package/dist/src/hooks/useFilterSliderProps.js +49 -0
  167. package/dist/src/hooks/useFilterSliderProps.js.map +1 -0
  168. package/dist/src/hooks/useFilters.d.ts +5 -2
  169. package/dist/src/hooks/useFilters.js +45 -11
  170. package/dist/src/hooks/useFilters.js.map +1 -1
  171. package/dist/src/hooks/usePagination.d.ts +10 -0
  172. package/dist/src/hooks/usePagination.js.map +1 -1
  173. package/dist/src/hooks/usePaginationLoadMore.js +1 -1
  174. package/dist/src/hooks/usePaginationLoadMore.js.map +1 -1
  175. package/dist/src/hooks/useReactifySearchContext.d.ts +12 -20
  176. package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
  177. package/dist/src/hooks/useSearch.d.ts +8 -3
  178. package/dist/src/hooks/useSearch.js +39 -17
  179. package/dist/src/hooks/useSearch.js.map +1 -1
  180. package/dist/src/hooks/useSortBy.d.ts +9 -0
  181. package/dist/src/hooks/{useSortby.js → useSortBy.js} +5 -5
  182. package/dist/src/hooks/useSortBy.js.map +1 -0
  183. package/dist/src/types/firestore.d.ts +3 -0
  184. package/dist/src/types/firestore.js.map +1 -1
  185. package/dist/src/types/reactivesearch.d.ts +2 -2
  186. package/dist/src/types/reactivesearch.js.map +1 -1
  187. package/dist/src/utility/debug.d.ts +1 -1
  188. package/dist/src/utility/debug.js.map +1 -1
  189. package/package.json +1 -1
  190. package/dist/src/components/Example/ExampleFilterStack.d.ts +0 -4
  191. package/dist/src/components/Example/ExampleFilterStack.js.map +0 -1
  192. package/dist/src/components/Example/ExampleSortby.d.ts +0 -4
  193. package/dist/src/components/Example/ExampleSortby.js.map +0 -1
  194. package/dist/src/components/Filter/FilterStack.d.ts +0 -7
  195. package/dist/src/components/Filter/FilterStack.js +0 -17
  196. package/dist/src/components/Filter/FilterStack.js.map +0 -1
  197. package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js.map +0 -1
  198. package/dist/src/components/ReactifySearchBase/index.d.ts +0 -1
  199. package/dist/src/components/ReactifySearchBase/index.js.map +0 -1
  200. package/dist/src/components/Result/ResultStack.js.map +0 -1
  201. package/dist/src/components/Search/SearchInput.d.ts +0 -8
  202. package/dist/src/components/Search/SearchInput.js +0 -18
  203. package/dist/src/components/Search/SearchInput.js.map +0 -1
  204. package/dist/src/components/Sensor/SensorStack.d.ts +0 -3
  205. package/dist/src/components/Sensor/SensorStack.js.map +0 -1
  206. package/dist/src/components/Sortby/Sortby.d.ts +0 -7
  207. package/dist/src/components/Sortby/Sortby.js +0 -17
  208. package/dist/src/components/Sortby/Sortby.js.map +0 -1
  209. package/dist/src/components/Sortby/index.d.ts +0 -1
  210. package/dist/src/hooks/useFilterStack.d.ts +0 -4
  211. package/dist/src/hooks/useFilterStack.js +0 -52
  212. package/dist/src/hooks/useFilterStack.js.map +0 -1
  213. package/dist/src/hooks/useSortby.d.ts +0 -6
  214. package/dist/src/hooks/useSortby.js.map +0 -1
@@ -1,2 +1,3 @@
1
1
  export * from "./Filter";
2
- export * from "./FilterStack";
2
+ export * from "./Filters";
3
+ export * from "./FiltersActive";
@@ -11,5 +11,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./Filter"), exports);
14
- __exportStar(require("./FilterStack"), exports);
14
+ __exportStar(require("./Filters"), exports);
15
+ __exportStar(require("./FiltersActive"), exports);
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,gDAA8B","sourcesContent":["export * from \"./Filter\";\nexport * from \"./FilterStack\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,kDAAgC","sourcesContent":["export * from \"./Filter\";\nexport * from \"./Filters\";\nexport * from \"./FiltersActive\";\n"]}
@@ -1,16 +1,16 @@
1
1
  import React from "react";
2
- export declare type ReactifySearchBaseProps = {
2
+ export declare type ReactifySearchProviderProps = {
3
3
  /** The search area the provider will be used in */
4
4
  mode: "search" | "collection" | "instant-search";
5
5
  /** Shopify store domain used to resolve the site configuration */
6
6
  shopifyPermanentDomain: string;
7
- /** Specific filter group handle, used to override automated logic */
8
- filterStackHandle?: string;
9
7
  /** Callback function for redirects, suitable for headless sites to avoid full page refresh */
10
8
  onRedirect?: (type: "redirect" | "search", url: string) => void;
11
9
  /** Render method to display a component when the config is loading */
12
10
  renderBooting?: () => JSX.Element | null;
13
- /** Advanced usage: Allows you to wrap the ReactifySearchBase in your own ReactiveBase component */
11
+ /** Advanced usage: Override the default Filters selection logic */
12
+ filtersHandle?: string;
13
+ /** Advanced usage: Allows you to wrap the ReactifySearchProvider in your own ReactiveBase component */
14
14
  noReactiveBase?: boolean;
15
15
  /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */
16
16
  additionalComponentHandles?: string[];
@@ -31,12 +31,8 @@ export declare type ReactifySearchBaseProps = {
31
31
  } | {
32
32
  mode: "collection";
33
33
  /** Collection object that includes the handle, used to find curations */
34
- collection: {
35
- id: number;
36
- title: string;
37
- handle: string;
38
- };
34
+ collectionHandle: string;
39
35
  } | {
40
36
  mode: "instant-search";
41
37
  });
42
- export declare const ReactifySearchBase: React.FC<ReactifySearchBaseProps>;
38
+ export declare const ReactifySearchProvider: React.FC<ReactifySearchProviderProps>;
@@ -22,32 +22,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ReactifySearchBase = void 0;
25
+ exports.ReactifySearchProvider = void 0;
26
26
  const react_1 = __importDefault(require("react"));
27
27
  const Sentry = __importStar(require("@sentry/react"));
28
28
  const hooks_1 = require("../../hooks");
29
29
  const components_1 = require("../../components");
30
30
  const utility_1 = require("../../utility");
31
- const ReactifySearchBase = (props) => {
31
+ const ReactifySearchProvider = (props) => {
32
32
  react_1.default.useEffect(() => {
33
- utility_1.debug.log("ReactifySearchBase", "props", props);
33
+ utility_1.debug.log("ReactifySearchProvider", "props", props);
34
34
  Sentry.setTags({
35
35
  "reactifysearch.index": props.index,
36
36
  "reactifysearch.shop": props.shopifyPermanentDomain,
37
37
  "reactifysearch.mode": props.mode,
38
- "reactifysearch.collection": props.mode === "collection" ? props.collection.handle : undefined,
39
- "reactifysearch.filter": props.filterStackHandle,
38
+ "reactifysearch.collection": props.mode === "collection" ? props.collectionHandle : undefined,
39
+ "reactifysearch.filter": props.filtersHandle,
40
40
  });
41
41
  }, [props]);
42
42
  return (react_1.default.createElement(Sentry.ErrorBoundary, { fallback: react_1.default.createElement("p", null, "An error has occurred") },
43
43
  react_1.default.createElement(ReactifySearchInner, Object.assign({}, props))));
44
44
  };
45
- exports.ReactifySearchBase = ReactifySearchBase;
45
+ exports.ReactifySearchProvider = ReactifySearchProvider;
46
46
  const ReactifySearchInner = (props) => {
47
47
  var _a, _b;
48
48
  const { config } = (0, hooks_1.useConfig)(props.shopifyPermanentDomain, props.configId);
49
- const [searchQuery, setSearchQuery] = react_1.default.useState("");
50
- const [instantSearchVisible, setInstantSearchVisible] = react_1.default.useState(false);
49
+ const [searchTerm, setSearchTerm] = react_1.default.useState("");
50
+ const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
51
51
  const [sortOption, setSortOption] = react_1.default.useState("");
52
52
  const credentials = (_a = props.credentials) !== null && _a !== void 0 ? _a : {
53
53
  username: "guest",
@@ -60,7 +60,7 @@ const ReactifySearchInner = (props) => {
60
60
  fontSize: "inherit",
61
61
  },
62
62
  };
63
- const searchQueryFromURL = react_1.default.useMemo(() => {
63
+ const searchTermFromURL = react_1.default.useMemo(() => {
64
64
  var _a;
65
65
  if (typeof window === "undefined") {
66
66
  return;
@@ -77,10 +77,10 @@ const ReactifySearchInner = (props) => {
77
77
  return (_a = urlParams.get("sort")) !== null && _a !== void 0 ? _a : undefined;
78
78
  }, [typeof window !== "undefined" && window.location.search]);
79
79
  react_1.default.useEffect(() => {
80
- if (searchQueryFromURL && searchQuery !== searchQueryFromURL) {
81
- setSearchQuery(searchQueryFromURL);
80
+ if (searchTermFromURL && searchTerm !== searchTermFromURL) {
81
+ setSearchTerm(searchTermFromURL);
82
82
  }
83
- }, [searchQueryFromURL]);
83
+ }, [searchTermFromURL]);
84
84
  react_1.default.useEffect(() => {
85
85
  if (searchSortFromURL && sortOption !== searchSortFromURL) {
86
86
  setSortOption(searchSortFromURL);
@@ -99,23 +99,22 @@ const ReactifySearchInner = (props) => {
99
99
  if (!config) {
100
100
  return;
101
101
  }
102
- const memoValue = {
102
+ return {
103
103
  config: config,
104
- options: Object.assign(Object.assign({}, props), { index: (_a = props.index) !== null && _a !== void 0 ? _a : config.index, filterStackHandle: props.filterStackHandle, credentials: credentials, theme: theme }),
104
+ options: Object.assign(Object.assign({}, props), { index: (_a = props.index) !== null && _a !== void 0 ? _a : config.index, filtersHandle: props.filtersHandle, credentials: credentials, theme: theme }),
105
105
  search: {
106
- searchQuery: searchQuery,
107
- setSearchQuery: setSearchQuery,
108
- instantSearchVisible: instantSearchVisible,
109
- setInstantSearchVisible: setInstantSearchVisible,
106
+ searchTerm: searchTerm,
107
+ setSearchTerm: setSearchTerm,
108
+ showInstantSearchResults: showInstantSearchResults,
109
+ setShowInstantSearchResults: setShowInstantSearchResults,
110
110
  },
111
111
  sortby: {
112
112
  sortOption: sortOption,
113
113
  setSortOption: setSortOption,
114
114
  },
115
115
  };
116
- utility_1.debug.log("ReactifySearchBase", "context", memoValue);
117
- return memoValue;
118
- }, [config, props, searchQuery, instantSearchVisible, sortOption]);
116
+ }, [config, props, searchTerm, showInstantSearchResults, sortOption]);
117
+ utility_1.debug.hook("ReactifySearchProvider", "context", contextValue);
119
118
  if (!contextValue) {
120
119
  if (props.renderBooting) {
121
120
  return props.renderBooting();
@@ -128,4 +127,4 @@ const ReactifySearchInner = (props) => {
128
127
  return (react_1.default.createElement(hooks_1.ReactifySearchContext.Provider, { value: contextValue },
129
128
  react_1.default.createElement(components_1.UtilityAuthenticatedReactiveBase, null, props.children)));
130
129
  };
131
- //# sourceMappingURL=ReactifySearchBase.js.map
130
+ //# sourceMappingURL=ReactifySearchProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactifySearchProvider.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/ReactifySearchProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,sDAAwC;AAExC,uCAA+D;AAC/D,iDAAoE;AACpE,2CAAsC;AA2C/B,MAAM,sBAAsB,GAA0C,CAC3E,KAAK,EACL,EAAE;IACF,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAEpD,MAAM,CAAC,OAAO,CAAC;YACb,sBAAsB,EAAE,KAAK,CAAC,KA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ACH;IAED,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY;QACjD,8BAAC,6CAAgC,QAC9B,KAAK,CAAC,QAAQ,CACkB,CACJ,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport * as Sentry from \"@sentry/react\";\n\nimport { ReactifySearchContext, useConfig } from \"../../hooks\";\nimport { UtilityAuthenticatedReactiveBase } from \"../../components\";\nimport { debug } from \"../../utility\";\n\nexport type ReactifySearchProviderProps = {\n /** The search area the provider will be used in */\n mode: \"search\" | \"collection\" | \"instant-search\";\n /** Shopify store domain used to resolve the site configuration */\n shopifyPermanentDomain: string;\n /** Callback function for redirects, suitable for headless sites to avoid full page refresh */\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n /** Render method to display a component when the config is loading */\n renderBooting?: () => JSX.Element | null;\n /** Advanced usage: Override the default Filters selection logic */\n filtersHandle?: string;\n /** Advanced usage: Allows you to wrap the ReactifySearchProvider in your own ReactiveBase component */\n noReactiveBase?: boolean;\n /** Advanced usage: Array of additional component IDs managed outside of Reactify Search */\n additionalComponentHandles?: string[];\n /** Advanced usage: Override the default Elasticsearch index */\n index?: string;\n /** Advanced usage: Override the default Reactify Search config (for multi-instance stores) */\n configId?: string;\n /** Advanced usage: Override the default Elasticsearch credentials */\n credentials?: {\n username: string;\n password: string;\n endpoint: string;\n };\n /** Advanced usage: Override the default ReactiveBase theme */\n theme?: Record<string, unknown>;\n} & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n /** Collection object that includes the handle, used to find curations */\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n);\n\nexport const ReactifySearchProvider: React.FC<ReactifySearchProviderProps> = (\n props\n) => {\n React.useEffect(() => {\n debug.log(\"ReactifySearchProvider\", \"props\", props);\n\n Sentry.setTags({\n \"reactifysearch.index\": props.index,\n \"reactifysearch.shop\": props.shopifyPermanentDomain,\n \"reactifysearch.mode\": props.mode,\n \"reactifysearch.collection\":\n props.mode === \"collection\" ? props.collectionHandle : undefined,\n \"reactifysearch.filter\": props.filtersHandle,\n });\n }, [props]);\n\n return (\n <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>\n <ReactifySearchInner {...props} />\n </Sentry.ErrorBoundary>\n );\n};\n\nconst ReactifySearchInner: React.FC<ReactifySearchProviderProps> = (props) => {\n const { config } = useConfig(props.shopifyPermanentDomain, props.configId);\n\n const [searchTerm, setSearchTerm] = React.useState<string>(\"\");\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\"\");\n\n const credentials = props.credentials ?? {\n username: \"guest\",\n password: \"password\",\n endpoint: \"https://api.search.reactify.app\",\n };\n\n const theme = props.theme ?? {\n typography: {\n fontFamily: \"inherit\",\n fontSize: \"inherit\",\n },\n };\n\n const searchTermFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"q\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const searchSortFromURL = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get(\"sort\") ?? undefined;\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n React.useEffect(() => {\n if (searchTermFromURL && searchTerm !== searchTermFromURL) {\n setSearchTerm(searchTermFromURL);\n }\n }, [searchTermFromURL]);\n\n React.useEffect(() => {\n if (searchSortFromURL && sortOption !== searchSortFromURL) {\n setSortOption(searchSortFromURL);\n }\n }, [searchSortFromURL]);\n\n React.useEffect(() => {\n if (typeof window == \"undefined\") {\n return;\n }\n\n if (window.location.search === \"\" && sortOption) {\n setSortOption(sortOption);\n }\n }, [typeof window !== \"undefined\" && window.location.search]);\n\n const contextValue = React.useMemo(() => {\n if (!config) {\n return;\n }\n\n return {\n config: config,\n options: {\n ...props,\n index: props.index ?? config.index,\n filtersHandle: props.filtersHandle,\n credentials: credentials,\n theme: theme,\n },\n search: {\n searchTerm: searchTerm,\n setSearchTerm: setSearchTerm,\n showInstantSearchResults: showInstantSearchResults,\n setShowInstantSearchResults: setShowInstantSearchResults,\n },\n sortby: {\n sortOption: sortOption,\n setSortOption: setSortOption,\n },\n };\n }, [config, props, searchTerm, showInstantSearchResults, sortOption]);\n\n debug.hook(\"ReactifySearchProvider\", \"context\", contextValue);\n\n if (!contextValue) {\n if (props.renderBooting) {\n return props.renderBooting();\n }\n return null;\n }\n\n if (props.noReactiveBase) {\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n {props.children}\n </ReactifySearchContext.Provider>\n );\n }\n\n return (\n <ReactifySearchContext.Provider value={contextValue}>\n <UtilityAuthenticatedReactiveBase>\n {props.children}\n </UtilityAuthenticatedReactiveBase>\n </ReactifySearchContext.Provider>\n );\n};\n"]}
@@ -0,0 +1 @@
1
+ export * from "./ReactifySearchProvider";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./ReactifySearchProvider"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ReactifySearchProvider/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC","sourcesContent":["export * from \"./ReactifySearchProvider\";\n"]}
@@ -1,12 +1,10 @@
1
1
  import React from "react";
2
2
  import { ElasticCallout } from "../../types";
3
+ import { ResultsProps } from "..";
3
4
  export declare type ResultCardCalloutProps = {
4
5
  pagePosition: number;
5
6
  document: ElasticCallout;
6
7
  callout: ElasticCallout["callout"];
7
- render?: React.FC<Omit<ResultCardCalloutProps, "render"> & {
8
- itemRef: (node?: Element | null) => void;
9
- handleClick: () => void;
10
- }>;
8
+ render?: ResultsProps["renderResultCardCallout"];
11
9
  };
12
10
  export declare const ResultCardCallout: React.FC<ResultCardCalloutProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA2C;AAC3C,0BAA8C;AAcvC,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uCAAS,EAAC;QAChC,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC;YACJ,SAAS,EAAE,gBAAgB;YAC3B,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;gBACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;aAC3B;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACxC,KAAK,CAAC;YACJ,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;gBACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;aAC3B;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,MAAM,EAAE;YACV,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4BAAwB,CAAC;IAEjE,OAAO,8BAAC,eAAe,oBAAK,KAAK,IAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,IAAI,CAAC;AAChF,CAAC,CAAC;AApCW,QAAA,iBAAiB,qBAoC5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { ElasticCallout } from \"../../types\";\nimport { useAnalytics } from \"../../hooks\";\nimport { ExampleResultCardCallout } from \"..\";\n\nexport type ResultCardCalloutProps = {\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n render?: React.FC<\n Omit<ResultCardCalloutProps, \"render\"> & {\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n};\n\nexport const ResultCardCallout: React.FC<ResultCardCalloutProps> = (props) => {\n const { track } = useAnalytics();\n const { ref, inView } = useInView({\n threshold: 0.5,\n triggerOnce: true,\n });\n\n const handleClick = React.useCallback(() => {\n track({\n eventName: \"clickPromotion\",\n payload: {\n link: props.callout.link,\n title: props.callout.title,\n },\n });\n }, [track, props.callout]);\n\n const handleView = React.useCallback(() => {\n track({\n eventName: \"viewPromotion\",\n payload: {\n link: props.callout.link,\n title: props.callout.title,\n },\n });\n }, [track, props.callout]);\n\n React.useEffect(() => {\n if (inView) {\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardCallout;\n\n return <RenderComponent {...props} itemRef={ref} handleClick={handleClick} />;\n};\n"]}
1
+ {"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA2C;AAC3C,0BAA4D;AASrD,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uCAAS,EAAC;QAChC,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC;YACJ,SAAS,EAAE,gBAAgB;YAC3B,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;gBACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;aAC3B;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACxC,KAAK,CAAC;YACJ,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;gBACxB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;aAC3B;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,MAAM,EAAE;YACV,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4BAAwB,CAAC;IAEjE,OAAO,8BAAC,eAAe,oBAAK,KAAK,IAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,IAAI,CAAC;AAChF,CAAC,CAAC;AApCW,QAAA,iBAAiB,qBAoC5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport { ElasticCallout } from \"../../types\";\nimport { useAnalytics } from \"../../hooks\";\nimport { ResultsProps, ExampleResultCardCallout } from \"..\";\n\nexport type ResultCardCalloutProps = {\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n render?: ResultsProps[\"renderResultCardCallout\"];\n};\n\nexport const ResultCardCallout: React.FC<ResultCardCalloutProps> = (props) => {\n const { track } = useAnalytics();\n const { ref, inView } = useInView({\n threshold: 0.5,\n triggerOnce: true,\n });\n\n const handleClick = React.useCallback(() => {\n track({\n eventName: \"clickPromotion\",\n payload: {\n link: props.callout.link,\n title: props.callout.title,\n },\n });\n }, [track, props.callout]);\n\n const handleView = React.useCallback(() => {\n track({\n eventName: \"viewPromotion\",\n payload: {\n link: props.callout.link,\n title: props.callout.title,\n },\n });\n }, [track, props.callout]);\n\n React.useEffect(() => {\n if (inView) {\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardCallout;\n\n return <RenderComponent {...props} itemRef={ref} handleClick={handleClick} />;\n};\n"]}
@@ -1,13 +1,10 @@
1
1
  import React from "react";
2
2
  import type { ElasticProduct } from "../../types";
3
- import { useProductPrice } from "../../hooks";
3
+ import { ResultsProps } from "../../components";
4
4
  export declare type ResultCardProductProps = {
5
5
  pagePosition: number;
6
6
  product: ElasticProduct;
7
7
  document: ElasticProduct;
8
- render?: React.FC<Omit<ResultCardProductProps, "render"> & ReturnType<typeof useProductPrice> & {
9
- itemRef: (node?: Element | null) => void;
10
- handleClick: () => void;
11
- }>;
8
+ render?: ResultsProps["renderResultCardProduct"];
12
9
  };
13
10
  export declare const ResultCardProduct: React.FC<ResultCardProductProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA4D;AAC5D,iDAA4D;AAerD,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uCAAS,EAAC;QAChC,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC;YACJ,SAAS,EAAE,cAAc;YACzB,OAAO,EAAE;gBACP,cAAc,EAAE;oBACd,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;oBACpB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;iBAC3B;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACxC,KAAK,CAAC;YACJ,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE;gBACP,cAAc,EAAE;oBACd,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;oBACpB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;iBAC3B;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,MAAM,EAAE;YACV,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,qCAAwB,CAAC;IAEjE,OAAO,CACL,8BAAC,eAAe,oBACV,YAAY,IAChB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,WAAW,IACxB,CACH,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,iBAAiB,qBAmD5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport type { ElasticProduct } from \"../../types\";\nimport { useProductPrice, useAnalytics } from \"../../hooks\";\nimport { ExampleResultCardProduct } from \"../../components\";\n\nexport type ResultCardProductProps = {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n render?: React.FC<\n Omit<ResultCardProductProps, \"render\"> &\n ReturnType<typeof useProductPrice> & {\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n};\n\nexport const ResultCardProduct: React.FC<ResultCardProductProps> = (props) => {\n const productPrice = useProductPrice(props.product);\n\n const { track } = useAnalytics();\n const { ref, inView } = useInView({\n threshold: 0.5,\n triggerOnce: true,\n });\n\n const handleClick = React.useCallback(() => {\n track({\n eventName: \"clickProduct\",\n payload: {\n elasticProduct: {\n id: props.product.id,\n title: props.product.title,\n },\n },\n });\n }, [track, props.product]);\n\n const handleView = React.useCallback(() => {\n track({\n eventName: \"viewProduct\",\n payload: {\n elasticProduct: {\n id: props.product.id,\n title: props.product.title,\n },\n },\n });\n }, [track, props.product]);\n\n React.useEffect(() => {\n if (inView) {\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardProduct;\n\n return (\n <RenderComponent\n {...productPrice}\n pagePosition={props.pagePosition}\n product={props.product}\n document={props.document}\n itemRef={ref}\n handleClick={handleClick}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA4D;AAC5D,iDAA0E;AASnE,MAAM,iBAAiB,GAAqC,CAAC,KAAK,EAAE,EAAE;;IAC3E,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uCAAS,EAAC;QAChC,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC;YACJ,SAAS,EAAE,cAAc;YACzB,OAAO,EAAE;gBACP,cAAc,EAAE;oBACd,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;oBACpB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;iBAC3B;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACxC,KAAK,CAAC;YACJ,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE;gBACP,cAAc,EAAE;oBACd,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;oBACpB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;iBAC3B;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3B,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,MAAM,EAAE;YACV,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,qCAAwB,CAAC;IAEjE,OAAO,CACL,8BAAC,eAAe,oBACV,YAAY,IAChB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,WAAW,IACxB,CACH,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,iBAAiB,qBAmD5B","sourcesContent":["import React from \"react\";\nimport { useInView } from \"react-intersection-observer\";\n\nimport type { ElasticProduct } from \"../../types\";\nimport { useProductPrice, useAnalytics } from \"../../hooks\";\nimport { ResultsProps, ExampleResultCardProduct } from \"../../components\";\n\nexport type ResultCardProductProps = {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n render?: ResultsProps[\"renderResultCardProduct\"];\n};\n\nexport const ResultCardProduct: React.FC<ResultCardProductProps> = (props) => {\n const productPrice = useProductPrice(props.product);\n\n const { track } = useAnalytics();\n const { ref, inView } = useInView({\n threshold: 0.5,\n triggerOnce: true,\n });\n\n const handleClick = React.useCallback(() => {\n track({\n eventName: \"clickProduct\",\n payload: {\n elasticProduct: {\n id: props.product.id,\n title: props.product.title,\n },\n },\n });\n }, [track, props.product]);\n\n const handleView = React.useCallback(() => {\n track({\n eventName: \"viewProduct\",\n payload: {\n elasticProduct: {\n id: props.product.id,\n title: props.product.title,\n },\n },\n });\n }, [track, props.product]);\n\n React.useEffect(() => {\n if (inView) {\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardProduct;\n\n return (\n <RenderComponent\n {...productPrice}\n pagePosition={props.pagePosition}\n product={props.product}\n document={props.document}\n itemRef={ref}\n handleClick={handleClick}\n />\n );\n};\n"]}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { ReactivesearchResultProps } from "../../types";
3
- import { usePaginationLoadMore } from "../../hooks";
3
+ import { ResultsProps } from "../../components";
4
4
  export declare type ResultPaginationLoadMoreProps = ReactivesearchResultProps & {
5
- render?: React.FC<ReturnType<typeof usePaginationLoadMore>>;
5
+ render?: ResultsProps["renderPaginationLoadMore"];
6
6
  };
7
7
  export declare const ResultPaginationLoadMore: React.FC<ResultPaginationLoadMoreProps>;
@@ -11,7 +11,7 @@ const ResultPaginationLoadMore = (props) => {
11
11
  var _a;
12
12
  const paginationLoadMoreHook = (0, hooks_1.usePaginationLoadMore)(props);
13
13
  const RenderPaginationComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultPaginationLoadMore;
14
- return (react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationLoadMoreHook)));
14
+ return react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationLoadMoreHook));
15
15
  };
16
16
  exports.ResultPaginationLoadMore = ResultPaginationLoadMore;
17
17
  //# sourceMappingURL=ResultPaginationLoadMore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResultPaginationLoadMore.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationLoadMore.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAoD;AACpD,iDAAmE;AAM5D,MAAM,wBAAwB,GAA4C,CAAC,KAAK,EAAE,EAAE;;IACzF,MAAM,sBAAsB,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;IAE5D,MAAM,yBAAyB,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElF,OAAO,CACL,8BAAC,yBAAyB,oBACpB,sBAAsB,EAC1B,CACH,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../../types\";\nimport { usePaginationLoadMore } from \"../../hooks\";\nimport { ExampleResultPaginationLoadMore } from \"../../components\";\n\nexport type ResultPaginationLoadMoreProps = ReactivesearchResultProps & {\n render?: React.FC<ReturnType<typeof usePaginationLoadMore>>;\n};\n\nexport const ResultPaginationLoadMore: React.FC<ResultPaginationLoadMoreProps> = (props) => {\n const paginationLoadMoreHook = usePaginationLoadMore(props);\n\n const RenderPaginationComponent = props.render ?? ExampleResultPaginationLoadMore;\n\n return (\n <RenderPaginationComponent\n {...paginationLoadMoreHook}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"ResultPaginationLoadMore.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationLoadMore.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAoD;AACpD,iDAG0B;AAMnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;;IACR,MAAM,sBAAsB,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;IAE5D,MAAM,yBAAyB,GAC7B,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElD,OAAO,8BAAC,yBAAyB,oBAAK,sBAAsB,EAAI,CAAC;AACnE,CAAC,CAAC;AARS,QAAA,wBAAwB,4BAQjC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../../types\";\nimport { usePaginationLoadMore } from \"../../hooks\";\nimport {\n ResultsProps,\n ExampleResultPaginationLoadMore,\n} from \"../../components\";\n\nexport type ResultPaginationLoadMoreProps = ReactivesearchResultProps & {\n render?: ResultsProps[\"renderPaginationLoadMore\"];\n};\n\nexport const ResultPaginationLoadMore: React.FC<ResultPaginationLoadMoreProps> =\n (props) => {\n const paginationLoadMoreHook = usePaginationLoadMore(props);\n\n const RenderPaginationComponent =\n props.render ?? ExampleResultPaginationLoadMore;\n\n return <RenderPaginationComponent {...paginationLoadMoreHook} />;\n };\n"]}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- import { usePagination } from "../../hooks";
3
2
  import { ReactivesearchPaginationProps } from "../../types";
3
+ import { ResultsProps } from "../../components";
4
4
  export declare type ResultPaginationNextPrevProps = ReactivesearchPaginationProps & {
5
- render?: React.FC<ReturnType<typeof usePagination>>;
5
+ render?: ResultsProps["renderPaginationNextPrev"];
6
6
  };
7
7
  export declare const ResultPaginationNextPrev: React.FC<ResultPaginationNextPrevProps>;
@@ -11,7 +11,7 @@ const ResultPaginationNextPrev = (props) => {
11
11
  var _a;
12
12
  const paginationHook = (0, hooks_1.usePagination)(props);
13
13
  const RenderPaginationComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultPaginationNextPrev;
14
- return (react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationHook)));
14
+ return react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationHook));
15
15
  };
16
16
  exports.ResultPaginationNextPrev = ResultPaginationNextPrev;
17
17
  //# sourceMappingURL=ResultPaginationNextPrev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResultPaginationNextPrev.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationNextPrev.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAA4C;AAE5C,iDAAmE;AAM5D,MAAM,wBAAwB,GAA4C,CAAC,KAAK,EAAE,EAAE;;IACzF,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,yBAAyB,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElF,OAAO,CACL,8BAAC,yBAAyB,oBACpB,cAAc,EAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","sourcesContent":["import React from \"react\";\n\nimport { usePagination } from \"../../hooks\";\nimport { ReactivesearchPaginationProps } from \"../../types\";\nimport { ExampleResultPaginationNextPrev } from \"../../components\";\n\nexport type ResultPaginationNextPrevProps = ReactivesearchPaginationProps & {\n render?: React.FC<ReturnType<typeof usePagination>>;\n};\n\nexport const ResultPaginationNextPrev: React.FC<ResultPaginationNextPrevProps> = (props) => {\n const paginationHook = usePagination(props);\n\n const RenderPaginationComponent = props.render ?? ExampleResultPaginationNextPrev;\n\n return (\n <RenderPaginationComponent\n {...paginationHook}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"ResultPaginationNextPrev.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationNextPrev.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAA4C;AAE5C,iDAG0B;AAMnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;;IACR,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,yBAAyB,GAC7B,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElD,OAAO,8BAAC,yBAAyB,oBAAK,cAAc,EAAI,CAAC;AAC3D,CAAC,CAAC;AARS,QAAA,wBAAwB,4BAQjC","sourcesContent":["import React from \"react\";\n\nimport { usePagination } from \"../../hooks\";\nimport { ReactivesearchPaginationProps } from \"../../types\";\nimport {\n ResultsProps,\n ExampleResultPaginationNextPrev,\n} from \"../../components\";\n\nexport type ResultPaginationNextPrevProps = ReactivesearchPaginationProps & {\n render?: ResultsProps[\"renderPaginationNextPrev\"];\n};\n\nexport const ResultPaginationNextPrev: React.FC<ResultPaginationNextPrevProps> =\n (props) => {\n const paginationHook = usePagination(props);\n\n const RenderPaginationComponent =\n props.render ?? ExampleResultPaginationNextPrev;\n\n return <RenderPaginationComponent {...paginationHook} />;\n };\n"]}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { ReactivesearchPaginationProps } from "../../types";
3
- import { usePagination } from "../../hooks";
3
+ import { ResultsProps } from "../../components";
4
4
  export declare type ResultPaginationNumberedProps = ReactivesearchPaginationProps & {
5
- render?: React.FC<ReturnType<typeof usePagination>>;
5
+ render?: ResultsProps["renderPaginationNumbered"];
6
6
  };
7
7
  export declare const ResultPaginationNumbered: React.FC<ResultPaginationNumberedProps>;
@@ -14,7 +14,7 @@ const ResultPaginationNumbered = (props) => {
14
14
  return null;
15
15
  }
16
16
  const RenderPaginationComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultPaginationNumbered;
17
- return (react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationHook)));
17
+ return react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationHook));
18
18
  };
19
19
  exports.ResultPaginationNumbered = ResultPaginationNumbered;
20
20
  //# sourceMappingURL=ResultPaginationNumbered.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResultPaginationNumbered.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationNumbered.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAA4C;AAC5C,iDAAmE;AAM5D,MAAM,wBAAwB,GAA4C,CAAC,KAAK,EAAE,EAAE;;IACzF,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;QAC9B,OAAO,IAAI,CAAC;KACb;IAED,MAAM,yBAAyB,GAAG,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElF,OAAO,CACL,8BAAC,yBAAyB,oBACpB,cAAc,EAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,wBAAwB,4BAcnC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchPaginationProps } from \"../../types\";\nimport { usePagination } from \"../../hooks\";\nimport { ExampleResultPaginationNumbered } from \"../../components\";\n\nexport type ResultPaginationNumberedProps = ReactivesearchPaginationProps & {\n render?: React.FC<ReturnType<typeof usePagination>>;\n};\n\nexport const ResultPaginationNumbered: React.FC<ResultPaginationNumberedProps> = (props) => {\n const paginationHook = usePagination(props);\n\n if (!paginationHook.totalPages) {\n return null;\n }\n \n const RenderPaginationComponent = props.render ?? ExampleResultPaginationNumbered;\n\n return (\n <RenderPaginationComponent\n {...paginationHook}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"ResultPaginationNumbered.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationNumbered.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAA4C;AAC5C,iDAG0B;AAMnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;;IACR,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;IAE5C,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;QAC9B,OAAO,IAAI,CAAC;KACb;IAED,MAAM,yBAAyB,GAC7B,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElD,OAAO,8BAAC,yBAAyB,oBAAK,cAAc,EAAI,CAAC;AAC3D,CAAC,CAAC;AAZS,QAAA,wBAAwB,4BAYjC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchPaginationProps } from \"../../types\";\nimport { usePagination } from \"../../hooks\";\nimport {\n ResultsProps,\n ExampleResultPaginationNumbered,\n} from \"../../components\";\n\nexport type ResultPaginationNumberedProps = ReactivesearchPaginationProps & {\n render?: ResultsProps[\"renderPaginationNumbered\"];\n};\n\nexport const ResultPaginationNumbered: React.FC<ResultPaginationNumberedProps> =\n (props) => {\n const paginationHook = usePagination(props);\n\n if (!paginationHook.totalPages) {\n return null;\n }\n\n const RenderPaginationComponent =\n props.render ?? ExampleResultPaginationNumbered;\n\n return <RenderPaginationComponent {...paginationHook} />;\n };\n"]}
@@ -1,15 +1,11 @@
1
1
  import React from "react";
2
- import { ResultCardCallout } from "./ResultCardCallout";
3
- import { ResultCardProduct } from "./ResultCardProduct";
4
- import { ResultPaginationNumbered } from "./ResultPaginationNumbered";
5
- import { ResultPaginationLoadMore } from "./ResultPaginationLoadMore";
6
- import { ResultPaginationNextPrev } from "./ResultPaginationNextPrev";
7
2
  import { ElasticCallout, ElasticProduct, ReactivesearchError, ReactivesearchResultProps } from "../../types";
3
+ import { useProductPrice, usePagination, usePaginationLoadMore } from "../../hooks";
8
4
  export declare type ResultProps = ReactivesearchResultProps & {
9
5
  callouts: ElasticCallout[];
10
6
  products: ElasticProduct[];
11
7
  };
12
- export declare type ResultStackProps = {
8
+ export declare type ResultsProps = {
13
9
  /** Style prop for the list wrapper */
14
10
  listStyle?: React.HTMLAttributes<HTMLElement>["style"];
15
11
  /** Classname prop for the list wrapper */
@@ -23,18 +19,30 @@ export declare type ResultStackProps = {
23
19
  /** Render method called when no results are found */
24
20
  renderNoResults?: React.FC;
25
21
  /** Render method called once for each product result */
26
- renderResultCardProduct?: React.ComponentProps<typeof ResultCardProduct>["render"];
22
+ renderResultCardProduct?: React.FC<ReturnType<typeof useProductPrice> & {
23
+ pagePosition: number;
24
+ product: ElasticProduct;
25
+ document: ElasticProduct;
26
+ itemRef: (node?: Element | null) => void;
27
+ handleClick: () => void;
28
+ }>;
27
29
  /** Render method called once for each callout result */
28
- renderResultCardCallout?: React.ComponentProps<typeof ResultCardCallout>["render"];
30
+ renderResultCardCallout?: React.FC<{
31
+ pagePosition: number;
32
+ document: ElasticCallout;
33
+ callout: ElasticCallout["callout"];
34
+ itemRef: (node?: Element | null) => void;
35
+ handleClick: () => void;
36
+ }>;
29
37
  /** Render method called for pagination type "pagination" */
30
- renderPaginationNumbered?: React.ComponentProps<typeof ResultPaginationNumbered>["render"];
38
+ renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;
31
39
  /** Render method called for pagination type "next_prev" */
32
- renderPaginationNextPrev?: React.ComponentProps<typeof ResultPaginationNextPrev>["render"];
40
+ renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;
33
41
  /** Render method called for pagination type "load_more" */
34
- renderPaginationLoadMore?: React.ComponentProps<typeof ResultPaginationLoadMore>["render"];
42
+ renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadMore>>;
35
43
  /** Render method called for pagination type "infinite_scroll" */
36
- renderPaginationInfiniteScroll?: React.ComponentProps<typeof ResultPaginationLoadMore>["render"];
44
+ renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof usePaginationLoadMore>>;
37
45
  /** Advanced Usage: Override the default amount of results per page */
38
46
  pageSize?: number;
39
47
  };
40
- export declare const ResultStack: React.FC<ResultStackProps>;
48
+ export declare const Results: React.FC<ResultsProps>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ResultStack = void 0;
6
+ exports.Results = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const ReactiveList_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/result/ReactiveList"));
9
9
  const ResultCardCallout_1 = require("./ResultCardCallout");
@@ -11,30 +11,31 @@ const ResultCardProduct_1 = require("./ResultCardProduct");
11
11
  const ResultPaginationNumbered_1 = require("./ResultPaginationNumbered");
12
12
  const ResultPaginationLoadMore_1 = require("./ResultPaginationLoadMore");
13
13
  const ResultPaginationNextPrev_1 = require("./ResultPaginationNextPrev");
14
- const hooks_1 = require("../../hooks");
15
14
  const types_1 = require("../../types");
16
- const ResultStack = (props) => {
15
+ const hooks_1 = require("../../hooks");
16
+ const utility_1 = require("../../utility");
17
+ const Results = (props) => {
17
18
  const reactiveReactiveListProps = (0, hooks_1.useReactiveReactiveListProps)({
18
19
  pageSize: props.pageSize,
19
20
  });
20
- return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveReactiveListProps, { render: (reactivesearchResultProps) => (react_1.default.createElement(ResultStackInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))), renderPagination: (reactivesearchPaginationProps) => (react_1.default.createElement(ResultStackPaginationStack, Object.assign({}, props, reactivesearchPaginationProps))) })));
21
+ return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveReactiveListProps, { render: (reactivesearchResultProps) => (react_1.default.createElement(ResultsInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))), renderPagination: (reactivesearchPaginationProps) => (react_1.default.createElement(ResultsPaginationStack, Object.assign({}, props, reactivesearchPaginationProps))) })));
21
22
  };
22
- exports.ResultStack = ResultStack;
23
- const ResultStackRenderErrorComponent = (props) => {
23
+ exports.Results = Results;
24
+ const ResultsRenderErrorComponent = (props) => {
24
25
  return (react_1.default.createElement("div", null,
25
26
  "Error: ",
26
27
  props.error.statusText));
27
28
  };
28
- const ResultStackRenderLoadingComponent = () => {
29
+ const ResultsRenderLoadingComponent = () => {
29
30
  return react_1.default.createElement("div", null, "Loading");
30
31
  };
31
- const ResultStackRenderNoResultsComponent = () => {
32
+ const ResultsRenderNoResultsComponent = () => {
32
33
  return react_1.default.createElement("div", null, "No results");
33
34
  };
34
- const ResultStackInner = (props) => {
35
+ const ResultsInner = (props) => {
35
36
  var _a, _b, _c;
36
37
  const { track } = (0, hooks_1.useAnalytics)();
37
- const { searchQuery } = (0, hooks_1.useSearch)();
38
+ const { searchTerm } = (0, hooks_1.useSearch)();
38
39
  const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
39
40
  typeof props.reactivesearchResultProps.resultStats.numberOfResults, [props.reactivesearchResultProps]);
40
41
  const listStyle = react_1.default.useMemo(() => {
@@ -45,24 +46,40 @@ const ResultStackInner = (props) => {
45
46
  gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
46
47
  };
47
48
  }, [props.listStyle]);
49
+ react_1.default.useEffect(() => {
50
+ if (!props.reactivesearchResultProps.loading &&
51
+ !props.reactivesearchResultProps.resultStats.numberOfResults) {
52
+ if (searchTerm) {
53
+ track({
54
+ eventName: "zeroResults",
55
+ payload: {
56
+ searchTerm: searchTerm,
57
+ },
58
+ });
59
+ }
60
+ }
61
+ }, [
62
+ props.reactivesearchResultProps.loading,
63
+ props.reactivesearchResultProps.resultStats.numberOfResults,
64
+ searchTerm,
65
+ ]);
48
66
  if (props.reactivesearchResultProps.error) {
49
- const RenderErrorComponent = (_a = props.renderError) !== null && _a !== void 0 ? _a : ResultStackRenderErrorComponent;
67
+ utility_1.debug.breadcrumb({
68
+ category: "result",
69
+ message: "error",
70
+ data: {
71
+ error: props.reactivesearchResultProps.error,
72
+ },
73
+ });
74
+ const RenderErrorComponent = (_a = props.renderError) !== null && _a !== void 0 ? _a : ResultsRenderErrorComponent;
50
75
  return (react_1.default.createElement(RenderErrorComponent, { error: props.reactivesearchResultProps.error }));
51
76
  }
52
77
  if (!initialSearchHasRun) {
53
- const RenderLoadingComponent = (_b = props.renderLoading) !== null && _b !== void 0 ? _b : ResultStackRenderLoadingComponent;
78
+ const RenderLoadingComponent = (_b = props.renderLoading) !== null && _b !== void 0 ? _b : ResultsRenderLoadingComponent;
54
79
  return react_1.default.createElement(RenderLoadingComponent, null);
55
80
  }
56
81
  if (!props.reactivesearchResultProps.resultStats.numberOfResults) {
57
- if (searchQuery) {
58
- track({
59
- eventName: "zeroResults",
60
- payload: {
61
- searchTerm: searchQuery,
62
- },
63
- });
64
- }
65
- const RenderNoResultsComponent = (_c = props.renderNoResults) !== null && _c !== void 0 ? _c : ResultStackRenderNoResultsComponent;
82
+ const RenderNoResultsComponent = (_c = props.renderNoResults) !== null && _c !== void 0 ? _c : ResultsRenderNoResultsComponent;
66
83
  return react_1.default.createElement(RenderNoResultsComponent, null);
67
84
  }
68
85
  return (react_1.default.createElement(react_1.default.Fragment, null,
@@ -76,12 +93,12 @@ const ResultStackInner = (props) => {
76
93
  }
77
94
  return null;
78
95
  })),
79
- react_1.default.createElement(ResultStackPaginationStackLoadMore, Object.assign({}, props, props.reactivesearchResultProps))));
96
+ react_1.default.createElement(ResultsPaginationStackLoadMore, Object.assign({}, props, props.reactivesearchResultProps))));
80
97
  };
81
98
  /** Handles rendering pagination for types that use "pagination props" */
82
- const ResultStackPaginationStack = (props) => {
99
+ const ResultsPaginationStack = (props) => {
83
100
  const { options } = (0, hooks_1.useReactifySearchContext)();
84
- const { filterStack } = (0, hooks_1.useFilterStack)();
101
+ const { filterStack } = (0, hooks_1.useFilters)();
85
102
  if (options.mode === "instant-search") {
86
103
  return null;
87
104
  }
@@ -94,9 +111,9 @@ const ResultStackPaginationStack = (props) => {
94
111
  return null;
95
112
  };
96
113
  /** Handles rendering pagination for types that use "result props" */
97
- const ResultStackPaginationStackLoadMore = (props) => {
114
+ const ResultsPaginationStackLoadMore = (props) => {
98
115
  const { options } = (0, hooks_1.useReactifySearchContext)();
99
- const { filterStack } = (0, hooks_1.useFilterStack)();
116
+ const { filterStack } = (0, hooks_1.useFilters)();
100
117
  if (options.mode === "instant-search") {
101
118
  return null;
102
119
  }
@@ -105,4 +122,4 @@ const ResultStackPaginationStackLoadMore = (props) => {
105
122
  }
106
123
  return null;
107
124
  };
108
- //# sourceMappingURL=ResultStack.js.map
125
+ //# sourceMappingURL=Results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAOqB;AACrB,uCASqB;AACrB,2CAAsC;AAkD/B,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC;QAC7D,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IAEH,OAAO,CACL,8BAAC,sBAAY,oBACP,yBAAyB,IAC7B,MAAM,EAAE,CAAC,yBAAoD,EAAE,EAAE,CAAC,CAChE,8BAAC,YAAY,oBACP,KAAK,IACT,yBAAyB,EAAE,yBAAyB,IACpD,CACH,EACD,gBAAgB,EAAE,CAChB,6BAA4D,EAC5D,EAA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AE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,IACT,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,8BAA8B,GAEhC,CAAC,KAAK,EAAE,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useReactiveReactiveListProps,\n useProductPrice,\n usePagination,\n usePaginationLoadMore,\n} from \"../../hooks\";\nimport { debug } from \"../../utility\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadMore>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadMore>\n >;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n });\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n renderPagination={(\n reactivesearchPaginationProps: ReactivesearchPaginationProps\n ) => (\n <ResultsPaginationStack {...props} {...reactivesearchPaginationProps} />\n )}\n />\n );\n};\n\nconst ResultsRenderErrorComponent: ResultsProps[\"renderError\"] = (props) => {\n return (\n <div>\n {\"Error: \"}\n {props.error.statusText}\n </div>\n );\n};\n\nconst ResultsRenderLoadingComponent: ResultsProps[\"renderLoading\"] = () => {\n return <div>{\"Loading\"}</div>;\n};\n\nconst ResultsRenderNoResultsComponent: ResultsProps[\"renderNoResults\"] = () => {\n return <div>{\"No results\"}</div>;\n};\n\nconst ResultsInner: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n const initialSearchHasRun = React.useMemo(\n () =>\n \"undefined\" !==\n typeof props.reactivesearchResultProps.resultStats.numberOfResults,\n [props.reactivesearchResultProps]\n );\n\n const listStyle = React.useMemo<React.HTMLAttributes<HTMLElement>[\"style\"]>(\n () =>\n props.listStyle ?? {\n display: \"grid\",\n gap: \"8px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n },\n [props.listStyle]\n );\n\n React.useEffect(() => {\n if (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n if (searchTerm) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchTerm,\n },\n });\n }\n }\n }, [\n props.reactivesearchResultProps.loading,\n props.reactivesearchResultProps.resultStats.numberOfResults,\n searchTerm,\n ]);\n\n if (props.reactivesearchResultProps.error) {\n debug.breadcrumb({\n category: \"result\",\n message: \"error\",\n data: {\n error: props.reactivesearchResultProps.error,\n },\n });\n\n const RenderErrorComponent =\n props.renderError ?? ResultsRenderErrorComponent;\n\n return (\n <RenderErrorComponent error={props.reactivesearchResultProps.error} />\n );\n }\n\n if (!initialSearchHasRun) {\n const RenderLoadingComponent =\n props.renderLoading ?? ResultsRenderLoadingComponent;\n return <RenderLoadingComponent />;\n }\n\n if (!props.reactivesearchResultProps.resultStats.numberOfResults) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n return <RenderNoResultsComponent />;\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n // @todo result.type is missing in v1 indexes, this check ensures that they are assumed to be products\n if (ElasticDocumentType.Product === item.type || !item.type) {\n return (\n <ResultCardProduct\n key={item._id}\n product={item}\n document={item}\n pagePosition={key + 1}\n render={props.renderResultCardProduct}\n />\n );\n }\n\n if (ElasticDocumentType.Callout === item.type) {\n return (\n <ResultCardCallout\n key={item._id}\n document={item}\n pagePosition={key + 1}\n callout={item.callout}\n render={props.renderResultCardCallout}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadMore\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<\n ResultsProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultsPaginationStackLoadMore: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n return null;\n};\n"]}
@@ -1,4 +1,4 @@
1
- export * from "./ResultStack";
1
+ export * from "./Results";
2
2
  export * from "./ResultCardCallout";
3
3
  export * from "./ResultCardProduct";
4
4
  export * from "./ResultStateProvider";