@usereactify/search 5.47.1 → 5.48.0-beta.0
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 +14 -0
- package/dist/package.json +1 -1
- package/dist/src/components/Filter/Filter.js +45 -10
- package/dist/src/components/Filter/Filter.js.map +1 -1
- package/dist/src/components/Result/Results.d.ts +0 -2
- package/dist/src/components/Result/Results.js +9 -21
- package/dist/src/components/Result/Results.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollection.js +8 -80
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
- package/dist/src/components/Sensor/SensorCustom.js +6 -2
- package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
- package/dist/src/components/Sensor/SensorInventoryAvailable.js +8 -44
- package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
- package/dist/src/components/Sensor/SensorPublished.js +7 -27
- package/dist/src/components/Sensor/SensorPublished.js.map +1 -1
- package/dist/src/components/Sensor/SensorSort.js +10 -203
- package/dist/src/components/Sensor/SensorSort.js.map +1 -1
- package/dist/src/hooks/reactivesearch/index.d.ts +0 -6
- package/dist/src/hooks/reactivesearch/index.js +0 -6
- package/dist/src/hooks/reactivesearch/index.js.map +1 -1
- package/dist/src/hooks/usePagination.js +1 -1
- package/dist/src/hooks/usePagination.js.map +1 -1
- package/dist/src/hooks/useSortBy.js +14 -17
- package/dist/src/hooks/useSortBy.js.map +1 -1
- package/dist/src/utility/curation.d.ts +7 -0
- package/dist/src/utility/curation.js +85 -0
- package/dist/src/utility/curation.js.map +1 -0
- package/dist/src/utility/filters.d.ts +6 -0
- package/dist/src/utility/filters.js +36 -0
- package/dist/src/utility/filters.js.map +1 -0
- package/dist/src/utility/props.d.ts +143 -10
- package/dist/src/utility/props.js +241 -25
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/server.js +1 -1
- package/dist/src/utility/server.js.map +1 -1
- package/dist/src/utility/sortOption.d.ts +22 -0
- package/dist/src/utility/sortOption.js +198 -0
- package/dist/src/utility/sortOption.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -84
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +0 -21
- package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +0 -86
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +0 -32
- package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +0 -77
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +0 -124
- package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +0 -83
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +0 -28
- package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -4
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +0 -32
- package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +0 -1
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +0 -6
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js +0 -38
- package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/utility/server.
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/utility/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,kFAAsE;AAEtE,qCAAqC;AACrC,mCAA8C;AAIvC,MAAM,qBAAqB,GAAG,CAAO,OAAoC,EAAwC,EAAE;IACxH,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAAC;QAChC,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/B,CAAC,CAAC;IAEH,uCACK,OAAO,KACV,OAAO,EAAE;YACP,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM,IAAA,gBAAkB,EAAC,KAAK,EAAE,IAAI,EAAE;gBAC3C,GAAG,EAAE,MAAM,CAAC,KAAK;gBACjB,GAAG,EAAE,MAAM,CAAC,QAAQ;aACrB,CAAC;SACH,IACF;AACH,CAAC,CAAA,CAAA;AAlBY,QAAA,qBAAqB,yBAkBjC","sourcesContent":["// @ts-expect-error missing types\nimport initReactivesearch from \"@appbaseio/reactivesearch/lib/server\";\n\nimport { getConfig } from \"./config\";\nimport { getPropsFilterGroup } from \"./props\";\nimport { ReactifySearchProviderProps } from \"../components\";\n\n\nexport const generateProviderProps = async (options: ReactifySearchProviderProps): Promise<ReactifySearchProviderProps> => {\n const config = await getConfig(options.shopifyPermanentDomain);\n const props = getPropsFilterGroup({\n provider: options,\n config: config,\n filterGroup: config.filters[0],\n });\n\n return {\n ...options,\n preload: {\n config: config,\n state: await initReactivesearch(props, null, {\n app: config.index,\n url: config.endpoint,\n }),\n }\n }\n}"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactifySearchProviderProps } from "../components";
|
|
2
|
+
import { Config, ConfigCuration, ConfigSort } from "../types";
|
|
3
|
+
export declare const getSortOptions: (options: {
|
|
4
|
+
provider: ReactifySearchProviderProps;
|
|
5
|
+
config: Config;
|
|
6
|
+
sortOption?: string;
|
|
7
|
+
}) => ConfigSort[];
|
|
8
|
+
export declare const getSortOption: (options: {
|
|
9
|
+
provider: ReactifySearchProviderProps;
|
|
10
|
+
config: Config;
|
|
11
|
+
sortOption?: string;
|
|
12
|
+
}) => ConfigSort;
|
|
13
|
+
export declare const generateSortSort: (options: {
|
|
14
|
+
provider: ReactifySearchProviderProps;
|
|
15
|
+
config: Config;
|
|
16
|
+
curation?: ConfigCuration;
|
|
17
|
+
sortOption?: ConfigSort;
|
|
18
|
+
}) => any[];
|
|
19
|
+
export declare const generateSortQuery: (options: {
|
|
20
|
+
curation?: ConfigCuration;
|
|
21
|
+
sortOption?: ConfigSort;
|
|
22
|
+
}) => Record<string, any> | undefined;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSortQuery = exports.generateSortSort = exports.getSortOption = exports.getSortOptions = void 0;
|
|
4
|
+
const getSortOptions = (options) => {
|
|
5
|
+
return options.config.sort
|
|
6
|
+
.sort((a, b) => {
|
|
7
|
+
const aInt = typeof a.position === "string"
|
|
8
|
+
? parseInt(a.position, 10)
|
|
9
|
+
: a.position;
|
|
10
|
+
const bInt = typeof b.position === "string"
|
|
11
|
+
? parseInt(b.position, 10)
|
|
12
|
+
: b.position;
|
|
13
|
+
return aInt - bInt;
|
|
14
|
+
})
|
|
15
|
+
.filter(({ visibility }) => ["all", options.provider.mode].includes(visibility));
|
|
16
|
+
};
|
|
17
|
+
exports.getSortOptions = getSortOptions;
|
|
18
|
+
const getSortOption = (options) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const sortOptions = (0, exports.getSortOptions)(options);
|
|
21
|
+
return (_a = sortOptions.find(({ handle }) => handle === options.sortOption)) !== null && _a !== void 0 ? _a : sortOptions[0];
|
|
22
|
+
};
|
|
23
|
+
exports.getSortOption = getSortOption;
|
|
24
|
+
const generateSortSort = (options) => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
// curation positions are only applied for the default `collections.position` or `_score` sort
|
|
27
|
+
// if the sort is something else, apply a normal sort which applies what the user has requested
|
|
28
|
+
if (options.provider.mode !== "instant-search") {
|
|
29
|
+
if (options.sortOption &&
|
|
30
|
+
!["_score", "collections.position"].includes(options.sortOption.field)) {
|
|
31
|
+
return [{ [options.sortOption.field]: options.sortOption.direction }];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const sorts = [];
|
|
35
|
+
// collection curation pin sorting
|
|
36
|
+
if (options.provider.mode === "collection" && options.provider.collectionHandle) {
|
|
37
|
+
if ((_a = options.curation) === null || _a === void 0 ? void 0 : _a.collectionHandle) {
|
|
38
|
+
const queries = [{
|
|
39
|
+
term: {
|
|
40
|
+
"curations.collectionHandle.keyword": options.curation.collectionHandle,
|
|
41
|
+
},
|
|
42
|
+
}];
|
|
43
|
+
if (options.provider.market) {
|
|
44
|
+
queries.push({
|
|
45
|
+
term: {
|
|
46
|
+
"curations.markets.keyword": options.provider.market,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
sorts.push({
|
|
51
|
+
"curations.position": {
|
|
52
|
+
unmapped_type: "long",
|
|
53
|
+
order: "asc",
|
|
54
|
+
nested: {
|
|
55
|
+
path: "curations",
|
|
56
|
+
filter: {
|
|
57
|
+
bool: {
|
|
58
|
+
must: queries
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// search options.curation pin sorting
|
|
67
|
+
if (options.provider.mode === "search" || options.provider.mode === "instant-search") {
|
|
68
|
+
if ((_b = options.curation) === null || _b === void 0 ? void 0 : _b.searchTerm) {
|
|
69
|
+
const queries = [{
|
|
70
|
+
term: {
|
|
71
|
+
"curations.searchTerm.keyword": options.curation.searchTerm.toLowerCase(),
|
|
72
|
+
},
|
|
73
|
+
}];
|
|
74
|
+
if (options.provider.market) {
|
|
75
|
+
queries.push({
|
|
76
|
+
term: {
|
|
77
|
+
"curations.markets.keyword": options.provider.market,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
sorts.push({
|
|
82
|
+
"curations.position": {
|
|
83
|
+
unmapped_type: "long",
|
|
84
|
+
order: "asc",
|
|
85
|
+
nested: {
|
|
86
|
+
path: "curations",
|
|
87
|
+
filter: {
|
|
88
|
+
bool: {
|
|
89
|
+
must: queries
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// options.curation boost sorting
|
|
98
|
+
if (options.curation) {
|
|
99
|
+
if (0 < options.curation.boosting.groupings.length) {
|
|
100
|
+
const groupings = options.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 (_c) {
|
|
108
|
+
console.error(`query could not be parsed for boost grouping`, grouping);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (0 < options.curation.boosting.sortings.length) {
|
|
113
|
+
const sortings = options.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 (_d) {
|
|
121
|
+
console.error(`query could not be parsed for boost sorting`, sorting);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// default collection sorting
|
|
127
|
+
if (options.provider.mode === "collection" && options.provider.collectionHandle) {
|
|
128
|
+
sorts.push({
|
|
129
|
+
"collections.position": {
|
|
130
|
+
order: "asc",
|
|
131
|
+
nested: {
|
|
132
|
+
path: "collections",
|
|
133
|
+
filter: {
|
|
134
|
+
term: {
|
|
135
|
+
"collections.handle.keyword": options.provider.collectionHandle,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// default search sorting
|
|
143
|
+
if (options.provider.mode === "search" || options.provider.mode === "instant-search") {
|
|
144
|
+
sorts.push("_score");
|
|
145
|
+
}
|
|
146
|
+
return sorts;
|
|
147
|
+
};
|
|
148
|
+
exports.generateSortSort = generateSortSort;
|
|
149
|
+
const generateSortQuery = (options) => {
|
|
150
|
+
var _a;
|
|
151
|
+
if (!options.curation || options.curation.id.includes("global")) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
bool: {
|
|
156
|
+
must_not: [
|
|
157
|
+
{
|
|
158
|
+
nested: {
|
|
159
|
+
path: "curations",
|
|
160
|
+
query: {
|
|
161
|
+
bool: {
|
|
162
|
+
must: [
|
|
163
|
+
{
|
|
164
|
+
term: {
|
|
165
|
+
[`curations.${"collection" === options.curation.type
|
|
166
|
+
? "collectionHandle"
|
|
167
|
+
: "searchTerm"}.keyword`]: "collection" === options.curation.type
|
|
168
|
+
? options.curation.collectionHandle
|
|
169
|
+
: (_a = options.curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
term: {
|
|
174
|
+
"curations.hidden": true,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
// hide callout when not sorting by _score or collections.position
|
|
183
|
+
...(options.sortOption &&
|
|
184
|
+
!["_score", "collections.position"].includes(options.sortOption.field)
|
|
185
|
+
? [
|
|
186
|
+
{
|
|
187
|
+
term: {
|
|
188
|
+
type: "callout",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
]
|
|
192
|
+
: []),
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
exports.generateSortQuery = generateSortQuery;
|
|
198
|
+
//# sourceMappingURL=sortOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortOption.js","sourceRoot":"","sources":["../../../src/utility/sortOption.ts"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,CAAC,OAI9B,EAAE,EAAE;IACH,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI;SACvB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,MAAM,IAAI,GACR,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;YAC5B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACjB,MAAM,IAAI,GACR,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ;YAC5B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACjB,OAAO,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAErF,CAAC,CAAA;AAnBY,QAAA,cAAc,kBAmB1B;AAEM,MAAM,aAAa,GAAG,CAAC,OAI7B,EAAE,EAAE;;IACH,MAAM,WAAW,GAAG,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAC;IAE5C,OAAO,MAAA,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,mCAAI,WAAW,C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BACpE,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;6BAChB;yBACF;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,iBAAiB,qBAqD5B","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration, ConfigSort } from \"../types\";\n\nexport const getSortOptions = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n sortOption?: string;\n}) => {\n return options.config.sort\n .sort((a, b) => {\n const aInt =\n typeof a.position === \"string\"\n ? parseInt(a.position, 10)\n : a.position;\n const bInt =\n typeof b.position === \"string\"\n ? parseInt(b.position, 10)\n : b.position;\n return aInt - bInt;\n })\n .filter(({ visibility }) => [\"all\", options.provider.mode].includes(visibility));\n\n}\n\nexport const getSortOption = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n sortOption?: string;\n}) => {\n const sortOptions = getSortOptions(options);\n\n return sortOptions.find(({ handle }) => handle === options.sortOption) ?? sortOptions[0];\n}\n\nexport const generateSortSort = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n}) => {\n // curation positions are only applied for the default `collections.position` or `_score` sort\n // if the sort is something else, apply a normal sort which applies what the user has requested\n if (options.provider.mode !== \"instant-search\") {\n if (\n options.sortOption &&\n ![\"_score\", \"collections.position\"].includes(options.sortOption.field)\n ) {\n return [{ [options.sortOption.field]: options.sortOption.direction }];\n }\n }\n\n const sorts = [];\n\n // collection curation pin sorting\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n if (options.curation?.collectionHandle) {\n const queries: Array<unknown> = [{\n term: {\n \"curations.collectionHandle.keyword\": options.curation.collectionHandle,\n },\n }];\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n });\n }\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n bool: {\n must: queries\n }\n }\n },\n },\n });\n }\n }\n\n // search options.curation pin sorting\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n if (options.curation?.searchTerm) {\n const queries: Array<unknown> = [{\n term: {\n \"curations.searchTerm.keyword\": options.curation.searchTerm.toLowerCase(),\n },\n }];\n if (options.provider.market) {\n queries.push({\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n });\n }\n sorts.push({\n \"curations.position\": {\n unmapped_type: \"long\",\n order: \"asc\",\n nested: {\n path: \"curations\",\n filter: {\n bool: {\n must: queries\n }\n }\n },\n },\n });\n }\n }\n\n // options.curation boost sorting\n if (options.curation) {\n if (0 < options.curation.boosting.groupings.length) {\n const groupings = options.curation.boosting.groupings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const grouping of groupings) {\n try {\n const query = JSON.parse(grouping.query);\n if (query) sorts.push(query);\n } catch {\n console.error(\n `query could not be parsed for boost grouping`,\n grouping\n );\n }\n }\n }\n\n if (0 < options.curation.boosting.sortings.length) {\n const sortings = options.curation.boosting.sortings.sort((a, b) =>\n a.position > b.position ? 1 : -1\n );\n\n for (const sorting of sortings) {\n try {\n const query = JSON.parse(sorting.query);\n if (query) sorts.push(query);\n } catch {\n console.error(`query could not be parsed for boost sorting`, sorting);\n }\n }\n }\n }\n\n // default collection sorting\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n sorts.push({\n \"collections.position\": {\n order: \"asc\",\n nested: {\n path: \"collections\",\n filter: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n });\n }\n\n // default search sorting\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n sorts.push(\"_score\");\n }\n\n return sorts;\n}\n\nexport const generateSortQuery = (options: {\n curation?: ConfigCuration;\n sortOption?: ConfigSort;\n}): Record<string, any> | undefined => {\n if (!options.curation || options.curation.id.includes(\"global\")) {\n return undefined;\n }\n\n return {\n bool: {\n must_not: [\n {\n nested: {\n path: \"curations\",\n query: {\n bool: {\n must: [\n {\n term: {\n [`curations.${\n \"collection\" === options.curation.type\n ? \"collectionHandle\"\n : \"searchTerm\"\n }.keyword`]:\n \"collection\" === options.curation.type\n ? options.curation.collectionHandle\n : options.curation.searchTerm?.toLowerCase(),\n },\n },\n {\n term: {\n \"curations.hidden\": true,\n },\n },\n ],\n },\n },\n },\n },\n // hide callout when not sorting by _score or collections.position\n ...(options.sortOption &&\n ![\"_score\", \"collections.position\"].includes(options.sortOption.field)\n ? [\n {\n term: {\n type: \"callout\",\n },\n },\n ]\n : []),\n ],\n },\n };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
queryFormat: "and" | "or";
|
|
8
|
-
showFilter: boolean;
|
|
9
|
-
showLoadMore: boolean;
|
|
10
|
-
showSearch: boolean;
|
|
11
|
-
showRadio: boolean;
|
|
12
|
-
showCheckbox: boolean;
|
|
13
|
-
nestedField: string | undefined;
|
|
14
|
-
customQuery: ((value?: string | string[] | undefined) => {
|
|
15
|
-
query?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
query: {
|
|
18
|
-
nested: {
|
|
19
|
-
path: string;
|
|
20
|
-
query: {
|
|
21
|
-
bool: {
|
|
22
|
-
must: ({
|
|
23
|
-
match: {
|
|
24
|
-
"variants.available": string;
|
|
25
|
-
};
|
|
26
|
-
terms?: undefined;
|
|
27
|
-
} | {
|
|
28
|
-
terms: {
|
|
29
|
-
[x: string]: string[];
|
|
30
|
-
};
|
|
31
|
-
match?: undefined;
|
|
32
|
-
})[];
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}) | undefined;
|
|
38
|
-
defaultQuery: (() => {
|
|
39
|
-
aggs: {
|
|
40
|
-
reactivesearch_nested: {
|
|
41
|
-
nested: {
|
|
42
|
-
path: string;
|
|
43
|
-
};
|
|
44
|
-
aggs: {
|
|
45
|
-
reactify_nested_outer: {
|
|
46
|
-
filter: {
|
|
47
|
-
bool: {
|
|
48
|
-
minimum_should_match: number;
|
|
49
|
-
should: {
|
|
50
|
-
match: {
|
|
51
|
-
"variants.available": string;
|
|
52
|
-
};
|
|
53
|
-
}[];
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
aggs: {
|
|
57
|
-
[x: string]: {
|
|
58
|
-
terms: {
|
|
59
|
-
field: string;
|
|
60
|
-
size: number;
|
|
61
|
-
order: {
|
|
62
|
-
_count: string;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
aggs: {
|
|
66
|
-
parent_docs: {
|
|
67
|
-
reverse_nested: {};
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
}) | undefined;
|
|
77
|
-
URLParams: boolean;
|
|
78
|
-
componentId: string;
|
|
79
|
-
dataField: string;
|
|
80
|
-
filterLabel: string;
|
|
81
|
-
react: {
|
|
82
|
-
and: string[];
|
|
83
|
-
};
|
|
84
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useReactiveFilterListProps = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const useReactiveFilterSharedProps_1 = require("./useReactiveFilterSharedProps");
|
|
9
|
-
/**
|
|
10
|
-
* For use with @appbaseio/reactivesearch SingleList and MultiList components
|
|
11
|
-
*/
|
|
12
|
-
const useReactiveFilterListProps = (filter) => {
|
|
13
|
-
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
14
|
-
const reactiveFilterListProps = react_1.default.useMemo(() => {
|
|
15
|
-
var _a, _b, _c, _d;
|
|
16
|
-
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { size: parseInt(filter.displaySize) || undefined, queryFormat: (_a = filter.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or", showFilter: (_b = filter.settingsShowFilter) !== null && _b !== void 0 ? _b : true, showLoadMore: (_c = filter.settingsShowMore) !== null && _c !== void 0 ? _c : false, showSearch: (_d = filter.settingsShowSearch) !== null && _d !== void 0 ? _d : false, showRadio: false, showCheckbox: false }));
|
|
17
|
-
}, [filter, reactiveFilterSharedProps]);
|
|
18
|
-
return reactiveFilterListProps;
|
|
19
|
-
};
|
|
20
|
-
exports.useReactiveFilterListProps = useReactiveFilterListProps;
|
|
21
|
-
//# sourceMappingURL=useReactiveFilterListProps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveFilterListProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveFilterListProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,iFAA8E;AAE9E;;GAEG;AACI,MAAM,0BAA0B,GAAG,CAAC,MAA0B,EAAE,EAAE;IACvE,MAAM,yBAAyB,GAAG,IAAA,2DAA4B,EAAC,MAAM,CAAC,CAAC;IAEvE,MAAM,uBAAuB,GAAG,eAAK,CAAC,OAAO,CAC3C,GAAG,EAAE;;QAAC,OAAA,iCACD,yBAAyB,KAC5B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,EAC/C,WAAW,EAAE,MAAA,MAAM,CAAC,mBAAmB,mCAAI,IAAI,EAC/C,UAAU,EAAE,MAAA,MAAM,CAAC,kBAAkB,mCAAI,IAAI,EAC7C,YAAY,EAAE,MAAA,MAAM,CAAC,gBAAgB,mCAAI,KAAK,EAC9C,UAAU,EAAE,MAAA,MAAM,CAAC,kBAAkB,mCAAI,KAAK,EAC9C,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,KAAK,IACnB,CAAA;KAAA,EACF,CAAC,MAAM,EAAE,yBAAyB,CAAC,CACpC,CAAC;IAEF,OAAO,uBAAuB,CAAC;AACjC,CAAC,CAAC;AAlBW,QAAA,0BAA0B,8BAkBrC","sourcesContent":["import React from \"react\";\n\nimport type { ConfigFilterOption } from \"../../types/config\";\nimport { useReactiveFilterSharedProps } from \"./useReactiveFilterSharedProps\";\n\n/**\n * For use with @appbaseio/reactivesearch SingleList and MultiList components\n */\nexport const useReactiveFilterListProps = (filter: ConfigFilterOption) => {\n const reactiveFilterSharedProps = useReactiveFilterSharedProps(filter);\n\n const reactiveFilterListProps = React.useMemo(\n () => ({\n ...reactiveFilterSharedProps,\n size: parseInt(filter.displaySize) || undefined,\n queryFormat: filter.settingsFilterLogic ?? \"or\",\n showFilter: filter.settingsShowFilter ?? true,\n showLoadMore: filter.settingsShowMore ?? false,\n showSearch: filter.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n }),\n [filter, reactiveFilterSharedProps]\n );\n\n return reactiveFilterListProps;\n};\n"]}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { ConfigFilterOption } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* For use with @appbaseio/reactivesearch SingleRange and MultiRange components
|
|
4
|
-
*/
|
|
5
|
-
export declare const useReactiveFilterRangeProps: (filter: ConfigFilterOption) => {
|
|
6
|
-
queryFormat: "and" | "or";
|
|
7
|
-
showFilter: boolean;
|
|
8
|
-
showRadio: boolean;
|
|
9
|
-
showCheckbox: boolean;
|
|
10
|
-
data: {
|
|
11
|
-
label: string;
|
|
12
|
-
start: number;
|
|
13
|
-
end: number;
|
|
14
|
-
}[];
|
|
15
|
-
nestedField: string | undefined;
|
|
16
|
-
customQuery: ((value?: string | string[] | undefined) => {
|
|
17
|
-
query?: undefined;
|
|
18
|
-
} | {
|
|
19
|
-
query: {
|
|
20
|
-
nested: {
|
|
21
|
-
path: string;
|
|
22
|
-
query: {
|
|
23
|
-
bool: {
|
|
24
|
-
must: ({
|
|
25
|
-
match: {
|
|
26
|
-
"variants.available": string;
|
|
27
|
-
};
|
|
28
|
-
terms?: undefined;
|
|
29
|
-
} | {
|
|
30
|
-
terms: {
|
|
31
|
-
[x: string]: string[];
|
|
32
|
-
};
|
|
33
|
-
match?: undefined;
|
|
34
|
-
})[];
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}) | undefined;
|
|
40
|
-
defaultQuery: (() => {
|
|
41
|
-
aggs: {
|
|
42
|
-
reactivesearch_nested: {
|
|
43
|
-
nested: {
|
|
44
|
-
path: string;
|
|
45
|
-
};
|
|
46
|
-
aggs: {
|
|
47
|
-
reactify_nested_outer: {
|
|
48
|
-
filter: {
|
|
49
|
-
bool: {
|
|
50
|
-
minimum_should_match: number;
|
|
51
|
-
should: {
|
|
52
|
-
match: {
|
|
53
|
-
"variants.available": string;
|
|
54
|
-
};
|
|
55
|
-
}[];
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
aggs: {
|
|
59
|
-
[x: string]: {
|
|
60
|
-
terms: {
|
|
61
|
-
field: string;
|
|
62
|
-
size: number;
|
|
63
|
-
order: {
|
|
64
|
-
_count: string;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
aggs: {
|
|
68
|
-
parent_docs: {
|
|
69
|
-
reverse_nested: {};
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
}) | undefined;
|
|
79
|
-
URLParams: boolean;
|
|
80
|
-
componentId: string;
|
|
81
|
-
dataField: string;
|
|
82
|
-
filterLabel: string;
|
|
83
|
-
react: {
|
|
84
|
-
and: string[];
|
|
85
|
-
};
|
|
86
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useReactiveFilterRangeProps = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const useReactiveFilterSharedProps_1 = require("./useReactiveFilterSharedProps");
|
|
9
|
-
/**
|
|
10
|
-
* For use with @appbaseio/reactivesearch SingleRange and MultiRange components
|
|
11
|
-
*/
|
|
12
|
-
const useReactiveFilterRangeProps = (filter) => {
|
|
13
|
-
const reactiveFilterSharedProps = (0, useReactiveFilterSharedProps_1.useReactiveFilterSharedProps)(filter);
|
|
14
|
-
const data = react_1.default.useMemo(() => {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
return ((_b = (_a = filter.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
|
|
17
|
-
const [label, start, end] = option.split(":");
|
|
18
|
-
return {
|
|
19
|
-
label: label,
|
|
20
|
-
start: start ? parseInt(start) : 0,
|
|
21
|
-
end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
|
|
22
|
-
};
|
|
23
|
-
})) !== null && _b !== void 0 ? _b : []);
|
|
24
|
-
}, []);
|
|
25
|
-
const reactiveFilterRangeProps = react_1.default.useMemo(() => {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
return (Object.assign(Object.assign({}, reactiveFilterSharedProps), { queryFormat: (_a = filter.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or", showFilter: (_b = filter.settingsShowFilter) !== null && _b !== void 0 ? _b : true, showRadio: false, showCheckbox: false, data: data }));
|
|
28
|
-
}, [filter, reactiveFilterSharedProps]);
|
|
29
|
-
return reactiveFilterRangeProps;
|
|
30
|
-
};
|
|
31
|
-
exports.useReactiveFilterRangeProps = useReactiveFilterRangeProps;
|
|
32
|
-
//# sourceMappingURL=useReactiveFilterRangeProps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useReactiveFilterRangeProps.js","sourceRoot":"","sources":["../../../../src/hooks/reactivesearch/useReactiveFilterRangeProps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B,iFAA8E;AAE9E;;GAEG;AACI,MAAM,2BAA2B,GAAG,CAAC,MAA0B,EAAE,EAAE;IACxE,MAAM,yBAAyB,GAAG,IAAA,2DAA4B,EAAC,MAAM,CAAC,CAAC;IAEvE,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC9B,OAAO,CACL,MAAA,MAAA,MAAM,CAAC,mBAAmB,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACzC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9C,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB;aACnD,CAAC;QACJ,CAAC,CAAC,mCAAI,EAAE,CACT,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,wBAAwB,GAAG,eAAK,CAAC,OAAO,CAC5C,GAAG,EAAE;;QAAC,OAAA,iCACD,yBAAyB,KAC5B,WAAW,EAAE,MAAA,MAAM,CAAC,mBAAmB,mCAAI,IAAI,EAC/C,UAAU,EAAE,MAAA,MAAM,CAAC,kBAAkB,mCAAI,IAAI,EAC7C,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,KAAK,EACnB,IAAI,EAAE,IAAI,IACV,CAAA;KAAA,EACF,CAAC,MAAM,EAAE,yBAAyB,CAAC,CACpC,CAAC;IAEF,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AA7BW,QAAA,2BAA2B,+BA6BtC","sourcesContent":["import React from \"react\";\n\nimport { ConfigFilterOption } from \"../../types\";\n\nimport { useReactiveFilterSharedProps } from \"./useReactiveFilterSharedProps\";\n\n/**\n * For use with @appbaseio/reactivesearch SingleRange and MultiRange components\n */\nexport const useReactiveFilterRangeProps = (filter: ConfigFilterOption) => {\n const reactiveFilterSharedProps = useReactiveFilterSharedProps(filter);\n\n const data = React.useMemo(() => {\n return (\n filter.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? []\n );\n }, []);\n\n const reactiveFilterRangeProps = React.useMemo(\n () => ({\n ...reactiveFilterSharedProps,\n queryFormat: filter.settingsFilterLogic ?? \"or\",\n showFilter: filter.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n }),\n [filter, reactiveFilterSharedProps]\n );\n\n return reactiveFilterRangeProps;\n};\n"]}
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
bool: {
|
|
41
|
-
minimum_should_match: number;
|
|
42
|
-
should: {
|
|
43
|
-
match: {
|
|
44
|
-
"variants.available": string;
|
|
45
|
-
};
|
|
46
|
-
}[];
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
aggs: {
|
|
50
|
-
[x: string]: {
|
|
51
|
-
terms: {
|
|
52
|
-
field: string;
|
|
53
|
-
size: number;
|
|
54
|
-
order: {
|
|
55
|
-
_count: string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
aggs: {
|
|
59
|
-
parent_docs: {
|
|
60
|
-
reverse_nested: {};
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}) | undefined;
|
|
70
|
-
URLParams: boolean;
|
|
71
|
-
componentId: string;
|
|
72
|
-
dataField: string;
|
|
73
|
-
filterLabel: string;
|
|
74
|
-
react: {
|
|
75
|
-
and: string[];
|
|
76
|
-
};
|
|
77
|
-
};
|