@usereactify/search 4.4.0-beta.0 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/package.json +8 -10
  3. package/dist/filter/Filter.d.ts +0 -12
  4. package/dist/filter/Filter.js +0 -71
  5. package/dist/filter/FilterList.d.ts +0 -4
  6. package/dist/filter/FilterList.js +0 -15
  7. package/dist/filter/FilterStack.d.ts +0 -11
  8. package/dist/filter/FilterStack.js +0 -25
  9. package/dist/filter/index.d.ts +0 -3
  10. package/dist/filter/index.js +0 -15
  11. package/dist/hooks/index.d.ts +0 -14
  12. package/dist/hooks/index.js +0 -26
  13. package/dist/hooks/reactivesearch/index.d.ts +0 -5
  14. package/dist/hooks/reactivesearch/index.js +0 -17
  15. package/dist/hooks/reactivesearch/useReactiveBaseProps.d.ts +0 -7
  16. package/dist/hooks/reactivesearch/useReactiveBaseProps.js +0 -43
  17. package/dist/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +0 -28
  18. package/dist/hooks/reactivesearch/useReactiveDataSearchProps.js +0 -71
  19. package/dist/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -68
  20. package/dist/hooks/reactivesearch/useReactiveFilterListProps.js +0 -106
  21. package/dist/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -3
  22. package/dist/hooks/reactivesearch/useReactiveReactProp.js +0 -25
  23. package/dist/hooks/reactivesearch/useReactiveResultListProps.d.ts +0 -19
  24. package/dist/hooks/reactivesearch/useReactiveResultListProps.js +0 -32
  25. package/dist/hooks/useAnalytics.d.ts +0 -95
  26. package/dist/hooks/useAnalytics.js +0 -110
  27. package/dist/hooks/useCollection.d.ts +0 -1
  28. package/dist/hooks/useCollection.js +0 -6
  29. package/dist/hooks/useConfig.d.ts +0 -1
  30. package/dist/hooks/useConfig.js +0 -6
  31. package/dist/hooks/useCuration.d.ts +0 -1
  32. package/dist/hooks/useCuration.js +0 -6
  33. package/dist/hooks/useFilterCollapsedState.d.ts +0 -8
  34. package/dist/hooks/useFilterCollapsedState.js +0 -27
  35. package/dist/hooks/useFilterListProps.d.ts +0 -22
  36. package/dist/hooks/useFilterListProps.js +0 -35
  37. package/dist/hooks/useFilterStack.d.ts +0 -1
  38. package/dist/hooks/useFilterStack.js +0 -6
  39. package/dist/hooks/useFilters.d.ts +0 -1
  40. package/dist/hooks/useFilters.js +0 -17
  41. package/dist/hooks/useLiveConfig.d.ts +0 -4
  42. package/dist/hooks/useLiveConfig.js +0 -74
  43. package/dist/hooks/usePages.d.ts +0 -10
  44. package/dist/hooks/usePages.js +0 -97
  45. package/dist/hooks/useProductPrice.d.ts +0 -12
  46. package/dist/hooks/useProductPrice.js +0 -61
  47. package/dist/hooks/useSearch.d.ts +0 -8
  48. package/dist/hooks/useSearch.js +0 -16
  49. package/dist/hooks/useSort.d.ts +0 -5
  50. package/dist/hooks/useSort.js +0 -24
  51. package/dist/index.d.ts +0 -9
  52. package/dist/index.js +0 -24
  53. package/dist/provider.d.ts +0 -78
  54. package/dist/provider.js +0 -287
  55. package/dist/result/ResultCard.d.ts +0 -14
  56. package/dist/result/ResultCard.js +0 -66
  57. package/dist/result/ResultCardCallout.d.ts +0 -13
  58. package/dist/result/ResultCardCallout.js +0 -53
  59. package/dist/result/ResultList.d.ts +0 -34
  60. package/dist/result/ResultList.js +0 -93
  61. package/dist/result/ResultLoadMoreButton.d.ts +0 -10
  62. package/dist/result/ResultLoadMoreButton.js +0 -61
  63. package/dist/result/ResultPagination.d.ts +0 -10
  64. package/dist/result/ResultPagination.js +0 -60
  65. package/dist/result/ResultPaginationNextPrev.d.ts +0 -8
  66. package/dist/result/ResultPaginationNextPrev.js +0 -30
  67. package/dist/result/ResultStateProvider.d.ts +0 -7
  68. package/dist/result/ResultStateProvider.js +0 -10
  69. package/dist/result/index.d.ts +0 -6
  70. package/dist/result/index.js +0 -18
  71. package/dist/search/SearchInput.d.ts +0 -9
  72. package/dist/search/SearchInput.js +0 -17
  73. package/dist/search/index.d.ts +0 -1
  74. package/dist/search/index.js +0 -13
  75. package/dist/sensor/SensorCollection.d.ts +0 -2
  76. package/dist/sensor/SensorCollection.js +0 -41
  77. package/dist/sensor/SensorInventoryAvailable.d.ts +0 -2
  78. package/dist/sensor/SensorInventoryAvailable.js +0 -52
  79. package/dist/sensor/SensorPublished.d.ts +0 -2
  80. package/dist/sensor/SensorPublished.js +0 -16
  81. package/dist/sensor/SensorSearch.d.ts +0 -2
  82. package/dist/sensor/SensorSearch.js +0 -82
  83. package/dist/sensor/SensorSort.d.ts +0 -2
  84. package/dist/sensor/SensorSort.js +0 -205
  85. package/dist/sensor/SensorSortScore.d.ts +0 -2
  86. package/dist/sensor/SensorSortScore.js +0 -12
  87. package/dist/sensor/SensorStack.d.ts +0 -2
  88. package/dist/sensor/SensorStack.js +0 -31
  89. package/dist/sensor/index.d.ts +0 -8
  90. package/dist/sensor/index.js +0 -29
  91. package/dist/types/config.d.ts +0 -25
  92. package/dist/types/config.js +0 -2
  93. package/dist/types/elastic.d.ts +0 -209
  94. package/dist/types/elastic.js +0 -18
  95. package/dist/types/firestore.d.ts +0 -280
  96. package/dist/types/firestore.js +0 -18
  97. package/dist/types/graphql.d.ts +0 -26545
  98. package/dist/types/graphql.js +0 -4687
  99. package/dist/types/reactivesearch.d.ts +0 -73
  100. package/dist/types/reactivesearch.js +0 -2
  101. package/dist/types/shopify.d.ts +0 -21
  102. package/dist/types/shopify.js +0 -27
  103. package/dist/utility/UtilityAuthenticatedReactiveBase.d.ts +0 -2
  104. package/dist/utility/UtilityAuthenticatedReactiveBase.js +0 -14
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ResultCard = void 0;
18
- const react_1 = __importDefault(require("react"));
19
- const react_intersection_observer_1 = require("react-intersection-observer");
20
- const hooks_1 = require("../hooks");
21
- const ResultCard = (_a) => {
22
- var { render } = _a, props = __rest(_a, ["render"]);
23
- const { product } = props;
24
- const productPrice = (0, hooks_1.useProductPrice)(product);
25
- const { formattedPrice, formattedCompareAtPrice, onSale } = productPrice;
26
- const { track } = (0, hooks_1.useAnalytics)();
27
- const { ref, inView } = (0, react_intersection_observer_1.useInView)({
28
- threshold: 0.5,
29
- triggerOnce: true,
30
- });
31
- const handleClick = react_1.default.useCallback(() => {
32
- track({
33
- eventName: "clickProduct",
34
- payload: {
35
- elasticProduct: {
36
- id: product.id,
37
- title: product.title,
38
- },
39
- },
40
- });
41
- }, [track, product]);
42
- const handleView = react_1.default.useCallback(() => {
43
- track({
44
- eventName: "viewProduct",
45
- payload: {
46
- elasticProduct: {
47
- id: product.id,
48
- title: product.title,
49
- },
50
- },
51
- });
52
- }, [track, product]);
53
- react_1.default.useEffect(() => {
54
- if (inView)
55
- handleView();
56
- }, [inView]);
57
- if (render)
58
- return render(Object.assign(Object.assign(Object.assign({}, props), productPrice), { itemRef: ref, handleClick }));
59
- return (react_1.default.createElement("article", { ref: ref },
60
- react_1.default.createElement("a", { onClick: handleClick, href: `/products/${product.handle}` },
61
- product.image && react_1.default.createElement("img", { src: product.image, width: "100%" }),
62
- product.title),
63
- react_1.default.createElement("span", null, formattedPrice),
64
- onSale && (react_1.default.createElement("span", { style: { textDecoration: "line-through" } }, formattedCompareAtPrice))));
65
- };
66
- exports.ResultCard = ResultCard;
@@ -1,13 +0,0 @@
1
- import React from "react";
2
- import { ElasticCallout } from "../types/elastic";
3
- declare type Props = {
4
- pagePosition: number;
5
- document: ElasticCallout;
6
- callout: ElasticCallout["callout"];
7
- render?: (props: Omit<Props, "render"> & {
8
- itemRef: (node?: Element | null) => void;
9
- handleClick: () => void;
10
- }) => JSX.Element;
11
- };
12
- export declare const ResultCardCallout: React.FC<Props>;
13
- export {};
@@ -1,53 +0,0 @@
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.ResultCardCallout = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const react_intersection_observer_1 = require("react-intersection-observer");
9
- const hooks_1 = require("../hooks");
10
- const ResultCardCallout = (props) => {
11
- const { callout, render } = props;
12
- const { track } = (0, hooks_1.useAnalytics)();
13
- const { ref, inView } = (0, react_intersection_observer_1.useInView)({
14
- threshold: 0.5,
15
- triggerOnce: true,
16
- });
17
- const handleClick = react_1.default.useCallback(() => {
18
- track({
19
- eventName: "clickPromotion",
20
- payload: {
21
- link: callout.link,
22
- title: callout.title,
23
- },
24
- });
25
- }, [track, callout]);
26
- const handleView = react_1.default.useCallback(() => {
27
- track({
28
- eventName: "viewPromotion",
29
- payload: {
30
- link: callout.link,
31
- title: callout.title,
32
- },
33
- });
34
- }, [track, callout]);
35
- react_1.default.useEffect(() => {
36
- if (inView)
37
- handleView();
38
- }, [inView]);
39
- const styleProp = react_1.default.useMemo(() => {
40
- var _a, _b;
41
- return ({
42
- gridRow: `span ${(_a = callout.displayRows) !== null && _a !== void 0 ? _a : 1}`,
43
- gridColumn: `span ${(_b = callout.displayColumns) !== null && _b !== void 0 ? _b : 1}`,
44
- });
45
- }, [callout]);
46
- if (render)
47
- return render(Object.assign(Object.assign({}, props), { itemRef: ref, handleClick }));
48
- return (react_1.default.createElement("article", { ref: ref, style: styleProp },
49
- react_1.default.createElement("a", { href: callout.link, onClick: handleClick },
50
- callout.desktopImage && (react_1.default.createElement("img", { src: callout.desktopImage, width: "100%" })),
51
- callout.title)));
52
- };
53
- exports.ResultCardCallout = ResultCardCallout;
@@ -1,34 +0,0 @@
1
- import React from "react";
2
- import { ResultCard } from "./ResultCard";
3
- import { ResultPagination } from "./ResultPagination";
4
- import { ResultCardCallout } from "./ResultCardCallout";
5
- import { ResultLoadMoreButton } from "./ResultLoadMoreButton";
6
- import { ResultPaginationNextPrev } from "./ResultPaginationNextPrev";
7
- import { ReactivesearchError, ReactivesearchResultProps } from "../types/reactivesearch";
8
- import { ElasticCallout, ElasticProduct } from "../types/elastic";
9
- declare type ResultProps = ReactivesearchResultProps & {
10
- callouts: ElasticCallout[];
11
- products: ElasticProduct[];
12
- };
13
- declare type Props = {
14
- pageSize?: number;
15
- gridGap?: number;
16
- gridColumns?: number;
17
- gridStyle?: React.HTMLAttributes<HTMLElement>["style"];
18
- listClassName?: string;
19
- renderLoading?: () => JSX.Element | null;
20
- renderNoResults?: () => JSX.Element | null;
21
- renderResultCard?: Parameters<typeof ResultCard>[0]["render"];
22
- renderPagination?: Parameters<typeof ResultPagination>[0]["render"];
23
- renderResultCardCallout?: Parameters<typeof ResultCardCallout>[0]["render"];
24
- renderAfter?: (props: ResultProps) => JSX.Element | null;
25
- renderBefore?: (props: ResultProps) => JSX.Element | null;
26
- renderResults?: (props: ResultProps) => JSX.Element | null;
27
- renderError?: (props: {
28
- error: ReactivesearchError;
29
- }) => JSX.Element | null;
30
- renderLoadMoreButton?: Parameters<typeof ResultLoadMoreButton>[0]["render"];
31
- renderPaginationNextPrev?: Parameters<typeof ResultPaginationNextPrev>[0]["render"];
32
- };
33
- export declare const ResultList: React.FC<Props>;
34
- export {};
@@ -1,93 +0,0 @@
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.ResultList = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const ReactiveList_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/result/ReactiveList"));
9
- const ResultCard_1 = require("./ResultCard");
10
- const ResultPagination_1 = require("./ResultPagination");
11
- const ResultCardCallout_1 = require("./ResultCardCallout");
12
- const ResultLoadMoreButton_1 = require("./ResultLoadMoreButton");
13
- const ResultPaginationNextPrev_1 = require("./ResultPaginationNextPrev");
14
- const __1 = require("../");
15
- const hooks_1 = require("../hooks");
16
- const elastic_1 = require("../types/elastic");
17
- const ResultList = (props) => {
18
- const { pageSize } = props;
19
- const reactiveResultListProps = (0, hooks_1.useReactiveResultListProps)({
20
- pageSize,
21
- });
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 }))) })));
23
- };
24
- exports.ResultList = ResultList;
25
- const ResultListInner = (props) => {
26
- const { gridGap, gridColumns, gridStyle, renderError, renderAfter, renderBefore, renderLoading, listClassName, renderResults, renderNoResults, renderResultCard, renderLoadMoreButton, renderResultCardCallout, reactivesearchResultProps, } = props;
27
- const filterStack = (0, hooks_1.useFilterStack)();
28
- const { instantSearch, searchQuery } = (0, hooks_1.useSearch)();
29
- const { track } = (0, __1.useAnalytics)();
30
- const initialSearchHasRun = react_1.default.useMemo(() => "undefined" !==
31
- typeof reactivesearchResultProps.resultStats.numberOfResults, [reactivesearchResultProps]);
32
- const styleProp = react_1.default.useMemo(() => gridStyle !== null && gridStyle !== void 0 ? gridStyle : {
33
- display: "grid",
34
- gap: `${gridGap !== null && gridGap !== void 0 ? gridGap : "0px"}`,
35
- gridTemplateColumns: `repeat(${gridColumns !== null && gridColumns !== void 0 ? gridColumns : 4}, minmax(0, 1fr))`,
36
- }, [gridGap, gridColumns, gridStyle]);
37
- const resultProps = react_1.default.useMemo(() => (Object.assign(Object.assign({}, reactivesearchResultProps), { products: reactivesearchResultProps.data.filter((document) => elastic_1.ElasticDocumentType.Product === document.type || !document.type), callouts: reactivesearchResultProps.data.filter((document) => elastic_1.ElasticDocumentType.Callout === document.type) })), [reactivesearchResultProps]);
38
- if (reactivesearchResultProps.error) {
39
- if (renderError)
40
- return renderError({ error: reactivesearchResultProps.error });
41
- return react_1.default.createElement("div", null,
42
- "Error: ",
43
- reactivesearchResultProps.error.statusText);
44
- }
45
- if (!initialSearchHasRun) {
46
- if (renderLoading)
47
- return renderLoading();
48
- return react_1.default.createElement("div", null, "Loading...");
49
- }
50
- if (!reactivesearchResultProps.resultStats.numberOfResults) {
51
- if (searchQuery)
52
- track({
53
- eventName: "zeroResults",
54
- payload: { searchTerm: searchQuery },
55
- });
56
- if (renderNoResults)
57
- return renderNoResults();
58
- return react_1.default.createElement("div", null, "No results");
59
- }
60
- if (renderResults) {
61
- return renderResults(resultProps);
62
- }
63
- return (react_1.default.createElement(react_1.default.Fragment, null,
64
- renderBefore && renderBefore(resultProps),
65
- react_1.default.createElement("section", { className: listClassName, style: styleProp }, reactivesearchResultProps.data.map((document, key) => {
66
- // @todo result.type is missing in v1 indexes, this check ensures that they are assumed to be products
67
- if (elastic_1.ElasticDocumentType.Product === document.type || !document.type) {
68
- return (react_1.default.createElement(ResultCard_1.ResultCard, { key: document._id, product: document, document: document, pagePosition: key + 1, render: renderResultCard }));
69
- }
70
- if (elastic_1.ElasticDocumentType.Callout === document.type) {
71
- return (react_1.default.createElement(ResultCardCallout_1.ResultCardCallout, { key: document._id, document: document, pagePosition: key + 1, callout: document.callout, render: renderResultCardCallout }));
72
- }
73
- return null;
74
- })),
75
- !instantSearch && "load_more" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType) && (react_1.default.createElement(ResultLoadMoreButton_1.ResultLoadMoreButton, Object.assign({}, reactivesearchResultProps, { render: renderLoadMoreButton }))),
76
- renderAfter && renderAfter(resultProps)));
77
- };
78
- const ResultPaginationInner = (props) => {
79
- const { renderPagination, renderPaginationNextPrev } = props;
80
- const filterStack = (0, hooks_1.useFilterStack)();
81
- const { instantSearch } = (0, hooks_1.useSearch)();
82
- // do not show pagination in instant search mode
83
- if (instantSearch)
84
- return null;
85
- // load more button is rendered inside the main render prop, as the loadMore prop is not available in renderPagination
86
- if ("load_more" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType)) {
87
- return null;
88
- }
89
- if ("next_prev" === (filterStack === null || filterStack === void 0 ? void 0 : filterStack.paginationType)) {
90
- return (react_1.default.createElement(ResultPaginationNextPrev_1.ResultPaginationNextPrev, Object.assign({}, props, { render: renderPaginationNextPrev })));
91
- }
92
- return react_1.default.createElement(ResultPagination_1.ResultPagination, Object.assign({}, props, { render: renderPagination }));
93
- };
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { ReactivesearchResultProps } from "../types/reactivesearch";
3
- declare type Props = ReactivesearchResultProps & {
4
- render?: (props: Omit<Props, "render"> & {
5
- hasMore: boolean;
6
- handleLoadMore: () => void;
7
- }) => JSX.Element;
8
- };
9
- export declare const ResultLoadMoreButton: React.FC<Props>;
10
- export {};
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.ResultLoadMoreButton = void 0;
34
- const react_1 = __importStar(require("react"));
35
- const hooks_1 = require("../hooks");
36
- const hooks_2 = require("../hooks");
37
- const ResultLoadMoreButton = (_a) => {
38
- var { render, loadMore } = _a, props = __rest(_a, ["render", "loadMore"]);
39
- const { track } = (0, hooks_1.useAnalytics)();
40
- const filterStack = (0, hooks_2.useFilterStack)();
41
- const { resultStats } = props;
42
- const hasMore = react_1.default.useMemo(() => resultStats.displayedResults !== resultStats.numberOfResults, [resultStats]);
43
- const handleLoadMore = (0, react_1.useCallback)(() => {
44
- loadMore();
45
- track({
46
- eventName: "paginationChange",
47
- payload: {
48
- page: Math.ceil(resultStats.displayedResults / ((filterStack === null || filterStack === void 0 ? void 0 : filterStack.pageSize) || 20)) + 1,
49
- source: window.location.pathname.includes("/search")
50
- ? "search"
51
- : "collection",
52
- },
53
- });
54
- }, [loadMore, track, resultStats, filterStack]);
55
- if (render)
56
- return render(Object.assign(Object.assign({}, props), { hasMore,
57
- // @todo: remove legacy loadMore prop in future versions
58
- loadMore: handleLoadMore, handleLoadMore }));
59
- return react_1.default.createElement("button", { onClick: () => loadMore() }, "Load more");
60
- };
61
- exports.ResultLoadMoreButton = ResultLoadMoreButton;
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { usePages } from "../hooks";
3
- import { ReactivesearchPaginationProps } from "../types/reactivesearch";
4
- declare type Props = ReactivesearchPaginationProps & {
5
- render?: (props: Omit<Props, "render"> & ReturnType<typeof usePages> & {
6
- handlePageChange: (event: any, page: number) => void;
7
- }) => JSX.Element;
8
- };
9
- export declare const ResultPagination: React.FC<Props>;
10
- export {};
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ResultPagination = void 0;
18
- const react_1 = __importDefault(require("react"));
19
- const hooks_1 = require("../hooks");
20
- const ResultPagination = (_a) => {
21
- var { render } = _a, props = __rest(_a, ["render"]);
22
- const { track } = (0, hooks_1.useAnalytics)();
23
- const pageProps = (0, hooks_1.usePages)(props);
24
- const { pagesToShow, buildPagePath } = pageProps;
25
- const { currentPage, totalPages, setPage } = props;
26
- const handlePageChange = react_1.default.useCallback((event, newPage) => {
27
- event.preventDefault();
28
- setPage(newPage);
29
- track({
30
- eventName: "paginationChange",
31
- payload: {
32
- page: newPage + 1,
33
- source: window.location.pathname.includes("/search")
34
- ? "search"
35
- : "collection",
36
- },
37
- });
38
- }, [setPage, track]);
39
- if (render)
40
- return render(Object.assign(Object.assign(Object.assign({}, props), pageProps), { handlePageChange }));
41
- if (!totalPages)
42
- return null;
43
- return (react_1.default.createElement("nav", null,
44
- currentPage > 0 && (react_1.default.createElement("a", { rel: "prev", href: buildPagePath(currentPage), onClick: (event) => handlePageChange(event, currentPage - 1) }, "Prev")),
45
- !pagesToShow.includes(0) && (react_1.default.createElement("a", { href: buildPagePath(1), onClick: (event) => handlePageChange(event, 0), rel: 0 === currentPage - 1 ? `prev` : undefined }, "1")),
46
- !pagesToShow.includes(1) && react_1.default.createElement("span", null, "..."),
47
- pagesToShow.map((page) => page === currentPage ? (react_1.default.createElement("span", { key: page + 1 }, page + 1)) : (react_1.default.createElement("a", { key: page + 1, href: buildPagePath(page + 1), onClick: (event) => handlePageChange(event, page), rel: page === currentPage + 1
48
- ? `next`
49
- : page === currentPage - 1
50
- ? `prev`
51
- : undefined }, page + 1))),
52
- !pagesToShow.includes(totalPages - 2) && react_1.default.createElement("span", null, "..."),
53
- !pagesToShow.includes(totalPages - 1) && (react_1.default.createElement("a", { href: buildPagePath(totalPages), onClick: (event) => handlePageChange(event, totalPages - 1), rel: totalPages - 1 === currentPage + 1
54
- ? `next`
55
- : totalPages - 1 === currentPage - 1
56
- ? `prev`
57
- : undefined }, totalPages)),
58
- currentPage + 1 < totalPages && (react_1.default.createElement("a", { rel: "next", href: buildPagePath(currentPage + 2), onClick: (event) => handlePageChange(event, currentPage + 1) }, "Next"))));
59
- };
60
- exports.ResultPagination = ResultPagination;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { usePages } from "../hooks";
3
- import { ReactivesearchPaginationProps } from "../types/reactivesearch";
4
- declare type Props = ReactivesearchPaginationProps & {
5
- render?: (props: Omit<Props, "render"> & ReturnType<typeof usePages>) => JSX.Element;
6
- };
7
- export declare const ResultPaginationNextPrev: React.FC<Props>;
8
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ResultPaginationNextPrev = void 0;
18
- const react_1 = __importDefault(require("react"));
19
- const hooks_1 = require("../hooks");
20
- const ResultPaginationNextPrev = (_a) => {
21
- var { render } = _a, props = __rest(_a, ["render"]);
22
- const pageProps = (0, hooks_1.usePages)(props);
23
- if (render)
24
- return render(Object.assign(Object.assign({}, props), pageProps));
25
- const { hasNextPage, buildPagePath, handleNextPage, hasPreviousPage, actualCurrentPage, handlePreviousPage, } = pageProps;
26
- return (react_1.default.createElement("nav", null,
27
- hasPreviousPage && (react_1.default.createElement("a", { rel: "prev", onClick: handlePreviousPage, href: buildPagePath(actualCurrentPage - 1) }, "Prev")),
28
- hasNextPage && (react_1.default.createElement("a", { rel: "next", onClick: handleNextPage, href: buildPagePath(actualCurrentPage + 1) }, "Next"))));
29
- };
30
- exports.ResultPaginationNextPrev = ResultPaginationNextPrev;
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- import { ReactivesearchSearchStatePage } from "../types/reactivesearch";
3
- declare type Props = {
4
- render: (props: ReactivesearchSearchStatePage) => JSX.Element | null;
5
- };
6
- export declare const ResultStateProvider: React.FC<Props>;
7
- export {};
@@ -1,10 +0,0 @@
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.ResultStateProvider = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const StateProvider_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/StateProvider"));
9
- const ResultStateProvider = ({ render }) => (react_1.default.createElement(StateProvider_1.default, { componentIds: ["page"], includeKeys: ["isLoading", "hits", "resultStats", "error"], render: (state) => render(state.searchState.page) }));
10
- exports.ResultStateProvider = ResultStateProvider;
@@ -1,6 +0,0 @@
1
- export * from "./ResultList";
2
- export * from "./ResultCard";
3
- export * from "./ResultPagination";
4
- export * from "./ResultStateProvider";
5
- export * from "./ResultLoadMoreButton";
6
- export * from "./ResultPaginationNextPrev";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./ResultList"), exports);
14
- __exportStar(require("./ResultCard"), exports);
15
- __exportStar(require("./ResultPagination"), exports);
16
- __exportStar(require("./ResultStateProvider"), exports);
17
- __exportStar(require("./ResultLoadMoreButton"), exports);
18
- __exportStar(require("./ResultPaginationNextPrev"), exports);
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- declare type Props = {
3
- [key: string]: any;
4
- debounce?: number;
5
- placeholder?: string;
6
- inputClassName?: string;
7
- };
8
- export declare const SearchInput: React.FC<Props>;
9
- export {};
@@ -1,17 +0,0 @@
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.SearchInput = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const DataSearch_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/search/DataSearch"));
9
- const hooks_1 = require("../hooks");
10
- const SearchInput = (props) => {
11
- const { debounce, placeholder, inputClassName } = props;
12
- const reactiveDataSearchProps = (0, hooks_1.useReactiveDataSearchProps)(Object.assign({ debounce,
13
- placeholder,
14
- inputClassName }, props));
15
- return react_1.default.createElement(DataSearch_1.default, Object.assign({}, reactiveDataSearchProps));
16
- };
17
- exports.SearchInput = SearchInput;
@@ -1 +0,0 @@
1
- export * from "./SearchInput";
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./SearchInput"), exports);
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const SensorCollection: React.FC;
@@ -1,41 +0,0 @@
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.SensorCollection = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
9
- const hooks_1 = require("../hooks");
10
- const SensorCollection = () => {
11
- const collection = (0, hooks_1.useCollection)();
12
- if (!collection)
13
- return null;
14
- return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCollection", customQuery: () => ({
15
- query: {
16
- bool: {
17
- should: [
18
- {
19
- nested: {
20
- path: "collections",
21
- query: {
22
- term: { "collections.handle.keyword": collection.handle },
23
- },
24
- },
25
- },
26
- {
27
- nested: {
28
- path: "curations",
29
- query: {
30
- term: {
31
- "curations.collectionHandle.keyword": collection.handle,
32
- },
33
- },
34
- },
35
- },
36
- ],
37
- },
38
- },
39
- }) }));
40
- };
41
- exports.SensorCollection = SensorCollection;
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const SensorInventoryAvailable: React.FC;
@@ -1,52 +0,0 @@
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.SensorInventoryAvailable = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
9
- const hooks_1 = require("../hooks");
10
- const SensorInventoryAvailable = () => {
11
- const filterStack = (0, hooks_1.useFilterStack)();
12
- if (!filterStack || "show_all" === filterStack.inventoryVisibility)
13
- return null;
14
- return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorInventoryAvailable", customQuery: () => ({
15
- query: {
16
- bool: {
17
- should: [
18
- {
19
- bool: {
20
- must: [
21
- {
22
- term: {
23
- type: {
24
- value: "product",
25
- },
26
- },
27
- },
28
- {
29
- nested: {
30
- path: "variants",
31
- query: {
32
- match: { "variants.available": true },
33
- },
34
- },
35
- },
36
- ],
37
- },
38
- },
39
- {
40
- term: {
41
- type: {
42
- value: "callout",
43
- },
44
- },
45
- },
46
- ],
47
- minimum_should_match: "1",
48
- },
49
- },
50
- }) }));
51
- };
52
- exports.SensorInventoryAvailable = SensorInventoryAvailable;