@usereactify/search 2.1.0-beta.4 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -5
- package/dist/filter/Filter.d.ts +1 -1
- package/dist/filter/FilterStack.d.ts +1 -1
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/index.js +0 -2
- package/dist/hooks/reactivesearch/useReactiveBaseProps.d.ts +1 -1
- package/dist/hooks/reactivesearch/useReactiveDataSearchProps.js +0 -8
- package/dist/hooks/reactivesearch/useReactiveFilterListProps.d.ts +1 -1
- package/dist/hooks/reactivesearch/useReactiveResultListProps.d.ts +0 -1
- package/dist/hooks/reactivesearch/useReactiveResultListProps.js +3 -3
- package/dist/hooks/useCollection.d.ts +1 -1
- package/dist/hooks/useFilterCollapsedState.d.ts +1 -1
- package/dist/hooks/useFilterListProps.d.ts +2 -1
- package/dist/hooks/useFilters.d.ts +1 -1
- package/dist/hooks/usePages.d.ts +1 -1
- package/dist/hooks/usePages.js +2 -7
- package/dist/hooks/useProductPrice.d.ts +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/provider.d.ts +34 -7
- package/dist/provider.js +1 -3
- package/dist/result/ResultCard.d.ts +2 -2
- package/dist/result/ResultCard.js +3 -14
- package/dist/result/ResultCardCallout.d.ts +2 -2
- package/dist/result/ResultCardCallout.js +2 -2
- package/dist/result/ResultList.d.ts +4 -7
- package/dist/result/ResultList.js +9 -20
- package/dist/result/ResultLoadMoreButton.d.ts +1 -1
- package/dist/result/ResultPagination.d.ts +1 -1
- package/dist/result/ResultPaginationNextPrev.d.ts +1 -1
- package/dist/result/ResultStateProvider.d.ts +1 -1
- package/dist/types/config.d.ts +17 -122
- package/dist/types/elastic.d.ts +209 -0
- package/dist/types/elastic.js +18 -0
- package/dist/types/firestore.d.ts +276 -0
- package/dist/types/firestore.js +18 -0
- package/dist/types/graphql.d.ts +26545 -0
- package/dist/types/graphql.js +4687 -0
- package/dist/types/{index.d.ts → reactivesearch.d.ts} +5 -11
- package/dist/types/{results.js → reactivesearch.js} +0 -0
- package/dist/types/shopify.d.ts +21 -0
- package/dist/types/shopify.js +27 -0
- package/package.json +1 -3
- package/dist/hooks/useAnalytics.d.ts +0 -14
- package/dist/hooks/useAnalytics.js +0 -47
- package/dist/hooks/useCombinedResults.d.ts +0 -7
- package/dist/hooks/useCombinedResults.js +0 -25
- package/dist/types/index.js +0 -14
- package/dist/types/results.d.ts +0 -48
package/README.md
CHANGED
package/dist/filter/Filter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ConfigFilterOption } from "../types";
|
|
2
|
+
import type { ConfigFilterOption } from "../types/config";
|
|
3
3
|
import { useFilterCollapsedState } from "../hooks";
|
|
4
4
|
declare type Props = {
|
|
5
5
|
render?: (filters: ConfigFilterOption[]) => JSX.Element;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -5,10 +5,8 @@ export * from "./useConfig";
|
|
|
5
5
|
export * from "./useSearch";
|
|
6
6
|
export * from "./useFilters";
|
|
7
7
|
export * from "./useCuration";
|
|
8
|
-
export * from "./useAnalytics";
|
|
9
8
|
export * from "./useCollection";
|
|
10
9
|
export * from "./useFilterStack";
|
|
11
10
|
export * from "./useProductPrice";
|
|
12
11
|
export * from "./useFilterListProps";
|
|
13
|
-
export * from "./useCombinedResults";
|
|
14
12
|
export * from "./useFilterCollapsedState";
|
package/dist/hooks/index.js
CHANGED
|
@@ -17,10 +17,8 @@ __exportStar(require("./useConfig"), exports);
|
|
|
17
17
|
__exportStar(require("./useSearch"), exports);
|
|
18
18
|
__exportStar(require("./useFilters"), exports);
|
|
19
19
|
__exportStar(require("./useCuration"), exports);
|
|
20
|
-
__exportStar(require("./useAnalytics"), exports);
|
|
21
20
|
__exportStar(require("./useCollection"), exports);
|
|
22
21
|
__exportStar(require("./useFilterStack"), exports);
|
|
23
22
|
__exportStar(require("./useProductPrice"), exports);
|
|
24
23
|
__exportStar(require("./useFilterListProps"), exports);
|
|
25
|
-
__exportStar(require("./useCombinedResults"), exports);
|
|
26
24
|
__exportStar(require("./useFilterCollapsedState"), exports);
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.useReactiveDataSearchProps = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ahooks_1 = require("ahooks");
|
|
9
|
-
const useAnalytics_1 = require("../useAnalytics");
|
|
10
9
|
const debug = require("debug")("reactify-search:useReactiveDataSearchProps");
|
|
11
10
|
const __1 = require("../");
|
|
12
11
|
// default field for when zero search fields have been configured in Reactify
|
|
@@ -34,15 +33,8 @@ const useReactiveDataSearchProps = (props = {}) => {
|
|
|
34
33
|
return;
|
|
35
34
|
submitSearch();
|
|
36
35
|
}, [submitSearch]);
|
|
37
|
-
const { track } = (0, useAnalytics_1.useAnalytics)();
|
|
38
|
-
const trackQuery = react_1.default.useCallback(() => {
|
|
39
|
-
if (!searchQuery)
|
|
40
|
-
return;
|
|
41
|
-
track({ eventName: "search", searchTerm: searchQuery });
|
|
42
|
-
}, [searchQuery, track]);
|
|
43
36
|
const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } = (0, ahooks_1.useDebounceFn)((triggerQuery) => {
|
|
44
37
|
triggerQuery();
|
|
45
|
-
trackQuery();
|
|
46
38
|
}, {
|
|
47
39
|
wait: debounce !== null && debounce !== void 0 ? debounce : 300,
|
|
48
40
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfigFilterOption } from "../../types";
|
|
1
|
+
import type { ConfigFilterOption } from "../../types/config";
|
|
2
2
|
export declare const useReactiveFilterListProps: (filter: ConfigFilterOption) => {
|
|
3
3
|
nestedField: string | undefined;
|
|
4
4
|
customQuery: ((value?: string | string[] | undefined) => {
|
|
@@ -8,13 +8,13 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
9
|
const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
10
10
|
const useReactiveResultListProps = (props = {}) => {
|
|
11
|
-
const { pageSize
|
|
11
|
+
const { pageSize } = props;
|
|
12
12
|
const filterStack = (0, hooks_1.useFilterStack)();
|
|
13
13
|
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)();
|
|
14
14
|
const size = react_1.default.useMemo(() => {
|
|
15
15
|
var _a;
|
|
16
|
-
return (
|
|
17
|
-
}, [pageSize,
|
|
16
|
+
return (_a = pageSize !== null && pageSize !== void 0 ? pageSize : filterStack === null || filterStack === void 0 ? void 0 : filterStack.pageSize) !== null && _a !== void 0 ? _a : 20;
|
|
17
|
+
}, [pageSize, filterStack]);
|
|
18
18
|
return react_1.default.useMemo(() => ({
|
|
19
19
|
size,
|
|
20
20
|
URLParams: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useCollection: () => import("
|
|
1
|
+
export declare const useCollection: () => import("../provider").Collection | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ConfigFilterOption
|
|
1
|
+
import { ConfigFilterOption } from "../types/config";
|
|
2
|
+
import { ReactivesearchFilterProps } from "../types/reactivesearch";
|
|
2
3
|
export declare const useFilterListProps: (filter: ConfigFilterOption, reactivesearchFilterProps: ReactivesearchFilterProps) => {
|
|
3
4
|
filter: ConfigFilterOption;
|
|
4
5
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFilters: () => import("
|
|
1
|
+
export declare const useFilters: () => Omit<import("../types/firestore").FilterOption, "enabled">[];
|
package/dist/hooks/usePages.d.ts
CHANGED
package/dist/hooks/usePages.js
CHANGED
|
@@ -16,19 +16,14 @@ const usePages = (props) => {
|
|
|
16
16
|
const pagesToShow = react_1.default.useMemo(() => getPages(pages, totalPages, currentPage), [pages, totalPages, currentPage]);
|
|
17
17
|
// default currentPage is zero-indexed, actualCurrentPage is one-indexed
|
|
18
18
|
const actualCurrentPage = react_1.default.useMemo(() => currentPage + 1, [currentPage]);
|
|
19
|
-
const hasNextPage = react_1.default.useMemo(() => actualCurrentPage < totalPages, [
|
|
20
|
-
actualCurrentPage,
|
|
21
|
-
totalPages,
|
|
22
|
-
]);
|
|
19
|
+
const hasNextPage = react_1.default.useMemo(() => actualCurrentPage < totalPages, [actualCurrentPage, totalPages]);
|
|
23
20
|
const handleNextPage = react_1.default.useCallback((event) => {
|
|
24
21
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
25
22
|
if (!hasNextPage)
|
|
26
23
|
return;
|
|
27
24
|
setPage(currentPage + 1);
|
|
28
25
|
}, [hasNextPage, currentPage, setPage]);
|
|
29
|
-
const hasPreviousPage = react_1.default.useMemo(() => actualCurrentPage > 1, [
|
|
30
|
-
actualCurrentPage,
|
|
31
|
-
]);
|
|
26
|
+
const hasPreviousPage = react_1.default.useMemo(() => actualCurrentPage > 1, [actualCurrentPage]);
|
|
32
27
|
const handlePreviousPage = react_1.default.useCallback((event) => {
|
|
33
28
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
34
29
|
if (!hasPreviousPage)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import currency from "currency.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ElasticProduct } from "../types/elastic";
|
|
3
3
|
declare type PriceResponse = {
|
|
4
4
|
onSale: boolean;
|
|
5
5
|
price?: currency;
|
|
@@ -8,5 +8,5 @@ declare type PriceResponse = {
|
|
|
8
8
|
compareAtPrice?: currency;
|
|
9
9
|
formattedCompareAtPrice?: string;
|
|
10
10
|
};
|
|
11
|
-
export declare const useProductPrice: (product:
|
|
11
|
+
export declare const useProductPrice: (product: ElasticProduct) => PriceResponse;
|
|
12
12
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
1
|
export * from "./hooks";
|
|
3
2
|
export * from "./filter";
|
|
4
3
|
export * from "./sensor";
|
|
5
4
|
export * from "./result";
|
|
6
5
|
export * from "./search";
|
|
7
6
|
export * from "./provider";
|
|
7
|
+
export * from "./types/config";
|
|
8
|
+
export * from "./types/elastic";
|
|
9
|
+
export * from "./types/reactivesearch";
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./types"), exports);
|
|
14
13
|
__exportStar(require("./hooks"), exports);
|
|
15
14
|
__exportStar(require("./filter"), exports);
|
|
16
15
|
__exportStar(require("./sensor"), exports);
|
|
17
16
|
__exportStar(require("./result"), exports);
|
|
18
17
|
__exportStar(require("./search"), exports);
|
|
19
18
|
__exportStar(require("./provider"), exports);
|
|
19
|
+
__exportStar(require("./types/config"), exports);
|
|
20
|
+
__exportStar(require("./types/elastic"), exports);
|
|
21
|
+
__exportStar(require("./types/reactivesearch"), exports);
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Config, ConfigSort, ConfigFilter, ConfigCuration } from "./types/config";
|
|
3
3
|
declare type Context = {
|
|
4
4
|
index: string;
|
|
5
5
|
config: Config;
|
|
6
|
-
shopName: string;
|
|
7
6
|
sortOption: ConfigSort;
|
|
8
7
|
sortOptions: ConfigSort[];
|
|
9
8
|
searchQuery?: string;
|
|
10
9
|
filterStack?: ConfigFilter;
|
|
11
10
|
collection?: Collection;
|
|
12
11
|
instantSearch: boolean;
|
|
13
|
-
credentials:
|
|
12
|
+
credentials: Credentials;
|
|
14
13
|
submitSearch: (localSearchQuery?: string) => void;
|
|
15
14
|
setSearchQuery: (searchQuery: string) => void;
|
|
16
15
|
setSortOption: (sortOptionId: string) => void;
|
|
17
16
|
showInstantSearchResults: boolean;
|
|
18
17
|
setShowInstantSearchResults: (showInstantSearchResults: boolean) => void;
|
|
19
|
-
theme?:
|
|
18
|
+
theme?: Theme;
|
|
20
19
|
curation?: ConfigCuration;
|
|
21
20
|
/** Array of additional component IDs managed outside of Reactify Search */
|
|
22
21
|
additionalComponentIds?: string[];
|
|
@@ -27,13 +26,12 @@ declare const Context: React.Context<Context | undefined>;
|
|
|
27
26
|
declare type Props = {
|
|
28
27
|
index: string;
|
|
29
28
|
config: Config;
|
|
30
|
-
shopName: string;
|
|
31
29
|
filterStackId?: string;
|
|
32
30
|
collection?: Collection;
|
|
33
31
|
noReactiveBase?: boolean;
|
|
34
32
|
instantSearch?: boolean;
|
|
35
|
-
credentials?:
|
|
36
|
-
theme?:
|
|
33
|
+
credentials?: Credentials;
|
|
34
|
+
theme?: Theme;
|
|
37
35
|
/** Array of additional component IDs managed outside of Reactify Search */
|
|
38
36
|
additionalComponentIds?: string[];
|
|
39
37
|
/** Enable the new callouts feature */
|
|
@@ -41,4 +39,33 @@ declare type Props = {
|
|
|
41
39
|
};
|
|
42
40
|
export declare const Provider: React.FC<Props>;
|
|
43
41
|
export declare const useContext: () => Context;
|
|
42
|
+
export interface Collection {
|
|
43
|
+
id: number;
|
|
44
|
+
handle: string;
|
|
45
|
+
title: string;
|
|
46
|
+
}
|
|
47
|
+
export interface Credentials {
|
|
48
|
+
username: string;
|
|
49
|
+
password: string;
|
|
50
|
+
endpoint: string;
|
|
51
|
+
}
|
|
52
|
+
export interface Theme {
|
|
53
|
+
component?: any;
|
|
54
|
+
colors?: ThemeColors;
|
|
55
|
+
typography?: ThemeTypography;
|
|
56
|
+
}
|
|
57
|
+
export interface ThemeTypography {
|
|
58
|
+
fontFamily?: string;
|
|
59
|
+
fontSize?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ThemeColors {
|
|
62
|
+
alertColor?: string;
|
|
63
|
+
backgroundColor?: string;
|
|
64
|
+
borderColor?: string;
|
|
65
|
+
extColor?: string;
|
|
66
|
+
primaryTextColor?: string;
|
|
67
|
+
primaryColor?: string;
|
|
68
|
+
textColor?: string;
|
|
69
|
+
titleColor?: string;
|
|
70
|
+
}
|
|
44
71
|
export {};
|
package/dist/provider.js
CHANGED
|
@@ -15,7 +15,7 @@ const defaultCredentials = {
|
|
|
15
15
|
};
|
|
16
16
|
const Provider = (props) => {
|
|
17
17
|
var _a;
|
|
18
|
-
const { index, config,
|
|
18
|
+
const { index, config, children, collection, instantSearch, filterStackId, noReactiveBase, enableCallouts, additionalComponentIds, } = props;
|
|
19
19
|
const credentials = (_a = props.credentials) !== null && _a !== void 0 ? _a : defaultCredentials;
|
|
20
20
|
const theme = props.theme || {
|
|
21
21
|
typography: {
|
|
@@ -64,7 +64,6 @@ const Provider = (props) => {
|
|
|
64
64
|
const contextValue = react_1.default.useMemo(() => ({
|
|
65
65
|
index,
|
|
66
66
|
config,
|
|
67
|
-
shopName,
|
|
68
67
|
collection,
|
|
69
68
|
credentials,
|
|
70
69
|
searchQuery,
|
|
@@ -85,7 +84,6 @@ const Provider = (props) => {
|
|
|
85
84
|
index,
|
|
86
85
|
config,
|
|
87
86
|
curation,
|
|
88
|
-
shopName,
|
|
89
87
|
collection,
|
|
90
88
|
credentials,
|
|
91
89
|
searchQuery,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { ElasticProduct } from "../types/elastic";
|
|
3
3
|
import { useProductPrice } from "../hooks";
|
|
4
4
|
declare type Props = {
|
|
5
|
-
product:
|
|
5
|
+
product: ElasticProduct;
|
|
6
6
|
pagePosition: number;
|
|
7
7
|
render?: (props: Omit<Props, "render"> & ReturnType<typeof useProductPrice>) => JSX.Element;
|
|
8
8
|
};
|
|
@@ -24,21 +24,10 @@ const ResultCard = (_a) => {
|
|
|
24
24
|
if (render)
|
|
25
25
|
return render(Object.assign(Object.assign({}, props), productPrice));
|
|
26
26
|
const { formattedPrice, formattedCompareAtPrice, onSale } = productPrice;
|
|
27
|
-
const { track } = (0, hooks_1.useAnalytics)();
|
|
28
|
-
const handleClick = react_1.default.useCallback((e) => {
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
const { id } = product;
|
|
31
|
-
console.log("tracking click product event");
|
|
32
|
-
track({
|
|
33
|
-
eventName: "select_item",
|
|
34
|
-
id,
|
|
35
|
-
}).then(() => {
|
|
36
|
-
console.log("tracking click product event finished");
|
|
37
|
-
window.location.href = `/products/${product.handle}`;
|
|
38
|
-
});
|
|
39
|
-
}, [track, product]);
|
|
40
27
|
return (react_1.default.createElement("article", null,
|
|
41
|
-
react_1.default.createElement("a", {
|
|
28
|
+
react_1.default.createElement("a", { href: `/products/${product.handle}` },
|
|
29
|
+
product.image && react_1.default.createElement("img", { src: product.image, width: "100%" }),
|
|
30
|
+
product.title),
|
|
42
31
|
react_1.default.createElement("span", null, formattedPrice),
|
|
43
32
|
onSale && (react_1.default.createElement("span", { style: { textDecoration: "line-through" } }, formattedCompareAtPrice))));
|
|
44
33
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ElasticCallout } from "../types/elastic";
|
|
3
3
|
declare type Props = {
|
|
4
|
-
callout:
|
|
4
|
+
callout: ElasticCallout;
|
|
5
5
|
pagePosition: number;
|
|
6
6
|
render?: (props: Omit<Props, "render">) => JSX.Element;
|
|
7
7
|
};
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.ResultCardCallout = void 0;
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const ResultCardCallout = (props) => {
|
|
20
|
-
const { callout } = props;
|
|
20
|
+
const { callout: { callout }, } = props;
|
|
21
21
|
const styleProp = react_1.default.useMemo(() => {
|
|
22
22
|
var _a, _b;
|
|
23
23
|
return ({
|
|
@@ -31,7 +31,7 @@ const ResultCardCallout = (props) => {
|
|
|
31
31
|
exports.ResultCardCallout = ResultCardCallout;
|
|
32
32
|
const ResultCardCalloutInner = (_a) => {
|
|
33
33
|
var { render } = _a, props = __rest(_a, ["render"]);
|
|
34
|
-
const { callout } = props;
|
|
34
|
+
const { callout: { callout }, } = props;
|
|
35
35
|
if (render)
|
|
36
36
|
return render(props);
|
|
37
37
|
return react_1.default.createElement("p", null, callout.title);
|
|
@@ -4,10 +4,7 @@ import { ResultPagination } from "./ResultPagination";
|
|
|
4
4
|
import { ResultCardCallout } from "./ResultCardCallout";
|
|
5
5
|
import { ResultLoadMoreButton } from "./ResultLoadMoreButton";
|
|
6
6
|
import { ResultPaginationNextPrev } from "./ResultPaginationNextPrev";
|
|
7
|
-
import {
|
|
8
|
-
declare type ResultProps = ReactivesearchResultProps & {
|
|
9
|
-
results: ResultCombined[];
|
|
10
|
-
};
|
|
7
|
+
import { ReactivesearchError, ReactivesearchResultProps } from "../types/reactivesearch";
|
|
11
8
|
declare type Props = {
|
|
12
9
|
pageSize?: number;
|
|
13
10
|
gridColumns?: number;
|
|
@@ -17,9 +14,9 @@ declare type Props = {
|
|
|
17
14
|
renderResultCard?: Parameters<typeof ResultCard>[0]["render"];
|
|
18
15
|
renderPagination?: Parameters<typeof ResultPagination>[0]["render"];
|
|
19
16
|
renderResultCardCallout?: Parameters<typeof ResultCardCallout>[0]["render"];
|
|
20
|
-
renderAfter?: (props:
|
|
21
|
-
renderBefore?: (props:
|
|
22
|
-
renderResults?: (props:
|
|
17
|
+
renderAfter?: (props: ReactivesearchResultProps) => JSX.Element | null;
|
|
18
|
+
renderBefore?: (props: ReactivesearchResultProps) => JSX.Element | null;
|
|
19
|
+
renderResults?: (props: ReactivesearchResultProps) => JSX.Element | null;
|
|
23
20
|
renderError?: (props: {
|
|
24
21
|
error: ReactivesearchError;
|
|
25
22
|
}) => JSX.Element | null;
|
|
@@ -13,20 +13,16 @@ const ResultLoadMoreButton_1 = require("./ResultLoadMoreButton");
|
|
|
13
13
|
const ResultPaginationNextPrev_1 = require("./ResultPaginationNextPrev");
|
|
14
14
|
const provider_1 = require("../provider");
|
|
15
15
|
const hooks_1 = require("../hooks");
|
|
16
|
+
const elastic_1 = require("../types/elastic");
|
|
16
17
|
const ResultList = (props) => {
|
|
17
|
-
var _a, _b;
|
|
18
18
|
const { pageSize } = props;
|
|
19
|
-
const curation = (0, hooks_1.useCuration)();
|
|
20
|
-
const { enableCallouts } = (0, provider_1.useContext)();
|
|
21
19
|
const reactiveResultListProps = (0, hooks_1.useReactiveResultListProps)({
|
|
22
20
|
pageSize,
|
|
23
|
-
pageSizeAdjust: enableCallouts ? (_b = (_a = curation === null || curation === void 0 ? void 0 : curation.callouts) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0,
|
|
24
21
|
});
|
|
25
22
|
return (react_1.default.createElement(ReactiveList_1.default, Object.assign({}, reactiveResultListProps, { renderPagination: (reactivesearchPaginationProps) => (react_1.default.createElement(ResultPaginationInner, Object.assign({}, props, reactivesearchPaginationProps))), render: (reactivesearchResultProps) => (react_1.default.createElement(ResultListInner, Object.assign({}, props, { reactivesearchResultProps: reactivesearchResultProps }))) })));
|
|
26
23
|
};
|
|
27
24
|
exports.ResultList = ResultList;
|
|
28
25
|
const ResultListInner = (props) => {
|
|
29
|
-
var _a;
|
|
30
26
|
const { gridColumns, renderError, renderAfter, renderBefore, renderLoading, listClassName, renderResults, renderNoResults, renderResultCard, renderLoadMoreButton, renderResultCardCallout, reactivesearchResultProps, } = props;
|
|
31
27
|
const curation = (0, hooks_1.useCuration)();
|
|
32
28
|
const filterStack = (0, hooks_1.useFilterStack)();
|
|
@@ -34,13 +30,6 @@ const ResultListInner = (props) => {
|
|
|
34
30
|
const { enableCallouts } = (0, provider_1.useContext)();
|
|
35
31
|
const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
|
|
36
32
|
typeof reactivesearchResultProps.resultStats.numberOfResults, [reactivesearchResultProps]);
|
|
37
|
-
const combinedResults = (0, hooks_1.useCombinedResults)({
|
|
38
|
-
callouts: (_a = curation === null || curation === void 0 ? void 0 : curation.callouts) !== null && _a !== void 0 ? _a : [],
|
|
39
|
-
products: reactivesearchResultProps.data,
|
|
40
|
-
});
|
|
41
|
-
const resultProps = react_1.default.useMemo(() => {
|
|
42
|
-
return Object.assign(Object.assign({}, reactivesearchResultProps), { results: combinedResults });
|
|
43
|
-
}, [combinedResults, reactivesearchResultProps]);
|
|
44
33
|
const styleProp = react_1.default.useMemo(() => !!enableCallouts
|
|
45
34
|
? {
|
|
46
35
|
display: "grid",
|
|
@@ -65,21 +54,21 @@ const ResultListInner = (props) => {
|
|
|
65
54
|
return react_1.default.createElement("div", null, "No results");
|
|
66
55
|
}
|
|
67
56
|
if (renderResults) {
|
|
68
|
-
return renderResults(
|
|
57
|
+
return renderResults(reactivesearchResultProps);
|
|
69
58
|
}
|
|
70
59
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
71
|
-
renderBefore && renderBefore(
|
|
72
|
-
react_1.default.createElement("section", { className: listClassName, style: styleProp },
|
|
73
|
-
if (
|
|
74
|
-
return (react_1.default.createElement(ResultCard_1.ResultCard, {
|
|
60
|
+
renderBefore && renderBefore(reactivesearchResultProps),
|
|
61
|
+
react_1.default.createElement("section", { className: listClassName, style: styleProp }, reactivesearchResultProps.data.map((result, key) => {
|
|
62
|
+
if (elastic_1.ElasticDocumentType.Product === result.type) {
|
|
63
|
+
return (react_1.default.createElement(ResultCard_1.ResultCard, { key: result._id, product: result, pagePosition: key + 1, render: renderResultCard }));
|
|
75
64
|
}
|
|
76
|
-
if (!!enableCallouts &&
|
|
77
|
-
return (react_1.default.createElement(ResultCardCallout_1.ResultCardCallout, {
|
|
65
|
+
if (!!enableCallouts && elastic_1.ElasticDocumentType.Callout === result.type) {
|
|
66
|
+
return (react_1.default.createElement(ResultCardCallout_1.ResultCardCallout, { key: result._id, callout: result, pagePosition: key + 1, render: renderResultCardCallout }));
|
|
78
67
|
}
|
|
79
68
|
return null;
|
|
80
69
|
})),
|
|
81
70
|
!instantSearch && "load_more" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType) && (react_1.default.createElement(ResultLoadMoreButton_1.ResultLoadMoreButton, Object.assign({}, reactivesearchResultProps, { render: renderLoadMoreButton }))),
|
|
82
|
-
renderAfter && renderAfter(
|
|
71
|
+
renderAfter && renderAfter(reactivesearchResultProps)));
|
|
83
72
|
};
|
|
84
73
|
const ResultPaginationInner = (props) => {
|
|
85
74
|
const { renderPagination, renderPaginationNextPrev } = props;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ReactivesearchResultProps } from "../types";
|
|
2
|
+
import { ReactivesearchResultProps } from "../types/reactivesearch";
|
|
3
3
|
declare type Props = ReactivesearchResultProps & {
|
|
4
4
|
render?: (props: Omit<Props, "render"> & {
|
|
5
5
|
hasMore: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { usePages } from "../hooks";
|
|
3
|
-
import { ReactivesearchPaginationProps } from "../types";
|
|
3
|
+
import { ReactivesearchPaginationProps } from "../types/reactivesearch";
|
|
4
4
|
declare type Props = ReactivesearchPaginationProps & {
|
|
5
5
|
render?: (props: Omit<Props, "render"> & ReturnType<typeof usePages>) => JSX.Element;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { usePages } from "../hooks";
|
|
3
|
-
import { ReactivesearchPaginationProps } from "../types";
|
|
3
|
+
import { ReactivesearchPaginationProps } from "../types/reactivesearch";
|
|
4
4
|
declare type Props = ReactivesearchPaginationProps & {
|
|
5
5
|
render?: (props: Omit<Props, "render"> & ReturnType<typeof usePages>) => JSX.Element;
|
|
6
6
|
};
|