@usereactify/search 3.12.0-beta.2 → 3.12.0-beta.3
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/dist/provider.js +13 -7
- package/package.json +1 -1
package/dist/provider.js
CHANGED
|
@@ -189,29 +189,35 @@ const useSortState = (config, collection) => {
|
|
|
189
189
|
// value within it is a "Filter Option"
|
|
190
190
|
const useFilterStack = (config, collection, filterStackHandle) => react_1.default.useMemo(() => {
|
|
191
191
|
const type = !!collection ? "collection" : "search";
|
|
192
|
-
//
|
|
193
|
-
const
|
|
192
|
+
// select filters by type
|
|
193
|
+
const matchingFilterStacks = config.filters.filter((filter) => filter.type === type);
|
|
194
194
|
// select filter stack by handle if provided
|
|
195
195
|
if (filterStackHandle) {
|
|
196
|
-
const matchingFilterStack =
|
|
196
|
+
const matchingFilterStack = matchingFilterStacks.find((filterStack) => filterStackHandle === filterStack.handle);
|
|
197
197
|
if (matchingFilterStack) {
|
|
198
198
|
return matchingFilterStack;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
// select filter stack by collection if provided
|
|
202
202
|
if (collection === null || collection === void 0 ? void 0 : collection.handle) {
|
|
203
|
-
const matchingFilterStack =
|
|
203
|
+
const matchingFilterStack = matchingFilterStacks.find((filterStack) => { var _a; return (_a = filterStack.collections) === null || _a === void 0 ? void 0 : _a.includes(collection.handle); });
|
|
204
204
|
if (matchingFilterStack) {
|
|
205
205
|
return matchingFilterStack;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
// select filter with "default" handle
|
|
209
|
-
|
|
208
|
+
// select filter with "default" handle
|
|
209
|
+
let matchingFilterStack = matchingFilterStacks.find((filterStack) => filterStack.handle === "default");
|
|
210
|
+
if (matchingFilterStack) {
|
|
211
|
+
return matchingFilterStack;
|
|
212
|
+
}
|
|
213
|
+
// select any filter with "default" handle
|
|
214
|
+
matchingFilterStack = config.filters.find((filterStack) => filterStack.handle === "default");
|
|
210
215
|
if (matchingFilterStack) {
|
|
211
216
|
return matchingFilterStack;
|
|
212
217
|
}
|
|
213
218
|
// select any available filter as a last resort
|
|
214
|
-
|
|
219
|
+
matchingFilterStack = config.filters[0];
|
|
220
|
+
return matchingFilterStack;
|
|
215
221
|
}, [config, collection]);
|
|
216
222
|
const useCuration = (config, collection, searchQuery) => react_1.default.useMemo(() => {
|
|
217
223
|
debug("resolveCuration.start", { config, collection, searchQuery });
|