@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.
- package/CHANGELOG.md +7 -0
- package/dist/package.json +66 -0
- package/dist/src/components/Example/ExampleFilterList.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterList.js +19 -0
- package/dist/src/components/Example/ExampleFilterRange.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterRange.js +21 -0
- package/dist/src/components/Example/ExampleFilterSlider.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterSlider.js +20 -0
- package/dist/src/components/Example/ExampleFilterStack.d.ts +4 -0
- package/dist/src/components/Example/ExampleFilterStack.js +12 -0
- package/dist/src/components/Example/ExampleResultCardCallout.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultCardCallout.js +21 -0
- package/dist/src/components/Example/ExampleResultCardProduct.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultCardProduct.js +18 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationLoadMore.js +11 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationNextPrev.js +13 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.d.ts +4 -0
- package/dist/src/components/Example/ExampleResultPaginationNumbered.js +26 -0
- package/dist/src/components/Example/ExampleSortby.d.ts +4 -0
- package/dist/src/components/Example/ExampleSortby.js +12 -0
- package/dist/src/components/Example/index.d.ts +10 -0
- package/dist/src/components/Example/index.js +22 -0
- package/dist/src/components/Filter/Filter.d.ts +20 -0
- package/dist/src/components/Filter/Filter.js +89 -0
- package/dist/src/components/Filter/FilterStack.d.ts +7 -0
- package/dist/src/components/Filter/FilterStack.js +16 -0
- package/dist/src/components/Filter/index.d.ts +2 -0
- package/dist/src/components/Filter/index.js +14 -0
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.d.ts +42 -0
- package/dist/src/components/ReactifySearchBase/ReactifySearchBase.js +140 -0
- package/dist/src/components/ReactifySearchBase/index.d.ts +1 -0
- package/dist/src/components/ReactifySearchBase/index.js +13 -0
- package/dist/src/components/Result/ResultCardCallout.d.ts +12 -0
- package/dist/src/components/Result/ResultCardCallout.js +46 -0
- package/dist/src/components/Result/ResultCardProduct.d.ts +13 -0
- package/dist/src/components/Result/ResultCardProduct.js +63 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationLoadMore.js +16 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationNextPrev.js +16 -0
- package/dist/src/components/Result/ResultPaginationNumbered.d.ts +7 -0
- package/dist/src/components/Result/ResultPaginationNumbered.js +19 -0
- package/dist/src/components/Result/ResultStack.d.ts +40 -0
- package/dist/src/components/Result/ResultStack.js +107 -0
- package/dist/src/components/Result/ResultStateProvider.d.ts +6 -0
- package/dist/src/components/Result/ResultStateProvider.js +10 -0
- package/dist/src/components/Result/index.d.ts +7 -0
- package/dist/src/components/Result/index.js +19 -0
- package/dist/src/components/Search/SearchInput.d.ts +8 -0
- package/dist/src/components/Search/SearchInput.js +17 -0
- package/dist/src/components/Search/index.d.ts +1 -0
- package/dist/src/components/Search/index.js +13 -0
- package/dist/src/components/Sensor/SensorCollection.d.ts +2 -0
- package/dist/src/components/Sensor/SensorCollection.js +44 -0
- package/dist/src/components/Sensor/SensorInventoryAvailable.d.ts +2 -0
- package/dist/src/components/Sensor/SensorInventoryAvailable.js +52 -0
- package/dist/src/components/Sensor/SensorPublished.d.ts +2 -0
- package/dist/src/components/Sensor/SensorPublished.js +16 -0
- package/dist/src/components/Sensor/SensorSearch.d.ts +2 -0
- package/dist/src/components/Sensor/SensorSearch.js +82 -0
- package/dist/src/components/Sensor/SensorSort.d.ts +2 -0
- package/dist/src/components/Sensor/SensorSort.js +204 -0
- package/dist/src/components/Sensor/SensorSortScore.d.ts +2 -0
- package/dist/src/components/Sensor/SensorSortScore.js +12 -0
- package/dist/src/components/Sensor/SensorStack.d.ts +3 -0
- package/dist/src/components/Sensor/SensorStack.js +31 -0
- package/dist/src/components/Sensor/index.d.ts +8 -0
- package/dist/src/components/Sensor/index.js +29 -0
- package/dist/src/components/Sortby/Sortby.d.ts +7 -0
- package/dist/src/components/Sortby/Sortby.js +16 -0
- package/dist/src/components/Sortby/index.d.ts +1 -0
- package/dist/src/components/Sortby/index.js +13 -0
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.d.ts +2 -0
- package/dist/src/components/Utility/UtilityAuthenticatedReactiveBase.js +14 -0
- package/dist/src/components/Utility/index.d.ts +1 -0
- package/dist/src/components/Utility/index.js +13 -0
- package/dist/src/components/index.d.ts +8 -0
- package/dist/src/components/index.js +20 -0
- package/dist/src/hooks/index.d.ts +14 -0
- package/dist/src/hooks/index.js +26 -0
- package/dist/src/hooks/reactivesearch/index.d.ts +8 -0
- package/dist/src/hooks/reactivesearch/index.js +20 -0
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.d.ts +7 -0
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +43 -0
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.d.ts +26 -0
- package/dist/src/hooks/reactivesearch/useReactiveDataSearchProps.js +70 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +73 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +21 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +70 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +21 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +67 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +105 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +68 -0
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +21 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +3 -0
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +25 -0
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.d.ts +17 -0
- package/dist/src/hooks/reactivesearch/useReactiveResultStackProps.js +31 -0
- package/dist/src/hooks/useAnalytics.d.ts +95 -0
- package/dist/src/hooks/useAnalytics.js +110 -0
- package/dist/src/hooks/useConfig.d.ts +4 -0
- package/dist/src/hooks/useConfig.js +81 -0
- package/dist/src/hooks/useCuration.d.ts +2 -0
- package/dist/src/hooks/useCuration.js +52 -0
- package/dist/src/hooks/useFilterCollapsedState.d.ts +8 -0
- package/dist/src/hooks/useFilterCollapsedState.js +27 -0
- package/dist/src/hooks/useFilterListProps.d.ts +12 -0
- package/dist/src/hooks/useFilterListProps.js +35 -0
- package/dist/src/hooks/useFilterStack.d.ts +2 -0
- package/dist/src/hooks/useFilterStack.js +46 -0
- package/dist/src/hooks/useFilters.d.ts +4 -0
- package/dist/src/hooks/useFilters.js +22 -0
- package/dist/src/hooks/usePagination.d.ts +14 -0
- package/dist/src/hooks/usePagination.js +97 -0
- package/dist/src/hooks/usePaginationLoadMore.d.ts +15 -0
- package/dist/src/hooks/usePaginationLoadMore.js +37 -0
- package/dist/src/hooks/useProductPrice.d.ts +10 -0
- package/dist/src/hooks/useProductPrice.js +63 -0
- package/dist/src/hooks/useReactifySearchContext.d.ts +78 -0
- package/dist/src/hooks/useReactifySearchContext.js +10 -0
- package/dist/src/hooks/useSearch.d.ts +8 -0
- package/dist/src/hooks/useSearch.js +36 -0
- package/dist/src/hooks/useSortby.d.ts +6 -0
- package/dist/src/hooks/useSortby.js +41 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +18 -0
- package/dist/src/types/config.d.ts +26 -0
- package/dist/src/types/config.js +2 -0
- package/dist/src/types/elastic.d.ts +209 -0
- package/dist/src/types/elastic.js +18 -0
- package/dist/src/types/firestore.d.ts +280 -0
- package/dist/src/types/firestore.js +18 -0
- package/dist/src/types/graphql.d.ts +26545 -0
- package/dist/src/types/graphql.js +4687 -0
- package/dist/src/types/index.d.ts +3 -0
- package/dist/src/types/index.js +15 -0
- package/dist/src/types/reactivesearch.d.ts +73 -0
- package/dist/src/types/reactivesearch.js +2 -0
- package/dist/src/types/shopify.d.ts +21 -0
- package/dist/src/types/shopify.js +27 -0
- package/package.json +3 -2
|
@@ -0,0 +1,26 @@
|
|
|
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);
|
|
@@ -0,0 +1,8 @@
|
|
|
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";
|
|
@@ -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("./useReactiveBaseProps"), exports);
|
|
14
|
+
__exportStar(require("./useReactiveReactProp"), exports);
|
|
15
|
+
__exportStar(require("./useReactiveFilterListProps"), exports);
|
|
16
|
+
__exportStar(require("./useReactiveFilterRangeProps"), exports);
|
|
17
|
+
__exportStar(require("./useReactiveFilterSliderProps"), exports);
|
|
18
|
+
__exportStar(require("./useReactiveFilterSharedProps"), exports);
|
|
19
|
+
__exportStar(require("./useReactiveResultStackProps"), exports);
|
|
20
|
+
__exportStar(require("./useReactiveDataSearchProps"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useReactiveBaseProps = void 0;
|
|
16
|
+
const react_1 = __importDefault(require("react"));
|
|
17
|
+
const hooks_1 = require("../../hooks");
|
|
18
|
+
const useReactiveBaseProps = () => {
|
|
19
|
+
const { options } = (0, hooks_1.useReactifySearchContext)();
|
|
20
|
+
return react_1.default.useMemo(() => ({
|
|
21
|
+
app: options.index,
|
|
22
|
+
url: options.credentials.endpoint,
|
|
23
|
+
credentials: `${options.credentials.username}:${options.credentials.password}`,
|
|
24
|
+
theme: options.theme,
|
|
25
|
+
transformResponse: (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
|
+
// support filtering inside nested aggregations by moving the inner aggregation
|
|
28
|
+
// up one level such that reactivesearch understands it
|
|
29
|
+
//
|
|
30
|
+
// see useReactiveFilterListProps > defaultQuery to see how a filter is being applied
|
|
31
|
+
// to variant aggregations to ensure that only in stock sizes are displayed as filter
|
|
32
|
+
// options, this involves a nested filter, which requires this fix
|
|
33
|
+
//
|
|
34
|
+
// https://github.com/appbaseio/reactivesearch/issues/1530
|
|
35
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.aggregations) === null || _a === void 0 ? void 0 : _a.reactivesearch_nested) === null || _b === void 0 ? void 0 : _b.reactify_nested_outer) {
|
|
36
|
+
response.aggregations.reactivesearch_nested =
|
|
37
|
+
(_d = (_c = response === null || response === void 0 ? void 0 : response.aggregations) === null || _c === void 0 ? void 0 : _c.reactivesearch_nested) === null || _d === void 0 ? void 0 : _d.reactify_nested_outer;
|
|
38
|
+
}
|
|
39
|
+
return response;
|
|
40
|
+
}),
|
|
41
|
+
}), [options.credentials, options.theme]);
|
|
42
|
+
};
|
|
43
|
+
exports.useReactiveBaseProps = useReactiveBaseProps;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const useReactiveDataSearchProps: (options: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
debounce?: number | undefined;
|
|
4
|
+
placeholder?: string | undefined;
|
|
5
|
+
inputClassName?: string | undefined;
|
|
6
|
+
}) => {
|
|
7
|
+
debounce?: number | undefined;
|
|
8
|
+
placeholder: string;
|
|
9
|
+
inputClassName?: string | undefined;
|
|
10
|
+
type: string;
|
|
11
|
+
showIcon: boolean;
|
|
12
|
+
fuzziness: 0 | 1 | 2 | "AUTO";
|
|
13
|
+
queryFormat: "and" | "or";
|
|
14
|
+
autosuggest: boolean;
|
|
15
|
+
value: string;
|
|
16
|
+
onKeyUp: (e: any) => void;
|
|
17
|
+
componentId: string;
|
|
18
|
+
dataField: string[];
|
|
19
|
+
fieldWeights: number[];
|
|
20
|
+
onChange: (value: string, triggerQuery: () => {}) => void;
|
|
21
|
+
onBlur: () => void;
|
|
22
|
+
onFocus: () => void;
|
|
23
|
+
innerClass: {
|
|
24
|
+
input: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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.useReactiveDataSearchProps = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const ahooks_1 = require("ahooks");
|
|
9
|
+
const debug = require("debug")("reactify-search:useReactiveDataSearchProps");
|
|
10
|
+
const hooks_1 = require("../../hooks");
|
|
11
|
+
// default field for when zero search fields have been configured in Reactify
|
|
12
|
+
const defaultSearchField = {
|
|
13
|
+
id: "title",
|
|
14
|
+
field: "title",
|
|
15
|
+
importance: 0,
|
|
16
|
+
searchType: "instant_search",
|
|
17
|
+
};
|
|
18
|
+
const useReactiveDataSearchProps = (options) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const { config } = (0, hooks_1.useReactifySearchContext)();
|
|
21
|
+
const { searchQuery, submitSearch, setSearchQuery, setShowInstantSearchResults, } = (0, hooks_1.useSearch)();
|
|
22
|
+
const searchFields = react_1.default.useMemo(() => 0 < config.fields.length
|
|
23
|
+
? config.fields.filter((field) => ["always_search", "instant_search"].includes(field.searchType))
|
|
24
|
+
: [defaultSearchField], []);
|
|
25
|
+
const handleKeyPress = react_1.default.useCallback((e) => {
|
|
26
|
+
if ("Enter" !== e.key)
|
|
27
|
+
return;
|
|
28
|
+
submitSearch();
|
|
29
|
+
}, [submitSearch]);
|
|
30
|
+
const { track } = (0, hooks_1.useAnalytics)();
|
|
31
|
+
const trackQuery = react_1.default.useCallback(() => {
|
|
32
|
+
if (!searchQuery || (searchQuery && searchQuery.length < 3))
|
|
33
|
+
return;
|
|
34
|
+
track({ eventName: "search", payload: { searchTerm: searchQuery } });
|
|
35
|
+
}, [searchQuery, track]);
|
|
36
|
+
const { run: runDebouncedTriggerQuery, cancel: cancelDebouncedTriggerQuery } = (0, ahooks_1.useDebounceFn)((triggerQuery) => {
|
|
37
|
+
triggerQuery();
|
|
38
|
+
trackQuery();
|
|
39
|
+
}, {
|
|
40
|
+
wait: (_a = options.debounce) !== null && _a !== void 0 ? _a : 300,
|
|
41
|
+
});
|
|
42
|
+
return react_1.default.useMemo(() => {
|
|
43
|
+
var _a;
|
|
44
|
+
return (Object.assign({ type: "search", showIcon: false, fuzziness: 1, queryFormat: "and", autosuggest: false, value: searchQuery !== null && searchQuery !== void 0 ? searchQuery : "", onKeyUp: handleKeyPress, componentId: "SearchInput", placeholder: (_a = options.placeholder) !== null && _a !== void 0 ? _a : "Search for a product...", dataField: searchFields.map((field) => field.field), fieldWeights: searchFields.map((field) => field.importance), onChange: (value, triggerQuery) => {
|
|
45
|
+
setSearchQuery(value);
|
|
46
|
+
if (!!value) {
|
|
47
|
+
runDebouncedTriggerQuery(triggerQuery);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
cancelDebouncedTriggerQuery();
|
|
51
|
+
}
|
|
52
|
+
}, onBlur: () => {
|
|
53
|
+
// setTimeout ensures that results are still clickable before close
|
|
54
|
+
setTimeout(() => setShowInstantSearchResults(false), 300);
|
|
55
|
+
}, onFocus: () => {
|
|
56
|
+
setShowInstantSearchResults(true);
|
|
57
|
+
}, innerClass: {
|
|
58
|
+
input: options.inputClassName,
|
|
59
|
+
} }, options));
|
|
60
|
+
}, [
|
|
61
|
+
searchQuery,
|
|
62
|
+
handleKeyPress,
|
|
63
|
+
options.placeholder,
|
|
64
|
+
searchFields,
|
|
65
|
+
setSearchQuery,
|
|
66
|
+
runDebouncedTriggerQuery,
|
|
67
|
+
cancelDebouncedTriggerQuery,
|
|
68
|
+
]);
|
|
69
|
+
};
|
|
70
|
+
exports.useReactiveDataSearchProps = useReactiveDataSearchProps;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ConfigFilterOption } from "../../types/config";
|
|
2
|
+
/**
|
|
3
|
+
* For use with @appbaseio/reactivesearch SingleList and MultiList components
|
|
4
|
+
*/
|
|
5
|
+
export declare const useReactiveFilterListProps: (filter: ConfigFilterOption) => {
|
|
6
|
+
size: number | undefined;
|
|
7
|
+
showFilter: boolean;
|
|
8
|
+
showLoadMore: boolean;
|
|
9
|
+
showSearch: boolean;
|
|
10
|
+
showRadio: boolean;
|
|
11
|
+
showCheckbox: boolean;
|
|
12
|
+
nestedField: string | undefined;
|
|
13
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
14
|
+
query?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
query: {
|
|
17
|
+
nested: {
|
|
18
|
+
path: string;
|
|
19
|
+
query: {
|
|
20
|
+
bool: {
|
|
21
|
+
must: ({
|
|
22
|
+
match: {
|
|
23
|
+
"variants.available": string;
|
|
24
|
+
};
|
|
25
|
+
terms?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
terms: {
|
|
28
|
+
[x: string]: string[];
|
|
29
|
+
};
|
|
30
|
+
match?: undefined;
|
|
31
|
+
})[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}) | undefined;
|
|
37
|
+
defaultQuery: (() => {
|
|
38
|
+
aggs: {
|
|
39
|
+
reactivesearch_nested: {
|
|
40
|
+
nested: {
|
|
41
|
+
path: string;
|
|
42
|
+
};
|
|
43
|
+
aggs: {
|
|
44
|
+
reactify_nested_outer: {
|
|
45
|
+
filter: {
|
|
46
|
+
match: {
|
|
47
|
+
"variants.available": string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
aggs: {
|
|
51
|
+
[x: string]: {
|
|
52
|
+
terms: {
|
|
53
|
+
field: string;
|
|
54
|
+
size: number;
|
|
55
|
+
order: {
|
|
56
|
+
_count: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}) | undefined;
|
|
66
|
+
URLParams: boolean;
|
|
67
|
+
componentId: string;
|
|
68
|
+
dataField: string;
|
|
69
|
+
filterLabel: string;
|
|
70
|
+
react: {
|
|
71
|
+
and: string[];
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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.useReactiveFilterListProps = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useReactiveFilterSharedProps_1 = require("./useReactiveFilterSharedProps");
|
|
9
|
+
const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
10
|
+
/**
|
|
11
|
+
* For use with @appbaseio/reactivesearch SingleList and MultiList components
|
|
12
|
+
*/
|
|
13
|
+
const useReactiveFilterListProps = (filter) => {
|
|
14
|
+
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
15
|
+
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
16
|
+
return react_1.default.useMemo(() => {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { size: parseInt(filter.displaySize) || undefined, showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true, showLoadMore: (_b = filter.settingsShowMore) !== null && _b !== void 0 ? _b : false, showSearch: (_c = filter.settingsShowSearch) !== null && _c !== void 0 ? _c : false, showRadio: false, showCheckbox: false }));
|
|
19
|
+
}, [filter, reactiveReactProp]);
|
|
20
|
+
};
|
|
21
|
+
exports.useReactiveFilterListProps = useReactiveFilterListProps;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ConfigFilterOption } from "../../types/config";
|
|
2
|
+
/**
|
|
3
|
+
* For use with @appbaseio/reactivesearch SingleRange and MultiRange components
|
|
4
|
+
*/
|
|
5
|
+
export declare const useReactiveFilterRangeProps: (filter: ConfigFilterOption) => {
|
|
6
|
+
showFilter: boolean;
|
|
7
|
+
showRadio: boolean;
|
|
8
|
+
showCheckbox: boolean;
|
|
9
|
+
nestedField: string | undefined;
|
|
10
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
11
|
+
query?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
query: {
|
|
14
|
+
nested: {
|
|
15
|
+
path: string;
|
|
16
|
+
query: {
|
|
17
|
+
bool: {
|
|
18
|
+
must: ({
|
|
19
|
+
match: {
|
|
20
|
+
"variants.available": string;
|
|
21
|
+
};
|
|
22
|
+
terms?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
terms: {
|
|
25
|
+
[x: string]: string[];
|
|
26
|
+
};
|
|
27
|
+
match?: undefined;
|
|
28
|
+
})[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}) | undefined;
|
|
34
|
+
defaultQuery: (() => {
|
|
35
|
+
aggs: {
|
|
36
|
+
reactivesearch_nested: {
|
|
37
|
+
nested: {
|
|
38
|
+
path: string;
|
|
39
|
+
};
|
|
40
|
+
aggs: {
|
|
41
|
+
reactify_nested_outer: {
|
|
42
|
+
filter: {
|
|
43
|
+
match: {
|
|
44
|
+
"variants.available": string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
aggs: {
|
|
48
|
+
[x: string]: {
|
|
49
|
+
terms: {
|
|
50
|
+
field: string;
|
|
51
|
+
size: number;
|
|
52
|
+
order: {
|
|
53
|
+
_count: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}) | undefined;
|
|
63
|
+
URLParams: boolean;
|
|
64
|
+
componentId: string;
|
|
65
|
+
dataField: string;
|
|
66
|
+
filterLabel: string;
|
|
67
|
+
react: {
|
|
68
|
+
and: string[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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.useReactiveFilterRangeProps = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useReactiveFilterSharedProps_1 = require("./useReactiveFilterSharedProps");
|
|
9
|
+
const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
10
|
+
/**
|
|
11
|
+
* For use with @appbaseio/reactivesearch SingleRange and MultiRange components
|
|
12
|
+
*/
|
|
13
|
+
const useReactiveFilterRangeProps = (filter) => {
|
|
14
|
+
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
15
|
+
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
16
|
+
return react_1.default.useMemo(() => {
|
|
17
|
+
var _a;
|
|
18
|
+
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true, showRadio: false, showCheckbox: false }));
|
|
19
|
+
}, [filter, reactiveReactProp]);
|
|
20
|
+
};
|
|
21
|
+
exports.useReactiveFilterRangeProps = useReactiveFilterRangeProps;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ConfigFilterOption } from "../../types/config";
|
|
2
|
+
/**
|
|
3
|
+
* For use with all @appbaseio/reactivesearch filter components
|
|
4
|
+
*/
|
|
5
|
+
export declare const useReactiveFilterSharedProps: (filter: ConfigFilterOption) => {
|
|
6
|
+
nestedField: string | undefined;
|
|
7
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
8
|
+
query?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
query: {
|
|
11
|
+
nested: {
|
|
12
|
+
path: string;
|
|
13
|
+
query: {
|
|
14
|
+
bool: {
|
|
15
|
+
must: ({
|
|
16
|
+
match: {
|
|
17
|
+
"variants.available": string;
|
|
18
|
+
};
|
|
19
|
+
terms?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
terms: {
|
|
22
|
+
[x: string]: string[];
|
|
23
|
+
};
|
|
24
|
+
match?: undefined;
|
|
25
|
+
})[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}) | undefined;
|
|
31
|
+
defaultQuery: (() => {
|
|
32
|
+
aggs: {
|
|
33
|
+
reactivesearch_nested: {
|
|
34
|
+
nested: {
|
|
35
|
+
path: string;
|
|
36
|
+
};
|
|
37
|
+
aggs: {
|
|
38
|
+
reactify_nested_outer: {
|
|
39
|
+
filter: {
|
|
40
|
+
match: {
|
|
41
|
+
"variants.available": string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
aggs: {
|
|
45
|
+
[x: string]: {
|
|
46
|
+
terms: {
|
|
47
|
+
field: string;
|
|
48
|
+
size: number;
|
|
49
|
+
order: {
|
|
50
|
+
_count: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}) | undefined;
|
|
60
|
+
URLParams: boolean;
|
|
61
|
+
componentId: string;
|
|
62
|
+
dataField: string;
|
|
63
|
+
filterLabel: string;
|
|
64
|
+
react: {
|
|
65
|
+
and: string[];
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
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.useReactiveFilterSharedProps = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
9
|
+
/**
|
|
10
|
+
* For use with all @appbaseio/reactivesearch filter components
|
|
11
|
+
*/
|
|
12
|
+
const useReactiveFilterSharedProps = (filter) => {
|
|
13
|
+
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
14
|
+
const nestedField = react_1.default.useMemo(() => {
|
|
15
|
+
const nestedFields = ["variants"];
|
|
16
|
+
const topField = filter.field.split(".")[0];
|
|
17
|
+
if (nestedFields.includes(topField))
|
|
18
|
+
return topField;
|
|
19
|
+
return undefined;
|
|
20
|
+
}, [filter]);
|
|
21
|
+
// define a custom query for when settingsHideUnavailable is enabled and the target field is inside variants
|
|
22
|
+
// customQuery defines how this filter affects *other* components like the results component
|
|
23
|
+
const customQuery = react_1.default.useMemo(() => {
|
|
24
|
+
if (!filter.settingsHideUnavailable ||
|
|
25
|
+
!filter.field.startsWith("variants."))
|
|
26
|
+
return undefined;
|
|
27
|
+
return (value) => {
|
|
28
|
+
if (!value)
|
|
29
|
+
return {};
|
|
30
|
+
// reactivesearch sometimes returns string, sometimes string[]
|
|
31
|
+
const valueArray = "string" === typeof value ? [value] : value;
|
|
32
|
+
if (0 === valueArray.length)
|
|
33
|
+
return {};
|
|
34
|
+
return {
|
|
35
|
+
query: {
|
|
36
|
+
nested: {
|
|
37
|
+
path: "variants",
|
|
38
|
+
query: {
|
|
39
|
+
bool: {
|
|
40
|
+
must: [
|
|
41
|
+
{
|
|
42
|
+
match: {
|
|
43
|
+
"variants.available": "true",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
terms: {
|
|
48
|
+
[filter.field]: valueArray,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}, [filter]);
|
|
59
|
+
// define a default query for when settingsHideUnavailable is enabled and the target field is inside variants
|
|
60
|
+
// defaultQuery defines how this filter affects itself i.e. the options displayed
|
|
61
|
+
const defaultQuery = react_1.default.useMemo(() => {
|
|
62
|
+
if (!filter.settingsHideUnavailable ||
|
|
63
|
+
!filter.field.startsWith("variants."))
|
|
64
|
+
return undefined;
|
|
65
|
+
// override the aggregation query to filter the results by the variants.available attribute
|
|
66
|
+
return () => {
|
|
67
|
+
return {
|
|
68
|
+
aggs: {
|
|
69
|
+
reactivesearch_nested: {
|
|
70
|
+
nested: { path: "variants" },
|
|
71
|
+
aggs: {
|
|
72
|
+
reactify_nested_outer: {
|
|
73
|
+
filter: {
|
|
74
|
+
match: {
|
|
75
|
+
"variants.available": "true",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
aggs: {
|
|
79
|
+
[filter.field]: {
|
|
80
|
+
terms: {
|
|
81
|
+
field: filter.field,
|
|
82
|
+
size: 100,
|
|
83
|
+
order: { _count: "desc" },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}, [filter]);
|
|
94
|
+
return react_1.default.useMemo(() => ({
|
|
95
|
+
nestedField,
|
|
96
|
+
customQuery,
|
|
97
|
+
defaultQuery,
|
|
98
|
+
URLParams: true,
|
|
99
|
+
componentId: filter.handle,
|
|
100
|
+
dataField: filter.field,
|
|
101
|
+
filterLabel: filter.name,
|
|
102
|
+
react: reactiveReactProp,
|
|
103
|
+
}), [filter, reactiveReactProp]);
|
|
104
|
+
};
|
|
105
|
+
exports.useReactiveFilterSharedProps = useReactiveFilterSharedProps;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ConfigFilterOption } from "../../types/config";
|
|
2
|
+
/**
|
|
3
|
+
* For use with @appbaseio/reactivesearch RangeSlider component
|
|
4
|
+
*/
|
|
5
|
+
export declare const useReactiveFilterSliderProps: (filter: ConfigFilterOption) => {
|
|
6
|
+
showFilter: boolean;
|
|
7
|
+
nestedField: string | undefined;
|
|
8
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
9
|
+
query?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
query: {
|
|
12
|
+
nested: {
|
|
13
|
+
path: string;
|
|
14
|
+
query: {
|
|
15
|
+
bool: {
|
|
16
|
+
must: ({
|
|
17
|
+
match: {
|
|
18
|
+
"variants.available": string;
|
|
19
|
+
};
|
|
20
|
+
terms?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
terms: {
|
|
23
|
+
[x: string]: string[];
|
|
24
|
+
};
|
|
25
|
+
match?: undefined;
|
|
26
|
+
})[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}) | undefined;
|
|
32
|
+
defaultQuery: (() => {
|
|
33
|
+
aggs: {
|
|
34
|
+
reactivesearch_nested: {
|
|
35
|
+
nested: {
|
|
36
|
+
path: string;
|
|
37
|
+
};
|
|
38
|
+
aggs: {
|
|
39
|
+
reactify_nested_outer: {
|
|
40
|
+
filter: {
|
|
41
|
+
match: {
|
|
42
|
+
"variants.available": string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
aggs: {
|
|
46
|
+
[x: string]: {
|
|
47
|
+
terms: {
|
|
48
|
+
field: string;
|
|
49
|
+
size: number;
|
|
50
|
+
order: {
|
|
51
|
+
_count: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}) | undefined;
|
|
61
|
+
URLParams: boolean;
|
|
62
|
+
componentId: string;
|
|
63
|
+
dataField: string;
|
|
64
|
+
filterLabel: string;
|
|
65
|
+
react: {
|
|
66
|
+
and: string[];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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.useReactiveFilterSliderProps = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useReactiveFilterSharedProps_1 = require("./useReactiveFilterSharedProps");
|
|
9
|
+
const useReactiveReactProp_1 = require("./useReactiveReactProp");
|
|
10
|
+
/**
|
|
11
|
+
* For use with @appbaseio/reactivesearch RangeSlider component
|
|
12
|
+
*/
|
|
13
|
+
const useReactiveFilterSliderProps = (filter) => {
|
|
14
|
+
const reactiveReactProp = (0, useReactiveReactProp_1.useReactiveReactProp)(filter.handle);
|
|
15
|
+
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
16
|
+
return react_1.default.useMemo(() => {
|
|
17
|
+
var _a;
|
|
18
|
+
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { showFilter: (_a = filter.settingsShowFilter) !== null && _a !== void 0 ? _a : true }));
|
|
19
|
+
}, [filter, reactiveReactProp]);
|
|
20
|
+
};
|
|
21
|
+
exports.useReactiveFilterSliderProps = useReactiveFilterSliderProps;
|