@usereactify/search 2.1.0-beta.0 → 2.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/filter/Filter.d.ts +12 -0
- package/dist/filter/Filter.js +58 -0
- package/dist/filter/FilterList.d.ts +4 -0
- package/dist/filter/FilterList.js +15 -0
- package/dist/filter/FilterStack.d.ts +11 -0
- package/dist/filter/FilterStack.js +25 -0
- package/dist/filter/index.d.ts +3 -0
- package/dist/filter/index.js +15 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +26 -0
- package/dist/hooks/reactivesearch/index.d.ts +5 -0
- package/dist/hooks/reactivesearch/index.js +17 -0
- package/dist/hooks/reactivesearch/useReactiveBaseProps.d.ts +7 -0
- package/dist/hooks/reactivesearch/useReactiveBaseProps.js +43 -0
- package/dist/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +24 -0
- package/dist/hooks/reactivesearch/useReactiveDataSearchProps.js +87 -0
- package/dist/hooks/reactivesearch/useReactiveFilterListProps.d.ts +68 -0
- package/dist/hooks/reactivesearch/useReactiveFilterListProps.js +106 -0
- package/dist/hooks/reactivesearch/useReactiveReactProp.d.ts +3 -0
- package/dist/hooks/reactivesearch/useReactiveReactProp.js +25 -0
- package/dist/hooks/reactivesearch/useReactiveResultListProps.d.ts +20 -0
- package/dist/hooks/reactivesearch/useReactiveResultListProps.js +32 -0
- package/dist/hooks/useAnalytics.d.ts +14 -0
- package/dist/hooks/useAnalytics.js +47 -0
- package/dist/hooks/useCollection.d.ts +1 -0
- package/dist/hooks/useCollection.js +6 -0
- package/dist/hooks/useCombinedResults.d.ts +7 -0
- package/dist/hooks/useCombinedResults.js +25 -0
- package/dist/hooks/useConfig.d.ts +1 -0
- package/dist/hooks/useConfig.js +6 -0
- package/dist/hooks/useCuration.d.ts +1 -0
- package/dist/hooks/useCuration.js +6 -0
- package/dist/hooks/useFilterCollapsedState.d.ts +8 -0
- package/dist/hooks/useFilterCollapsedState.js +27 -0
- package/dist/hooks/useFilterListProps.d.ts +21 -0
- package/dist/hooks/useFilterListProps.js +35 -0
- package/dist/hooks/useFilterStack.d.ts +1 -0
- package/dist/hooks/useFilterStack.js +6 -0
- package/dist/hooks/useFilters.d.ts +1 -0
- package/dist/hooks/useFilters.js +17 -0
- package/dist/hooks/usePages.d.ts +10 -0
- package/dist/hooks/usePages.js +82 -0
- package/dist/hooks/useProductPrice.d.ts +12 -0
- package/dist/hooks/useProductPrice.js +61 -0
- package/dist/hooks/useSearch.d.ts +8 -0
- package/dist/hooks/useSearch.js +16 -0
- package/dist/hooks/useSort.d.ts +5 -0
- package/dist/hooks/useSort.js +9 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +19 -0
- package/dist/provider.d.ts +44 -0
- package/dist/provider.js +165 -0
- package/dist/result/ResultCard.d.ts +10 -0
- package/dist/result/ResultCard.js +45 -0
- package/dist/result/ResultCardCallout.d.ts +9 -0
- package/dist/result/ResultCardCallout.js +38 -0
- package/dist/result/ResultList.d.ts +30 -0
- package/dist/result/ResultList.js +99 -0
- package/dist/result/ResultLoadMoreButton.d.ts +9 -0
- package/dist/result/ResultLoadMoreButton.js +27 -0
- package/dist/result/ResultPagination.d.ts +8 -0
- package/dist/result/ResultPagination.js +50 -0
- package/dist/result/ResultPaginationNextPrev.d.ts +8 -0
- package/dist/result/ResultPaginationNextPrev.js +30 -0
- package/dist/result/ResultStateProvider.d.ts +7 -0
- package/dist/result/ResultStateProvider.js +10 -0
- package/dist/result/index.d.ts +5 -0
- package/dist/result/index.js +17 -0
- package/dist/search/SearchInput.d.ts +8 -0
- package/dist/search/SearchInput.js +19 -0
- package/dist/search/index.d.ts +1 -0
- package/dist/search/index.js +13 -0
- package/dist/sensor/SensorCollection.d.ts +2 -0
- package/dist/sensor/SensorCollection.js +41 -0
- package/dist/sensor/SensorInventoryAvailable.d.ts +2 -0
- package/dist/sensor/SensorInventoryAvailable.js +25 -0
- package/dist/sensor/SensorPublished.d.ts +2 -0
- package/dist/sensor/SensorPublished.js +16 -0
- package/dist/sensor/SensorSearch.d.ts +2 -0
- package/dist/sensor/SensorSearch.js +81 -0
- package/dist/sensor/SensorSort.d.ts +2 -0
- package/dist/sensor/SensorSort.js +144 -0
- package/dist/sensor/SensorSortScore.d.ts +2 -0
- package/dist/sensor/SensorSortScore.js +12 -0
- package/dist/sensor/SensorStack.d.ts +2 -0
- package/dist/sensor/SensorStack.js +31 -0
- package/dist/sensor/index.d.ts +8 -0
- package/dist/sensor/index.js +29 -0
- package/dist/types/config.d.ts +130 -0
- package/dist/types/config.js +2 -0
- package/dist/types/index.d.ts +79 -0
- package/dist/types/index.js +14 -0
- package/dist/types/results.d.ts +48 -0
- package/dist/types/results.js +2 -0
- package/dist/utility/UtilityAuthenticatedReactiveBase.d.ts +2 -0
- package/dist/utility/UtilityAuthenticatedReactiveBase.js +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
nested: {
|
|
17
|
+
path: "variants",
|
|
18
|
+
query: {
|
|
19
|
+
match: { "variants.available": true },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}) }));
|
|
24
|
+
};
|
|
25
|
+
exports.SensorInventoryAvailable = SensorInventoryAvailable;
|
|
@@ -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.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;
|
|
@@ -0,0 +1,81 @@
|
|
|
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 { fields } = (0, hooks_1.useConfig)();
|
|
12
|
+
const { searchQuery } = (0, hooks_1.useSearch)();
|
|
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)), []);
|
|
15
|
+
if (!searchQuery)
|
|
16
|
+
return null;
|
|
17
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
18
|
+
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) => {
|
|
19
|
+
const { dataField, fieldWeights } = props;
|
|
20
|
+
const fieldsCrossFields = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
|
|
21
|
+
const fieldsPhrase = dataField.map((field, index) => `${field}^${fieldWeights[index]}`);
|
|
22
|
+
const fieldsPhrasePrefix = dataField
|
|
23
|
+
.filter((field) => !field.includes("."))
|
|
24
|
+
.map((field, index) => `${field}^${fieldWeights[index]}`);
|
|
25
|
+
const query = {
|
|
26
|
+
bool: {
|
|
27
|
+
should: [
|
|
28
|
+
{
|
|
29
|
+
nested: {
|
|
30
|
+
path: "curations",
|
|
31
|
+
query: {
|
|
32
|
+
term: {
|
|
33
|
+
"curations.searchTerm.keyword": value === null || value === void 0 ? void 0 : value.toLowerCase(),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
...(fieldsCrossFields.length > 0
|
|
39
|
+
? [
|
|
40
|
+
{
|
|
41
|
+
multi_match: {
|
|
42
|
+
query: value,
|
|
43
|
+
fields: fieldsCrossFields,
|
|
44
|
+
type: "cross_fields",
|
|
45
|
+
operator: "and",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
: []),
|
|
50
|
+
...(fieldsPhrase.length > 0
|
|
51
|
+
? [
|
|
52
|
+
{
|
|
53
|
+
multi_match: {
|
|
54
|
+
query: value,
|
|
55
|
+
fields: fieldsPhrase,
|
|
56
|
+
type: "phrase",
|
|
57
|
+
operator: "and",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
: []),
|
|
62
|
+
...(fieldsPhrasePrefix.length > 0
|
|
63
|
+
? [
|
|
64
|
+
{
|
|
65
|
+
multi_match: {
|
|
66
|
+
query: value,
|
|
67
|
+
fields: fieldsPhrasePrefix,
|
|
68
|
+
type: "phrase_prefix",
|
|
69
|
+
operator: "and",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
]
|
|
73
|
+
: []),
|
|
74
|
+
],
|
|
75
|
+
minimum_should_match: "1",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
return { query };
|
|
79
|
+
} })));
|
|
80
|
+
};
|
|
81
|
+
exports.SensorSearch = SensorSearch;
|
|
@@ -0,0 +1,144 @@
|
|
|
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 config = (0, hooks_1.useConfig)();
|
|
13
|
+
const curation = (0, hooks_1.useCuration)();
|
|
14
|
+
const { sortOption } = (0, hooks_1.useSort)();
|
|
15
|
+
const searchQuery = react_1.default.useMemo(() => {
|
|
16
|
+
if (typeof window === "undefined")
|
|
17
|
+
return "";
|
|
18
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
19
|
+
return urlParams.get("q") || "";
|
|
20
|
+
}, []);
|
|
21
|
+
const { sort, query } = react_1.default.useMemo(() => {
|
|
22
|
+
return {
|
|
23
|
+
sort: buildSort(config, curation, sortOption),
|
|
24
|
+
query: buildQuery(curation),
|
|
25
|
+
};
|
|
26
|
+
}, [config, sortOption, curation]);
|
|
27
|
+
react_1.default.useEffect(() => {
|
|
28
|
+
debug("searchQuery", searchQuery);
|
|
29
|
+
debug("sort", sort);
|
|
30
|
+
debug("query", query);
|
|
31
|
+
}, [searchQuery, sort]);
|
|
32
|
+
return (react_1.default.createElement(ReactiveComponent_1.default, { componentId: "SensorSort", customQuery: () => ({
|
|
33
|
+
sort,
|
|
34
|
+
query,
|
|
35
|
+
}) }));
|
|
36
|
+
};
|
|
37
|
+
exports.SensorSort = SensorSort;
|
|
38
|
+
const buildSort = (config, curation, sortState) => {
|
|
39
|
+
var _a;
|
|
40
|
+
debug("buildSortQuery.start", {
|
|
41
|
+
config,
|
|
42
|
+
curation,
|
|
43
|
+
sortState,
|
|
44
|
+
});
|
|
45
|
+
// return default collection position if unset
|
|
46
|
+
if (!sortState) {
|
|
47
|
+
return [{ "collections.position": "asc" }];
|
|
48
|
+
}
|
|
49
|
+
// curation positions are only applied for the default `collections.position` or `_score` sort
|
|
50
|
+
// if the sort is something else, apply a normal sort which applies what the user has requested
|
|
51
|
+
if (!["collections.position", "_score"].includes(sortState.field)) {
|
|
52
|
+
return [{ [sortState.field]: sortState.direction }];
|
|
53
|
+
}
|
|
54
|
+
// no matching curation, return default sort order
|
|
55
|
+
if (!curation) {
|
|
56
|
+
return [{ [sortState.field]: sortState.direction }];
|
|
57
|
+
}
|
|
58
|
+
const sorts = [];
|
|
59
|
+
// show pins first
|
|
60
|
+
sorts.push({
|
|
61
|
+
"curations.position": {
|
|
62
|
+
unmapped_type: "long",
|
|
63
|
+
order: "asc",
|
|
64
|
+
nested: {
|
|
65
|
+
path: "curations",
|
|
66
|
+
filter: {
|
|
67
|
+
term: {
|
|
68
|
+
[`curations.${"collection" === curation.type ? "collectionHandle" : "searchTerm"}.keyword`]: "collection" === curation.type
|
|
69
|
+
? curation.collectionHandle
|
|
70
|
+
: (_a = curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
if (0 < curation.boosting.groupings.length) {
|
|
77
|
+
const groupings = curation.boosting.groupings.sort((a, b) => a.position > b.position ? 1 : -1);
|
|
78
|
+
for (const grouping of groupings) {
|
|
79
|
+
try {
|
|
80
|
+
const query = JSON.parse(grouping.query);
|
|
81
|
+
if (query)
|
|
82
|
+
sorts.push(query);
|
|
83
|
+
}
|
|
84
|
+
catch (_b) {
|
|
85
|
+
console.error(`query could not be parsed for boost grouping`, grouping);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (0 < curation.boosting.sortings.length) {
|
|
90
|
+
const sortings = curation.boosting.sortings.sort((a, b) => a.position > b.position ? 1 : -1);
|
|
91
|
+
for (const sorting of sortings) {
|
|
92
|
+
try {
|
|
93
|
+
const query = JSON.parse(sorting.query);
|
|
94
|
+
if (query)
|
|
95
|
+
sorts.push(query);
|
|
96
|
+
}
|
|
97
|
+
catch (_c) {
|
|
98
|
+
console.error(`query could not be parsed for boost sorting`, sorting);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// finally, sort by elastic score or index order
|
|
103
|
+
// using index order ensures a consistent output order for queries which don't really
|
|
104
|
+
// use a relevance score like collections
|
|
105
|
+
if ("collection" === curation.type)
|
|
106
|
+
sorts.push("_doc");
|
|
107
|
+
else
|
|
108
|
+
sorts.push("_score");
|
|
109
|
+
return sorts;
|
|
110
|
+
};
|
|
111
|
+
const buildQuery = (curation) => {
|
|
112
|
+
var _a;
|
|
113
|
+
if (!curation)
|
|
114
|
+
return undefined;
|
|
115
|
+
return {
|
|
116
|
+
bool: {
|
|
117
|
+
must_not: {
|
|
118
|
+
nested: {
|
|
119
|
+
path: "curations",
|
|
120
|
+
query: {
|
|
121
|
+
bool: {
|
|
122
|
+
must: [
|
|
123
|
+
{
|
|
124
|
+
term: {
|
|
125
|
+
[`curations.${"collection" === curation.type
|
|
126
|
+
? "collectionHandle"
|
|
127
|
+
: "searchTerm"}.keyword`]: "collection" === curation.type
|
|
128
|
+
? curation.collectionHandle
|
|
129
|
+
: (_a = curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
term: {
|
|
134
|
+
"curations.hidden": true,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { instantSearch } = (0, hooks_1.useSearch)();
|
|
17
|
+
// instant search mode
|
|
18
|
+
if (instantSearch) {
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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[];
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
sort: ConfigSort[];
|
|
3
|
+
fields: ConfigField[];
|
|
4
|
+
filters: ConfigFilter[];
|
|
5
|
+
curations: ConfigCuration[];
|
|
6
|
+
redirects: ConfigRedirect[];
|
|
7
|
+
}
|
|
8
|
+
export interface ConfigSort {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
field: string;
|
|
12
|
+
position: number;
|
|
13
|
+
visibility: string;
|
|
14
|
+
direction: "asc" | "desc";
|
|
15
|
+
}
|
|
16
|
+
export interface ConfigField {
|
|
17
|
+
id: string;
|
|
18
|
+
field: string;
|
|
19
|
+
importance: number;
|
|
20
|
+
searchType: "always_search" | "search_page" | "instant_search";
|
|
21
|
+
}
|
|
22
|
+
export interface ConfigFilter {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
pageSize: number;
|
|
27
|
+
defaultSort: string;
|
|
28
|
+
paginationType: "pagination" | "load_more" | "next_prev" | "infinite_scroll";
|
|
29
|
+
options: ConfigFilterOption[];
|
|
30
|
+
inventoryVisibility: "show_all" | "hide_products" | "hide_variants" | "hide_all";
|
|
31
|
+
}
|
|
32
|
+
export interface ConfigFilterOption {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
field: string;
|
|
36
|
+
position: number;
|
|
37
|
+
displaySize: string;
|
|
38
|
+
displaySliderStep: string;
|
|
39
|
+
displaySliderInterval: string;
|
|
40
|
+
displayView: ConfigFilterOptionDisplayView;
|
|
41
|
+
displayType: ConfigFilterOptionDisplayType;
|
|
42
|
+
settingsShowMore: boolean;
|
|
43
|
+
settingsUppercase: boolean;
|
|
44
|
+
settingsShowFilter: boolean;
|
|
45
|
+
settingsShowSearch: boolean;
|
|
46
|
+
settingsHideUnavailable: boolean;
|
|
47
|
+
settingsCollapsedMobile: boolean;
|
|
48
|
+
settingsCollapsedDesktop: boolean;
|
|
49
|
+
valuesShow: string;
|
|
50
|
+
valuesExclude: string[];
|
|
51
|
+
valuesManual: string[];
|
|
52
|
+
}
|
|
53
|
+
export declare type ConfigFilterOptionDisplayView = "list" | "check" | "box" | "swatch";
|
|
54
|
+
export declare type ConfigFilterOptionDisplayType = "multi" | "single" | "range" | "slider";
|
|
55
|
+
export interface ConfigCuration {
|
|
56
|
+
id: string;
|
|
57
|
+
title: string;
|
|
58
|
+
status: string;
|
|
59
|
+
published: boolean;
|
|
60
|
+
searchTerm?: string;
|
|
61
|
+
collectionHandle?: string;
|
|
62
|
+
type: "collection" | "search";
|
|
63
|
+
boosting: {
|
|
64
|
+
groupings: ConfigBoostGrouping[];
|
|
65
|
+
sortings: ConfigBoostSorting[];
|
|
66
|
+
};
|
|
67
|
+
callouts?: ConfigCallout[];
|
|
68
|
+
}
|
|
69
|
+
export interface ConfigBoostGrouping {
|
|
70
|
+
key: string;
|
|
71
|
+
value: string;
|
|
72
|
+
field: string;
|
|
73
|
+
query: string;
|
|
74
|
+
position: number;
|
|
75
|
+
operation: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ConfigBoostSorting {
|
|
78
|
+
key: string;
|
|
79
|
+
field: string;
|
|
80
|
+
query: string;
|
|
81
|
+
position: number;
|
|
82
|
+
direction: string;
|
|
83
|
+
}
|
|
84
|
+
export interface ConfigCallout {
|
|
85
|
+
id: string;
|
|
86
|
+
link: string;
|
|
87
|
+
title: string;
|
|
88
|
+
type: "callout";
|
|
89
|
+
content: string;
|
|
90
|
+
position: number;
|
|
91
|
+
textColor: string;
|
|
92
|
+
mobileImage: string;
|
|
93
|
+
mobileVideo: string;
|
|
94
|
+
desktopVideo: string;
|
|
95
|
+
desktopImage: string;
|
|
96
|
+
backgroundColor: string;
|
|
97
|
+
visibility: "desktop" | "mobile" | "all";
|
|
98
|
+
displayColumns: string;
|
|
99
|
+
displayRows: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ConfigRedirect {
|
|
102
|
+
id: string;
|
|
103
|
+
url: string;
|
|
104
|
+
query: string;
|
|
105
|
+
}
|
|
106
|
+
export interface ConfigCredentials {
|
|
107
|
+
username: string;
|
|
108
|
+
password: string;
|
|
109
|
+
endpoint: string;
|
|
110
|
+
}
|
|
111
|
+
interface ConfigThemeTypography {
|
|
112
|
+
fontFamily?: string;
|
|
113
|
+
fontSize?: string;
|
|
114
|
+
}
|
|
115
|
+
interface ConfigThemeColors {
|
|
116
|
+
alertColor?: string;
|
|
117
|
+
backgroundColor?: string;
|
|
118
|
+
borderColor?: string;
|
|
119
|
+
extColor?: string;
|
|
120
|
+
primaryTextColor?: string;
|
|
121
|
+
primaryColor?: string;
|
|
122
|
+
textColor?: string;
|
|
123
|
+
titleColor?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface ConfigTheme {
|
|
126
|
+
typography?: ConfigThemeTypography;
|
|
127
|
+
colors?: ConfigThemeColors;
|
|
128
|
+
component?: any;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export * from "./config";
|
|
2
|
+
export * from "./results";
|
|
3
|
+
import { Hit, Product } from "./results";
|
|
4
|
+
export interface ReactivesearchFilterProps {
|
|
5
|
+
loading: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
handleChange: () => void;
|
|
8
|
+
data: {
|
|
9
|
+
doc_count: number;
|
|
10
|
+
key: string;
|
|
11
|
+
}[];
|
|
12
|
+
value: string | {
|
|
13
|
+
[key: string]: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface ReactivesearchPaginationProps {
|
|
17
|
+
pages: number;
|
|
18
|
+
showEndPage: false;
|
|
19
|
+
totalPages: number;
|
|
20
|
+
currentPage: number;
|
|
21
|
+
setPage: (page: number) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface ReactivesearchResultProps<T = Product> {
|
|
24
|
+
error?: ReactivesearchError;
|
|
25
|
+
loading: boolean;
|
|
26
|
+
data: (Hit & T)[];
|
|
27
|
+
loadMore: () => void;
|
|
28
|
+
customData: unknown;
|
|
29
|
+
promotedData: unknown;
|
|
30
|
+
aggregationData: unknown;
|
|
31
|
+
rawData?: {
|
|
32
|
+
_shards: {
|
|
33
|
+
failed: number;
|
|
34
|
+
skipped: number;
|
|
35
|
+
successful: number;
|
|
36
|
+
total: number;
|
|
37
|
+
};
|
|
38
|
+
took: number;
|
|
39
|
+
status: number;
|
|
40
|
+
timed_out: boolean;
|
|
41
|
+
hits: Hit & {
|
|
42
|
+
_source: T;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
resultStats: {
|
|
46
|
+
time: number;
|
|
47
|
+
hidden: number;
|
|
48
|
+
promoted: number;
|
|
49
|
+
currentPage: number;
|
|
50
|
+
numberOfPages: number;
|
|
51
|
+
numberOfResults?: number;
|
|
52
|
+
displayedResults: number;
|
|
53
|
+
};
|
|
54
|
+
streamData: unknown;
|
|
55
|
+
triggerAnalytics: unknown;
|
|
56
|
+
triggerClickAnalytics: unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface ReactivesearchSearchStatePage {
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
hits: {
|
|
61
|
+
hidden: number;
|
|
62
|
+
time: number;
|
|
63
|
+
total: number;
|
|
64
|
+
hits: Hit & {
|
|
65
|
+
_source: Product;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
resultStats: {
|
|
69
|
+
hidden: number;
|
|
70
|
+
numberOfResults?: number;
|
|
71
|
+
promoted: number;
|
|
72
|
+
time: number;
|
|
73
|
+
};
|
|
74
|
+
error?: ReactivesearchError;
|
|
75
|
+
}
|
|
76
|
+
export interface ReactivesearchError {
|
|
77
|
+
status: number;
|
|
78
|
+
statusText: string;
|
|
79
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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("./config"), exports);
|
|
14
|
+
__exportStar(require("./results"), exports);
|