@usereactify/search 5.3.5 → 5.4.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 +12 -0
- package/dist/package.json +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/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/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 +6 -3
- package/dist/src/components/Result/Results.js +7 -2
- 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,18 @@
|
|
|
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.4.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.3.5...release-v5.4.0) (2022-10-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add scrollTarget prop and infinite scroll pagination rendered ([11f4d02](https://bitbucket.org/usereactify/reactify-search-ui/commit/11f4d02b43058e65a1d1ffa5f96a311f102ef6cf))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* switch from usePaginationLoadMore to usePaginationLoadable ([1337749](https://bitbucket.org/usereactify/reactify-search-ui/commit/1337749b0806d82a5026600387edd91886f3f4c5))
|
|
16
|
+
|
|
5
17
|
### [5.3.5](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.3.4...release-v5.3.5) (2022-09-28)
|
|
6
18
|
|
|
7
19
|
|
package/dist/package.json
CHANGED
|
@@ -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"]}
|
|
@@ -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"]}
|
|
@@ -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,12 @@ 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 */
|
|
49
|
+
scrollTarget?: React.ComponentProps<typeof ReactiveList>["scrollTarget"];
|
|
47
50
|
};
|
|
48
51
|
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.scrollTarget,
|
|
20
22
|
});
|
|
21
23
|
const { track } = (0, hooks_1.useAnalytics)();
|
|
22
24
|
const { searchTerm } = (0, hooks_1.useSearch)();
|
|
@@ -88,7 +90,7 @@ const ResultsInner = (props) => {
|
|
|
88
90
|
}
|
|
89
91
|
return null;
|
|
90
92
|
})),
|
|
91
|
-
react_1.default.createElement(
|
|
93
|
+
react_1.default.createElement(ResultsPaginationStackLoadable, Object.assign({}, props, props.reactivesearchResultProps))));
|
|
92
94
|
};
|
|
93
95
|
/** Handles rendering pagination for types that use "pagination props" */
|
|
94
96
|
const ResultsPaginationStack = (props) => {
|
|
@@ -106,7 +108,7 @@ const ResultsPaginationStack = (props) => {
|
|
|
106
108
|
return null;
|
|
107
109
|
};
|
|
108
110
|
/** Handles rendering pagination for types that use "result props" */
|
|
109
|
-
const
|
|
111
|
+
const ResultsPaginationStackLoadable = (props) => {
|
|
110
112
|
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
111
113
|
const { filterStack } = (0, hooks_1.useFilters)();
|
|
112
114
|
if (options.mode === "instant-search") {
|
|
@@ -115,6 +117,9 @@ const ResultsPaginationStackLoadMore = (props) => {
|
|
|
115
117
|
if ("load_more" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType)) {
|
|
116
118
|
return (react_1.default.createElement(ResultPaginationLoadMore_1.ResultPaginationLoadMore, Object.assign({}, props.reactivesearchResultProps, { render: props.renderPaginationLoadMore })));
|
|
117
119
|
}
|
|
120
|
+
if ("infinite_scroll" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType)) {
|
|
121
|
+
return (react_1.default.createElement(ResultPaginationInfiniteScroll_1.ResultPaginationInfiniteScroll, Object.assign({}, props.reactivesearchResultProps, { render: props.renderPaginationInfiniteScroll })));
|
|
122
|
+
}
|
|
118
123
|
return null;
|
|
119
124
|
};
|
|
120
125
|
//# sourceMappingURL=Results.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Results.js","sourceRoot":"","sources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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,YAAY,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAChD,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,IACT,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,IACT,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,8BAA8B,GAEhC,CAAC,KAAK,EAAE,EAAE;IACZ,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAErC,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,MAAK,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,CAAA,EAAE;QAC/C,OAAO,CACL,8BAAC,mDAAwB,oBACnB,KAAK,CAAC,yBAAyB,IACnC,MAAM,EAAE,KAAK,CAAC,wBAAwB,IACtC,CACH,CAAC;KACH;IAED,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;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;qBAC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,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 */\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"]}
|
|
@@ -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,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import { 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"]}
|