@usereactify/search 5.8.1 → 5.9.0-beta.1

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,36 @@
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
+ ## [5.9.0-beta.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.9.0-beta.0...beta-v5.9.0-beta.1) (2022-10-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * correct typings for result stats ([d01b918](https://bitbucket.org/usereactify/reactify-search-ui/commit/d01b91806d4ef276930fa6395589c84127149ced))
11
+
12
+ ## [5.9.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.6.1-beta.0...beta-v5.9.0-beta.0) (2022-10-16)
13
+
14
+
15
+ ### Features
16
+
17
+ * add hook to access results ([80e19f6](https://bitbucket.org/usereactify/reactify-search-ui/commit/80e19f6afe2a516e2b7592555e5fdb6769912fa9))
18
+ * add support for multiple select ranges ([7c35973](https://bitbucket.org/usereactify/reactify-search-ui/commit/7c3597332bfd68088dbd454c4f0a2dd80ce1cd95))
19
+ * support filter option for displaying empty values ([9e66934](https://bitbucket.org/usereactify/reactify-search-ui/commit/9e66934714ef4ceb6563ce3d9be76e72453e7557))
20
+ * update examples for range and selected filters ([b264aa2](https://bitbucket.org/usereactify/reactify-search-ui/commit/b264aa2af8a8bbddd76e48c22575c6b082777ec6))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * exclude exact tag fields from span_term filtering ([be206ca](https://bitbucket.org/usereactify/reactify-search-ui/commit/be206ca0f0015e556ffceb4df2139a3d8b8e660b))
26
+ * prevent initial query without search term and sort option ([44976fd](https://bitbucket.org/usereactify/reactify-search-ui/commit/44976fd5b8861d55ebe9aaf269a014c5c3ca1cc6))
27
+
28
+ ### [5.8.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.8.1...release-v5.8.2) (2022-10-13)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * prevent initial query without search term and sort option ([44976fd](https://bitbucket.org/usereactify/reactify-search-ui/commit/44976fd5b8861d55ebe9aaf269a014c5c3ca1cc6))
34
+
5
35
  ### [5.8.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.8.0...release-v5.8.1) (2022-10-13)
6
36
 
7
37
 
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": "5.8.1",
4
+ "version": "5.9.0-beta.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -43,7 +43,7 @@ const Filter = (props) => {
43
43
  if ("range" === props.filter.displayType) {
44
44
  return react_1.default.createElement(FilterRangeSingle, Object.assign({}, props));
45
45
  }
46
- console.log(`filter with display type "${props.filter.displayType}" not yet supported`);
46
+ console.warn(`filter with display type "${props.filter.displayType}" not yet supported`);
47
47
  return null;
48
48
  };
49
49
  exports.Filter = Filter;
@@ -1 +1 @@
1
- {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wGAAgF;AAChF,0GAAkF;AAClF,2HAAmG;AACnG,6GAAqF;AACrF,2GAAmF;AAMnF,uCAOqB;AACrB,iDAI0B;AAsBnB,MAAM,MAAM,GAA0B,CAAC,KAAK,EAAE,EAAE;IACrD,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;QACzC,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;YACxC,OAAO,8BAAC,iBAAiB,oBAAK,KAAK,EAAI,CAAC;SACzC;QACD,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAAC;KACxC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xC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;QACnC,OAAO,CACL,8BAAC,SAAS,kBACR,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAiB,kBAChB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\nimport DynamicRangeSlider from \"@appbaseio/reactivesearch/lib/components/range/DynamicRangeSlider\";\nimport SingleRange from \"@appbaseio/reactivesearch/lib/components/range/SingleRange\";\nimport MultiRange from \"@appbaseio/reactivesearch/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSliderProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n }>;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.log(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactiveFilterSliderProps = useReactiveFilterSliderProps(props.filter);\n\n const filterSliderProps = useFilterSliderProps(props.filter);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <>\n {props.renderFilterSlider ? (\n <div\n style={{\n display: \"none\",\n }}\n >\n <DynamicRangeSlider\n {...reactiveFilterSliderProps}\n value={() => filterSliderProps.value}\n onChange={(value) =>\n filterSliderProps.handleChange({\n start: value[0],\n end: value[1],\n })\n }\n />\n </div>\n ) : null}\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n filter={props.filter}\n />\n </>\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (0 === filterListProps.options.length) {\n return null;\n }\n\n if (renderFilterList) {\n const Component = renderFilterList;\n return (\n <Component\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterList\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"Filter.js","sourceRoot":"","sources":["../../../../src/components/Filter/Filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wGAAgF;AAChF,0GAAkF;AAClF,2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AC;AACJ,CAAC,CAAC;AAEF,qFAAqF;AACrF,MAAM,eAAe,GAEjB,CAAC,KAAK,EAAE,EAAE;IACZ,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,yBAAyB,KACzD,KAAK,EADyD,UAAU,UACxE,KAAK,EADD,2DAAsE,CACrE,CAAC;IAER,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IAE9E,+CAA+C;IAC/C,IAAI,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAG,gBAAgB,CAAC;QACnC,OAAO,CACL,8BAAC,SAAS,kBACR,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAiB,kBAChB,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,IACV,UAAU,EACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport MultiList from \"@appbaseio/reactivesearch/lib/components/list/MultiList\";\nimport SingleList from \"@appbaseio/reactivesearch/lib/components/list/SingleList\";\nimport DynamicRangeSlider from \"@appbaseio/reactivesearch/lib/components/range/DynamicRangeSlider\";\nimport SingleRange from \"@appbaseio/reactivesearch/lib/components/range/SingleRange\";\nimport MultiRange from \"@appbaseio/reactivesearch/lib/components/range/MultiRange\";\n\nimport type {\n ConfigFilterOption,\n ReactivesearchFilterListProps,\n} from \"../../types\";\nimport {\n useFilterListProps,\n useFilterRangeProps,\n useFilterSliderProps,\n useReactiveFilterListProps,\n useReactiveFilterRangeProps,\n useReactiveFilterSliderProps,\n} from \"../../hooks\";\nimport {\n ExampleFilterList,\n ExampleFilterRange,\n ExampleFilterSlider,\n} from \"../../components\";\n\nexport type FilterProps = {\n /** The filter option being rendered */\n filter: ConfigFilterOption;\n /** Render method for List filters */\n renderFilterList?: React.FC<{\n filter: ConfigFilterOption;\n filterListProps: ReturnType<typeof useFilterListProps>;\n }>;\n /** Render method for Range filters */\n renderFilterRange?: React.FC<{\n filter: ConfigFilterOption;\n filterRangeProps: ReturnType<typeof useFilterRangeProps>;\n }>;\n /** Render method for Slider filters */\n renderFilterSlider?: React.FC<{\n filter: ConfigFilterOption;\n filterSliderProps: ReturnType<typeof useFilterSliderProps>;\n }>;\n};\n\nexport const Filter: React.FC<FilterProps> = (props) => {\n if (\"single\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeSingle {...props} />;\n }\n return <FilterSingleList {...props} />;\n }\n\n if (\"multi\" === props.filter.displayType) {\n if (\"range\" === props.filter.displayView) {\n return <FilterRangeMulti {...props} />;\n }\n return <FilterMultiList {...props} />;\n }\n\n if (\"slider\" === props.filter.displayType) {\n return <FilterSlider {...props} />;\n }\n\n // TODO: Legacy range filter, migrate to new single and multi ranges\n if (\"range\" === props.filter.displayType) {\n return <FilterRangeSingle {...props} />;\n }\n\n console.warn(\n `filter with display type \"${props.filter.displayType}\" not yet supported`\n );\n\n return null;\n};\n\nconst FilterSingleList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <SingleList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterMultiList: React.FC<FilterProps> = (props) => {\n const reactiveFilterListProps = useReactiveFilterListProps(props.filter);\n\n return (\n <MultiList\n {...reactiveFilterListProps}\n render={(reactivesearchFilterProps: ReactivesearchFilterListProps) => (\n <FilterListInner\n {...props}\n reactivesearchFilterProps={reactivesearchFilterProps}\n />\n )}\n />\n );\n};\n\nconst FilterRangeSingle: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <SingleRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values[0]}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterRangeMulti: React.FC<FilterProps> = (props) => {\n const reactiveFilterRangeProps = useReactiveFilterRangeProps(props.filter);\n\n const filterRangeProps = useFilterRangeProps(props.filter);\n\n const RenderRangeComponent = props.renderFilterRange ?? ExampleFilterRange;\n\n return (\n <>\n <div\n style={{\n display: \"none\",\n }}\n >\n <MultiRange\n {...reactiveFilterRangeProps}\n value={filterRangeProps.values}\n onChange={filterRangeProps.handleChange}\n />\n </div>\n <RenderRangeComponent\n filterRangeProps={filterRangeProps}\n filter={props.filter}\n />\n </>\n );\n};\n\nconst FilterSlider: React.FC<FilterProps> = (props) => {\n const reactiveFilterSliderProps = useReactiveFilterSliderProps(props.filter);\n\n const filterSliderProps = useFilterSliderProps(props.filter);\n\n const RenderSliderComponent = props.renderFilterSlider ?? ExampleFilterSlider;\n\n return (\n <>\n {props.renderFilterSlider ? (\n <div\n style={{\n display: \"none\",\n }}\n >\n <DynamicRangeSlider\n {...reactiveFilterSliderProps}\n value={() => filterSliderProps.value}\n onChange={(value) =>\n filterSliderProps.handleChange({\n start: value[0],\n end: value[1],\n })\n }\n />\n </div>\n ) : null}\n <RenderSliderComponent\n filterSliderProps={filterSliderProps}\n filter={props.filter}\n />\n </>\n );\n};\n\n// inner component exists only so we can use memos in reactivesearch render functions\nconst FilterListInner: React.FC<\n FilterProps & { reactivesearchFilterProps: ReactivesearchFilterListProps }\n> = (props) => {\n const { filter, renderFilterList, reactivesearchFilterProps, ...otherProps } =\n props;\n\n const filterListProps = useFilterListProps(filter, reactivesearchFilterProps);\n\n // hide entire filter when no options available\n if (0 === filterListProps.options.length) {\n return null;\n }\n\n if (renderFilterList) {\n const Component = renderFilterList;\n return (\n <Component\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n }\n\n return (\n <ExampleFilterList\n filterListProps={filterListProps}\n filter={filter}\n {...otherProps}\n />\n );\n};\n"]}
@@ -46,9 +46,6 @@ 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 [searchTerm, setSearchTerm] = react_1.default.useState("");
50
- const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
51
- const [sortOption, setSortOption] = react_1.default.useState("");
52
49
  const credentials = (_a = props.credentials) !== null && _a !== void 0 ? _a : {
53
50
  username: "guest",
54
51
  password: "password",
@@ -76,6 +73,11 @@ const ReactifySearchInner = (props) => {
76
73
  const urlParams = new URLSearchParams(window.location.search);
77
74
  return (_a = urlParams.get("sort")) !== null && _a !== void 0 ? _a : undefined;
78
75
  }, [typeof window !== "undefined" && window.location.search]);
76
+ const [searchTerm, setSearchTerm] = react_1.default.useState(searchTermFromURL !== null && searchTermFromURL !== void 0 ? searchTermFromURL : "");
77
+ const [showInstantSearchResults, setShowInstantSearchResults] = react_1.default.useState(false);
78
+ const [sortOption, setSortOption] = react_1.default.useState(searchSortFromURL !== null && searchSortFromURL !== void 0 ? searchSortFromURL : "");
79
+ const [results, setResults] = react_1.default.useState([]);
80
+ const [resultStats, setResultStats] = react_1.default.useState();
79
81
  react_1.default.useEffect(() => {
80
82
  if (searchTermFromURL && searchTerm !== searchTermFromURL) {
81
83
  setSearchTerm(searchTermFromURL);
@@ -86,14 +88,6 @@ const ReactifySearchInner = (props) => {
86
88
  setSortOption(searchSortFromURL);
87
89
  }
88
90
  }, [searchSortFromURL]);
89
- react_1.default.useEffect(() => {
90
- if (typeof window == "undefined") {
91
- return;
92
- }
93
- if (window.location.search === "" && sortOption) {
94
- setSortOption(sortOption);
95
- }
96
- }, [typeof window !== "undefined" && window.location.search]);
97
91
  const contextValue = react_1.default.useMemo(() => {
98
92
  var _a;
99
93
  if (!config) {
@@ -112,8 +106,22 @@ const ReactifySearchInner = (props) => {
112
106
  sortOption: sortOption,
113
107
  setSortOption: setSortOption,
114
108
  },
109
+ results: {
110
+ results: results,
111
+ setResults: setResults,
112
+ resultStats: resultStats,
113
+ setResultStats: setResultStats,
114
+ },
115
115
  };
116
- }, [config, props, searchTerm, showInstantSearchResults, sortOption]);
116
+ }, [
117
+ config,
118
+ props,
119
+ searchTerm,
120
+ showInstantSearchResults,
121
+ sortOption,
122
+ results,
123
+ resultStats,
124
+ ]);
117
125
  utility_1.debug.hook("ReactifySearchProvider", "context", contextValue);
118
126
  if (!contextValue) {
119
127
  if (props.renderBooting) {
@@ -1 +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;AAiD/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,KAAK;YACnC,qBAAqB,EAAE,KAAK,CAAC,sBAAsB;YACnD,qBAAqB,EAAE,KAAK,CAAC,IAAI;YACjC,2BAA2B,EACzB,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;YAClE,uBAAuB,EAAE,KAAK,CAAC,aAAa;SAC7C,C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Y,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACtC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,OAAO;YACL,MAAM,EAAE,MAAM;YACd,OAAO,kCACF,KAAK,KACR,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,MAAM,CAAC,KAAK,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,GACb;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;gBAC5B,wBAAwB,EAAE,wBAAwB;gBAClD,2BAA2B,EAAE,2BAA2B;aACzD;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;aAC7B;SACF,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtE,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,cAAc,EAAE;QACxB,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAChD,KAAK,CAAC,QAAQ,CACgB,CAClC,CAAC;KACH;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 /** Standard react children */\n children?: React.ReactNode | undefined;\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 additionalComponentIds?: 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 /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: string[];\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: string[];\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"]}
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;AAkD/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,KAAK;YACnC,qBAAqB,EAAE,KAAK,CAAC,sBAAsB;YACnD,qBAAqB,EAAE,KAAK,CAAC,IAAI;YACjC,2BAA2B,EACzB,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;YAClE,uBAAuB,EAAE,KAAK,CAAC,aAAa;SAC7C,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAA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,OAAO,kCACF,KAAK,KACR,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,MAAM,CAAC,KAAK,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,GACb;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;gBAC5B,wBAAwB,EAAE,wBAAwB;gBAClD,2BAA2B,EAAE,2BAA2B;aACzD;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,UAAU;gBACtB,aAAa,EAAE,aAAa;aAC7B;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,UAAU;gBACtB,WAAW,EAAE,WAAW;gBACxB,cAAc,EAAE,cAAc;aAC/B;SACF,CAAC;IACJ,CAAC,EAAE;QACD,MAAM;QACN,KAAK;QACL,UAAU;QACV,wBAAwB;QACxB,UAAU;QACV,OAAO;QACP,WAAW;KACZ,CAAC,CAAC;IAEH,eAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,cAAc,EAAE;QACxB,OAAO,CACL,8BAAC,6BAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAChD,KAAK,CAAC,QAAQ,CACgB,CAClC,CAAC;KACH;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\";\nimport { ReactivesearchResultProps } from \"../../types\";\n\nexport type ReactifySearchProviderProps = {\n /** Standard react children */\n children?: React.ReactNode | undefined;\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 additionalComponentIds?: 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 /** Advanced usage: Fields to include in the Elasticsearch response e.g. [\"title\"] */\n includeFields?: string[];\n /** Advanced usage: Fields to exclude from the Elasticsearch response e.g. [\"variant_skus\", \"*price*\"] */\n excludeFields?: string[];\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 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 const [searchTerm, setSearchTerm] = React.useState<string>(\n searchTermFromURL ?? \"\"\n );\n const [showInstantSearchResults, setShowInstantSearchResults] =\n React.useState<boolean>(false);\n const [sortOption, setSortOption] = React.useState<string>(\n searchSortFromURL ?? \"\"\n );\n\n const [results, setResults] = React.useState<\n ReactivesearchResultProps[\"data\"]\n >([]);\n const [resultStats, setResultStats] =\n React.useState<ReactivesearchResultProps[\"resultStats\"]>();\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 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 results: {\n results: results,\n setResults: setResults,\n resultStats: resultStats,\n setResultStats: setResultStats,\n },\n };\n }, [\n config,\n props,\n searchTerm,\n showInstantSearchResults,\n sortOption,\n results,\n resultStats,\n ]);\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"]}
@@ -50,6 +50,7 @@ const ResultsRenderNoResultsComponent = () => {
50
50
  const ResultsInner = (props) => {
51
51
  var _a, _b, _c, _d, _e;
52
52
  const filtersHook = (0, hooks_1.useFilters)();
53
+ const resultsHook = (0, hooks_1.useResults)();
53
54
  const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
54
55
  typeof props.reactivesearchResultProps.resultStats.numberOfResults, [props.reactivesearchResultProps]);
55
56
  const listStyle = react_1.default.useMemo(() => {
@@ -73,6 +74,10 @@ const ResultsInner = (props) => {
73
74
  props.reactivesearchResultProps.resultStats.displayedResults,
74
75
  props.infiniteScrollPosition,
75
76
  ]);
77
+ react_1.default.useEffect(() => {
78
+ resultsHook.setResults(props.reactivesearchResultProps.data);
79
+ resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);
80
+ }, [props.reactivesearchResultProps.data.map((item) => item._id).join("")]);
76
81
  if (props.reactivesearchResultProps.error) {
77
82
  utility_1.debug.breadcrumb({
78
83
  category: "result",
@@ -1 +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;AACtC,qFAAkF;AAwD3E,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC;QAC7D,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,YAAY,EAAE,KAAK,CAAC,uBAAuB;KAC5C,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,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,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE;YACtB,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,eAAe,EAAE;gBACpE,IAAI,UAAU,EAAE;oBACd,KAAK,CAAC;wBACJ,SAAS,EAAE,aAAa;wBACxB,OAAO,EAAE;4BACP,UAAU,EAAE,UAAU;yBACvB;qBACF,CAAC,CAAC;iBACJ;aACF;QACH,CAAC,EACD,gBAAgB,EAAE,CAChB,6BAA4D,EAC5D,EAAE,CAAC,CACH,8BAAC,sBAAsB,oBAAK,KAAK,EAAM,6BAA6B,EAAI,CACzE,IACD,CACH,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,OAAO,WAoClB;AAEF,MAAM,2BAA2B,G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AgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,YAAY,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAChD,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,IACT,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;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,IAAI,iBAAiB,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QACrD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,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 usePaginationLoadable,\n} from \"../../hooks\";\nimport { debug } from \"../../utility\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\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 usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadable>\n >;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<\n typeof ReactiveList\n >[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n scrollTarget: props.infiniteScrollContainer,\n });\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n onData={(renderProps) => {\n if (!renderProps.loading && !renderProps.resultStats.numberOfResults) {\n if (searchTerm) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchTerm,\n },\n });\n }\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 filtersHook = useFilters();\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 const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\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 (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n if (ElasticDocumentType.Product === 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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable\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 ResultsPaginationStackLoadable: 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 if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
1
+ {"version":3,"file":"Results.js","sourceRoot":"","sources":["../../../../src/components/Result/Results.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gHAAwF;AAExF,2DAAwD;AACxD,2DAAwD;AACxD,yEAAs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AA,EAAE;QACrD,OAAO,CACL,8BAAC,+DAA8B,oBACzB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,8BAA8B,IAC5C,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 usePaginationLoadable,\n useResults,\n} from \"../../hooks\";\nimport { debug } from \"../../utility\";\nimport { ResultPaginationInfiniteScroll } from \"./ResultPaginationInfiniteScroll\";\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 usePaginationLoadable>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadable>\n >;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n /** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */\n infiniteScrollContainer?: React.ComponentProps<\n typeof ReactiveList\n >[\"scrollTarget\"];\n /** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */\n infiniteScrollPosition?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n scrollTarget: props.infiniteScrollContainer,\n });\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n return (\n <ReactiveList\n {...reactiveReactiveListProps}\n render={(reactivesearchResultProps: ReactivesearchResultProps) => (\n <ResultsInner\n {...props}\n reactivesearchResultProps={reactivesearchResultProps}\n />\n )}\n onData={(renderProps) => {\n if (!renderProps.loading && !renderProps.resultStats.numberOfResults) {\n if (searchTerm) {\n track({\n eventName: \"zeroResults\",\n payload: {\n searchTerm: searchTerm,\n },\n });\n }\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 filtersHook = useFilters();\n const resultsHook = useResults();\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 const infiniteScrollPosition = React.useMemo<number>(() => {\n if (!props.infiniteScrollPosition) {\n return NaN;\n }\n\n const scrollPositionOffset =\n props.reactivesearchResultProps.resultStats.displayedResults -\n (props.pageSize ?? filtersHook.filterStack?.pageSize ?? 0);\n\n return scrollPositionOffset + (props.infiniteScrollPosition ?? 0);\n }, [\n props.pageSize ?? filtersHook.filterStack?.pageSize,\n props.reactivesearchResultProps.resultStats.displayedResults,\n props.infiniteScrollPosition,\n ]);\n\n React.useEffect(() => {\n resultsHook.setResults(props.reactivesearchResultProps.data);\n resultsHook.setResultStats(props.reactivesearchResultProps.resultStats);\n }, [props.reactivesearchResultProps.data.map((item) => item._id).join(\"\")]);\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 (\n !props.reactivesearchResultProps.loading &&\n !props.reactivesearchResultProps.resultStats.numberOfResults\n ) {\n const RenderNoResultsComponent =\n props.renderNoResults ?? ResultsRenderNoResultsComponent;\n\n return <RenderNoResultsComponent />;\n }\n\n return (\n <>\n <section style={listStyle} className={props.listClassName}>\n {props.reactivesearchResultProps.data.map((item, key) => {\n if (ElasticDocumentType.Product === 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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\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 {...(infiniteScrollPosition === key + 1\n ? {\n onView: () => props.reactivesearchResultProps.loadMore(),\n }\n : {})}\n />\n );\n }\n\n return null;\n })}\n </section>\n <ResultsPaginationStackLoadable\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 ResultsPaginationStackLoadable: 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 if (\"infinite_scroll\" === filterStack?.paginationType) {\n return (\n <ResultPaginationInfiniteScroll\n {...props.reactivesearchResultProps}\n render={props.renderPaginationInfiniteScroll}\n />\n );\n }\n\n return null;\n};\n"]}
@@ -12,7 +12,7 @@ const SensorSearchTerm = () => {
12
12
  const { options, config } = (0, hooks_1.useReactifySearchContext)();
13
13
  const { track } = (0, hooks_1.useAnalytics)();
14
14
  const { searchTerm } = (0, hooks_1.useSearch)();
15
- const [searchTermDebounced, setSearchTermDebounced] = react_1.default.useState("");
15
+ const [searchTermDebounced, setSearchTermDebounced] = react_1.default.useState(searchTerm);
16
16
  // ignore search fields only set for instant search
17
17
  const searchFields = react_1.default.useMemo(() => {
18
18
  if (options.mode === "search") {
@@ -1 +1 @@
1
- {"version":3,"file":"SensorSearchTerm.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSearchTerm.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mCAAuC;AACvC,4GAAoF;AAEpF,uCAAgF;AAEzE,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,oBAAY,GAAE,CAAC;IACjC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IACnC,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GACjD,eAAK,CAAC,QAAQ,CAAS,EAAE,CAAC,CAAC;IAE7B,mDAAmD;IACnD,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtC,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC7B,OAAO,MAAM,CAAC,MAAM,CA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e,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;yBAC5D;wBACD,oBAAoB,EAAE,GAAG;qBAC1B;iBACF,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC,GACD,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAnKW,QAAA,gBAAgB,oBAmK3B","sourcesContent":["import React from \"react\";\nimport { useDebounceFn } from \"ahooks\";\nimport DataSearch from \"@appbaseio/reactivesearch/lib/components/search/DataSearch\";\n\nimport { useAnalytics, useReactifySearchContext, useSearch } from \"../../hooks\";\n\nexport const SensorSearchTerm: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n const [searchTermDebounced, setSearchTermDebounced] =\n React.useState<string>(\"\");\n\n // ignore search fields only set for instant search\n const searchFields = React.useMemo(() => {\n if (options.mode === \"search\") {\n return config.fields.filter((field) =>\n [\"always_search\", \"search_page\"].includes(field.searchType)\n );\n }\n\n if (options.mode === \"instant-search\") {\n return config.fields.filter((field) =>\n [\"always_search\", \"instant_search\"].includes(field.searchType)\n );\n }\n\n return [];\n }, [config.fields]);\n\n const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } =\n useDebounceFn(\n (value: string) => {\n setSearchTermDebounced(value);\n\n if (!value || (value && value.length < 3)) {\n return;\n }\n\n track({\n eventName: \"search\",\n payload: {\n searchTerm: value,\n },\n });\n },\n {\n wait: 300,\n }\n );\n\n React.useEffect(() => {\n runDebouncedTriggerQuery(searchTerm);\n }, [searchTerm]);\n\n if (searchFields.length === 0) {\n return null;\n }\n\n return (\n <>\n <DataSearch\n fuzziness={1}\n queryFormat=\"and\"\n autosuggest={false}\n value={searchTermDebounced}\n componentId=\"SensorSearchTerm\"\n style={{ display: \"none\" }}\n dataField={searchFields.map((field) => field.field)}\n fieldWeights={searchFields.map((field) => field.importance)}\n customQuery={(value, props) => {\n const { dataField, fieldWeights } = props;\n\n const fieldsCrossFields = dataField.map(\n (field: string, index: number) => `${field}^${fieldWeights[index]}`\n );\n\n const fieldsPhrase = dataField.map(\n (field: string, index: number) => `${field}^${fieldWeights[index]}`\n );\n\n const fieldsPhrasePrefix = dataField\n .map(\n (field: string, index: number) =>\n `${field}^${fieldWeights[index]}`\n )\n .filter((field: string) => !field.includes(\".\"));\n\n const fieldsSpanFirst: any = dataField\n .filter((field: string) => {\n if (field.startsWith(\"tags\") && field.endsWith(\".keyword\")) {\n return false;\n }\n\n return true;\n })\n .map((field: string) => ({\n span_first: {\n match: {\n span_term: { [`${field}`]: value },\n },\n end: 1,\n },\n }));\n\n const query = {\n bool: {\n should: [\n ...(value\n ? [\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.searchTerm.keyword\":\n value.toLowerCase(),\n },\n },\n },\n },\n ]\n : []),\n ...(fieldsPhrase.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsPhrase,\n type: \"phrase\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsPhrasePrefix.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsPhrasePrefix,\n type: \"phrase_prefix\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsCrossFields.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsCrossFields,\n type: \"cross_fields\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsSpanFirst.length > 0 ? [...fieldsSpanFirst] : []),\n ],\n minimum_should_match: \"1\",\n },\n };\n return { query };\n }}\n />\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"SensorSearchTerm.js","sourceRoot":"","sources":["../../../../src/components/Sensor/SensorSearchTerm.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mCAAuC;AACvC,4GAAoF;AAEpF,uCAAgF;AAEzE,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,M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ACE;wCACE,WAAW,EAAE;4CACX,KAAK,EAAE,KAAK;4CACZ,MAAM,EAAE,kBAAkB;4CAC1B,IAAI,EAAE,eAAe;4CACrB,QAAQ,EAAE,KAAK;yCAChB;qCACF;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;4BACP,GAAG,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;gCAC9B,CAAC,CAAC;oCACE;wCACE,WAAW,EAAE;4CACX,KAAK,EAAE,KAAK;4CACZ,MAAM,EAAE,iBAAiB;4CACzB,IAAI,EAAE,cAAc;4CACpB,QAAQ,EAAE,KAAK;yCAChB;qCACF;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;4BACP,GAAG,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;yBAC5D;wBACD,oBAAoB,EAAE,GAAG;qBAC1B;iBACF,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC,GACD,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AApKW,QAAA,gBAAgB,oBAoK3B","sourcesContent":["import React from \"react\";\nimport { useDebounceFn } from \"ahooks\";\nimport DataSearch from \"@appbaseio/reactivesearch/lib/components/search/DataSearch\";\n\nimport { useAnalytics, useReactifySearchContext, useSearch } from \"../../hooks\";\n\nexport const SensorSearchTerm: React.FC = () => {\n const { options, config } = useReactifySearchContext();\n const { track } = useAnalytics();\n const { searchTerm } = useSearch();\n\n const [searchTermDebounced, setSearchTermDebounced] =\n React.useState<string>(searchTerm);\n\n // ignore search fields only set for instant search\n const searchFields = React.useMemo(() => {\n if (options.mode === \"search\") {\n return config.fields.filter((field) =>\n [\"always_search\", \"search_page\"].includes(field.searchType)\n );\n }\n\n if (options.mode === \"instant-search\") {\n return config.fields.filter((field) =>\n [\"always_search\", \"instant_search\"].includes(field.searchType)\n );\n }\n\n return [];\n }, [config.fields]);\n\n const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } =\n useDebounceFn(\n (value: string) => {\n setSearchTermDebounced(value);\n\n if (!value || (value && value.length < 3)) {\n return;\n }\n\n track({\n eventName: \"search\",\n payload: {\n searchTerm: value,\n },\n });\n },\n {\n wait: 300,\n }\n );\n\n React.useEffect(() => {\n runDebouncedTriggerQuery(searchTerm);\n }, [searchTerm]);\n\n if (searchFields.length === 0) {\n return null;\n }\n\n return (\n <>\n <DataSearch\n fuzziness={1}\n queryFormat=\"and\"\n autosuggest={false}\n value={searchTermDebounced}\n componentId=\"SensorSearchTerm\"\n style={{ display: \"none\" }}\n dataField={searchFields.map((field) => field.field)}\n fieldWeights={searchFields.map((field) => field.importance)}\n customQuery={(value, props) => {\n const { dataField, fieldWeights } = props;\n\n const fieldsCrossFields = dataField.map(\n (field: string, index: number) => `${field}^${fieldWeights[index]}`\n );\n\n const fieldsPhrase = dataField.map(\n (field: string, index: number) => `${field}^${fieldWeights[index]}`\n );\n\n const fieldsPhrasePrefix = dataField\n .map(\n (field: string, index: number) =>\n `${field}^${fieldWeights[index]}`\n )\n .filter((field: string) => !field.includes(\".\"));\n\n const fieldsSpanFirst: any = dataField\n .filter((field: string) => {\n if (field.startsWith(\"tags\") && field.endsWith(\".keyword\")) {\n return false;\n }\n\n return true;\n })\n .map((field: string) => ({\n span_first: {\n match: {\n span_term: { [`${field}`]: value },\n },\n end: 1,\n },\n }));\n\n const query = {\n bool: {\n should: [\n ...(value\n ? [\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.searchTerm.keyword\":\n value.toLowerCase(),\n },\n },\n },\n },\n ]\n : []),\n ...(fieldsPhrase.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsPhrase,\n type: \"phrase\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsPhrasePrefix.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsPhrasePrefix,\n type: \"phrase_prefix\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsCrossFields.length > 0\n ? [\n {\n multi_match: {\n query: value,\n fields: fieldsCrossFields,\n type: \"cross_fields\",\n operator: \"and\",\n },\n },\n ]\n : []),\n ...(fieldsSpanFirst.length > 0 ? [...fieldsSpanFirst] : []),\n ],\n minimum_should_match: \"1\",\n },\n };\n return { query };\n }}\n />\n </>\n );\n};\n"]}
@@ -14,3 +14,4 @@ export * from "./useFilterSliderProps";
14
14
  export * from "./useFilterCollapsedState";
15
15
  export * from "./useConfig";
16
16
  export * from "./useReactifySearchContext";
17
+ export * from "./useResults";
@@ -26,4 +26,5 @@ __exportStar(require("./useFilterSliderProps"), exports);
26
26
  __exportStar(require("./useFilterCollapsedState"), exports);
27
27
  __exportStar(require("./useConfig"), exports);
28
28
  __exportStar(require("./useReactifySearchContext"), exports);
29
+ __exportStar(require("./useResults"), exports);
29
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AAEjC,gDAA8B;AAC9B,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC;AACxC,8CAA4B;AAC5B,gDAA8B;AAC9B,iDAA+B;AAC/B,+CAA6B;AAC7B,oDAAkC;AAClC,uDAAqC;AACrC,wDAAsC;AACtC,yDAAuC;AACvC,4DAA0C;AAC1C,8CAA4B;AAC5B,6DAA2C","sourcesContent":["export * from \"./reactivesearch\";\n\nexport * from \"./useDebugger\";\nexport * from \"./useSortBy\";\nexport * from \"./usePagination\";\nexport * from \"./usePaginationLoadable\";\nexport * from \"./useSearch\";\nexport * from \"./useCuration\";\nexport * from \"./useAnalytics\";\nexport * from \"./useFilters\";\nexport * from \"./useProductPrice\";\nexport * from \"./useFilterListProps\";\nexport * from \"./useFilterRangeProps\";\nexport * from \"./useFilterSliderProps\";\nexport * from \"./useFilterCollapsedState\";\nexport * from \"./useConfig\";\nexport * from \"./useReactifySearchContext\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AAEjC,gDAA8B;AAC9B,8CAA4B;AAC5B,kDAAgC;AAChC,0DAAwC;AACxC,8CAA4B;AAC5B,gDAA8B;AAC9B,iDAA+B;AAC/B,+CAA6B;AAC7B,oDAAkC;AAClC,uDAAqC;AACrC,wDAAsC;AACtC,yDAAuC;AACvC,4DAA0C;AAC1C,8CAA4B;AAC5B,6DAA2C;AAC3C,+CAA6B","sourcesContent":["export * from \"./reactivesearch\";\n\nexport * from \"./useDebugger\";\nexport * from \"./useSortBy\";\nexport * from \"./usePagination\";\nexport * from \"./usePaginationLoadable\";\nexport * from \"./useSearch\";\nexport * from \"./useCuration\";\nexport * from \"./useAnalytics\";\nexport * from \"./useFilters\";\nexport * from \"./useProductPrice\";\nexport * from \"./useFilterListProps\";\nexport * from \"./useFilterRangeProps\";\nexport * from \"./useFilterSliderProps\";\nexport * from \"./useFilterCollapsedState\";\nexport * from \"./useConfig\";\nexport * from \"./useReactifySearchContext\";\nexport * from \"./useResults\";\n"]}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Config } from "../types";
2
+ import { Config, ReactivesearchResultProps } from "../types";
3
3
  export declare type ReactifySearchMode = "search" | "collection" | "instant-search";
4
4
  export declare const ReactifySearchContext: React.Context<{
5
5
  config: Config;
@@ -36,6 +36,12 @@ export declare const ReactifySearchContext: React.Context<{
36
36
  sortOption: string;
37
37
  setSortOption: React.Dispatch<React.SetStateAction<string>>;
38
38
  };
39
+ results: {
40
+ results: ReactivesearchResultProps["data"];
41
+ setResults: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["data"]>>;
42
+ resultStats?: ReactivesearchResultProps["resultStats"];
43
+ setResultStats: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["resultStats"] | undefined>>;
44
+ };
39
45
  } | undefined>;
40
46
  export declare const useReactifySearchContext: () => {
41
47
  config: Config;
@@ -72,4 +78,10 @@ export declare const useReactifySearchContext: () => {
72
78
  sortOption: string;
73
79
  setSortOption: React.Dispatch<React.SetStateAction<string>>;
74
80
  };
81
+ results: {
82
+ results: ReactivesearchResultProps["data"];
83
+ setResults: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["data"]>>;
84
+ resultStats?: ReactivesearchResultProps["resultStats"];
85
+ setResultStats: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["resultStats"] | undefined>>;
86
+ };
75
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAMb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CA4CtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,eAAK,CAAC,UAAU,CAAC,6BAAqB,CAAE,CAAC;AAD9B,QAAA,wBAAwB,4BACM","sourcesContent":["import React from \"react\";\n\nimport { Config } from \"../types\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n filtersHandle?: string;\n credentials: {\n username: string;\n password: string;\n endpoint: string;\n };\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<\n React.SetStateAction<boolean>\n >;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
1
+ {"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAMb,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CAwDtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAC3C,eAAK,CAAC,UAAU,CAAC,6BAAqB,CAAE,CAAC;AAD9B,QAAA,wBAAwB,4BACM","sourcesContent":["import React from \"react\";\n\nimport { Config, ReactivesearchResultProps } from \"../types\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n filtersHandle?: string;\n credentials: {\n username: string;\n password: string;\n endpoint: string;\n };\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<\n React.SetStateAction<boolean>\n >;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n results: {\n results: ReactivesearchResultProps[\"data\"];\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n setResultStats: React.Dispatch<\n React.SetStateAction<\n ReactivesearchResultProps[\"resultStats\"] | undefined\n >\n >;\n };\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () =>\n React.useContext(ReactifySearchContext)!;\n"]}
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { ReactivesearchResultProps } from "../types";
3
+ /** This hook must never be used to render results */
4
+ export declare const useResults: () => {
5
+ /** All of the current results */
6
+ results: ReactivesearchResultProps["data"];
7
+ /** Function for setting the current results */
8
+ setResults: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["data"]>>;
9
+ /** All of the current result stats */
10
+ resultStats?: {
11
+ time: number;
12
+ hidden: number;
13
+ promoted: number;
14
+ currentPage: number;
15
+ numberOfPages: number;
16
+ numberOfResults?: number | undefined;
17
+ displayedResults: number;
18
+ } | undefined;
19
+ /** Function for setting the current result stats */
20
+ setResultStats: React.Dispatch<React.SetStateAction<ReactivesearchResultProps["resultStats"] | undefined>>;
21
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useResults = void 0;
4
+ const hooks_1 = require("../hooks");
5
+ const utility_1 = require("../utility");
6
+ /** This hook must never be used to render results */
7
+ const useResults = () => {
8
+ const { results } = (0, hooks_1.useReactifySearchContext)();
9
+ utility_1.debug.hook("useResults", "results", results.results);
10
+ utility_1.debug.hook("useResults", "resultStats", results.resultStats);
11
+ return {
12
+ results: results.results,
13
+ setResults: results.setResults,
14
+ resultStats: results.resultStats,
15
+ setResultStats: results.setResultStats,
16
+ };
17
+ };
18
+ exports.useResults = useResults;
19
+ //# sourceMappingURL=useResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResults.js","sourceRoot":"","sources":["../../../src/hooks/useResults.ts"],"names":[],"mappings":";;;AAGA,oCAAoD;AACpD,wCAAmC;AAEnC,qDAAqD;AAC9C,MAAM,UAAU,GAAG,GAaxB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,eAAK,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7D,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,UAAU,cAyBrB","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../types\";\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\n/** This hook must never be used to render results */\nexport const useResults = (): {\n /** All of the current results */\n results: ReactivesearchResultProps[\"data\"];\n /** Function for setting the current results */\n setResults: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"data\"]>\n >;\n /** All of the current result stats */\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n /** Function for setting the current result stats */\n setResultStats: React.Dispatch<\n React.SetStateAction<ReactivesearchResultProps[\"resultStats\"] | undefined>\n >;\n} => {\n const { results } = useReactifySearchContext();\n\n debug.hook(\"useResults\", \"results\", results.results);\n debug.hook(\"useResults\", \"resultStats\", results.resultStats);\n\n return {\n results: results.results,\n setResults: results.setResults,\n resultStats: results.resultStats,\n setResultStats: results.setResultStats,\n };\n};\n"]}
@@ -21,7 +21,7 @@ export interface ReactivesearchPaginationProps {
21
21
  export interface ReactivesearchResultProps {
22
22
  error?: ReactivesearchError;
23
23
  loading: boolean;
24
- data: (Omit<ElasticHit, "_source"> & ElasticDocument)[];
24
+ data: Array<Omit<ElasticHit, "_source"> & ElasticDocument>;
25
25
  loadMore: () => void;
26
26
  customData: unknown;
27
27
  promotedData: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"reactivesearch.js","sourceRoot":"","sources":["../../../src/types/reactivesearch.ts"],"names":[],"mappings":"","sourcesContent":["import { ElasticDocument, ElasticHit } from \"./elastic\";\n\n// props passed to SingleList/MultiList.render\nexport interface ReactivesearchFilterListProps {\n loading: boolean;\n error: Error | null;\n handleChange: (key: string) => void;\n data: { doc_count: number; key: string }[];\n value: string | { [key: string]: boolean };\n}\n\n// props passed to ReactiveList.renderPagination\nexport interface ReactivesearchPaginationProps {\n pages: number;\n showEndPage: false;\n totalPages: number;\n currentPage: number;\n setPage: (page: number) => void;\n}\n\n// props passed to ReactiveList.render\n// @todo complete missing types\nexport interface ReactivesearchResultProps {\n error?: ReactivesearchError;\n loading: boolean;\n data: (Omit<ElasticHit, \"_source\"> & ElasticDocument)[];\n loadMore: () => void;\n customData: unknown;\n promotedData: unknown;\n aggregationData: unknown;\n rawData?: {\n _shards: {\n failed: number;\n skipped: number;\n successful: number;\n total: number;\n };\n took: number;\n status: number;\n timed_out: boolean;\n hits: ElasticHit[];\n };\n resultStats: {\n time: number;\n hidden: number;\n promoted: number;\n currentPage: number;\n numberOfPages: number;\n numberOfResults?: number;\n displayedResults: number;\n };\n streamData: unknown;\n triggerAnalytics: unknown;\n triggerClickAnalytics: unknown;\n}\n\n// state for the \"page\" component returned by StateProvider when given the keys: [\"isLoading\", \"hits\", \"resultStats\", \"error\"]\nexport interface ReactivesearchSearchStatePage {\n isLoading: boolean;\n hits: {\n hidden: number;\n time: number;\n total: number;\n hits: ElasticHit[];\n };\n resultStats: {\n hidden: number;\n numberOfResults?: number;\n promoted: number;\n time: number;\n };\n error?: ReactivesearchError;\n}\n\nexport interface ReactivesearchError {\n status: number;\n statusText: string;\n}\n"]}
1
+ {"version":3,"file":"reactivesearch.js","sourceRoot":"","sources":["../../../src/types/reactivesearch.ts"],"names":[],"mappings":"","sourcesContent":["import { ElasticDocument, ElasticHit } from \"./elastic\";\n\n// props passed to SingleList/MultiList.render\nexport interface ReactivesearchFilterListProps {\n loading: boolean;\n error: Error | null;\n handleChange: (key: string) => void;\n data: { doc_count: number; key: string }[];\n value: string | { [key: string]: boolean };\n}\n\n// props passed to ReactiveList.renderPagination\nexport interface ReactivesearchPaginationProps {\n pages: number;\n showEndPage: false;\n totalPages: number;\n currentPage: number;\n setPage: (page: number) => void;\n}\n\n// props passed to ReactiveList.render\n// @todo complete missing types\nexport interface ReactivesearchResultProps {\n error?: ReactivesearchError;\n loading: boolean;\n data: Array<Omit<ElasticHit, \"_source\"> & ElasticDocument>;\n loadMore: () => void;\n customData: unknown;\n promotedData: unknown;\n aggregationData: unknown;\n rawData?: {\n _shards: {\n failed: number;\n skipped: number;\n successful: number;\n total: number;\n };\n took: number;\n status: number;\n timed_out: boolean;\n hits: ElasticHit[];\n };\n resultStats: {\n time: number;\n hidden: number;\n promoted: number;\n currentPage: number;\n numberOfPages: number;\n numberOfResults?: number;\n displayedResults: number;\n };\n streamData: unknown;\n triggerAnalytics: unknown;\n triggerClickAnalytics: unknown;\n}\n\n// state for the \"page\" component returned by StateProvider when given the keys: [\"isLoading\", \"hits\", \"resultStats\", \"error\"]\nexport interface ReactivesearchSearchStatePage {\n isLoading: boolean;\n hits: {\n hidden: number;\n time: number;\n total: number;\n hits: ElasticHit[];\n };\n resultStats: {\n hidden: number;\n numberOfResults?: number;\n promoted: number;\n time: number;\n };\n error?: ReactivesearchError;\n}\n\nexport interface ReactivesearchError {\n status: number;\n statusText: string;\n}\n"]}
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": "5.8.1",
4
+ "version": "5.9.0-beta.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",