@usereactify/search 4.4.1 → 5.0.0-beta.2
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 +47 -0
- package/dist/package.json +8 -9
- package/dist/src/components/Example/ExampleFilterList.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterList.js +19 -0
- package/dist/src/components/Example/ExampleFilterRange.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterRange.js +21 -0
- package/dist/src/components/Example/ExampleFilterSlider.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterSlider.js +20 -0
- package/dist/src/components/Example/ExampleFilterStack.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterStack.js +12 -0
- package/dist/src/components/Example/ExampleResultCardCallout.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultCardCallout.js +21 -0
- package/dist/src/components/Example/ExampleResultCardProduct.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultCardProduct.js +18 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js +11 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js +13 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js +26 -0
- package/dist/src/components/Example/ExampleSortby.d.ts +4 -0
- package/dist/src/components/Example/ExampleSortby.js +12 -0
- package/dist/src/components/Example/index.d.ts +10 -0
- package/dist/src/components/Example/index.js +22 -0
- package/dist/src/components/Filter/Filter.d.ts +20 -0
- package/dist/src/components/Filter/Filter.js +89 -0
- package/dist/src/components/Filter/FilterStack.d.ts +7 -0
- package/dist/src/components/Filter/FilterStack.js +16 -0
- package/dist/src/{filter → components/Filter}/index.d.ts +0 -1
- package/dist/src/{filter → components/Filter}/index.js +0 -1
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.d.ts +42 -0
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js +140 -0
- package/dist/src/components/ReactifySearchBase/index.d.ts +1 -0
- package/dist/src/components/ReactifySearchBase/index.js +13 -0
- package/dist/src/components/Result/ResultCardCallout.d.ts +12 -0
- package/dist/src/{result → components/Result}/ResultCardCallout.js +15 -22
- package/dist/src/components/Result/ResultCardProduct.d.ts +13 -0
- package/dist/src/{result/ResultCard.js → components/Result/ResultCardProduct.js} +19 -22
- package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.js +16 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.js +16 -0
- package/dist/src/components/Result/ResultPaginationNumbered.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationNumbered.js +19 -0
- package/dist/src/components/Result/ResultStack.d.ts +40 -0
- package/dist/src/components/Result/ResultStack.js +107 -0
- package/dist/src/components/Result/ResultStateProvider.d.ts +6 -0
- package/dist/src/{result → components/Result}/ResultStateProvider.js +0 -0
- package/dist/src/components/Result/index.d.ts +7 -0
- package/dist/src/{result → components/Result}/index.js +5 -4
- package/dist/src/components/Search/SearchInput.d.ts +8 -0
- package/dist/src/{search → components/Search}/SearchInput.js +2 -2
- package/dist/src/{search → components/Search}/index.d.ts +0 -0
- package/dist/src/{search → components/Search}/index.js +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorCollection.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorCollection.js +8 -5
- package/dist/src/{sensor → components/Sensor}/SensorInventoryAvailable.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorInventoryAvailable.js +1 -1
- package/dist/src/{sensor → components/Sensor}/SensorPublished.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorPublished.js +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSearch.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSearch.js +3 -3
- package/dist/src/{sensor → components/Sensor}/SensorSort.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSort.js +4 -5
- package/dist/src/{sensor → components/Sensor}/SensorSortScore.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/SensorSortScore.js +0 -0
- package/dist/src/components/Sensor/SensorStack.d.ts +3 -0
- package/dist/src/{sensor → components/Sensor}/SensorStack.js +3 -3
- package/dist/src/{sensor → components/Sensor}/index.d.ts +0 -0
- package/dist/src/{sensor → components/Sensor}/index.js +0 -0
- package/dist/src/components/Sortby/Sortby.d.ts +7 -0
- package/dist/src/components/Sortby/Sortby.js +16 -0
- package/dist/src/components/Sortby/index.d.ts +1 -0
- package/dist/src/components/Sortby/index.js +13 -0
- package/dist/src/{utility → components/Utility}/UtilityAuthenticatedReactiveBase.d.ts +0 -0
- package/dist/src/{utility → components/Utility}/UtilityAuthenticatedReactiveBase.js +2 -2
- package/dist/src/components/Utility/index.d.ts +1 -0
- package/dist/src/components/Utility/index.js +13 -0
- package/dist/src/components/index.d.ts +8 -0
- package/dist/src/components/index.js +20 -0
- package/dist/src/hooks/index.d.ts +5 -5
- package/dist/src/hooks/index.js +5 -5
- package/dist/src/hooks/reactivesearch/index.d.ts +4 -1
- package/dist/src/hooks/reactivesearch/index.js +4 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +7 -7
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +5 -7
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +29 -30
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +9 -4
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +9 -94
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +70 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +21 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +67 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +105 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +68 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +21 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +8 -8
- package/dist/src/hooks/reactivesearch/{useReactiveResultListProps.d.ts → useReactiveResultStackProps.d.ts} +2 -4
- package/dist/src/hooks/reactivesearch/{useReactiveResultListProps.js → useReactiveResultStackProps.js} +7 -8
- package/dist/src/hooks/useAnalytics.js +4 -4
- package/dist/src/hooks/useConfig.d.ts +4 -1
- package/dist/src/hooks/useConfig.js +77 -2
- package/dist/src/hooks/useCuration.d.ts +2 -1
- package/dist/src/hooks/useCuration.js +48 -2
- package/dist/src/hooks/useFilterListProps.d.ts +4 -14
- package/dist/src/hooks/useFilterStack.d.ts +2 -1
- package/dist/src/hooks/useFilterStack.js +42 -2
- package/dist/src/hooks/useFilters.d.ts +4 -1
- package/dist/src/hooks/useFilters.js +10 -5
- package/dist/src/hooks/usePagination.d.ts +14 -0
- package/dist/src/hooks/{usePages.js → usePagination.js} +30 -30
- package/dist/src/hooks/usePaginationLoadMore.d.ts +15 -0
- package/dist/src/hooks/usePaginationLoadMore.js +37 -0
- package/dist/src/hooks/useProductPrice.d.ts +3 -5
- package/dist/src/hooks/useProductPrice.js +42 -40
- package/dist/src/hooks/useReactifySearchContext.d.ts +78 -0
- package/dist/src/hooks/useReactifySearchContext.js +10 -0
- package/dist/src/hooks/useSearch.d.ts +4 -4
- package/dist/src/hooks/useSearch.js +28 -8
- package/dist/src/hooks/useSortby.d.ts +6 -0
- package/dist/src/hooks/useSortby.js +41 -0
- package/dist/src/index.d.ts +2 -8
- package/dist/src/index.js +2 -8
- package/dist/src/types/config.d.ts +1 -0
- package/dist/src/types/index.d.ts +3 -0
- package/dist/src/types/index.js +15 -0
- package/package.json +8 -9
- package/dist/src/filter/Filter.d.ts +0 -12
- package/dist/src/filter/Filter.js +0 -71
- package/dist/src/filter/FilterList.d.ts +0 -4
- package/dist/src/filter/FilterList.js +0 -15
- package/dist/src/filter/FilterStack.d.ts +0 -11
- package/dist/src/filter/FilterStack.js +0 -25
- package/dist/src/hooks/useCollection.d.ts +0 -1
- package/dist/src/hooks/useCollection.js +0 -6
- package/dist/src/hooks/useLiveConfig.d.ts +0 -4
- package/dist/src/hooks/useLiveConfig.js +0 -74
- package/dist/src/hooks/usePages.d.ts +0 -10
- package/dist/src/hooks/useSort.d.ts +0 -5
- package/dist/src/hooks/useSort.js +0 -24
- package/dist/src/provider.d.ts +0 -78
- package/dist/src/provider.js +0 -287
- package/dist/src/result/ResultCard.d.ts +0 -14
- package/dist/src/result/ResultCardCallout.d.ts +0 -13
- package/dist/src/result/ResultList.d.ts +0 -34
- package/dist/src/result/ResultList.js +0 -93
- package/dist/src/result/ResultLoadMoreButton.d.ts +0 -10
- package/dist/src/result/ResultLoadMoreButton.js +0 -61
- package/dist/src/result/ResultPagination.d.ts +0 -10
- package/dist/src/result/ResultPagination.js +0 -60
- package/dist/src/result/ResultPaginationNextPrev.d.ts +0 -8
- package/dist/src/result/ResultPaginationNextPrev.js +0 -30
- package/dist/src/result/ResultStateProvider.d.ts +0 -7
- package/dist/src/result/index.d.ts +0 -6
- package/dist/src/search/SearchInput.d.ts +0 -9
- package/dist/src/sensor/SensorStack.d.ts +0 -2
|
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SensorCollection = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
|
-
const hooks_1 = require("
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
10
|
const SensorCollection = () => {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
11
|
+
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
12
|
+
if (options.mode !== "collection") {
|
|
13
13
|
return null;
|
|
14
|
+
}
|
|
14
15
|
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCollection", customQuery: () => ({
|
|
15
16
|
query: {
|
|
16
17
|
bool: {
|
|
@@ -19,7 +20,9 @@ const SensorCollection = () => {
|
|
|
19
20
|
nested: {
|
|
20
21
|
path: "collections",
|
|
21
22
|
query: {
|
|
22
|
-
term: {
|
|
23
|
+
term: {
|
|
24
|
+
"collections.handle.keyword": options.collection.handle,
|
|
25
|
+
},
|
|
23
26
|
},
|
|
24
27
|
},
|
|
25
28
|
},
|
|
@@ -28,7 +31,7 @@ const SensorCollection = () => {
|
|
|
28
31
|
path: "curations",
|
|
29
32
|
query: {
|
|
30
33
|
term: {
|
|
31
|
-
"curations.collectionHandle.keyword": collection.handle,
|
|
34
|
+
"curations.collectionHandle.keyword": options.collection.handle,
|
|
32
35
|
},
|
|
33
36
|
},
|
|
34
37
|
},
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SensorInventoryAvailable = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
|
-
const hooks_1 = require("
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
10
|
const SensorInventoryAvailable = () => {
|
|
11
11
|
const filterStack = (0, hooks_1.useFilterStack)();
|
|
12
12
|
if (!filterStack || "show_all" === filterStack.inventoryVisibility)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SensorSearch = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const DataSearch_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/search/DataSearch"));
|
|
9
|
-
const hooks_1 = require("
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
10
|
const SensorSearch = () => {
|
|
11
|
-
const {
|
|
11
|
+
const { config } = (0, hooks_1.useReactifySearchContext)();
|
|
12
12
|
const { searchQuery } = (0, hooks_1.useSearch)();
|
|
13
13
|
// ignore search fields only set for instant search
|
|
14
|
-
const searchFields = react_1.default.useMemo(() => fields.filter((field) => ["always_search", "search_page"].includes(field.searchType)), [fields]);
|
|
14
|
+
const searchFields = react_1.default.useMemo(() => config.fields.filter((field) => ["always_search", "search_page"].includes(field.searchType)), [config.fields]);
|
|
15
15
|
if (!searchQuery || !searchFields.length) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
File without changes
|
|
@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SensorSort = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
|
-
const hooks_1 = require("
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
10
|
const debug = require("debug")("reactify-search:SensorSort");
|
|
11
11
|
const SensorSort = () => {
|
|
12
|
-
const config = (0, hooks_1.
|
|
12
|
+
const { options, config } = (0, hooks_1.useReactifySearchContext)();
|
|
13
13
|
const curation = (0, hooks_1.useCuration)();
|
|
14
|
-
const collection = (0, hooks_1.useCollection)();
|
|
15
14
|
const globalCuration = (curation === null || curation === void 0 ? void 0 : curation.id) === "global";
|
|
16
|
-
const { sortOption } = (0, hooks_1.
|
|
15
|
+
const { sortOption } = (0, hooks_1.useSortby)();
|
|
17
16
|
const searchQuery = react_1.default.useMemo(() => {
|
|
18
17
|
if (typeof window === "undefined")
|
|
19
18
|
return "";
|
|
@@ -25,7 +24,7 @@ const SensorSort = () => {
|
|
|
25
24
|
sort: buildSort({
|
|
26
25
|
config,
|
|
27
26
|
sortOption,
|
|
28
|
-
collection,
|
|
27
|
+
collection: options.mode === "collection" ? options.collection : undefined,
|
|
29
28
|
curation,
|
|
30
29
|
globalCuration,
|
|
31
30
|
}),
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SensorStack = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const hooks_1 = require("
|
|
8
|
+
const hooks_1 = require("../../hooks");
|
|
9
9
|
const SensorSort_1 = require("./SensorSort");
|
|
10
10
|
const SensorSearch_1 = require("./SensorSearch");
|
|
11
11
|
const SensorSortScore_1 = require("./SensorSortScore");
|
|
@@ -13,9 +13,9 @@ const SensorPublished_1 = require("./SensorPublished");
|
|
|
13
13
|
const SensorCollection_1 = require("./SensorCollection");
|
|
14
14
|
const SensorInventoryAvailable_1 = require("./SensorInventoryAvailable");
|
|
15
15
|
const SensorStack = () => {
|
|
16
|
-
const {
|
|
16
|
+
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
17
17
|
// instant search mode
|
|
18
|
-
if (
|
|
18
|
+
if (options.mode === "instant-search") {
|
|
19
19
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
20
20
|
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
21
21
|
react_1.default.createElement(SensorSortScore_1.SensorSortScore, null)));
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useSortby } from "../../hooks";
|
|
3
|
+
export declare type SortbyProps = {
|
|
4
|
+
/** Render method called once for all sort options */
|
|
5
|
+
renderSortOptions?: React.FC<ReturnType<typeof useSortby>>;
|
|
6
|
+
};
|
|
7
|
+
export declare const Sortby: React.FC<SortbyProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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.Sortby = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const hooks_1 = require("../../hooks");
|
|
9
|
+
const components_1 = require("../../components");
|
|
10
|
+
const Sortby = (props) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const sortbyData = (0, hooks_1.useSortby)();
|
|
13
|
+
const RenderSortOptionsComponent = (_a = props.renderSortOptions) !== null && _a !== void 0 ? _a : components_1.ExampleSortby;
|
|
14
|
+
return (react_1.default.createElement(RenderSortOptionsComponent, Object.assign({}, sortbyData)));
|
|
15
|
+
};
|
|
16
|
+
exports.Sortby = Sortby;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Sortby";
|
|
@@ -0,0 +1,13 @@
|
|
|
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("./Sortby"), exports);
|
|
File without changes
|
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.UtilityAuthenticatedReactiveBase = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
8
|
+
const hooks_1 = require("../../hooks");
|
|
9
9
|
const ReactiveBase_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveBase"));
|
|
10
10
|
const UtilityAuthenticatedReactiveBase = ({ children }) => {
|
|
11
|
-
const props = (0,
|
|
11
|
+
const props = (0, hooks_1.useReactiveBaseProps)();
|
|
12
12
|
return react_1.default.createElement(ReactiveBase_1.default, Object.assign({}, props), children);
|
|
13
13
|
};
|
|
14
14
|
exports.UtilityAuthenticatedReactiveBase = UtilityAuthenticatedReactiveBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./UtilityAuthenticatedReactiveBase";
|
|
@@ -0,0 +1,13 @@
|
|
|
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("./UtilityAuthenticatedReactiveBase"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./Example"), exports);
|
|
14
|
+
__exportStar(require("./Filter"), exports);
|
|
15
|
+
__exportStar(require("./ReactifySearchBase"), exports);
|
|
16
|
+
__exportStar(require("./Result"), exports);
|
|
17
|
+
__exportStar(require("./Search"), exports);
|
|
18
|
+
__exportStar(require("./Sensor"), exports);
|
|
19
|
+
__exportStar(require("./Sortby"), exports);
|
|
20
|
+
__exportStar(require("./Utility"), exports);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export * from "./reactivesearch";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
2
|
+
export * from "./useSortby";
|
|
3
|
+
export * from "./usePagination";
|
|
4
|
+
export * from "./usePaginationLoadMore";
|
|
5
5
|
export * from "./useSearch";
|
|
6
6
|
export * from "./useFilters";
|
|
7
7
|
export * from "./useCuration";
|
|
8
8
|
export * from "./useAnalytics";
|
|
9
|
-
export * from "./useCollection";
|
|
10
9
|
export * from "./useFilterStack";
|
|
11
10
|
export * from "./useProductPrice";
|
|
12
11
|
export * from "./useFilterListProps";
|
|
13
12
|
export * from "./useFilterCollapsedState";
|
|
14
|
-
export * from "./
|
|
13
|
+
export * from "./useConfig";
|
|
14
|
+
export * from "./useReactifySearchContext";
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -11,16 +11,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./reactivesearch"), exports);
|
|
14
|
-
__exportStar(require("./
|
|
15
|
-
__exportStar(require("./
|
|
16
|
-
__exportStar(require("./
|
|
14
|
+
__exportStar(require("./useSortby"), exports);
|
|
15
|
+
__exportStar(require("./usePagination"), exports);
|
|
16
|
+
__exportStar(require("./usePaginationLoadMore"), exports);
|
|
17
17
|
__exportStar(require("./useSearch"), exports);
|
|
18
18
|
__exportStar(require("./useFilters"), exports);
|
|
19
19
|
__exportStar(require("./useCuration"), exports);
|
|
20
20
|
__exportStar(require("./useAnalytics"), exports);
|
|
21
|
-
__exportStar(require("./useCollection"), exports);
|
|
22
21
|
__exportStar(require("./useFilterStack"), exports);
|
|
23
22
|
__exportStar(require("./useProductPrice"), exports);
|
|
24
23
|
__exportStar(require("./useFilterListProps"), exports);
|
|
25
24
|
__exportStar(require("./useFilterCollapsedState"), exports);
|
|
26
|
-
__exportStar(require("./
|
|
25
|
+
__exportStar(require("./useConfig"), exports);
|
|
26
|
+
__exportStar(require("./useReactifySearchContext"), exports);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from "./useReactiveBaseProps";
|
|
2
2
|
export * from "./useReactiveReactProp";
|
|
3
3
|
export * from "./useReactiveFilterListProps";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./useReactiveFilterRangeProps";
|
|
5
|
+
export * from "./useReactiveFilterSliderProps";
|
|
6
|
+
export * from "./useReactiveFilterSharedProps";
|
|
7
|
+
export * from "./useReactiveResultStackProps";
|
|
5
8
|
export * from "./useReactiveDataSearchProps";
|
|
@@ -13,5 +13,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./useReactiveBaseProps"), exports);
|
|
14
14
|
__exportStar(require("./useReactiveReactProp"), exports);
|
|
15
15
|
__exportStar(require("./useReactiveFilterListProps"), exports);
|
|
16
|
-
__exportStar(require("./
|
|
16
|
+
__exportStar(require("./useReactiveFilterRangeProps"), exports);
|
|
17
|
+
__exportStar(require("./useReactiveFilterSliderProps"), exports);
|
|
18
|
+
__exportStar(require("./useReactiveFilterSharedProps"), exports);
|
|
19
|
+
__exportStar(require("./useReactiveResultStackProps"), exports);
|
|
17
20
|
__exportStar(require("./useReactiveDataSearchProps"), exports);
|
|
@@ -14,14 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.useReactiveBaseProps = void 0;
|
|
16
16
|
const react_1 = __importDefault(require("react"));
|
|
17
|
-
const
|
|
17
|
+
const hooks_1 = require("../../hooks");
|
|
18
18
|
const useReactiveBaseProps = () => {
|
|
19
|
-
const {
|
|
19
|
+
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
20
20
|
return react_1.default.useMemo(() => ({
|
|
21
|
-
app: index,
|
|
22
|
-
url: credentials.endpoint,
|
|
23
|
-
credentials: `${credentials.username}:${credentials.password}`,
|
|
24
|
-
theme,
|
|
21
|
+
app: options.index,
|
|
22
|
+
url: options.credentials.endpoint,
|
|
23
|
+
credentials: `${options.credentials.username}:${options.credentials.password}`,
|
|
24
|
+
theme: options.theme,
|
|
25
25
|
transformResponse: (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
var _a, _b, _c, _d;
|
|
27
27
|
// support filtering inside nested aggregations by moving the inner aggregation
|
|
@@ -38,6 +38,6 @@ const useReactiveBaseProps = () => {
|
|
|
38
38
|
}
|
|
39
39
|
return response;
|
|
40
40
|
}),
|
|
41
|
-
}), [credentials, theme]);
|
|
41
|
+
}), [options.credentials, options.theme]);
|
|
42
42
|
};
|
|
43
43
|
exports.useReactiveBaseProps = useReactiveBaseProps;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
declare
|
|
1
|
+
export declare const useReactiveDataSearchProps: (options: {
|
|
2
2
|
[key: string]: any;
|
|
3
|
-
debounce?: number;
|
|
4
|
-
placeholder?: string;
|
|
5
|
-
inputClassName?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const useReactiveDataSearchProps: (props?: Props) => {
|
|
3
|
+
debounce?: number | undefined;
|
|
4
|
+
placeholder?: string | undefined;
|
|
5
|
+
inputClassName?: string | undefined;
|
|
6
|
+
}) => {
|
|
8
7
|
debounce?: number | undefined;
|
|
9
8
|
placeholder: string;
|
|
10
9
|
inputClassName?: string | undefined;
|
|
@@ -25,4 +24,3 @@ export declare const useReactiveDataSearchProps: (props?: Props) => {
|
|
|
25
24
|
input: string | undefined;
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
|
-
export {};
|
|
@@ -7,7 +7,7 @@ exports.useReactiveDataSearchProps = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const ahooks_1 = require("ahooks");
|
|
9
9
|
const debug = require("debug")("reactify-search:useReactiveDataSearchProps");
|
|
10
|
-
const
|
|
10
|
+
const hooks_1 = require("../../hooks");
|
|
11
11
|
// default field for when zero search fields have been configured in Reactify
|
|
12
12
|
const defaultSearchField = {
|
|
13
13
|
id: "title",
|
|
@@ -15,25 +15,19 @@ const defaultSearchField = {
|
|
|
15
15
|
importance: 0,
|
|
16
16
|
searchType: "instant_search",
|
|
17
17
|
};
|
|
18
|
-
const useReactiveDataSearchProps = (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const { searchQuery, submitSearch, setSearchQuery, setShowInstantSearchResults, } = (0, __1.useSearch)();
|
|
25
|
-
const searchFields = react_1.default.useMemo(() => 0 < fields.length
|
|
26
|
-
? fields.filter((field) => ["always_search", "instant_search"].includes(field.searchType))
|
|
18
|
+
const useReactiveDataSearchProps = (options) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const { config } = (0, hooks_1.useReactifySearchContext)();
|
|
21
|
+
const { searchQuery, submitSearch, setSearchQuery, setShowInstantSearchResults, } = (0, hooks_1.useSearch)();
|
|
22
|
+
const searchFields = react_1.default.useMemo(() => 0 < config.fields.length
|
|
23
|
+
? config.fields.filter((field) => ["always_search", "instant_search"].includes(field.searchType))
|
|
27
24
|
: [defaultSearchField], []);
|
|
28
|
-
react_1.default.useEffect(() => {
|
|
29
|
-
debug("searchFields", searchFields);
|
|
30
|
-
}, [searchFields]);
|
|
31
25
|
const handleKeyPress = react_1.default.useCallback((e) => {
|
|
32
26
|
if ("Enter" !== e.key)
|
|
33
27
|
return;
|
|
34
28
|
submitSearch();
|
|
35
29
|
}, [submitSearch]);
|
|
36
|
-
const { track } = (0,
|
|
30
|
+
const { track } = (0, hooks_1.useAnalytics)();
|
|
37
31
|
const trackQuery = react_1.default.useCallback(() => {
|
|
38
32
|
if (!searchQuery || (searchQuery && searchQuery.length < 3))
|
|
39
33
|
return;
|
|
@@ -43,25 +37,30 @@ const useReactiveDataSearchProps = (props = {}) => {
|
|
|
43
37
|
triggerQuery();
|
|
44
38
|
trackQuery();
|
|
45
39
|
}, {
|
|
46
|
-
wait: debounce !== null &&
|
|
40
|
+
wait: (_a = options.debounce) !== null && _a !== void 0 ? _a : 300,
|
|
47
41
|
});
|
|
48
|
-
return react_1.default.useMemo(() =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
return react_1.default.useMemo(() => {
|
|
43
|
+
var _a;
|
|
44
|
+
return (Object.assign({ type: "search", showIcon: false, fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchQuery !== null && searchQuery !== void 0 ? searchQuery : "", onKeyUp: handleKeyPress, componentId: "SearchInput", placeholder: (_a = options.placeholder) !== null && _a !== void 0 ? _a : "Search for a product...", dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), onChange: (value, triggerQuery) => {
|
|
45
|
+
setSearchQuery(value);
|
|
46
|
+
if (!!value) {
|
|
47
|
+
runDebouncedTriggerQuery(triggerQuery);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
cancelDebouncedTriggerQuery();
|
|
51
|
+
}
|
|
52
|
+
}, onBlur: () => {
|
|
53
|
+
// setTimeout ensures that results are still clickable before close
|
|
54
|
+
setTimeout(() => setShowInstantSearchResults(false), 300);
|
|
55
|
+
}, onFocus: () => {
|
|
56
|
+
setShowInstantSearchResults(true);
|
|
57
|
+
}, innerClass: {
|
|
58
|
+
input: options.inputClassName,
|
|
59
|
+
} }, options));
|
|
60
|
+
}, [
|
|
62
61
|
searchQuery,
|
|
63
62
|
handleKeyPress,
|
|
64
|
-
placeholder,
|
|
63
|
+
options.placeholder,
|
|
65
64
|
searchFields,
|
|
66
65
|
setSearchQuery,
|
|
67
66
|
runDebouncedTriggerQuery,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { ConfigFilterOption } from "../../types/config";
|
|
2
|
+
/**
|
|
3
|
+
* For use with @appbaseio/reactivesearch SingleList and MultiList components
|
|
4
|
+
*/
|
|
2
5
|
export declare const useReactiveFilterListProps: (filter: ConfigFilterOption) => {
|
|
6
|
+
size: number | undefined;
|
|
7
|
+
showFilter: boolean;
|
|
8
|
+
showLoadMore: boolean;
|
|
9
|
+
showSearch: boolean;
|
|
10
|
+
showRadio: boolean;
|
|
11
|
+
showCheckbox: boolean;
|
|
3
12
|
nestedField: string | undefined;
|
|
4
13
|
customQuery: ((value?: string | string[] | undefined) => {
|
|
5
14
|
query?: undefined;
|
|
@@ -61,8 +70,4 @@ export declare const useReactiveFilterListProps: (filter: ConfigFilterOption) =>
|
|
|
61
70
|
react: {
|
|
62
71
|
and: string[];
|
|
63
72
|
};
|
|
64
|
-
size: number | undefined;
|
|
65
|
-
showFilter: true;
|
|
66
|
-
showLoadMore: boolean;
|
|
67
|
-
showSearch: boolean;
|
|
68
73
|
};
|
|
@@ -5,102 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useReactiveFilterListProps = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useReactiveFilterSharedProps_1 = require("./useReactiveFilterSharedProps");
|
|
8
9
|
const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
10
|
+
/**
|
|
11
|
+
* For use with @appbaseio/reactivesearch SingleList and MultiList components
|
|
12
|
+
*/
|
|
9
13
|
const useReactiveFilterListProps = (filter) => {
|
|
10
14
|
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return undefined;
|
|
17
|
-
}, [filter]);
|
|
18
|
-
// define a custom query for when settingsHideUnavailable is enabled and the target field is inside variants
|
|
19
|
-
// customQuery defines how this filter affects *other* components like the results component
|
|
20
|
-
const customQuery = react_1.default.useMemo(() => {
|
|
21
|
-
if (!filter.settingsHideUnavailable ||
|
|
22
|
-
!filter.field.startsWith("variants."))
|
|
23
|
-
return undefined;
|
|
24
|
-
return (value) => {
|
|
25
|
-
if (!value)
|
|
26
|
-
return {};
|
|
27
|
-
// reactivesearch sometimes returns string, sometimes string[]
|
|
28
|
-
const valueArray = "string" === typeof value ? [value] : value;
|
|
29
|
-
if (0 === valueArray.length)
|
|
30
|
-
return {};
|
|
31
|
-
return {
|
|
32
|
-
query: {
|
|
33
|
-
nested: {
|
|
34
|
-
path: "variants",
|
|
35
|
-
query: {
|
|
36
|
-
bool: {
|
|
37
|
-
must: [
|
|
38
|
-
{
|
|
39
|
-
match: {
|
|
40
|
-
"variants.available": "true",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
terms: {
|
|
45
|
-
[filter.field]: valueArray,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
}, [filter]);
|
|
56
|
-
// define a default query for when settingsHideUnavailable is enabled and the target field is inside variants
|
|
57
|
-
// defaultQuery defines how this filter affects itself i.e. the options displayed
|
|
58
|
-
const defaultQuery = react_1.default.useMemo(() => {
|
|
59
|
-
if (!filter.settingsHideUnavailable ||
|
|
60
|
-
!filter.field.startsWith("variants."))
|
|
61
|
-
return undefined;
|
|
62
|
-
// override the aggregation query to filter the results by the variants.available attribute
|
|
63
|
-
return () => {
|
|
64
|
-
return {
|
|
65
|
-
aggs: {
|
|
66
|
-
reactivesearch_nested: {
|
|
67
|
-
nested: { path: "variants" },
|
|
68
|
-
aggs: {
|
|
69
|
-
reactify_nested_outer: {
|
|
70
|
-
filter: {
|
|
71
|
-
match: {
|
|
72
|
-
"variants.available": "true",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
aggs: {
|
|
76
|
-
[filter.field]: {
|
|
77
|
-
terms: {
|
|
78
|
-
field: filter.field,
|
|
79
|
-
size: 100,
|
|
80
|
-
order: { _count: "desc" },
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
}, [filter]);
|
|
91
|
-
return react_1.default.useMemo(() => ({
|
|
92
|
-
nestedField,
|
|
93
|
-
customQuery,
|
|
94
|
-
defaultQuery,
|
|
95
|
-
URLParams: true,
|
|
96
|
-
componentId: filter.handle,
|
|
97
|
-
dataField: filter.field,
|
|
98
|
-
filterLabel: filter.name,
|
|
99
|
-
react: reactiveReactProp,
|
|
100
|
-
size: parseInt(filter.displaySize) || undefined,
|
|
101
|
-
showFilter: filter.settingsShowFilter || true,
|
|
102
|
-
showLoadMore: filter.settingsShowMore || false,
|
|
103
|
-
showSearch: (filter === null || filter === void 0 ? void 0 : filter.settingsShowSearch) || false,
|
|
104
|
-
}), [filter, reactiveReactProp]);
|
|
15
|
+
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
16
|
+
return react_1.default.useMemo(() => {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { size: parseInt(filter.displaySize) || undefined, showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true, showLoadMore: (_b = filter.settingsShowMore) !== null && _b !== void 0 ? _b : false, showSearch: (_c = filter.settingsShowSearch) !== null && _c !== void 0 ? _c : false, showRadio: false, showCheckbox: false }));
|
|
19
|
+
}, [filter, reactiveReactProp]);
|
|
105
20
|
};
|
|
106
21
|
exports.useReactiveFilterListProps = useReactiveFilterListProps;
|