@usereactify/search 5.4.0 → 5.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/package.json +1 -1
- package/dist/src/components/Example/ExampleResultCardProduct.js +1 -1
- package/dist/src/components/Example/ExampleResultCardProduct.js.map +1 -1
- package/dist/src/components/Example/ExampleResults.js +2 -1
- package/dist/src/components/Example/ExampleResults.js.map +1 -1
- package/dist/src/components/Result/ResultCardCallout.d.ts +1 -0
- package/dist/src/components/Result/ResultCardCallout.js +2 -0
- package/dist/src/components/Result/ResultCardCallout.js.map +1 -1
- package/dist/src/components/Result/ResultCardProduct.d.ts +1 -0
- package/dist/src/components/Result/ResultCardProduct.js +2 -0
- package/dist/src/components/Result/ResultCardProduct.js.map +1 -1
- package/dist/src/components/Result/Results.d.ts +4 -2
- package/dist/src/components/Result/Results.js +30 -9
- package/dist/src/components/Result/Results.js.map +1 -1
- package/dist/src/components/Sensor/SensorSearchTerm.js +1 -1
- package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -1
- package/dist/src/components/Sensor/Sensors.js +6 -7
- package/dist/src/components/Sensor/Sensors.js.map +1 -1
- package/dist/src/hooks/useCuration.js +4 -0
- package/dist/src/hooks/useCuration.js.map +1 -1
- package/package.json +1 -1
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.6.0-beta.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/beta-v5.2.2-beta.0...beta-v5.6.0-beta.0) (2022-10-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add scrollPosition prop to Results to trigger load more ([c2dc2a4](https://bitbucket.org/usereactify/reactify-search-ui/commit/c2dc2a44c853f52691f11ffc8459e64e6ea439ed))
|
|
11
|
+
* add scrollTarget prop and infinite scroll pagination rendered ([11f4d02](https://bitbucket.org/usereactify/reactify-search-ui/commit/11f4d02b43058e65a1d1ffa5f96a311f102ef6cf))
|
|
12
|
+
* align queries and sensors for both search and instant search modes ([481c9c6](https://bitbucket.org/usereactify/reactify-search-ui/commit/481c9c62a0c6f3088dd2b0bc2f0fcbb94cbebf9a))
|
|
13
|
+
* switch from npm to pnpm ([1166f9a](https://bitbucket.org/usereactify/reactify-search-ui/commit/1166f9ae5eab18e4519c3b5be7c9fd5526e6c35e))
|
|
14
|
+
* upgrade to react 18 ([f059591](https://bitbucket.org/usereactify/reactify-search-ui/commit/f059591a752fa4cf3a3bfd3709c1053224e1fcdf))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add debounce and tracking to search term sensor ([7563319](https://bitbucket.org/usereactify/reactify-search-ui/commit/75633197026554b1835ab1f683edc5cc8fcb35c7))
|
|
20
|
+
* add lib options to tsconfig ([11da357](https://bitbucket.org/usereactify/reactify-search-ui/commit/11da3571dce6bf8039863fd49bf403c68b8f168d))
|
|
21
|
+
* correctly apply weights for phrase-prefix ([88dbac1](https://bitbucket.org/usereactify/reactify-search-ui/commit/88dbac1c902691f6fba99e4a1b2dfab883f00dd7))
|
|
22
|
+
* minor clean up for react 18 ([c8a4775](https://bitbucket.org/usereactify/reactify-search-ui/commit/c8a477585acb01960a69734688fe6eac6ae6b672))
|
|
23
|
+
* switch from usePaginationLoadMore to usePaginationLoadable ([1337749](https://bitbucket.org/usereactify/reactify-search-ui/commit/1337749b0806d82a5026600387edd91886f3f4c5))
|
|
24
|
+
* track zeroResults event when the result data changes rather than the search term ([c10bb44](https://bitbucket.org/usereactify/reactify-search-ui/commit/c10bb4427b77e1cb6581ca35f43b56fd7e715670))
|
|
25
|
+
* use pnpm during cicd build process ([fb7c399](https://bitbucket.org/usereactify/reactify-search-ui/commit/fb7c39922afe269af4d93bf59da16874fe671ec7))
|
|
26
|
+
* weight search matches higher when field starts with term ([db1d430](https://bitbucket.org/usereactify/reactify-search-ui/commit/db1d43024dc97fb2547c7656b109d34becee6e45))
|
|
27
|
+
|
|
28
|
+
## [5.5.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.4.0...release-v5.5.0) (2022-10-06)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* add scrollPosition prop to Results to trigger load more ([c2dc2a4](https://bitbucket.org/usereactify/reactify-search-ui/commit/c2dc2a44c853f52691f11ffc8459e64e6ea439ed))
|
|
34
|
+
|
|
5
35
|
## [5.4.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.3.5...release-v5.4.0) (2022-10-06)
|
|
6
36
|
|
|
7
37
|
|
package/dist/package.json
CHANGED
|
@@ -8,7 +8,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const ExampleResultCardProduct = (props) => {
|
|
9
9
|
return (react_1.default.createElement("div", { ref: props.itemRef, className: "rs__result-card-product" },
|
|
10
10
|
react_1.default.createElement("a", { className: "rs__result-card-product__link", onClick: props.handleClick, href: `/products/${props.product.handle}` },
|
|
11
|
-
props.product.image && (react_1.default.createElement("img", { className: "rs__result-card-product__image", src: props.product.image, width: "100%" })),
|
|
11
|
+
props.product.image && (react_1.default.createElement("img", { className: "rs__result-card-product__image", src: props.product.image, width: "100%", height: "190px" })),
|
|
12
12
|
react_1.default.createElement("span", { className: "rs__result-card-product__title" }, props.product.title)),
|
|
13
13
|
react_1.default.createElement("span", { className: "rs__result-card-product__price" }, props.formattedPrice),
|
|
14
14
|
props.onSale && (react_1.default.createElement("span", { className: "rs__result-card-product__price-sale", style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAQnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CACL,uCAAK,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAC,yBAAyB;QAC1D,qCACE,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,KAAK,CAAC,WAAW,EAC1B,IAAI,EAAE,aAAa,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YAExC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CACtB,uCACE,SAAS,EAAC,gCAAgC,EAC1C,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,EACxB,KAAK,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"ExampleResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAQnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CACL,uCAAK,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAC,yBAAyB;QAC1D,qCACE,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,KAAK,CAAC,WAAW,EAC1B,IAAI,EAAE,aAAa,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YAExC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CACtB,uCACE,SAAS,EAAC,gCAAgC,EAC1C,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,EACxB,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,OAAO,GACd,CACH;YACD,wCAAM,SAAS,EAAC,gCAAgC,IAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CACf,CACL;QACJ,wCAAM,SAAS,EAAC,gCAAgC,IAC7C,KAAK,CAAC,cAAc,CAChB;QACN,KAAK,CAAC,MAAM,IAAI,CACf,wCACE,SAAS,EAAC,qCAAqC,EAC/C,KAAK,EAAE;gBACL,cAAc,EAAE,cAAc;aAC/B,IAEA,KAAK,CAAC,uBAAuB,CACzB,CACR,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AApCS,QAAA,wBAAwB,4BAoCjC","sourcesContent":["import React from \"react\";\n\nimport { ResultCardProductProps } from \"../../components\";\n\nexport type ExampleResultCardProductProps = React.ComponentProps<\n NonNullable<ResultCardProductProps[\"render\"]>\n>;\n\nexport const ExampleResultCardProduct: React.FC<ExampleResultCardProductProps> =\n (props) => {\n return (\n <div ref={props.itemRef} className=\"rs__result-card-product\">\n <a\n className=\"rs__result-card-product__link\"\n onClick={props.handleClick}\n href={`/products/${props.product.handle}`}\n >\n {props.product.image && (\n <img\n className=\"rs__result-card-product__image\"\n src={props.product.image}\n width=\"100%\"\n height=\"190px\"\n />\n )}\n <span className=\"rs__result-card-product__title\">\n {props.product.title}\n </span>\n </a>\n <span className=\"rs__result-card-product__price\">\n {props.formattedPrice}\n </span>\n {props.onSale && (\n <span\n className=\"rs__result-card-product__price-sale\"\n style={{\n textDecoration: \"line-through\",\n }}\n >\n {props.formattedCompareAtPrice}\n </span>\n )}\n </div>\n );\n };\n"]}
|
|
@@ -10,13 +10,14 @@ const ExampleResultCardProduct_1 = require("./ExampleResultCardProduct");
|
|
|
10
10
|
const ExampleResultCardCallout_1 = require("./ExampleResultCardCallout");
|
|
11
11
|
const ExampleResultPaginationNumbered_1 = require("./ExampleResultPaginationNumbered");
|
|
12
12
|
const ExampleResultPaginationLoadMore_1 = require("./ExampleResultPaginationLoadMore");
|
|
13
|
+
const ExampleResultPaginationInfiniteScroll_1 = require("./ExampleResultPaginationInfiniteScroll");
|
|
13
14
|
const ExampleResultPaginationNextPrev_1 = require("./ExampleResultPaginationNextPrev");
|
|
14
15
|
const Component = () => {
|
|
15
16
|
return (react_1.default.createElement(components_1.Results, { listStyle: {
|
|
16
17
|
display: "grid",
|
|
17
18
|
gap: "10px",
|
|
18
19
|
gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
|
|
19
|
-
}, renderResultCardProduct: ExampleResultCardProduct_1.ExampleResultCardProduct, renderResultCardCallout: ExampleResultCardCallout_1.ExampleResultCardCallout, renderPaginationNumbered: ExampleResultPaginationNumbered_1.ExampleResultPaginationNumbered, renderPaginationLoadMore: ExampleResultPaginationLoadMore_1.ExampleResultPaginationLoadMore, renderPaginationNextPrev: ExampleResultPaginationNextPrev_1.ExampleResultPaginationNextPrev }));
|
|
20
|
+
}, renderResultCardProduct: ExampleResultCardProduct_1.ExampleResultCardProduct, renderResultCardCallout: ExampleResultCardCallout_1.ExampleResultCardCallout, renderPaginationNumbered: ExampleResultPaginationNumbered_1.ExampleResultPaginationNumbered, renderPaginationLoadMore: ExampleResultPaginationLoadMore_1.ExampleResultPaginationLoadMore, renderPaginationNextPrev: ExampleResultPaginationNextPrev_1.ExampleResultPaginationNextPrev, renderPaginationInfiniteScroll: ExampleResultPaginationInfiniteScroll_1.ExampleResultPaginationInfiniteScroll }));
|
|
20
21
|
};
|
|
21
22
|
exports.Component = Component;
|
|
22
23
|
//# sourceMappingURL=ExampleResults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleResults.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResults.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA2C;AAE3C,yEAAsE;AACtE,yEAAsE;AACtE,uFAAoF;AACpF,uFAAoF;AACpF,uFAAoF;AAE7E,MAAM,SAAS,GAAa,GAAG,EAAE;IACtC,OAAO,CACL,8BAAC,oBAAO,IACN,SAAS,EAAE;YACT,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,MAAM;YACX,mBAAmB,EAAE,2BAA2B;SACjD,EACD,uBAAuB,EAAE,mDAAwB,EACjD,uBAAuB,EAAE,mDAAwB,EACjD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,
|
|
1
|
+
{"version":3,"file":"ExampleResults.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResults.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAA2C;AAE3C,yEAAsE;AACtE,yEAAsE;AACtE,uFAAoF;AACpF,uFAAoF;AACpF,mGAAgG;AAChG,uFAAoF;AAE7E,MAAM,SAAS,GAAa,GAAG,EAAE;IACtC,OAAO,CACL,8BAAC,oBAAO,IACN,SAAS,EAAE;YACT,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,MAAM;YACX,mBAAmB,EAAE,2BAA2B;SACjD,EACD,uBAAuB,EAAE,mDAAwB,EACjD,uBAAuB,EAAE,mDAAwB,EACjD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,EACzD,wBAAwB,EAAE,iEAA+B,EACzD,8BAA8B,EAAE,6EAAqC,GACrE,CACH,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,SAAS,aAgBpB","sourcesContent":["import React from \"react\";\n\nimport { Results } from \"../../components\";\n\nimport { ExampleResultCardProduct } from \"./ExampleResultCardProduct\";\nimport { ExampleResultCardCallout } from \"./ExampleResultCardCallout\";\nimport { ExampleResultPaginationNumbered } from \"./ExampleResultPaginationNumbered\";\nimport { ExampleResultPaginationLoadMore } from \"./ExampleResultPaginationLoadMore\";\nimport { ExampleResultPaginationInfiniteScroll } from \"./ExampleResultPaginationInfiniteScroll\";\nimport { ExampleResultPaginationNextPrev } from \"./ExampleResultPaginationNextPrev\";\n\nexport const Component: React.FC = () => {\n return (\n <Results\n listStyle={{\n display: \"grid\",\n gap: \"10px\",\n gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\",\n }}\n renderResultCardProduct={ExampleResultCardProduct}\n renderResultCardCallout={ExampleResultCardCallout}\n renderPaginationNumbered={ExampleResultPaginationNumbered}\n renderPaginationLoadMore={ExampleResultPaginationLoadMore}\n renderPaginationNextPrev={ExampleResultPaginationNextPrev}\n renderPaginationInfiniteScroll={ExampleResultPaginationInfiniteScroll}\n />\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA2C;AAC3C,0BAA4D;
|
|
1
|
+
{"version":3,"file":"ResultCardCallout.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardCallout.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA2C;AAC3C,0BAA4D;AAUrD,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,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW,CAAC;YACjB,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;AArCW,QAAA,iBAAiB,qBAqC5B","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 onView?: () => void;\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 props.onView?.();\n handleView();\n }\n }, [inView]);\n\n const RenderComponent = props.render ?? ExampleResultCardCallout;\n\n return <RenderComponent {...props} itemRef={ref} handleClick={handleClick} />;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA4D;AAC5D,iDAA0E;
|
|
1
|
+
{"version":3,"file":"ResultCardProduct.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultCardProduct.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6EAAwD;AAGxD,uCAA4D;AAC5D,iDAA0E;AAUnE,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,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW,CAAC;YACjB,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;AApDW,QAAA,iBAAiB,qBAoD5B","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 onView?: () => void;\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 props.onView?.();\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"]}
|
|
@@ -45,7 +45,9 @@ export declare type ResultsProps = {
|
|
|
45
45
|
renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof usePaginationLoadable>>;
|
|
46
46
|
/** Advanced Usage: Override the default amount of results per page */
|
|
47
47
|
pageSize?: number;
|
|
48
|
-
/** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered */
|
|
49
|
-
|
|
48
|
+
/** Advanced Usage: Override the default scrollTarget used to determine when infinite load should be triggered (infinite scroll) */
|
|
49
|
+
infiniteScrollContainer?: React.ComponentProps<typeof ReactiveList>["scrollTarget"];
|
|
50
|
+
/** Advanced Usage: Provide a specific result position to trigger loading more results (infinite scroll) */
|
|
51
|
+
infiniteScrollPosition?: number;
|
|
50
52
|
};
|
|
51
53
|
export declare const Results: React.FC<ResultsProps>;
|
|
@@ -18,7 +18,7 @@ const ResultPaginationInfiniteScroll_1 = require("./ResultPaginationInfiniteScro
|
|
|
18
18
|
const Results = (props) => {
|
|
19
19
|
const reactiveReactiveListProps = (0, hooks_1.useReactiveReactiveListProps)({
|
|
20
20
|
pageSize: props.pageSize,
|
|
21
|
-
scrollTarget: props.
|
|
21
|
+
scrollTarget: props.infiniteScrollContainer,
|
|
22
22
|
});
|
|
23
23
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
24
24
|
const { searchTerm } = (0, hooks_1.useSearch)();
|
|
@@ -48,7 +48,8 @@ const ResultsRenderNoResultsComponent = () => {
|
|
|
48
48
|
return react_1.default.createElement("div", null, "No results");
|
|
49
49
|
};
|
|
50
50
|
const ResultsInner = (props) => {
|
|
51
|
-
var _a, _b, _c;
|
|
51
|
+
var _a, _b, _c, _d, _e;
|
|
52
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
52
53
|
const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
|
|
53
54
|
typeof props.reactivesearchResultProps.resultStats.numberOfResults, [props.reactivesearchResultProps]);
|
|
54
55
|
const listStyle = react_1.default.useMemo(() => {
|
|
@@ -59,6 +60,19 @@ const ResultsInner = (props) => {
|
|
|
59
60
|
gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
|
|
60
61
|
};
|
|
61
62
|
}, [props.listStyle]);
|
|
63
|
+
const infiniteScrollPosition = react_1.default.useMemo(() => {
|
|
64
|
+
var _a, _b, _c, _d;
|
|
65
|
+
if (!props.infiniteScrollPosition) {
|
|
66
|
+
return NaN;
|
|
67
|
+
}
|
|
68
|
+
const scrollPositionOffset = props.reactivesearchResultProps.resultStats.displayedResults -
|
|
69
|
+
((_c = (_a = props.pageSize) !== null && _a !== void 0 ? _a : (_b = filtersHook.filterStack) === null || _b === void 0 ? void 0 : _b.pageSize) !== null && _c !== void 0 ? _c : 0);
|
|
70
|
+
return scrollPositionOffset + ((_d = props.infiniteScrollPosition) !== null && _d !== void 0 ? _d : 0);
|
|
71
|
+
}, [
|
|
72
|
+
(_a = props.pageSize) !== null && _a !== void 0 ? _a : (_b = filtersHook.filterStack) === null || _b === void 0 ? void 0 : _b.pageSize,
|
|
73
|
+
props.reactivesearchResultProps.resultStats.displayedResults,
|
|
74
|
+
props.infiniteScrollPosition,
|
|
75
|
+
]);
|
|
62
76
|
if (props.reactivesearchResultProps.error) {
|
|
63
77
|
utility_1.debug.breadcrumb({
|
|
64
78
|
category: "result",
|
|
@@ -67,26 +81,33 @@ const ResultsInner = (props) => {
|
|
|
67
81
|
error: props.reactivesearchResultProps.error,
|
|
68
82
|
},
|
|
69
83
|
});
|
|
70
|
-
const RenderErrorComponent = (
|
|
84
|
+
const RenderErrorComponent = (_c = props.renderError) !== null && _c !== void 0 ? _c : ResultsRenderErrorComponent;
|
|
71
85
|
return (react_1.default.createElement(RenderErrorComponent, { error: props.reactivesearchResultProps.error }));
|
|
72
86
|
}
|
|
73
87
|
if (!initialSearchHasRun) {
|
|
74
|
-
const RenderLoadingComponent = (
|
|
88
|
+
const RenderLoadingComponent = (_d = props.renderLoading) !== null && _d !== void 0 ? _d : ResultsRenderLoadingComponent;
|
|
75
89
|
return react_1.default.createElement(RenderLoadingComponent, null);
|
|
76
90
|
}
|
|
77
91
|
if (!props.reactivesearchResultProps.loading &&
|
|
78
92
|
!props.reactivesearchResultProps.resultStats.numberOfResults) {
|
|
79
|
-
const RenderNoResultsComponent = (
|
|
93
|
+
const RenderNoResultsComponent = (_e = props.renderNoResults) !== null && _e !== void 0 ? _e : ResultsRenderNoResultsComponent;
|
|
80
94
|
return react_1.default.createElement(RenderNoResultsComponent, null);
|
|
81
95
|
}
|
|
82
96
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
83
97
|
react_1.default.createElement("section", { style: listStyle, className: props.listClassName }, props.reactivesearchResultProps.data.map((item, key) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
if (types_1.ElasticDocumentType.Product === item.type) {
|
|
99
|
+
return (react_1.default.createElement(ResultCardProduct_1.ResultCardProduct, Object.assign({ key: item._id, product: item, document: item, pagePosition: key + 1, render: props.renderResultCardProduct }, (infiniteScrollPosition === key + 1
|
|
100
|
+
? {
|
|
101
|
+
onView: () => props.reactivesearchResultProps.loadMore(),
|
|
102
|
+
}
|
|
103
|
+
: {}))));
|
|
87
104
|
}
|
|
88
105
|
if (types_1.ElasticDocumentType.Callout === item.type) {
|
|
89
|
-
return (react_1.default.createElement(ResultCardCallout_1.ResultCardCallout, { key: item._id, document: item, pagePosition: key + 1, callout: item.callout, render: props.renderResultCardCallout }
|
|
106
|
+
return (react_1.default.createElement(ResultCardCallout_1.ResultCardCallout, Object.assign({ key: item._id, document: item, pagePosition: key + 1, callout: item.callout, render: props.renderResultCardCallout }, (infiniteScrollPosition === key + 1
|
|
107
|
+
? {
|
|
108
|
+
onView: () => props.reactivesearchResultProps.loadMore(),
|
|
109
|
+
}
|
|
110
|
+
: {}))));
|
|
90
111
|
}
|
|
91
112
|
return null;
|
|
92
113
|
})),
|
|
@@ -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;AAoD3E,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,YAAY;KACjC,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,CA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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 */\n scrollTarget?: React.ComponentProps<typeof ReactiveList>[\"scrollTarget\"];\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n scrollTarget: props.scrollTarget,\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 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 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 // @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 <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,yEAAsE;AACtE,yEAAsE;AACtE,yEAAsE;AAEtE,uCAOqB;AACrB,uCASqB;AACrB,2CAAsC;AACtC,qFAAkF;AAwD3E,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,y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B,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 +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,eAA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CACE,WAAW,EAAE;4CACX,KAAK,EAAE,KAAK;4CACZ,MAAM,EAAE,YAAY;4CACpB,IAAI,EAAE,QAAQ;4CACd,QAAQ,EAAE,KAAK;yCAChB;qCACF;iCACF;gCACH,CAAC,CAAC,EAAE,CAAC;4BACP,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;gCAC/B,CAAC,CAAC;oCACE;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;AA3JW,QAAA,gBAAgB,oBA2J3B","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.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"]}
|
|
@@ -7,13 +7,18 @@ exports.Sensors = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
9
|
const SensorSort_1 = require("./SensorSort");
|
|
10
|
-
const SensorSortScore_1 = require("./SensorSortScore");
|
|
11
10
|
const SensorPublished_1 = require("./SensorPublished");
|
|
12
11
|
const SensorCollection_1 = require("./SensorCollection");
|
|
13
12
|
const SensorSearchTerm_1 = require("./SensorSearchTerm");
|
|
14
13
|
const SensorInventoryAvailable_1 = require("./SensorInventoryAvailable");
|
|
15
14
|
const Sensors = () => {
|
|
16
15
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
16
|
+
if (options.mode === "instant-search") {
|
|
17
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
18
|
+
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
19
|
+
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
20
|
+
react_1.default.createElement(SensorSearchTerm_1.SensorSearchTerm, null)));
|
|
21
|
+
}
|
|
17
22
|
if (options.mode === "search") {
|
|
18
23
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
19
24
|
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
@@ -28,12 +33,6 @@ const Sensors = () => {
|
|
|
28
33
|
react_1.default.createElement(SensorCollection_1.SensorCollection, null),
|
|
29
34
|
react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null)));
|
|
30
35
|
}
|
|
31
|
-
if (options.mode === "instant-search") {
|
|
32
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
33
|
-
react_1.default.createElement(SensorSortScore_1.SensorSortScore, null),
|
|
34
|
-
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
35
|
-
react_1.default.createElement(SensorSearchTerm_1.SensorSearchTerm, null)));
|
|
36
|
-
}
|
|
37
36
|
return null;
|
|
38
37
|
};
|
|
39
38
|
exports.Sensors = Sensors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sensors.js","sourceRoot":"","sources":["../../../../src/components/Sensor/Sensors.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAAuD;AAEvD,6CAA0C;AAC1C,uDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"Sensors.js","sourceRoot":"","sources":["../../../../src/components/Sensor/Sensors.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,uCAAuD;AAEvD,6CAA0C;AAC1C,uDAAoD;AACpD,yDAAsD;AACtD,yDAAsD;AACtD,yEAAsE;AAM/D,MAAM,OAAO,GAA2B,GAAG,EAAE;IAClD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/C,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG,CACnB,CACJ,CAAC;KACH;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC7B,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,mDAAwB,OAAG,CAC3B,CACJ,CAAC;KACH;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;QACjC,OAAO,CACL;YACE,8BAAC,uBAAU,OAAG;YACd,8BAAC,iCAAe,OAAG;YACnB,8BAAC,mCAAgB,OAAG;YACpB,8BAAC,mDAAwB,OAAG,CAC3B,CACJ,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AApCW,QAAA,OAAO,WAoClB","sourcesContent":["import React from \"react\";\n\nimport { useReactifySearchContext } from \"../../hooks\";\n\nimport { SensorSort } from \"./SensorSort\";\nimport { SensorPublished } from \"./SensorPublished\";\nimport { SensorCollection } from \"./SensorCollection\";\nimport { SensorSearchTerm } from \"./SensorSearchTerm\";\nimport { SensorInventoryAvailable } from \"./SensorInventoryAvailable\";\n\nexport type SensorsProps = {\n /** This component does not support any props */\n};\n\nexport const Sensors: React.FC<SensorsProps> = () => {\n const { options } = useReactifySearchContext();\n\n if (options.mode === \"instant-search\") {\n return (\n <>\n <SensorSort />\n <SensorPublished />\n <SensorSearchTerm />\n </>\n );\n }\n\n if (options.mode === \"search\") {\n return (\n <>\n <SensorSort />\n <SensorPublished />\n <SensorSearchTerm />\n <SensorInventoryAvailable />\n </>\n );\n }\n\n if (options.mode === \"collection\") {\n return (\n <>\n <SensorSort />\n <SensorPublished />\n <SensorCollection />\n <SensorInventoryAvailable />\n </>\n );\n }\n\n return null;\n};\n"]}
|
|
@@ -20,6 +20,10 @@ const useCuration = () => {
|
|
|
20
20
|
var _a, _b;
|
|
21
21
|
const normalisedSearchTerm = (_a = curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase().trim();
|
|
22
22
|
const normalisedCollectionHandle = (_b = curation.collectionHandle) === null || _b === void 0 ? void 0 : _b.toLowerCase().trim();
|
|
23
|
+
if ("instant-search" === options.mode) {
|
|
24
|
+
return ("search" === curation.type &&
|
|
25
|
+
normalisedHandleOrSearchTerm === normalisedSearchTerm);
|
|
26
|
+
}
|
|
23
27
|
if ("search" === options.mode) {
|
|
24
28
|
return ("search" === curation.type &&
|
|
25
29
|
normalisedHandleOrSearchTerm === normalisedSearchTerm);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCuration.js","sourceRoot":"","sources":["../../../src/hooks/useCuration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAA+D;AAC/D,wCAAmC;AAE5B,MAAM,WAAW,GAAG,GAEzB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IACvD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;IAEnC,MAAM,QAAQ,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC;QAExE,MAAM,4BAA4B,GAAG,kBAAkB;aACpD,WAAW,EAAE;aACb,IAAI,EAAE,CAAC;QAEV,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CACzE,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;;YAClD,MAAM,oBAAoB,GAAG,MAAA,QAAQ,CAAC,UAAU,0CAAE,WAAW,GAAG,IAAI,EAAE,CAAC;YACvE,MAAM,0BAA0B,GAAG,MAAA,QAAQ,CAAC,gBAAgB,0CACxD,WAAW,GACZ,IAAI,EAAE,CAAC;YAEV,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE;gBAC7B,OAAO,CACL,QAAQ,KAAK,QAAQ,CA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IAEH,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO;QACL,QAAQ,EAAE,QAAQ;KACnB,CAAC;AACJ,CAAC,CAAC;AAxFW,QAAA,WAAW,eAwFtB","sourcesContent":["import React from \"react\";\n\nimport { ConfigCuration } from \"../types\";\nimport { useReactifySearchContext, useSearch } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useCuration = (): {\n curation?: ConfigCuration;\n} => {\n const { options, config } = useReactifySearchContext();\n const { searchTerm } = useSearch();\n\n const curation = React.useMemo(() => {\n const handleOrSearchTerm =\n options.mode === \"collection\" ? options.collectionHandle : searchTerm;\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm\n .toLowerCase()\n .trim();\n\n const globalCuration = config.curations.find(\n (curation) => curation.id === \"global\" && curation.type === options.mode\n );\n\n const curation = config.curations.find((curation) => {\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle\n ?.toLowerCase()\n .trim();\n\n if (\"instant-search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"search\" === options.mode) {\n return (\n \"search\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedSearchTerm\n );\n }\n\n if (\"collection\" === options.mode) {\n return (\n \"collection\" === curation.type &&\n normalisedHandleOrSearchTerm === normalisedCollectionHandle\n );\n }\n\n return false;\n });\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n const curationIsCollection = curation.type === \"collection\";\n if (!curationIsCollection) {\n return curation;\n }\n\n const curationHasRules =\n !!curation.boosting.groupings.length ||\n !!curation.boosting.sortings.length;\n\n if (curationHasRules || !globalCuration) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n return curation\n ? addGlobalBoosting(curation)\n : globalCuration\n ? globalCuration\n : undefined;\n }, [\n config,\n options.mode === \"collection\" ? options.collectionHandle : undefined,\n searchTerm,\n ]);\n\n React.useEffect(() => {\n debug.log(\"useCuration\", \"curation\", curation);\n }, [curation]);\n\n return {\n curation: curation,\n };\n};\n"]}
|