@usereactify/search 5.0.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.
- package/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/dist/package.json +0 -65
- package/dist/src/components/context/ReactifySearchBase.d.ts +0 -42
- package/dist/src/components/context/ReactifySearchBase.js +0 -140
- package/dist/src/components/context/index.d.ts +0 -1
- package/dist/src/components/context/index.js +0 -13
- package/dist/src/components/example/ExampleFilterList.d.ts +0 -4
- package/dist/src/components/example/ExampleFilterList.js +0 -19
- package/dist/src/components/example/ExampleFilterRange.d.ts +0 -4
- package/dist/src/components/example/ExampleFilterRange.js +0 -21
- package/dist/src/components/example/ExampleFilterSlider.d.ts +0 -4
- package/dist/src/components/example/ExampleFilterSlider.js +0 -20
- package/dist/src/components/example/ExampleFilterStack.d.ts +0 -4
- package/dist/src/components/example/ExampleFilterStack.js +0 -12
- package/dist/src/components/example/ExampleResultCardCallout.d.ts +0 -4
- package/dist/src/components/example/ExampleResultCardCallout.js +0 -21
- package/dist/src/components/example/ExampleResultCardProduct.d.ts +0 -4
- package/dist/src/components/example/ExampleResultCardProduct.js +0 -18
- package/dist/src/components/example/ExampleResultPaginationLoadMore.d.ts +0 -4
- package/dist/src/components/example/ExampleResultPaginationLoadMore.js +0 -11
- package/dist/src/components/example/ExampleResultPaginationNextPrev.d.ts +0 -4
- package/dist/src/components/example/ExampleResultPaginationNextPrev.js +0 -13
- package/dist/src/components/example/ExampleResultPaginationNumbered.d.ts +0 -4
- package/dist/src/components/example/ExampleResultPaginationNumbered.js +0 -26
- package/dist/src/components/example/ExampleSortby.d.ts +0 -4
- package/dist/src/components/example/ExampleSortby.js +0 -12
- package/dist/src/components/example/index.d.ts +0 -10
- package/dist/src/components/example/index.js +0 -22
- package/dist/src/components/filter/Filter.d.ts +0 -20
- package/dist/src/components/filter/Filter.js +0 -89
- package/dist/src/components/filter/FilterStack.d.ts +0 -7
- package/dist/src/components/filter/FilterStack.js +0 -16
- package/dist/src/components/filter/index.d.ts +0 -2
- package/dist/src/components/filter/index.js +0 -14
- package/dist/src/components/index.d.ts +0 -8
- package/dist/src/components/index.js +0 -20
- package/dist/src/components/result/ResultCardCallout.d.ts +0 -12
- package/dist/src/components/result/ResultCardCallout.js +0 -46
- package/dist/src/components/result/ResultCardProduct.d.ts +0 -13
- package/dist/src/components/result/ResultCardProduct.js +0 -63
- package/dist/src/components/result/ResultPaginationLoadMore.d.ts +0 -7
- package/dist/src/components/result/ResultPaginationLoadMore.js +0 -16
- package/dist/src/components/result/ResultPaginationNextPrev.d.ts +0 -7
- package/dist/src/components/result/ResultPaginationNextPrev.js +0 -16
- package/dist/src/components/result/ResultPaginationNumbered.d.ts +0 -7
- package/dist/src/components/result/ResultPaginationNumbered.js +0 -19
- package/dist/src/components/result/ResultStack.d.ts +0 -40
- package/dist/src/components/result/ResultStack.js +0 -107
- package/dist/src/components/result/ResultStateProvider.d.ts +0 -6
- package/dist/src/components/result/ResultStateProvider.js +0 -10
- package/dist/src/components/result/index.d.ts +0 -7
- package/dist/src/components/result/index.js +0 -19
- package/dist/src/components/search/SearchInput.d.ts +0 -8
- package/dist/src/components/search/SearchInput.js +0 -17
- package/dist/src/components/search/index.d.ts +0 -1
- package/dist/src/components/search/index.js +0 -13
- package/dist/src/components/sensor/SensorCollection.d.ts +0 -2
- package/dist/src/components/sensor/SensorCollection.js +0 -44
- package/dist/src/components/sensor/SensorInventoryAvailable.d.ts +0 -2
- package/dist/src/components/sensor/SensorInventoryAvailable.js +0 -52
- package/dist/src/components/sensor/SensorPublished.d.ts +0 -2
- package/dist/src/components/sensor/SensorPublished.js +0 -16
- package/dist/src/components/sensor/SensorSearch.d.ts +0 -2
- package/dist/src/components/sensor/SensorSearch.js +0 -82
- package/dist/src/components/sensor/SensorSort.d.ts +0 -2
- package/dist/src/components/sensor/SensorSort.js +0 -204
- package/dist/src/components/sensor/SensorSortScore.d.ts +0 -2
- package/dist/src/components/sensor/SensorSortScore.js +0 -12
- package/dist/src/components/sensor/SensorStack.d.ts +0 -3
- package/dist/src/components/sensor/SensorStack.js +0 -31
- package/dist/src/components/sensor/index.d.ts +0 -8
- package/dist/src/components/sensor/index.js +0 -29
- package/dist/src/components/sortby/Sortby.d.ts +0 -7
- package/dist/src/components/sortby/Sortby.js +0 -16
- package/dist/src/components/sortby/index.d.ts +0 -1
- package/dist/src/components/sortby/index.js +0 -13
- package/dist/src/components/utility/UtilityAuthenticatedReactiveBase.d.ts +0 -2
- package/dist/src/components/utility/UtilityAuthenticatedReactiveBase.js +0 -14
- package/dist/src/components/utility/index.d.ts +0 -1
- package/dist/src/components/utility/index.js +0 -13
- package/dist/src/hooks/index.d.ts +0 -14
- package/dist/src/hooks/index.js +0 -26
- package/dist/src/hooks/reactivesearch/index.d.ts +0 -8
- package/dist/src/hooks/reactivesearch/index.js +0 -20
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +0 -7
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +0 -43
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +0 -26
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +0 -70
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -73
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +0 -21
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +0 -70
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +0 -21
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +0 -67
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +0 -105
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +0 -68
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +0 -21
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -3
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +0 -25
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.d.ts +0 -17
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js +0 -31
- package/dist/src/hooks/useAnalytics.d.ts +0 -95
- package/dist/src/hooks/useAnalytics.js +0 -110
- package/dist/src/hooks/useConfig.d.ts +0 -4
- package/dist/src/hooks/useConfig.js +0 -81
- package/dist/src/hooks/useCuration.d.ts +0 -2
- package/dist/src/hooks/useCuration.js +0 -52
- package/dist/src/hooks/useFilterCollapsedState.d.ts +0 -8
- package/dist/src/hooks/useFilterCollapsedState.js +0 -27
- package/dist/src/hooks/useFilterListProps.d.ts +0 -12
- package/dist/src/hooks/useFilterListProps.js +0 -35
- package/dist/src/hooks/useFilterStack.d.ts +0 -2
- package/dist/src/hooks/useFilterStack.js +0 -46
- package/dist/src/hooks/useFilters.d.ts +0 -4
- package/dist/src/hooks/useFilters.js +0 -22
- package/dist/src/hooks/usePagination.d.ts +0 -14
- package/dist/src/hooks/usePagination.js +0 -97
- package/dist/src/hooks/usePaginationLoadMore.d.ts +0 -14
- package/dist/src/hooks/usePaginationLoadMore.js +0 -35
- package/dist/src/hooks/useProductPrice.d.ts +0 -10
- package/dist/src/hooks/useProductPrice.js +0 -63
- package/dist/src/hooks/useReactifySearchContext.d.ts +0 -78
- package/dist/src/hooks/useReactifySearchContext.js +0 -10
- package/dist/src/hooks/useSearch.d.ts +0 -8
- package/dist/src/hooks/useSearch.js +0 -36
- package/dist/src/hooks/useSortby.d.ts +0 -6
- package/dist/src/hooks/useSortby.js +0 -41
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -18
- package/dist/src/types/config.d.ts +0 -26
- package/dist/src/types/config.js +0 -2
- package/dist/src/types/elastic.d.ts +0 -209
- package/dist/src/types/elastic.js +0 -18
- package/dist/src/types/firestore.d.ts +0 -280
- package/dist/src/types/firestore.js +0 -18
- package/dist/src/types/graphql.d.ts +0 -26545
- package/dist/src/types/graphql.js +0 -4687
- package/dist/src/types/index.d.ts +0 -3
- package/dist/src/types/index.js +0 -15
- package/dist/src/types/reactivesearch.d.ts +0 -73
- package/dist/src/types/reactivesearch.js +0 -2
- package/dist/src/types/shopify.d.ts +0 -21
- package/dist/src/types/shopify.js +0 -27
|
@@ -1,44 +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 { options } = (0, hooks_1.useReactifySearchContext)();
|
|
12
|
-
if (options.mode !== "collection") {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorCollection", customQuery: () => ({
|
|
16
|
-
query: {
|
|
17
|
-
bool: {
|
|
18
|
-
should: [
|
|
19
|
-
{
|
|
20
|
-
nested: {
|
|
21
|
-
path: "collections",
|
|
22
|
-
query: {
|
|
23
|
-
term: {
|
|
24
|
-
"collections.handle.keyword": options.collection.handle,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
nested: {
|
|
31
|
-
path: "curations",
|
|
32
|
-
query: {
|
|
33
|
-
term: {
|
|
34
|
-
"curations.collectionHandle.keyword": options.collection.handle,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}) }));
|
|
43
|
-
};
|
|
44
|
-
exports.SensorCollection = SensorCollection;
|
|
@@ -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;
|
|
@@ -1,16 +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.SensorPublished = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
|
-
const SensorPublished = () => (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorPublished", customQuery: () => ({
|
|
10
|
-
query: {
|
|
11
|
-
match: {
|
|
12
|
-
published: true,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
}) }));
|
|
16
|
-
exports.SensorPublished = SensorPublished;
|
|
@@ -1,82 +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.SensorSearch = 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 SensorSearch = () => {
|
|
11
|
-
const { config } = (0, hooks_1.useReactifySearchContext)();
|
|
12
|
-
const { searchQuery } = (0, hooks_1.useSearch)();
|
|
13
|
-
// ignore search fields only set for instant search
|
|
14
|
-
const searchFields = react_1.default.useMemo(() => config.fields.filter((field) => ["always_search", "search_page"].includes(field.searchType)), [config.fields]);
|
|
15
|
-
if (!searchQuery || !searchFields.length) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
19
|
-
react_1.default.createElement(DataSearch_1.default, { fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchQuery, componentId: "SensorSearch", style: { display: "none" }, dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), customQuery: (value, props) => {
|
|
20
|
-
const { dataField, fieldWeights } = props;
|
|
21
|
-
const fieldsCrossFields = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
|
|
22
|
-
const fieldsPhrase = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
|
|
23
|
-
const fieldsPhrasePrefix = dataField
|
|
24
|
-
.filter((field) => !field.includes("."))
|
|
25
|
-
.map((field, index) => `${field}^${fieldWeights[index]}`);
|
|
26
|
-
const query = {
|
|
27
|
-
bool: {
|
|
28
|
-
should: [
|
|
29
|
-
{
|
|
30
|
-
nested: {
|
|
31
|
-
path: "curations",
|
|
32
|
-
query: {
|
|
33
|
-
term: {
|
|
34
|
-
"curations.searchTerm.keyword": value === null || value === void 0 ? void 0 : value.toLowerCase(),
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
...(fieldsCrossFields.length > 0
|
|
40
|
-
? [
|
|
41
|
-
{
|
|
42
|
-
multi_match: {
|
|
43
|
-
query: value,
|
|
44
|
-
fields: fieldsCrossFields,
|
|
45
|
-
type: "cross_fields",
|
|
46
|
-
operator: "and",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
: []),
|
|
51
|
-
...(fieldsPhrase.length > 0
|
|
52
|
-
? [
|
|
53
|
-
{
|
|
54
|
-
multi_match: {
|
|
55
|
-
query: value,
|
|
56
|
-
fields: fieldsPhrase,
|
|
57
|
-
type: "phrase",
|
|
58
|
-
operator: "and",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
]
|
|
62
|
-
: []),
|
|
63
|
-
...(fieldsPhrasePrefix.length > 0
|
|
64
|
-
? [
|
|
65
|
-
{
|
|
66
|
-
multi_match: {
|
|
67
|
-
query: value,
|
|
68
|
-
fields: fieldsPhrasePrefix,
|
|
69
|
-
type: "phrase_prefix",
|
|
70
|
-
operator: "and",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
]
|
|
74
|
-
: []),
|
|
75
|
-
],
|
|
76
|
-
minimum_should_match: "1",
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
return { query };
|
|
80
|
-
} })));
|
|
81
|
-
};
|
|
82
|
-
exports.SensorSearch = SensorSearch;
|
|
@@ -1,204 +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.SensorSort = 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 debug = require("debug")("reactify-search:SensorSort");
|
|
11
|
-
const SensorSort = () => {
|
|
12
|
-
const { options, config } = (0, hooks_1.useReactifySearchContext)();
|
|
13
|
-
const curation = (0, hooks_1.useCuration)();
|
|
14
|
-
const globalCuration = (curation === null || curation === void 0 ? void 0 : curation.id) === "global";
|
|
15
|
-
const { sortOption } = (0, hooks_1.useSortby)();
|
|
16
|
-
const searchQuery = react_1.default.useMemo(() => {
|
|
17
|
-
if (typeof window === "undefined")
|
|
18
|
-
return "";
|
|
19
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
20
|
-
return urlParams.get("q") || "";
|
|
21
|
-
}, []);
|
|
22
|
-
const { sort, query } = react_1.default.useMemo(() => {
|
|
23
|
-
return {
|
|
24
|
-
sort: buildSort({
|
|
25
|
-
config,
|
|
26
|
-
sortOption,
|
|
27
|
-
collection: options.mode === "collection" ? options.collection : undefined,
|
|
28
|
-
curation,
|
|
29
|
-
globalCuration,
|
|
30
|
-
}),
|
|
31
|
-
query: buildQuery({
|
|
32
|
-
sortOption,
|
|
33
|
-
curation,
|
|
34
|
-
globalCuration,
|
|
35
|
-
}),
|
|
36
|
-
};
|
|
37
|
-
}, [config, sortOption, curation]);
|
|
38
|
-
react_1.default.useEffect(() => {
|
|
39
|
-
debug("searchQuery", searchQuery);
|
|
40
|
-
debug("sort", sort);
|
|
41
|
-
debug("query", query);
|
|
42
|
-
}, [searchQuery, sort]);
|
|
43
|
-
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorSort", customQuery: () => ({
|
|
44
|
-
sort,
|
|
45
|
-
query,
|
|
46
|
-
}) }));
|
|
47
|
-
};
|
|
48
|
-
exports.SensorSort = SensorSort;
|
|
49
|
-
const buildSort = (args) => {
|
|
50
|
-
var _a;
|
|
51
|
-
const { config, curation, sortOption, collection, globalCuration } = args;
|
|
52
|
-
debug("buildSortQuery.start", {
|
|
53
|
-
config,
|
|
54
|
-
curation,
|
|
55
|
-
sortOption,
|
|
56
|
-
});
|
|
57
|
-
// return default sort option if unset
|
|
58
|
-
if (!sortOption) {
|
|
59
|
-
return collection
|
|
60
|
-
? mapCollectionPositionSortClause(collection)
|
|
61
|
-
: ["_score"];
|
|
62
|
-
}
|
|
63
|
-
// curation positions are only applied for the default `collections.position` or `_score` sort
|
|
64
|
-
// if the sort is something else, apply a normal sort which applies what the user has requested
|
|
65
|
-
if (!["_score", "collections.position"].includes(sortOption.field)) {
|
|
66
|
-
return [{ [sortOption.field]: sortOption.direction }];
|
|
67
|
-
}
|
|
68
|
-
// no matching curation, return default sort clause
|
|
69
|
-
if (!curation) {
|
|
70
|
-
return collection
|
|
71
|
-
? mapCollectionPositionSortClause(collection)
|
|
72
|
-
: ["_score"];
|
|
73
|
-
}
|
|
74
|
-
const sorts = [];
|
|
75
|
-
// show pins first
|
|
76
|
-
if (globalCuration && collection) {
|
|
77
|
-
sorts.push(...mapCollectionPositionSortClause(collection));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
sorts.push({
|
|
81
|
-
"curations.position": {
|
|
82
|
-
unmapped_type: "long",
|
|
83
|
-
order: "asc",
|
|
84
|
-
nested: {
|
|
85
|
-
path: "curations",
|
|
86
|
-
filter: {
|
|
87
|
-
term: {
|
|
88
|
-
[`curations.${"collection" === curation.type
|
|
89
|
-
? "collectionHandle"
|
|
90
|
-
: "searchTerm"}.keyword`]: "collection" === curation.type
|
|
91
|
-
? curation.collectionHandle
|
|
92
|
-
: (_a = curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
if (0 < curation.boosting.groupings.length) {
|
|
100
|
-
const groupings = curation.boosting.groupings.sort((a, b) => a.position > b.position ? 1 : -1);
|
|
101
|
-
for (const grouping of groupings) {
|
|
102
|
-
try {
|
|
103
|
-
const query = JSON.parse(grouping.query);
|
|
104
|
-
if (query)
|
|
105
|
-
sorts.push(query);
|
|
106
|
-
}
|
|
107
|
-
catch (_b) {
|
|
108
|
-
console.error(`query could not be parsed for boost grouping`, grouping);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (0 < curation.boosting.sortings.length) {
|
|
113
|
-
const sortings = curation.boosting.sortings.sort((a, b) => a.position > b.position ? 1 : -1);
|
|
114
|
-
for (const sorting of sortings) {
|
|
115
|
-
try {
|
|
116
|
-
const query = JSON.parse(sorting.query);
|
|
117
|
-
if (query)
|
|
118
|
-
sorts.push(query);
|
|
119
|
-
}
|
|
120
|
-
catch (_c) {
|
|
121
|
-
console.error(`query could not be parsed for boost sorting`, sorting);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// finally, for collections, if no other sorting is defined, sort by index order to provide
|
|
126
|
-
// a consistent order
|
|
127
|
-
if ("collection" === curation.type && sorts.length === 0) {
|
|
128
|
-
sorts.push("_doc");
|
|
129
|
-
}
|
|
130
|
-
// finally, for search, sort by score
|
|
131
|
-
if ("search" === curation.type) {
|
|
132
|
-
sorts.push("_score");
|
|
133
|
-
}
|
|
134
|
-
return sorts;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Return a sort clause which sorts by position within the given collection.
|
|
138
|
-
*/
|
|
139
|
-
function mapCollectionPositionSortClause(collection) {
|
|
140
|
-
return [
|
|
141
|
-
{
|
|
142
|
-
"collections.position": {
|
|
143
|
-
order: "asc",
|
|
144
|
-
nested: {
|
|
145
|
-
path: "collections",
|
|
146
|
-
filter: {
|
|
147
|
-
term: {
|
|
148
|
-
"collections.handle.keyword": collection.handle,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
const buildQuery = (args) => {
|
|
157
|
-
var _a;
|
|
158
|
-
const { curation, sortOption, globalCuration } = args;
|
|
159
|
-
if (!curation || globalCuration) {
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
bool: {
|
|
164
|
-
must_not: [
|
|
165
|
-
{
|
|
166
|
-
nested: {
|
|
167
|
-
path: "curations",
|
|
168
|
-
query: {
|
|
169
|
-
bool: {
|
|
170
|
-
must: [
|
|
171
|
-
{
|
|
172
|
-
term: {
|
|
173
|
-
[`curations.${"collection" === curation.type
|
|
174
|
-
? "collectionHandle"
|
|
175
|
-
: "searchTerm"}.keyword`]: "collection" === curation.type
|
|
176
|
-
? curation.collectionHandle
|
|
177
|
-
: (_a = curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
term: {
|
|
182
|
-
"curations.hidden": true,
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
// hide callout when not sorting by _score or collections.position
|
|
191
|
-
...(sortOption &&
|
|
192
|
-
!["_score", "collections.position"].includes(sortOption.field)
|
|
193
|
-
? [
|
|
194
|
-
{
|
|
195
|
-
term: {
|
|
196
|
-
type: "callout",
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
]
|
|
200
|
-
: []),
|
|
201
|
-
],
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
};
|
|
@@ -1,12 +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.SensorSortScore = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const ReactiveComponent_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent"));
|
|
9
|
-
const SensorSortScore = () => (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorSortScore", customQuery: () => ({
|
|
10
|
-
sort: { _score: "desc" },
|
|
11
|
-
}) }));
|
|
12
|
-
exports.SensorSortScore = SensorSortScore;
|
|
@@ -1,31 +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.SensorStack = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const hooks_1 = require("../../hooks");
|
|
9
|
-
const SensorSort_1 = require("./SensorSort");
|
|
10
|
-
const SensorSearch_1 = require("./SensorSearch");
|
|
11
|
-
const SensorSortScore_1 = require("./SensorSortScore");
|
|
12
|
-
const SensorPublished_1 = require("./SensorPublished");
|
|
13
|
-
const SensorCollection_1 = require("./SensorCollection");
|
|
14
|
-
const SensorInventoryAvailable_1 = require("./SensorInventoryAvailable");
|
|
15
|
-
const SensorStack = () => {
|
|
16
|
-
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
17
|
-
// instant search mode
|
|
18
|
-
if (options.mode === "instant-search") {
|
|
19
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
20
|
-
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
21
|
-
react_1.default.createElement(SensorSortScore_1.SensorSortScore, null)));
|
|
22
|
-
}
|
|
23
|
-
// result grid mode
|
|
24
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
25
|
-
react_1.default.createElement(SensorSort_1.SensorSort, null),
|
|
26
|
-
react_1.default.createElement(SensorSearch_1.SensorSearch, null),
|
|
27
|
-
react_1.default.createElement(SensorPublished_1.SensorPublished, null),
|
|
28
|
-
react_1.default.createElement(SensorCollection_1.SensorCollection, null),
|
|
29
|
-
react_1.default.createElement(SensorInventoryAvailable_1.SensorInventoryAvailable, null)));
|
|
30
|
-
};
|
|
31
|
-
exports.SensorStack = SensorStack;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./SensorSort";
|
|
2
|
-
export * from "./SensorSearch";
|
|
3
|
-
export * from "./SensorPublished";
|
|
4
|
-
export * from "./SensorSortScore";
|
|
5
|
-
export * from "./SensorCollection";
|
|
6
|
-
export * from "./SensorInventoryAvailable";
|
|
7
|
-
export * from "./SensorStack";
|
|
8
|
-
export declare const SENSOR_IDS: string[];
|
|
@@ -1,29 +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
|
-
exports.SENSOR_IDS = void 0;
|
|
14
|
-
__exportStar(require("./SensorSort"), exports);
|
|
15
|
-
__exportStar(require("./SensorSearch"), exports);
|
|
16
|
-
__exportStar(require("./SensorPublished"), exports);
|
|
17
|
-
__exportStar(require("./SensorSortScore"), exports);
|
|
18
|
-
__exportStar(require("./SensorCollection"), exports);
|
|
19
|
-
__exportStar(require("./SensorInventoryAvailable"), exports);
|
|
20
|
-
__exportStar(require("./SensorStack"), exports);
|
|
21
|
-
// this is consumed by the react prop in various components
|
|
22
|
-
exports.SENSOR_IDS = [
|
|
23
|
-
"SensorSort",
|
|
24
|
-
"SensorSearch",
|
|
25
|
-
"SensorSortScore",
|
|
26
|
-
"SensorPublished",
|
|
27
|
-
"SensorCollection",
|
|
28
|
-
"SensorInventoryAvailable",
|
|
29
|
-
];
|
|
@@ -1,7 +0,0 @@
|
|
|
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>;
|
|
@@ -1,16 +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.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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Sortby";
|
|
@@ -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("./Sortby"), exports);
|
|
@@ -1,14 +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.UtilityAuthenticatedReactiveBase = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const hooks_1 = require("../../hooks");
|
|
9
|
-
const ReactiveBase_1 = __importDefault(require("@appbaseio/reactivesearch/lib/components/basic/ReactiveBase"));
|
|
10
|
-
const UtilityAuthenticatedReactiveBase = ({ children }) => {
|
|
11
|
-
const props = (0, hooks_1.useReactiveBaseProps)();
|
|
12
|
-
return react_1.default.createElement(ReactiveBase_1.default, Object.assign({}, props), children);
|
|
13
|
-
};
|
|
14
|
-
exports.UtilityAuthenticatedReactiveBase = UtilityAuthenticatedReactiveBase;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./UtilityAuthenticatedReactiveBase";
|
|
@@ -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("./UtilityAuthenticatedReactiveBase"), exports);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from "./reactivesearch";
|
|
2
|
-
export * from "./useSortby";
|
|
3
|
-
export * from "./usePagination";
|
|
4
|
-
export * from "./usePaginationLoadMore";
|
|
5
|
-
export * from "./useSearch";
|
|
6
|
-
export * from "./useFilters";
|
|
7
|
-
export * from "./useCuration";
|
|
8
|
-
export * from "./useAnalytics";
|
|
9
|
-
export * from "./useFilterStack";
|
|
10
|
-
export * from "./useProductPrice";
|
|
11
|
-
export * from "./useFilterListProps";
|
|
12
|
-
export * from "./useFilterCollapsedState";
|
|
13
|
-
export * from "./useConfig";
|
|
14
|
-
export * from "./useReactifySearchContext";
|
package/dist/src/hooks/index.js
DELETED
|
@@ -1,26 +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("./reactivesearch"), exports);
|
|
14
|
-
__exportStar(require("./useSortby"), exports);
|
|
15
|
-
__exportStar(require("./usePagination"), exports);
|
|
16
|
-
__exportStar(require("./usePaginationLoadMore"), exports);
|
|
17
|
-
__exportStar(require("./useSearch"), exports);
|
|
18
|
-
__exportStar(require("./useFilters"), exports);
|
|
19
|
-
__exportStar(require("./useCuration"), exports);
|
|
20
|
-
__exportStar(require("./useAnalytics"), exports);
|
|
21
|
-
__exportStar(require("./useFilterStack"), exports);
|
|
22
|
-
__exportStar(require("./useProductPrice"), exports);
|
|
23
|
-
__exportStar(require("./useFilterListProps"), exports);
|
|
24
|
-
__exportStar(require("./useFilterCollapsedState"), exports);
|
|
25
|
-
__exportStar(require("./useConfig"), exports);
|
|
26
|
-
__exportStar(require("./useReactifySearchContext"), exports);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./useReactiveBaseProps";
|
|
2
|
-
export * from "./useReactiveReactProp";
|
|
3
|
-
export * from "./useReactiveFilterListProps";
|
|
4
|
-
export * from "./useReactiveFilterRangeProps";
|
|
5
|
-
export * from "./useReactiveFilterSliderProps";
|
|
6
|
-
export * from "./useReactiveFilterSharedProps";
|
|
7
|
-
export * from "./useReactiveResultStackProps";
|
|
8
|
-
export * from "./useReactiveDataSearchProps";
|