@usereactify/search 5.3.5 → 5.5.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 +19 -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/ExampleResultPaginationInfiniteScroll.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationInfiniteScroll.js +15 -0
- package/dist/src/components/Example/ExampleResultPaginationInfiniteScroll.js.map +1 -0
- package/dist/src/components/Example/ExampleResults.js +2 -1
- package/dist/src/components/Example/ExampleResults.js.map +1 -1
- package/dist/src/components/Example/index.d.ts +1 -0
- package/dist/src/components/Example/index.js +1 -0
- package/dist/src/components/Example/index.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/ResultPaginationInfiniteScroll.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationInfiniteScroll.js +17 -0
- package/dist/src/components/Result/ResultPaginationInfiniteScroll.js.map +1 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.js +1 -1
- package/dist/src/components/Result/ResultPaginationLoadMore.js.map +1 -1
- package/dist/src/components/Result/Results.d.ts +8 -3
- package/dist/src/components/Result/Results.js +36 -10
- package/dist/src/components/Result/Results.js.map +1 -1
- package/dist/src/components/Result/index.d.ts +1 -0
- package/dist/src/components/Result/index.js +1 -0
- package/dist/src/components/Result/index.js.map +1 -1
- package/dist/src/hooks/index.d.ts +1 -1
- package/dist/src/hooks/index.js +1 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js +1 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +1 -1
- package/dist/src/hooks/{usePaginationLoadMore.d.ts → usePaginationLoadable.d.ts} +1 -1
- package/dist/src/hooks/{usePaginationLoadMore.js → usePaginationLoadable.js} +8 -8
- package/dist/src/hooks/usePaginationLoadable.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/hooks/usePaginationLoadMore.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
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.5.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.4.0...release-v5.5.0) (2022-10-06)
|
|
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
|
+
|
|
12
|
+
## [5.4.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.3.5...release-v5.4.0) (2022-10-06)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add scrollTarget prop and infinite scroll pagination rendered ([11f4d02](https://bitbucket.org/usereactify/reactify-search-ui/commit/11f4d02b43058e65a1d1ffa5f96a311f102ef6cf))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* switch from usePaginationLoadMore to usePaginationLoadable ([1337749](https://bitbucket.org/usereactify/reactify-search-ui/commit/1337749b0806d82a5026600387edd91886f3f4c5))
|
|
23
|
+
|
|
5
24
|
### [5.3.5](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.3.4...release-v5.3.5) (2022-09-28)
|
|
6
25
|
|
|
7
26
|
|
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"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ResultPaginationInfiniteScrollProps } from "../../components";
|
|
3
|
+
export declare type ExampleResultPaginationInfiniteScrollProps = React.ComponentProps<NonNullable<ResultPaginationInfiniteScrollProps["render"]>>;
|
|
4
|
+
export declare const ExampleResultPaginationInfiniteScroll: React.FC<ExampleResultPaginationInfiniteScrollProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ExampleResultPaginationInfiniteScroll = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const ExampleResultPaginationInfiniteScroll = (props) => {
|
|
9
|
+
if (props.loading) {
|
|
10
|
+
return (react_1.default.createElement("div", { className: "rs__pagination__infinitescroll-loading" }, "Loading..."));
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
exports.ExampleResultPaginationInfiniteScroll = ExampleResultPaginationInfiniteScroll;
|
|
15
|
+
//# sourceMappingURL=ExampleResultPaginationInfiniteScroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExampleResultPaginationInfiniteScroll.js","sourceRoot":"","sources":["../../../../src/components/Example/ExampleResultPaginationInfiniteScroll.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAQnB,MAAM,qCAAqC,GAChD,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,KAAK,CAAC,OAAO,EAAE;QACjB,OAAO,CACL,uCAAK,SAAS,EAAC,wCAAwC,IACpD,YAAY,CACT,CACP,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVS,QAAA,qCAAqC,yCAU9C","sourcesContent":["import React from \"react\";\n\nimport { ResultPaginationInfiniteScrollProps } from \"../../components\";\n\nexport type ExampleResultPaginationInfiniteScrollProps = React.ComponentProps<\n NonNullable<ResultPaginationInfiniteScrollProps[\"render\"]>\n>;\n\nexport const ExampleResultPaginationInfiniteScroll: React.FC<ExampleResultPaginationInfiniteScrollProps> =\n (props) => {\n if (props.loading) {\n return (\n <div className=\"rs__pagination__infinitescroll-loading\">\n {\"Loading...\"}\n </div>\n );\n }\n return null;\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"]}
|
|
@@ -12,6 +12,7 @@ export * from "./ExampleResultCardCallout";
|
|
|
12
12
|
export * from "./ExampleResultCardProduct";
|
|
13
13
|
export * from "./ExampleResultPaginationNumbered";
|
|
14
14
|
export * from "./ExampleResultPaginationLoadMore";
|
|
15
|
+
export * from "./ExampleResultPaginationInfiniteScroll";
|
|
15
16
|
export * from "./ExampleResultPaginationNextPrev";
|
|
16
17
|
export * from "./ExampleSearch";
|
|
17
18
|
export * from "./ExampleSortBy";
|
|
@@ -24,6 +24,7 @@ __exportStar(require("./ExampleResultCardCallout"), exports);
|
|
|
24
24
|
__exportStar(require("./ExampleResultCardProduct"), exports);
|
|
25
25
|
__exportStar(require("./ExampleResultPaginationNumbered"), exports);
|
|
26
26
|
__exportStar(require("./ExampleResultPaginationLoadMore"), exports);
|
|
27
|
+
__exportStar(require("./ExampleResultPaginationInfiniteScroll"), exports);
|
|
27
28
|
__exportStar(require("./ExampleResultPaginationNextPrev"), exports);
|
|
28
29
|
__exportStar(require("./ExampleSearch"), exports);
|
|
29
30
|
__exportStar(require("./ExampleSortBy"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Example/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkC;AAClC,2DAAyC;AACzC,sDAAoC;AACpC,uDAAqC;AACrC,wDAAsC;AACtC,mDAAiC;AACjC,2DAAyC;AACzC,4EAA0D;AAC1D,+EAA6D;AAC7D,wEAAsD;AACtD,6DAA2C;AAC3C,6DAA2C;AAC3C,oEAAkD;AAClD,oEAAkD;AAClD,oEAAkD;AAClD,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B;AAE/B,yDAAuC;AACvC,yDAAuC","sourcesContent":["export * from \"./ExampleClearAll\";\nexport * from \"./ExampleCustomComponent\";\nexport * from \"./ExampleFilterList\";\nexport * from \"./ExampleFilterRange\";\nexport * from \"./ExampleFilterSlider\";\nexport * from \"./ExampleFilters\";\nexport * from \"./ExampleFiltersSelected\";\nexport * from \"./ExampleReactiveSearchProviderCollection\";\nexport * from \"./ExampleReactiveSearchProviderInstantSearch\";\nexport * from \"./ExampleReactiveSearchProviderSearch\";\nexport * from \"./ExampleResultCardCallout\";\nexport * from \"./ExampleResultCardProduct\";\nexport * from \"./ExampleResultPaginationNumbered\";\nexport * from \"./ExampleResultPaginationLoadMore\";\nexport * from \"./ExampleResultPaginationNextPrev\";\nexport * from \"./ExampleSearch\";\nexport * from \"./ExampleSortBy\";\nexport * from \"./ExampleStats\";\n\nexport * from \"./ExampleHookUseSearch\";\nexport * from \"./ExampleHookUseSortBy\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Example/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkC;AAClC,2DAAyC;AACzC,sDAAoC;AACpC,uDAAqC;AACrC,wDAAsC;AACtC,mDAAiC;AACjC,2DAAyC;AACzC,4EAA0D;AAC1D,+EAA6D;AAC7D,wEAAsD;AACtD,6DAA2C;AAC3C,6DAA2C;AAC3C,oEAAkD;AAClD,oEAAkD;AAClD,0EAAwD;AACxD,oEAAkD;AAClD,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B;AAE/B,yDAAuC;AACvC,yDAAuC","sourcesContent":["export * from \"./ExampleClearAll\";\nexport * from \"./ExampleCustomComponent\";\nexport * from \"./ExampleFilterList\";\nexport * from \"./ExampleFilterRange\";\nexport * from \"./ExampleFilterSlider\";\nexport * from \"./ExampleFilters\";\nexport * from \"./ExampleFiltersSelected\";\nexport * from \"./ExampleReactiveSearchProviderCollection\";\nexport * from \"./ExampleReactiveSearchProviderInstantSearch\";\nexport * from \"./ExampleReactiveSearchProviderSearch\";\nexport * from \"./ExampleResultCardCallout\";\nexport * from \"./ExampleResultCardProduct\";\nexport * from \"./ExampleResultPaginationNumbered\";\nexport * from \"./ExampleResultPaginationLoadMore\";\nexport * from \"./ExampleResultPaginationInfiniteScroll\";\nexport * from \"./ExampleResultPaginationNextPrev\";\nexport * from \"./ExampleSearch\";\nexport * from \"./ExampleSortBy\";\nexport * from \"./ExampleStats\";\n\nexport * from \"./ExampleHookUseSearch\";\nexport * from \"./ExampleHookUseSortBy\";\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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactivesearchResultProps } from "../../types";
|
|
3
|
+
import { ResultsProps } from "../../components";
|
|
4
|
+
export declare type ResultPaginationInfiniteScrollProps = ReactivesearchResultProps & {
|
|
5
|
+
render?: ResultsProps["renderPaginationInfiniteScroll"];
|
|
6
|
+
};
|
|
7
|
+
export declare const ResultPaginationInfiniteScroll: React.FC<ResultPaginationInfiniteScrollProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ResultPaginationInfiniteScroll = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const hooks_1 = require("../../hooks");
|
|
9
|
+
const components_1 = require("../../components");
|
|
10
|
+
const ResultPaginationInfiniteScroll = (props) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const usePaginationLoadableHook = (0, hooks_1.usePaginationLoadable)(props);
|
|
13
|
+
const RenderPaginationComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultPaginationInfiniteScroll;
|
|
14
|
+
return react_1.default.createElement(RenderPaginationComponent, Object.assign({}, usePaginationLoadableHook));
|
|
15
|
+
};
|
|
16
|
+
exports.ResultPaginationInfiniteScroll = ResultPaginationInfiniteScroll;
|
|
17
|
+
//# sourceMappingURL=ResultPaginationInfiniteScroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultPaginationInfiniteScroll.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationInfiniteScroll.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAoD;AACpD,iDAG0B;AAMnB,MAAM,8BAA8B,GACzC,CAAC,KAAK,EAAE,EAAE;;IACR,MAAM,yBAAyB,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;IAE/D,MAAM,yBAAyB,GAC7B,MAAA,KAAK,CAAC,MAAM,mCAAI,kDAAqC,CAAC;IAExD,OAAO,8BAAC,yBAAyB,oBAAK,yBAAyB,EAAI,CAAC;AACtE,CAAC,CAAC;AARS,QAAA,8BAA8B,kCAQvC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../../types\";\nimport { usePaginationLoadable } from \"../../hooks\";\nimport {\n ResultsProps,\n ExampleResultPaginationInfiniteScroll,\n} from \"../../components\";\n\nexport type ResultPaginationInfiniteScrollProps = ReactivesearchResultProps & {\n render?: ResultsProps[\"renderPaginationInfiniteScroll\"];\n};\n\nexport const ResultPaginationInfiniteScroll: React.FC<ResultPaginationInfiniteScrollProps> =\n (props) => {\n const usePaginationLoadableHook = usePaginationLoadable(props);\n\n const RenderPaginationComponent =\n props.render ?? ExampleResultPaginationInfiniteScroll;\n\n return <RenderPaginationComponent {...usePaginationLoadableHook} />;\n };\n"]}
|
|
@@ -9,7 +9,7 @@ const hooks_1 = require("../../hooks");
|
|
|
9
9
|
const components_1 = require("../../components");
|
|
10
10
|
const ResultPaginationLoadMore = (props) => {
|
|
11
11
|
var _a;
|
|
12
|
-
const paginationLoadMoreHook = (0, hooks_1.
|
|
12
|
+
const paginationLoadMoreHook = (0, hooks_1.usePaginationLoadable)(props);
|
|
13
13
|
const RenderPaginationComponent = (_a = props.render) !== null && _a !== void 0 ? _a : components_1.ExampleResultPaginationLoadMore;
|
|
14
14
|
return react_1.default.createElement(RenderPaginationComponent, Object.assign({}, paginationLoadMoreHook));
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultPaginationLoadMore.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationLoadMore.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAoD;AACpD,iDAG0B;AAMnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;;IACR,MAAM,sBAAsB,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;IAE5D,MAAM,yBAAyB,GAC7B,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElD,OAAO,8BAAC,yBAAyB,oBAAK,sBAAsB,EAAI,CAAC;AACnE,CAAC,CAAC;AARS,QAAA,wBAAwB,4BAQjC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../../types\";\nimport {
|
|
1
|
+
{"version":3,"file":"ResultPaginationLoadMore.js","sourceRoot":"","sources":["../../../../src/components/Result/ResultPaginationLoadMore.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAoD;AACpD,iDAG0B;AAMnB,MAAM,wBAAwB,GACnC,CAAC,KAAK,EAAE,EAAE;;IACR,MAAM,sBAAsB,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC;IAE5D,MAAM,yBAAyB,GAC7B,MAAA,KAAK,CAAC,MAAM,mCAAI,4CAA+B,CAAC;IAElD,OAAO,8BAAC,yBAAyB,oBAAK,sBAAsB,EAAI,CAAC;AACnE,CAAC,CAAC;AARS,QAAA,wBAAwB,4BAQjC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../../types\";\nimport { usePaginationLoadable } from \"../../hooks\";\nimport {\n ResultsProps,\n ExampleResultPaginationLoadMore,\n} from \"../../components\";\n\nexport type ResultPaginationLoadMoreProps = ReactivesearchResultProps & {\n render?: ResultsProps[\"renderPaginationLoadMore\"];\n};\n\nexport const ResultPaginationLoadMore: React.FC<ResultPaginationLoadMoreProps> =\n (props) => {\n const paginationLoadMoreHook = usePaginationLoadable(props);\n\n const RenderPaginationComponent =\n props.render ?? ExampleResultPaginationLoadMore;\n\n return <RenderPaginationComponent {...paginationLoadMoreHook} />;\n };\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import ReactiveList from "@appbaseio/reactivesearch/lib/components/result/ReactiveList";
|
|
2
3
|
import { ElasticCallout, ElasticProduct, ReactivesearchError, ReactivesearchResultProps } from "../../types";
|
|
3
|
-
import { useProductPrice, usePagination,
|
|
4
|
+
import { useProductPrice, usePagination, usePaginationLoadable } from "../../hooks";
|
|
4
5
|
export declare type ResultProps = ReactivesearchResultProps & {
|
|
5
6
|
callouts: ElasticCallout[];
|
|
6
7
|
products: ElasticProduct[];
|
|
@@ -39,10 +40,14 @@ export declare type ResultsProps = {
|
|
|
39
40
|
/** Render method called for pagination type "next_prev" */
|
|
40
41
|
renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;
|
|
41
42
|
/** Render method called for pagination type "load_more" */
|
|
42
|
-
renderPaginationLoadMore?: React.FC<ReturnType<typeof
|
|
43
|
+
renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadable>>;
|
|
43
44
|
/** Render method called for pagination type "infinite_scroll" */
|
|
44
|
-
renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof
|
|
45
|
+
renderPaginationInfiniteScroll?: React.FC<ReturnType<typeof usePaginationLoadable>>;
|
|
45
46
|
/** Advanced Usage: Override the default amount of results per page */
|
|
46
47
|
pageSize?: number;
|
|
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;
|
|
47
52
|
};
|
|
48
53
|
export declare const Results: React.FC<ResultsProps>;
|
|
@@ -14,9 +14,11 @@ const ResultPaginationNextPrev_1 = require("./ResultPaginationNextPrev");
|
|
|
14
14
|
const types_1 = require("../../types");
|
|
15
15
|
const hooks_1 = require("../../hooks");
|
|
16
16
|
const utility_1 = require("../../utility");
|
|
17
|
+
const ResultPaginationInfiniteScroll_1 = require("./ResultPaginationInfiniteScroll");
|
|
17
18
|
const Results = (props) => {
|
|
18
19
|
const reactiveReactiveListProps = (0, hooks_1.useReactiveReactiveListProps)({
|
|
19
20
|
pageSize: props.pageSize,
|
|
21
|
+
scrollTarget: props.infiniteScrollContainer,
|
|
20
22
|
});
|
|
21
23
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
22
24
|
const { searchTerm } = (0, hooks_1.useSearch)();
|
|
@@ -46,7 +48,8 @@ const ResultsRenderNoResultsComponent = () => {
|
|
|
46
48
|
return react_1.default.createElement("div", null, "No results");
|
|
47
49
|
};
|
|
48
50
|
const ResultsInner = (props) => {
|
|
49
|
-
var _a, _b, _c;
|
|
51
|
+
var _a, _b, _c, _d, _e;
|
|
52
|
+
const filtersHook = (0, hooks_1.useFilters)();
|
|
50
53
|
const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
|
|
51
54
|
typeof props.reactivesearchResultProps.resultStats.numberOfResults, [props.reactivesearchResultProps]);
|
|
52
55
|
const listStyle = react_1.default.useMemo(() => {
|
|
@@ -57,6 +60,19 @@ const ResultsInner = (props) => {
|
|
|
57
60
|
gridTemplateColumns: "repeat(4, minmax(0, 1fr))",
|
|
58
61
|
};
|
|
59
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
|
+
]);
|
|
60
76
|
if (props.reactivesearchResultProps.error) {
|
|
61
77
|
utility_1.debug.breadcrumb({
|
|
62
78
|
category: "result",
|
|
@@ -65,30 +81,37 @@ const ResultsInner = (props) => {
|
|
|
65
81
|
error: props.reactivesearchResultProps.error,
|
|
66
82
|
},
|
|
67
83
|
});
|
|
68
|
-
const RenderErrorComponent = (
|
|
84
|
+
const RenderErrorComponent = (_c = props.renderError) !== null && _c !== void 0 ? _c : ResultsRenderErrorComponent;
|
|
69
85
|
return (react_1.default.createElement(RenderErrorComponent, { error: props.reactivesearchResultProps.error }));
|
|
70
86
|
}
|
|
71
87
|
if (!initialSearchHasRun) {
|
|
72
|
-
const RenderLoadingComponent = (
|
|
88
|
+
const RenderLoadingComponent = (_d = props.renderLoading) !== null && _d !== void 0 ? _d : ResultsRenderLoadingComponent;
|
|
73
89
|
return react_1.default.createElement(RenderLoadingComponent, null);
|
|
74
90
|
}
|
|
75
91
|
if (!props.reactivesearchResultProps.loading &&
|
|
76
92
|
!props.reactivesearchResultProps.resultStats.numberOfResults) {
|
|
77
|
-
const RenderNoResultsComponent = (
|
|
93
|
+
const RenderNoResultsComponent = (_e = props.renderNoResults) !== null && _e !== void 0 ? _e : ResultsRenderNoResultsComponent;
|
|
78
94
|
return react_1.default.createElement(RenderNoResultsComponent, null);
|
|
79
95
|
}
|
|
80
96
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
81
97
|
react_1.default.createElement("section", { style: listStyle, className: props.listClassName }, props.reactivesearchResultProps.data.map((item, key) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
: {}))));
|
|
85
104
|
}
|
|
86
105
|
if (types_1.ElasticDocumentType.Callout === item.type) {
|
|
87
|
-
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
|
+
: {}))));
|
|
88
111
|
}
|
|
89
112
|
return null;
|
|
90
113
|
})),
|
|
91
|
-
react_1.default.createElement(
|
|
114
|
+
react_1.default.createElement(ResultsPaginationStackLoadable, Object.assign({}, props, props.reactivesearchResultProps))));
|
|
92
115
|
};
|
|
93
116
|
/** Handles rendering pagination for types that use "pagination props" */
|
|
94
117
|
const ResultsPaginationStack = (props) => {
|
|
@@ -106,7 +129,7 @@ const ResultsPaginationStack = (props) => {
|
|
|
106
129
|
return null;
|
|
107
130
|
};
|
|
108
131
|
/** Handles rendering pagination for types that use "result props" */
|
|
109
|
-
const
|
|
132
|
+
const ResultsPaginationStackLoadable = (props) => {
|
|
110
133
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
111
134
|
const { filterStack } = (0, hooks_1.useFilters)();
|
|
112
135
|
if (options.mode === "instant-search") {
|
|
@@ -115,6 +138,9 @@ const ResultsPaginationStackLoadMore = (props) => {
|
|
|
115
138
|
if ("load_more" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType)) {
|
|
116
139
|
return (react_1.default.createElement(ResultPaginationLoadMore_1.ResultPaginationLoadMore, Object.assign({}, props.reactivesearchResultProps, { render: props.renderPaginationLoadMore })));
|
|
117
140
|
}
|
|
141
|
+
if ("infinite_scroll" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType)) {
|
|
142
|
+
return (react_1.default.createElement(ResultPaginationInfiniteScroll_1.ResultPaginationInfiniteScroll, Object.assign({}, props.reactivesearchResultProps, { render: props.renderPaginationInfiniteScroll })));
|
|
143
|
+
}
|
|
118
144
|
return null;
|
|
119
145
|
};
|
|
120
146
|
//# sourceMappingURL=Results.js.map
|
|
@@ -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;AAkD/B,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,yBAAyB,GAAG,IAAA,oCAA4B,EAAC;QAC7D,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;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,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KAAK,EAAE,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { ResultCardCallout } from \"./ResultCardCallout\";\nimport { ResultCardProduct } from \"./ResultCardProduct\";\nimport { ResultPaginationNumbered } from \"./ResultPaginationNumbered\";\nimport { ResultPaginationLoadMore } from \"./ResultPaginationLoadMore\";\nimport { ResultPaginationNextPrev } from \"./ResultPaginationNextPrev\";\n\nimport {\n ElasticCallout,\n ElasticProduct,\n ElasticDocumentType,\n ReactivesearchError,\n ReactivesearchResultProps,\n ReactivesearchPaginationProps,\n} from \"../../types\";\nimport {\n useReactifySearchContext,\n useAnalytics,\n useSearch,\n useFilters,\n useReactiveReactiveListProps,\n useProductPrice,\n usePagination,\n usePaginationLoadMore,\n} from \"../../hooks\";\nimport { debug } from \"../../utility\";\n\nexport type ResultProps = ReactivesearchResultProps & {\n callouts: ElasticCallout[];\n products: ElasticProduct[];\n};\n\nexport type ResultsProps = {\n /** Style prop for the list wrapper */\n listStyle?: React.HTMLAttributes<HTMLElement>[\"style\"];\n /** Classname prop for the list wrapper */\n listClassName?: string;\n /** Render method called when an error occurs */\n renderError?: React.FC<{ error: ReactivesearchError }>;\n /** Render method called while loading for the first time */\n renderLoading?: React.FC;\n /** Render method called when no results are found */\n renderNoResults?: React.FC;\n /** Render method called once for each product result */\n renderResultCardProduct?: React.FC<\n ReturnType<typeof useProductPrice> & {\n pagePosition: number;\n product: ElasticProduct;\n document: ElasticProduct;\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }\n >;\n /** Render method called once for each callout result */\n renderResultCardCallout?: React.FC<{\n pagePosition: number;\n document: ElasticCallout;\n callout: ElasticCallout[\"callout\"];\n itemRef: (node?: Element | null) => void;\n handleClick: () => void;\n }>;\n /** Render method called for pagination type \"pagination\" */\n renderPaginationNumbered?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"next_prev\" */\n renderPaginationNextPrev?: React.FC<ReturnType<typeof usePagination>>;\n /** Render method called for pagination type \"load_more\" */\n renderPaginationLoadMore?: React.FC<ReturnType<typeof usePaginationLoadMore>>;\n /** Render method called for pagination type \"infinite_scroll\" */\n renderPaginationInfiniteScroll?: React.FC<\n ReturnType<typeof usePaginationLoadMore>\n >;\n /** Advanced Usage: Override the default amount of results per page */\n pageSize?: number;\n};\n\nexport const Results: React.FC<ResultsProps> = (props) => {\n const reactiveReactiveListProps = useReactiveReactiveListProps({\n pageSize: props.pageSize,\n });\n 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 <ResultsPaginationStackLoadMore\n {...props}\n {...props.reactivesearchResultProps}\n />\n </>\n );\n};\n\n/** Handles rendering pagination for types that use \"pagination props\" */\nconst ResultsPaginationStack: React.FC<\n ResultsProps & ReactivesearchPaginationProps\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"pagination\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNumbered\n {...props}\n render={props.renderPaginationNumbered}\n />\n );\n }\n\n if (\"next_prev\" === filterStack?.paginationType) {\n return (\n <ResultPaginationNextPrev\n {...props}\n render={props.renderPaginationNextPrev}\n />\n );\n }\n\n return null;\n};\n\n/** Handles rendering pagination for types that use \"result props\" */\nconst ResultsPaginationStackLoadMore: React.FC<\n ResultsProps & { reactivesearchResultProps: ReactivesearchResultProps }\n> = (props) => {\n const { options } = useReactifySearchContext();\n const { filterStack } = useFilters();\n\n if (options.mode === \"instant-search\") {\n return null;\n }\n\n if (\"load_more\" === filterStack?.paginationType) {\n return (\n <ResultPaginationLoadMore\n {...props.reactivesearchResultProps}\n render={props.renderPaginationLoadMore}\n />\n );\n }\n\n return null;\n};\n"]}
|
|
1
|
+
{"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,Y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AAO,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"]}
|
|
@@ -16,5 +16,6 @@ __exportStar(require("./ResultCardProduct"), exports);
|
|
|
16
16
|
__exportStar(require("./ResultStateProvider"), exports);
|
|
17
17
|
__exportStar(require("./ResultPaginationNumbered"), exports);
|
|
18
18
|
__exportStar(require("./ResultPaginationLoadMore"), exports);
|
|
19
|
+
__exportStar(require("./ResultPaginationInfiniteScroll"), exports);
|
|
19
20
|
__exportStar(require("./ResultPaginationNextPrev"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Result/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,sDAAoC;AACpC,sDAAoC;AACpC,wDAAsC;AACtC,6DAA2C;AAC3C,6DAA2C;AAC3C,6DAA2C","sourcesContent":["export * from \"./Results\";\nexport * from \"./ResultCardCallout\";\nexport * from \"./ResultCardProduct\";\nexport * from \"./ResultStateProvider\";\nexport * from \"./ResultPaginationNumbered\";\nexport * from \"./ResultPaginationLoadMore\";\nexport * from \"./ResultPaginationNextPrev\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Result/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,sDAAoC;AACpC,sDAAoC;AACpC,wDAAsC;AACtC,6DAA2C;AAC3C,6DAA2C;AAC3C,mEAAiD;AACjD,6DAA2C","sourcesContent":["export * from \"./Results\";\nexport * from \"./ResultCardCallout\";\nexport * from \"./ResultCardProduct\";\nexport * from \"./ResultStateProvider\";\nexport * from \"./ResultPaginationNumbered\";\nexport * from \"./ResultPaginationLoadMore\";\nexport * from \"./ResultPaginationInfiniteScroll\";\nexport * from \"./ResultPaginationNextPrev\";\n"]}
|
|
@@ -2,7 +2,7 @@ export * from "./reactivesearch";
|
|
|
2
2
|
export * from "./useDebugger";
|
|
3
3
|
export * from "./useSortBy";
|
|
4
4
|
export * from "./usePagination";
|
|
5
|
-
export * from "./
|
|
5
|
+
export * from "./usePaginationLoadable";
|
|
6
6
|
export * from "./useSearch";
|
|
7
7
|
export * from "./useCuration";
|
|
8
8
|
export * from "./useAnalytics";
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -14,7 +14,7 @@ __exportStar(require("./reactivesearch"), exports);
|
|
|
14
14
|
__exportStar(require("./useDebugger"), exports);
|
|
15
15
|
__exportStar(require("./useSortBy"), exports);
|
|
16
16
|
__exportStar(require("./usePagination"), exports);
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./usePaginationLoadable"), exports);
|
|
18
18
|
__exportStar(require("./useSearch"), exports);
|
|
19
19
|
__exportStar(require("./useCuration"), exports);
|
|
20
20
|
__exportStar(require("./useAnalytics"), exports);
|
|
@@ -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 \"./
|
|
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"]}
|
|
@@ -2,4 +2,5 @@ import React from "react";
|
|
|
2
2
|
import ReactiveList from "@appbaseio/reactivesearch/lib/components/result/ReactiveList";
|
|
3
3
|
export declare const useReactiveReactiveListProps: (options: {
|
|
4
4
|
pageSize?: number;
|
|
5
|
+
scrollTarget?: React.ComponentProps<typeof ReactiveList>["scrollTarget"];
|
|
5
6
|
}) => React.ComponentProps<typeof ReactiveList>;
|
|
@@ -25,6 +25,7 @@ const useReactiveReactiveListProps = (options) => {
|
|
|
25
25
|
react: reactiveReactProp,
|
|
26
26
|
includeFields,
|
|
27
27
|
excludeFields,
|
|
28
|
+
scrollTarget: options.scrollTarget,
|
|
28
29
|
componentId: "page",
|
|
29
30
|
scrollOnChange: false,
|
|
30
31
|
pagination: (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType) !== "infinite_scroll",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveReactiveListProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveReactiveListProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAmE;AACnE,iEAA8D;AAEvD,MAAM,4BAA4B,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"useReactiveReactiveListProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveReactiveListProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,uCAAmE;AACnE,iEAA8D;AAEvD,MAAM,4BAA4B,GAAG,CAAC,OAG5C,EAA6C,EAAE;IAC9C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IACrC,MAAM,iBAAiB,GAAG,IAAA,2CAAoB,GAAE,CAAC;IACjD,MAAM,OAAO,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC3C,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAEzD,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC9B,OAAO,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,mCAAI,EAAE,CAAC;IACzD,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpC,MAAM,yBAAyB,GAAG,eAAK,CAAC,OAAO,CAG7C,GAAG,EAAE,CAAC,CAAC;QACL,IAAI;QACJ,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,OAAO;QAClB,eAAe,EAAE,KAAK;QACtB,KAAK,EAAE,iBAAiB;QACxB,aAAa;QACb,aAAa;QACb,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,WAAW,EAAE,MAAM;QACnB,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,MAAK,iBAAiB;QAC7D,cAAc,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,MAAK,iBAAiB;QACjE,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,mDAAmD;KACjF,CAAC,EACF,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,CACnD,CAAC;IAEF,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC;AApCW,QAAA,4BAA4B,gCAoCvC","sourcesContent":["import React from \"react\";\nimport ReactiveList from \"@appbaseio/reactivesearch/lib/components/result/ReactiveList\";\n\nimport { useFilters, useReactifySearchContext } from \"../../hooks\";\nimport { useReactiveReactProp } from \"./useReactiveReactProp\";\n\nexport const useReactiveReactiveListProps = (options: {\n pageSize?: number;\n scrollTarget?: React.ComponentProps<typeof ReactiveList>[\"scrollTarget\"];\n}): React.ComponentProps<typeof ReactiveList> => {\n const { filterStack } = useFilters();\n const reactiveReactProp = useReactiveReactProp();\n const context = useReactifySearchContext();\n const { includeFields, excludeFields } = context.options;\n\n const size = React.useMemo(() => {\n return options.pageSize ?? filterStack?.pageSize ?? 20;\n }, [options.pageSize, filterStack]);\n\n const reactiveReactiveListProps = React.useMemo<\n React.ComponentProps<typeof ReactiveList>\n >(\n () => ({\n size,\n URLParams: true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: reactiveReactProp,\n includeFields,\n excludeFields,\n scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: filterStack?.paginationType !== \"infinite_scroll\",\n infiniteScroll: filterStack?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n }),\n [filterStack, reactiveReactProp, options.pageSize]\n );\n\n return reactiveReactiveListProps;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactivesearchResultProps } from "../types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const usePaginationLoadable: (input: ReactivesearchResultProps) => {
|
|
3
3
|
loading: boolean;
|
|
4
4
|
hasMore: boolean;
|
|
5
5
|
handleLoadMore: () => void;
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.usePaginationLoadable = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
8
|
+
const _1 = require(".");
|
|
9
9
|
const utility_1 = require("../utility");
|
|
10
|
-
const
|
|
11
|
-
const analyticsHook = (0,
|
|
12
|
-
const { filterStack } = (0,
|
|
10
|
+
const usePaginationLoadable = (input) => {
|
|
11
|
+
const analyticsHook = (0, _1.useAnalytics)();
|
|
12
|
+
const { filterStack } = (0, _1.useFilters)();
|
|
13
13
|
const hasMore = input.resultStats.displayedResults !== input.resultStats.numberOfResults;
|
|
14
14
|
const handleLoadMore = react_1.default.useCallback(() => {
|
|
15
|
-
utility_1.debug.log("
|
|
15
|
+
utility_1.debug.log("usePaginationLoadable", "handleLoadMore");
|
|
16
16
|
if (!hasMore) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
@@ -34,5 +34,5 @@ const usePaginationLoadMore = (input) => {
|
|
|
34
34
|
resultStats: input.resultStats,
|
|
35
35
|
}), [input.loading, hasMore, handleLoadMore, input.resultStats]);
|
|
36
36
|
};
|
|
37
|
-
exports.
|
|
38
|
-
//# sourceMappingURL=
|
|
37
|
+
exports.usePaginationLoadable = usePaginationLoadable;
|
|
38
|
+
//# sourceMappingURL=usePaginationLoadable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePaginationLoadable.js","sourceRoot":"","sources":["../../../src/hooks/usePaginationLoadable.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,wBAA6C;AAC7C,wCAAmC;AAE5B,MAAM,qBAAqB,GAAG,CACnC,KAAgC,EAchC,EAAE;IACF,MAAM,aAAa,GAAG,IAAA,eAAY,GAAE,CAAC;IACrC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,aAAU,GAAE,CAAC;IAErC,MAAM,OAAO,GACX,KAAK,CAAC,WAAW,CAAC,gBAAgB,KAAK,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC;IAE3E,MAAM,cAAc,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC5C,eAAK,CAAC,GAAG,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;QAErD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,aAAa,CAAC,KAAK,CAAC;YAClB,SAAS,EAAE,kBAAkB;YAC7B,OAAO,EAAE;gBACP,IAAI,EACF,IAAI,CAAC,IAAI,CACP,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,KAAI,EAAE,CAAC,CACnE,GAAG,CAAC;gBACP,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;oBAClD,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,YAAY;aACjB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAE1E,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO;QACP,cAAc;QACd,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC,EACF,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC,CAC5D,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,qBAAqB,yBAqDhC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../types\";\nimport { useAnalytics, useFilters } from \".\";\nimport { debug } from \"../utility\";\n\nexport const usePaginationLoadable = (\n input: ReactivesearchResultProps\n): {\n loading: boolean;\n hasMore: boolean;\n handleLoadMore: () => void;\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} => {\n const analyticsHook = useAnalytics();\n const { filterStack } = useFilters();\n\n const hasMore =\n input.resultStats.displayedResults !== input.resultStats.numberOfResults;\n\n const handleLoadMore = React.useCallback(() => {\n debug.log(\"usePaginationLoadable\", \"handleLoadMore\");\n\n if (!hasMore) {\n return;\n }\n\n input.loadMore();\n analyticsHook.track({\n eventName: \"paginationChange\",\n payload: {\n page:\n Math.ceil(\n input.resultStats.displayedResults / (filterStack?.pageSize || 20)\n ) + 1,\n source: window.location.pathname.includes(\"/search\")\n ? \"search\"\n : \"collection\",\n },\n });\n }, [input.loadMore, analyticsHook.track, input.resultStats, filterStack]);\n\n return React.useMemo(\n () => ({\n loading: input.loading,\n hasMore,\n handleLoadMore,\n resultStats: input.resultStats,\n }),\n [input.loading, hasMore, handleLoadMore, input.resultStats]\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePaginationLoadMore.js","sourceRoot":"","sources":["../../../src/hooks/usePaginationLoadMore.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,oCAAoD;AACpD,wCAAmC;AAE5B,MAAM,qBAAqB,GAAG,CACnC,KAAgC,EAchC,EAAE;IACF,MAAM,aAAa,GAAG,IAAA,oBAAY,GAAE,CAAC;IACrC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,MAAM,OAAO,GACX,KAAK,CAAC,WAAW,CAAC,gBAAgB,KAAK,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC;IAE3E,MAAM,cAAc,GAAG,eAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC5C,eAAK,CAAC,GAAG,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;QAErD,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,aAAa,CAAC,KAAK,CAAC;YAClB,SAAS,EAAE,kBAAkB;YAC7B,OAAO,EAAE;gBACP,IAAI,EACF,IAAI,CAAC,IAAI,CACP,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,KAAI,EAAE,CAAC,CACnE,GAAG,CAAC;gBACP,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;oBAClD,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,YAAY;aACjB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAE1E,OAAO,eAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO;QACP,cAAc;QACd,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC,EACF,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC,CAC5D,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,qBAAqB,yBAqDhC","sourcesContent":["import React from \"react\";\n\nimport { ReactivesearchResultProps } from \"../types\";\nimport { useAnalytics, useFilters } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const usePaginationLoadMore = (\n input: ReactivesearchResultProps\n): {\n loading: boolean;\n hasMore: boolean;\n handleLoadMore: () => void;\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} => {\n const analyticsHook = useAnalytics();\n const { filterStack } = useFilters();\n\n const hasMore =\n input.resultStats.displayedResults !== input.resultStats.numberOfResults;\n\n const handleLoadMore = React.useCallback(() => {\n debug.log(\"usePaginationLoadMore\", \"handleLoadMore\");\n\n if (!hasMore) {\n return;\n }\n\n input.loadMore();\n analyticsHook.track({\n eventName: \"paginationChange\",\n payload: {\n page:\n Math.ceil(\n input.resultStats.displayedResults / (filterStack?.pageSize || 20)\n ) + 1,\n source: window.location.pathname.includes(\"/search\")\n ? \"search\"\n : \"collection\",\n },\n });\n }, [input.loadMore, analyticsHook.track, input.resultStats, filterStack]);\n\n return React.useMemo(\n () => ({\n loading: input.loading,\n hasMore,\n handleLoadMore,\n resultStats: input.resultStats,\n }),\n [input.loading, hasMore, handleLoadMore, input.resultStats]\n );\n};\n"]}
|