@usereactify/search 5.0.0-beta.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/package.json +66 -0
  3. package/dist/src/components/Example/ExampleFilterList.d.ts +4 -0
  4. package/dist/src/components/Example/ExampleFilterList.js +19 -0
  5. package/dist/src/components/Example/ExampleFilterRange.d.ts +4 -0
  6. package/dist/src/components/Example/ExampleFilterRange.js +21 -0
  7. package/dist/src/components/Example/ExampleFilterSlider.d.ts +4 -0
  8. package/dist/src/components/Example/ExampleFilterSlider.js +20 -0
  9. package/dist/src/components/Example/ExampleFilterStack.d.ts +4 -0
  10. package/dist/src/components/Example/ExampleFilterStack.js +12 -0
  11. package/dist/src/components/Example/ExampleResultCardCallout.d.ts +4 -0
  12. package/dist/src/components/Example/ExampleResultCardCallout.js +21 -0
  13. package/dist/src/components/Example/ExampleResultCardProduct.d.ts +4 -0
  14. package/dist/src/components/Example/ExampleResultCardProduct.js +18 -0
  15. package/dist/src/components/Example/ExampleResultPaginationLoadMore.d.ts +4 -0
  16. package/dist/src/components/Example/ExampleResultPaginationLoadMore.js +11 -0
  17. package/dist/src/components/Example/ExampleResultPaginationNextPrev.d.ts +4 -0
  18. package/dist/src/components/Example/ExampleResultPaginationNextPrev.js +13 -0
  19. package/dist/src/components/Example/ExampleResultPaginationNumbered.d.ts +4 -0
  20. package/dist/src/components/Example/ExampleResultPaginationNumbered.js +26 -0
  21. package/dist/src/components/Example/ExampleSortby.d.ts +4 -0
  22. package/dist/src/components/Example/ExampleSortby.js +12 -0
  23. package/dist/src/components/Example/index.d.ts +10 -0
  24. package/dist/src/components/Example/index.js +22 -0
  25. package/dist/src/components/Filter/Filter.d.ts +20 -0
  26. package/dist/src/components/Filter/Filter.js +89 -0
  27. package/dist/src/components/Filter/FilterStack.d.ts +7 -0
  28. package/dist/src/components/Filter/FilterStack.js +16 -0
  29. package/dist/src/components/Filter/index.d.ts +2 -0
  30. package/dist/src/components/Filter/index.js +14 -0
  31. package/dist/src/components/ReactifySearchBase/ReactifySearchBase.d.ts +42 -0
  32. package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js +140 -0
  33. package/dist/src/components/ReactifySearchBase/index.d.ts +1 -0
  34. package/dist/src/components/ReactifySearchBase/index.js +13 -0
  35. package/dist/src/components/Result/ResultCardCallout.d.ts +12 -0
  36. package/dist/src/components/Result/ResultCardCallout.js +46 -0
  37. package/dist/src/components/Result/ResultCardProduct.d.ts +13 -0
  38. package/dist/src/components/Result/ResultCardProduct.js +63 -0
  39. package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +7 -0
  40. package/dist/src/components/Result/ResultPaginationLoadMore.js +16 -0
  41. package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +7 -0
  42. package/dist/src/components/Result/ResultPaginationNextPrev.js +16 -0
  43. package/dist/src/components/Result/ResultPaginationNumbered.d.ts +7 -0
  44. package/dist/src/components/Result/ResultPaginationNumbered.js +19 -0
  45. package/dist/src/components/Result/ResultStack.d.ts +40 -0
  46. package/dist/src/components/Result/ResultStack.js +107 -0
  47. package/dist/src/components/Result/ResultStateProvider.d.ts +6 -0
  48. package/dist/src/components/Result/ResultStateProvider.js +10 -0
  49. package/dist/src/components/Result/index.d.ts +7 -0
  50. package/dist/src/components/Result/index.js +19 -0
  51. package/dist/src/components/Search/SearchInput.d.ts +8 -0
  52. package/dist/src/components/Search/SearchInput.js +17 -0
  53. package/dist/src/components/Search/index.d.ts +1 -0
  54. package/dist/src/components/Search/index.js +13 -0
  55. package/dist/src/components/Sensor/SensorCollection.d.ts +2 -0
  56. package/dist/src/components/Sensor/SensorCollection.js +44 -0
  57. package/dist/src/components/Sensor/SensorInventoryAvailable.d.ts +2 -0
  58. package/dist/src/components/Sensor/SensorInventoryAvailable.js +52 -0
  59. package/dist/src/components/Sensor/SensorPublished.d.ts +2 -0
  60. package/dist/src/components/Sensor/SensorPublished.js +16 -0
  61. package/dist/src/components/Sensor/SensorSearch.d.ts +2 -0
  62. package/dist/src/components/Sensor/SensorSearch.js +82 -0
  63. package/dist/src/components/Sensor/SensorSort.d.ts +2 -0
  64. package/dist/src/components/Sensor/SensorSort.js +204 -0
  65. package/dist/src/components/Sensor/SensorSortScore.d.ts +2 -0
  66. package/dist/src/components/Sensor/SensorSortScore.js +12 -0
  67. package/dist/src/components/Sensor/SensorStack.d.ts +3 -0
  68. package/dist/src/components/Sensor/SensorStack.js +31 -0
  69. package/dist/src/components/Sensor/index.d.ts +8 -0
  70. package/dist/src/components/Sensor/index.js +29 -0
  71. package/dist/src/components/Sortby/Sortby.d.ts +7 -0
  72. package/dist/src/components/Sortby/Sortby.js +16 -0
  73. package/dist/src/components/Sortby/index.d.ts +1 -0
  74. package/dist/src/components/Sortby/index.js +13 -0
  75. package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.d.ts +2 -0
  76. package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js +14 -0
  77. package/dist/src/components/Utility/index.d.ts +1 -0
  78. package/dist/src/components/Utility/index.js +13 -0
  79. package/dist/src/components/index.d.ts +8 -0
  80. package/dist/src/components/index.js +20 -0
  81. package/dist/src/hooks/index.d.ts +14 -0
  82. package/dist/src/hooks/index.js +26 -0
  83. package/dist/src/hooks/reactivesearch/index.d.ts +8 -0
  84. package/dist/src/hooks/reactivesearch/index.js +20 -0
  85. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +7 -0
  86. package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +43 -0
  87. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +26 -0
  88. package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +70 -0
  89. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +73 -0
  90. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +21 -0
  91. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +70 -0
  92. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +21 -0
  93. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +67 -0
  94. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +105 -0
  95. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +68 -0
  96. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +21 -0
  97. package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +3 -0
  98. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +25 -0
  99. package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.d.ts +17 -0
  100. package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js +31 -0
  101. package/dist/src/hooks/useAnalytics.d.ts +95 -0
  102. package/dist/src/hooks/useAnalytics.js +110 -0
  103. package/dist/src/hooks/useConfig.d.ts +4 -0
  104. package/dist/src/hooks/useConfig.js +81 -0
  105. package/dist/src/hooks/useCuration.d.ts +2 -0
  106. package/dist/src/hooks/useCuration.js +52 -0
  107. package/dist/src/hooks/useFilterCollapsedState.d.ts +8 -0
  108. package/dist/src/hooks/useFilterCollapsedState.js +27 -0
  109. package/dist/src/hooks/useFilterListProps.d.ts +12 -0
  110. package/dist/src/hooks/useFilterListProps.js +35 -0
  111. package/dist/src/hooks/useFilterStack.d.ts +2 -0
  112. package/dist/src/hooks/useFilterStack.js +46 -0
  113. package/dist/src/hooks/useFilters.d.ts +4 -0
  114. package/dist/src/hooks/useFilters.js +22 -0
  115. package/dist/src/hooks/usePagination.d.ts +14 -0
  116. package/dist/src/hooks/usePagination.js +97 -0
  117. package/dist/src/hooks/usePaginationLoadMore.d.ts +15 -0
  118. package/dist/src/hooks/usePaginationLoadMore.js +37 -0
  119. package/dist/src/hooks/useProductPrice.d.ts +10 -0
  120. package/dist/src/hooks/useProductPrice.js +63 -0
  121. package/dist/src/hooks/useReactifySearchContext.d.ts +78 -0
  122. package/dist/src/hooks/useReactifySearchContext.js +10 -0
  123. package/dist/src/hooks/useSearch.d.ts +8 -0
  124. package/dist/src/hooks/useSearch.js +36 -0
  125. package/dist/src/hooks/useSortby.d.ts +6 -0
  126. package/dist/src/hooks/useSortby.js +41 -0
  127. package/dist/src/index.d.ts +3 -0
  128. package/dist/src/index.js +18 -0
  129. package/dist/src/types/config.d.ts +26 -0
  130. package/dist/src/types/config.js +2 -0
  131. package/dist/src/types/elastic.d.ts +209 -0
  132. package/dist/src/types/elastic.js +18 -0
  133. package/dist/src/types/firestore.d.ts +280 -0
  134. package/dist/src/types/firestore.js +18 -0
  135. package/dist/src/types/graphql.d.ts +26545 -0
  136. package/dist/src/types/graphql.js +4687 -0
  137. package/dist/src/types/index.d.ts +3 -0
  138. package/dist/src/types/index.js +15 -0
  139. package/dist/src/types/reactivesearch.d.ts +73 -0
  140. package/dist/src/types/reactivesearch.js +2 -0
  141. package/dist/src/types/shopify.d.ts +21 -0
  142. package/dist/src/types/shopify.js +27 -0
  143. package/package.json +3 -2
@@ -0,0 +1,44 @@
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;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const SensorInventoryAvailable: React.FC;
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const SensorPublished: React.FC;
@@ -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,2 @@
1
+ import React from "react";
2
+ export declare const SensorSearch: React.FC;
@@ -0,0 +1,82 @@
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;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const SensorSort: React.FC;
@@ -0,0 +1,204 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const SensorSortScore: React.FC;
@@ -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,3 @@
1
+ import React from "react";
2
+ export declare type SensorStackProps = {};
3
+ export declare const SensorStack: React.FC<SensorStackProps>;
@@ -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 { 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;
@@ -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,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);
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const UtilityAuthenticatedReactiveBase: React.FC;
@@ -0,0 +1,14 @@
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;
@@ -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,8 @@
1
+ export * from "./Example";
2
+ export * from "./Filter";
3
+ export * from "./ReactifySearchBase";
4
+ export * from "./Result";
5
+ export * from "./Search";
6
+ export * from "./Sensor";
7
+ export * from "./Sortby";
8
+ export * from "./Utility";
@@ -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);
@@ -0,0 +1,14 @@
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";