@usereactify/search 5.45.0 → 5.46.0-beta.1
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 +16 -0
- package/dist/package.json +2 -1
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +6 -0
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +3 -3
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
- package/dist/src/components/Sensor/SensorCustom.js +1 -1
- package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js +40 -35
- package/dist/src/hooks/reactivesearch/useReactiveBaseProps.js.map +1 -1
- package/dist/src/hooks/useAnalytics.js +3 -0
- package/dist/src/hooks/useAnalytics.js.map +1 -1
- package/dist/src/hooks/useConfig.d.ts +1 -1
- package/dist/src/hooks/useConfig.js +3 -6
- package/dist/src/hooks/useConfig.js.map +1 -1
- package/dist/src/hooks/useFlags.js +8 -2
- package/dist/src/hooks/useFlags.js.map +1 -1
- package/dist/src/hooks/useReactifySearchContext.d.ts +8 -0
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
- package/dist/src/hooks/useSortBy.js +4 -1
- package/dist/src/hooks/useSortBy.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/utility/config.d.ts +4 -0
- package/dist/src/utility/config.js +57 -0
- package/dist/src/utility/config.js.map +1 -0
- package/dist/src/utility/props.d.ts +292 -0
- package/dist/src/utility/props.js +255 -0
- package/dist/src/utility/props.js.map +1 -0
- package/dist/src/utility/server.d.ts +2 -0
- package/dist/src/utility/server.js +36 -0
- package/dist/src/utility/server.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getConfig = exports.getConfigFromNetwork = exports.getConfigFromCache = void 0;
|
|
13
|
+
const getConfigFromCache = () => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if (typeof window === "undefined") {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const configFromCache = JSON.parse((_a = window.sessionStorage.getItem("reactify-search:config")) !== null && _a !== void 0 ? _a : "null");
|
|
19
|
+
if (configFromCache) {
|
|
20
|
+
if (((_b = configFromCache.config.cache) === null || _b === void 0 ? void 0 : _b.enabled) === false) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return configFromCache.config;
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
};
|
|
27
|
+
exports.getConfigFromCache = getConfigFromCache;
|
|
28
|
+
const getConfigFromNetwork = (shopifyPermanentDomain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
let configFromNetwork;
|
|
31
|
+
try {
|
|
32
|
+
configFromNetwork = (_a = (yield fetch(`https://config.usereactify.com/?shop=${shopifyPermanentDomain}`).then((response) => response.json()))) === null || _a === void 0 ? void 0 : _a.body;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
configFromNetwork = (_b = (yield fetch(`https://config.usereactify.com/?shop=${shopifyPermanentDomain}`).then((response) => response.json()))) === null || _b === void 0 ? void 0 : _b.body;
|
|
36
|
+
}
|
|
37
|
+
return configFromNetwork;
|
|
38
|
+
});
|
|
39
|
+
exports.getConfigFromNetwork = getConfigFromNetwork;
|
|
40
|
+
const getConfig = (shopifyPermanentDomain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const configFromCache = (0, exports.getConfigFromCache)();
|
|
42
|
+
if (configFromCache) {
|
|
43
|
+
return configFromCache;
|
|
44
|
+
}
|
|
45
|
+
const configFromNetwork = yield (0, exports.getConfigFromNetwork)(shopifyPermanentDomain);
|
|
46
|
+
if (!configFromNetwork) {
|
|
47
|
+
throw new Error("Unable to load config");
|
|
48
|
+
}
|
|
49
|
+
if (typeof window !== "undefined") {
|
|
50
|
+
window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
|
|
51
|
+
config: configFromNetwork,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
return configFromNetwork;
|
|
55
|
+
});
|
|
56
|
+
exports.getConfig = getConfig;
|
|
57
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utility/config.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEO,MAAM,kBAAkB,GAAG,GAAuB,EAAE;;IACzD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO;KACR;IAED,MAAM,eAAe,GAEV,IAAI,CAAC,KAAK,CACnB,MAAA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,wBAAwB,CAAC,mCAAI,MAAM,CAClE,CAAC;IAEF,IAAI,eAAe,EAAE;QACnB,IAAI,CAAA,MAAA,eAAe,CAAC,MAAM,CAAC,KAAK,0CAAE,OAAO,MAAK,KAAK,EAAE;YACnD,OAAO;SACR;QAED,OAAO,eAAe,CAAC,MAAM,CAAC;KAC/B;IAED,OAAO;AACT,C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export const getConfigFromCache = (): Config | undefined => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const configFromCache: {\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (configFromCache) {\n if (configFromCache.config.cache?.enabled === false) {\n return;\n }\n\n return configFromCache.config;\n }\n\n return;\n};\n\nexport const getConfigFromNetwork = async (shopifyPermanentDomain: string): Promise<Config | undefined> => {\n let configFromNetwork: Config | undefined;\n try {\n configFromNetwork = (await fetch(\n `https://config.usereactify.com/?shop=${shopifyPermanentDomain}`\n ).then((response) => response.json()))?.body;\n \n } catch (error) {\n configFromNetwork = (await fetch(\n `https://config.usereactify.com/?shop=${shopifyPermanentDomain}`\n ).then((response) => response.json()))?.body;\n }\n\n return configFromNetwork;\n};\n\nexport const getConfig = async (shopifyPermanentDomain: string): Promise<Config> => {\n const configFromCache = getConfigFromCache();\n if (configFromCache) {\n return configFromCache;\n }\n\n const configFromNetwork = await getConfigFromNetwork(shopifyPermanentDomain);\n\n if (!configFromNetwork) {\n throw new Error(\"Unable to load config\");\n }\n\n if (typeof window !== \"undefined\") {\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n config: configFromNetwork,\n })\n );\n }\n\n return configFromNetwork;\n};\n"]}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ReactiveList } from "@appbaseio/reactivesearch";
|
|
3
|
+
import { Config, ConfigFilter, ConfigFilterOption } from "../types";
|
|
4
|
+
export declare type GeneratePropsFilterGroupOptions = {
|
|
5
|
+
mode: "search" | "instant-search" | "collection";
|
|
6
|
+
config: Config;
|
|
7
|
+
filterGroup: ConfigFilter;
|
|
8
|
+
additionalComponentIds?: Array<string>;
|
|
9
|
+
includeFields?: Array<string>;
|
|
10
|
+
excludeFields?: Array<string>;
|
|
11
|
+
};
|
|
12
|
+
export declare const getPropsFilterGroup: (options: GeneratePropsFilterGroupOptions) => ({
|
|
13
|
+
URLParams: boolean;
|
|
14
|
+
componentId: string;
|
|
15
|
+
dataField: string;
|
|
16
|
+
filterLabel: string;
|
|
17
|
+
nestedField: string | undefined;
|
|
18
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
19
|
+
query?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
query: {
|
|
22
|
+
nested: {
|
|
23
|
+
path: string;
|
|
24
|
+
query: {
|
|
25
|
+
bool: {
|
|
26
|
+
must: ({
|
|
27
|
+
match: {
|
|
28
|
+
"variants.available": string;
|
|
29
|
+
};
|
|
30
|
+
terms?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
terms: {
|
|
33
|
+
[x: string]: string[];
|
|
34
|
+
};
|
|
35
|
+
match?: undefined;
|
|
36
|
+
})[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}) | undefined;
|
|
42
|
+
defaultQuery: (() => {
|
|
43
|
+
aggs: {
|
|
44
|
+
reactivesearch_nested: {
|
|
45
|
+
nested: {
|
|
46
|
+
path: string;
|
|
47
|
+
};
|
|
48
|
+
aggs: {
|
|
49
|
+
reactify_nested_outer: {
|
|
50
|
+
filter: {
|
|
51
|
+
bool: {
|
|
52
|
+
minimum_should_match: number;
|
|
53
|
+
should: {
|
|
54
|
+
match: {
|
|
55
|
+
"variants.available": string;
|
|
56
|
+
};
|
|
57
|
+
}[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
aggs: {
|
|
61
|
+
[x: string]: {
|
|
62
|
+
terms: {
|
|
63
|
+
field: string;
|
|
64
|
+
size: number;
|
|
65
|
+
order: {
|
|
66
|
+
_count: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
aggs: {
|
|
70
|
+
parent_docs: {
|
|
71
|
+
reverse_nested: {};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}) | undefined;
|
|
81
|
+
source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | undefined;
|
|
82
|
+
react: {
|
|
83
|
+
and: string[];
|
|
84
|
+
};
|
|
85
|
+
} | {
|
|
86
|
+
size: number;
|
|
87
|
+
URLParams: boolean;
|
|
88
|
+
showLoader: boolean;
|
|
89
|
+
dataField: string;
|
|
90
|
+
showResultStats: boolean;
|
|
91
|
+
react: {
|
|
92
|
+
and: string[];
|
|
93
|
+
};
|
|
94
|
+
includeFields: string[];
|
|
95
|
+
excludeFields: string[];
|
|
96
|
+
componentId: string;
|
|
97
|
+
scrollOnChange: boolean;
|
|
98
|
+
pagination: boolean;
|
|
99
|
+
infiniteScroll: boolean;
|
|
100
|
+
renderNoResults: () => null;
|
|
101
|
+
source: typeof ReactiveList;
|
|
102
|
+
})[];
|
|
103
|
+
export declare const getPropsFilterGroupOption: (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {
|
|
104
|
+
URLParams: boolean;
|
|
105
|
+
componentId: string;
|
|
106
|
+
dataField: string;
|
|
107
|
+
filterLabel: string;
|
|
108
|
+
nestedField: string | undefined;
|
|
109
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
110
|
+
query?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
query: {
|
|
113
|
+
nested: {
|
|
114
|
+
path: string;
|
|
115
|
+
query: {
|
|
116
|
+
bool: {
|
|
117
|
+
must: ({
|
|
118
|
+
match: {
|
|
119
|
+
"variants.available": string;
|
|
120
|
+
};
|
|
121
|
+
terms?: undefined;
|
|
122
|
+
} | {
|
|
123
|
+
terms: {
|
|
124
|
+
[x: string]: string[];
|
|
125
|
+
};
|
|
126
|
+
match?: undefined;
|
|
127
|
+
})[];
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
}) | undefined;
|
|
133
|
+
defaultQuery: (() => {
|
|
134
|
+
aggs: {
|
|
135
|
+
reactivesearch_nested: {
|
|
136
|
+
nested: {
|
|
137
|
+
path: string;
|
|
138
|
+
};
|
|
139
|
+
aggs: {
|
|
140
|
+
reactify_nested_outer: {
|
|
141
|
+
filter: {
|
|
142
|
+
bool: {
|
|
143
|
+
minimum_should_match: number;
|
|
144
|
+
should: {
|
|
145
|
+
match: {
|
|
146
|
+
"variants.available": string;
|
|
147
|
+
};
|
|
148
|
+
}[];
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
aggs: {
|
|
152
|
+
[x: string]: {
|
|
153
|
+
terms: {
|
|
154
|
+
field: string;
|
|
155
|
+
size: number;
|
|
156
|
+
order: {
|
|
157
|
+
_count: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
aggs: {
|
|
161
|
+
parent_docs: {
|
|
162
|
+
reverse_nested: {};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
}) | undefined;
|
|
172
|
+
source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | undefined;
|
|
173
|
+
react: {
|
|
174
|
+
and: string[];
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
export declare const getPropsResults: (options: GeneratePropsFilterGroupOptions) => {
|
|
178
|
+
size: number;
|
|
179
|
+
URLParams: boolean;
|
|
180
|
+
showLoader: boolean;
|
|
181
|
+
dataField: string;
|
|
182
|
+
showResultStats: boolean;
|
|
183
|
+
react: {
|
|
184
|
+
and: string[];
|
|
185
|
+
};
|
|
186
|
+
includeFields: string[];
|
|
187
|
+
excludeFields: string[];
|
|
188
|
+
componentId: string;
|
|
189
|
+
scrollOnChange: boolean;
|
|
190
|
+
pagination: boolean;
|
|
191
|
+
infiniteScroll: boolean;
|
|
192
|
+
renderNoResults: () => null;
|
|
193
|
+
source: typeof ReactiveList;
|
|
194
|
+
};
|
|
195
|
+
export declare const getPropsReact: (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterOption | undefined) => {
|
|
196
|
+
and: string[];
|
|
197
|
+
};
|
|
198
|
+
export declare const getPropsShared: (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {
|
|
199
|
+
URLParams: boolean;
|
|
200
|
+
componentId: string;
|
|
201
|
+
dataField: string;
|
|
202
|
+
filterLabel: string;
|
|
203
|
+
nestedField: string | undefined;
|
|
204
|
+
customQuery: ((value?: string | string[] | undefined) => {
|
|
205
|
+
query?: undefined;
|
|
206
|
+
} | {
|
|
207
|
+
query: {
|
|
208
|
+
nested: {
|
|
209
|
+
path: string;
|
|
210
|
+
query: {
|
|
211
|
+
bool: {
|
|
212
|
+
must: ({
|
|
213
|
+
match: {
|
|
214
|
+
"variants.available": string;
|
|
215
|
+
};
|
|
216
|
+
terms?: undefined;
|
|
217
|
+
} | {
|
|
218
|
+
terms: {
|
|
219
|
+
[x: string]: string[];
|
|
220
|
+
};
|
|
221
|
+
match?: undefined;
|
|
222
|
+
})[];
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
}) | undefined;
|
|
228
|
+
defaultQuery: (() => {
|
|
229
|
+
aggs: {
|
|
230
|
+
reactivesearch_nested: {
|
|
231
|
+
nested: {
|
|
232
|
+
path: string;
|
|
233
|
+
};
|
|
234
|
+
aggs: {
|
|
235
|
+
reactify_nested_outer: {
|
|
236
|
+
filter: {
|
|
237
|
+
bool: {
|
|
238
|
+
minimum_should_match: number;
|
|
239
|
+
should: {
|
|
240
|
+
match: {
|
|
241
|
+
"variants.available": string;
|
|
242
|
+
};
|
|
243
|
+
}[];
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
aggs: {
|
|
247
|
+
[x: string]: {
|
|
248
|
+
terms: {
|
|
249
|
+
field: string;
|
|
250
|
+
size: number;
|
|
251
|
+
order: {
|
|
252
|
+
_count: string;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
aggs: {
|
|
256
|
+
parent_docs: {
|
|
257
|
+
reverse_nested: {};
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
}) | undefined;
|
|
267
|
+
source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | undefined;
|
|
268
|
+
react: {
|
|
269
|
+
and: string[];
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
export declare const getPropsFilterList: (filterGroupOption: ConfigFilterOption) => {
|
|
273
|
+
size: number | undefined;
|
|
274
|
+
queryFormat: "and" | "or";
|
|
275
|
+
showFilter: boolean;
|
|
276
|
+
showLoadMore: boolean;
|
|
277
|
+
showSearch: boolean;
|
|
278
|
+
showRadio: boolean;
|
|
279
|
+
showCheckbox: boolean;
|
|
280
|
+
};
|
|
281
|
+
export declare const getPropsFilterRange: (filterGroupOption: ConfigFilterOption) => {
|
|
282
|
+
queryFormat: "and" | "or";
|
|
283
|
+
showFilter: boolean;
|
|
284
|
+
showRadio: boolean;
|
|
285
|
+
showCheckbox: boolean;
|
|
286
|
+
data: {
|
|
287
|
+
label: string;
|
|
288
|
+
start: number;
|
|
289
|
+
end: number;
|
|
290
|
+
}[];
|
|
291
|
+
};
|
|
292
|
+
export declare const getPropsFilterSlider: (filterGroupOption: ConfigFilterOption) => {};
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsFilterGroupOption = exports.getPropsFilterGroup = void 0;
|
|
4
|
+
const reactivesearch_1 = require("@appbaseio/reactivesearch");
|
|
5
|
+
const components_1 = require("../components");
|
|
6
|
+
const getPropsFilterGroup = (options) => {
|
|
7
|
+
return [
|
|
8
|
+
...options.filterGroup.options.map((filterGroupOption) => (0, exports.getPropsFilterGroupOption)(options, filterGroupOption)),
|
|
9
|
+
(0, exports.getPropsResults)(options),
|
|
10
|
+
];
|
|
11
|
+
};
|
|
12
|
+
exports.getPropsFilterGroup = getPropsFilterGroup;
|
|
13
|
+
const getPropsFilterGroupOption = (options, filterGroupOption) => {
|
|
14
|
+
let filterProps = {};
|
|
15
|
+
if (filterGroupOption.displayType === "slider") {
|
|
16
|
+
filterProps = (0, exports.getPropsFilterSlider)(filterGroupOption);
|
|
17
|
+
}
|
|
18
|
+
if (filterGroupOption.displayType === "single" || filterGroupOption.displayType === "multi") {
|
|
19
|
+
if (filterGroupOption.displayView === "range") {
|
|
20
|
+
filterProps = (0, exports.getPropsFilterRange)(filterGroupOption);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
filterProps = (0, exports.getPropsFilterList)(filterGroupOption);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const sharedProps = (0, exports.getPropsShared)(options, filterGroupOption);
|
|
27
|
+
return Object.assign(Object.assign({}, sharedProps), filterProps);
|
|
28
|
+
};
|
|
29
|
+
exports.getPropsFilterGroupOption = getPropsFilterGroupOption;
|
|
30
|
+
const getPropsResults = (options) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const includeFieldsProp = (() => {
|
|
33
|
+
var _a;
|
|
34
|
+
return [
|
|
35
|
+
...((_a = options.includeFields) !== null && _a !== void 0 ? _a : []),
|
|
36
|
+
"id",
|
|
37
|
+
"title",
|
|
38
|
+
"type",
|
|
39
|
+
"handle",
|
|
40
|
+
"image",
|
|
41
|
+
"variants.id",
|
|
42
|
+
"variants.presentment_prices",
|
|
43
|
+
"callout",
|
|
44
|
+
];
|
|
45
|
+
})();
|
|
46
|
+
const excludeFieldsProp = (() => {
|
|
47
|
+
var _a;
|
|
48
|
+
return [...((_a = options.excludeFields) !== null && _a !== void 0 ? _a : [])];
|
|
49
|
+
})();
|
|
50
|
+
return {
|
|
51
|
+
size: options.filterGroup.pageSize,
|
|
52
|
+
URLParams: true,
|
|
53
|
+
showLoader: false,
|
|
54
|
+
dataField: "title",
|
|
55
|
+
showResultStats: false,
|
|
56
|
+
react: (0, exports.getPropsReact)(options),
|
|
57
|
+
includeFields: includeFieldsProp,
|
|
58
|
+
excludeFields: excludeFieldsProp,
|
|
59
|
+
// scrollTarget: options.scrollTarget,
|
|
60
|
+
componentId: "page",
|
|
61
|
+
scrollOnChange: false,
|
|
62
|
+
pagination: ((_a = options.filterGroup) === null || _a === void 0 ? void 0 : _a.paginationType) !== "infinite_scroll",
|
|
63
|
+
infiniteScroll: ((_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.paginationType) === "infinite_scroll",
|
|
64
|
+
renderNoResults: () => null,
|
|
65
|
+
source: reactivesearch_1.ReactiveList,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.getPropsResults = getPropsResults;
|
|
69
|
+
const getPropsReact = (options, filterGroupOption) => {
|
|
70
|
+
const sensorIds = (0, components_1.SENSOR_IDS)(options.mode, options.config);
|
|
71
|
+
const reactProp = (() => {
|
|
72
|
+
var _a, _b, _c;
|
|
73
|
+
if (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.settingsShowEmptyValues) {
|
|
74
|
+
return {
|
|
75
|
+
and: sensorIds,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
and: [
|
|
80
|
+
...sensorIds,
|
|
81
|
+
...((_a = options.additionalComponentIds) !== null && _a !== void 0 ? _a : []),
|
|
82
|
+
...((_c = (_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.options.map((filter) => filter.handle)) !== null && _c !== void 0 ? _c : []),
|
|
83
|
+
].filter((handle) => handle !== (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.handle)),
|
|
84
|
+
};
|
|
85
|
+
})();
|
|
86
|
+
return reactProp;
|
|
87
|
+
};
|
|
88
|
+
exports.getPropsReact = getPropsReact;
|
|
89
|
+
const getPropsShared = (options, filterGroupOption) => {
|
|
90
|
+
const reactProp = (0, exports.getPropsReact)(options, filterGroupOption);
|
|
91
|
+
const nestedFieldProp = (() => {
|
|
92
|
+
const nestedFields = ["variants"];
|
|
93
|
+
const topField = filterGroupOption.field.split(".")[0];
|
|
94
|
+
if (nestedFields.includes(topField)) {
|
|
95
|
+
return topField;
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
})();
|
|
99
|
+
const customQueryProp = (() => {
|
|
100
|
+
if (!filterGroupOption.settingsHideUnavailable ||
|
|
101
|
+
!filterGroupOption.field.startsWith("variants."))
|
|
102
|
+
return undefined;
|
|
103
|
+
return (value) => {
|
|
104
|
+
if (!value)
|
|
105
|
+
return {};
|
|
106
|
+
// reactivesearch sometimes returns string, sometimes string[]
|
|
107
|
+
const valueArray = "string" === typeof value ? [value] : value;
|
|
108
|
+
if (0 === valueArray.length)
|
|
109
|
+
return {};
|
|
110
|
+
return {
|
|
111
|
+
query: {
|
|
112
|
+
nested: {
|
|
113
|
+
path: "variants",
|
|
114
|
+
query: {
|
|
115
|
+
bool: {
|
|
116
|
+
must: [
|
|
117
|
+
{
|
|
118
|
+
match: {
|
|
119
|
+
"variants.available": "true",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
terms: {
|
|
124
|
+
[filterGroupOption.field]: valueArray,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
})();
|
|
135
|
+
const defaultQueryProp = (() => {
|
|
136
|
+
if (!filterGroupOption.field.startsWith("variants.")) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
// override the aggregation query to filter the results by the variants.available attribute
|
|
140
|
+
return () => {
|
|
141
|
+
return {
|
|
142
|
+
aggs: {
|
|
143
|
+
reactivesearch_nested: {
|
|
144
|
+
nested: { path: "variants" },
|
|
145
|
+
aggs: {
|
|
146
|
+
reactify_nested_outer: {
|
|
147
|
+
filter: {
|
|
148
|
+
bool: {
|
|
149
|
+
minimum_should_match: 1,
|
|
150
|
+
should: [
|
|
151
|
+
{
|
|
152
|
+
match: {
|
|
153
|
+
"variants.available": "true",
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
match: {
|
|
158
|
+
"variants.available": filterGroupOption.settingsHideUnavailable
|
|
159
|
+
? "true"
|
|
160
|
+
: "false",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
aggs: {
|
|
167
|
+
[filterGroupOption.field]: {
|
|
168
|
+
terms: {
|
|
169
|
+
field: filterGroupOption.field,
|
|
170
|
+
size: 100,
|
|
171
|
+
order: { _count: "desc" },
|
|
172
|
+
},
|
|
173
|
+
aggs: {
|
|
174
|
+
parent_docs: { reverse_nested: {} },
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
})();
|
|
185
|
+
const sourceProp = (() => {
|
|
186
|
+
if (filterGroupOption.displayType === "slider") {
|
|
187
|
+
return reactivesearch_1.ReactiveComponent;
|
|
188
|
+
}
|
|
189
|
+
if (filterGroupOption.displayType === "single") {
|
|
190
|
+
if (filterGroupOption.displayView === "range") {
|
|
191
|
+
return reactivesearch_1.SingleRange;
|
|
192
|
+
}
|
|
193
|
+
return reactivesearch_1.SingleList;
|
|
194
|
+
}
|
|
195
|
+
if (filterGroupOption.displayType === "multi") {
|
|
196
|
+
if (filterGroupOption.displayView === "range") {
|
|
197
|
+
return reactivesearch_1.MultiRange;
|
|
198
|
+
}
|
|
199
|
+
return reactivesearch_1.MultiList;
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
})();
|
|
203
|
+
return {
|
|
204
|
+
URLParams: true,
|
|
205
|
+
componentId: filterGroupOption.handle,
|
|
206
|
+
dataField: filterGroupOption.field,
|
|
207
|
+
filterLabel: filterGroupOption.name,
|
|
208
|
+
nestedField: nestedFieldProp,
|
|
209
|
+
customQuery: customQueryProp,
|
|
210
|
+
defaultQuery: defaultQueryProp,
|
|
211
|
+
source: sourceProp,
|
|
212
|
+
react: reactProp,
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
exports.getPropsShared = getPropsShared;
|
|
216
|
+
const getPropsFilterList = (filterGroupOption) => {
|
|
217
|
+
var _a, _b, _c, _d;
|
|
218
|
+
return {
|
|
219
|
+
size: parseInt(filterGroupOption.displaySize) || undefined,
|
|
220
|
+
queryFormat: (_a = filterGroupOption.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or",
|
|
221
|
+
showFilter: (_b = filterGroupOption.settingsShowFilter) !== null && _b !== void 0 ? _b : true,
|
|
222
|
+
showLoadMore: (_c = filterGroupOption.settingsShowMore) !== null && _c !== void 0 ? _c : false,
|
|
223
|
+
showSearch: (_d = filterGroupOption.settingsShowSearch) !== null && _d !== void 0 ? _d : false,
|
|
224
|
+
showRadio: false,
|
|
225
|
+
showCheckbox: false,
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
exports.getPropsFilterList = getPropsFilterList;
|
|
229
|
+
const getPropsFilterRange = (filterGroupOption) => {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
const data = (() => {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
return ((_b = (_a = filterGroupOption.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
|
|
234
|
+
const [label, start, end] = option.split(":");
|
|
235
|
+
return {
|
|
236
|
+
label: label,
|
|
237
|
+
start: start ? parseInt(start) : 0,
|
|
238
|
+
end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
|
|
239
|
+
};
|
|
240
|
+
})) !== null && _b !== void 0 ? _b : []);
|
|
241
|
+
})();
|
|
242
|
+
return {
|
|
243
|
+
queryFormat: (_a = filterGroupOption.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or",
|
|
244
|
+
showFilter: (_b = filterGroupOption.settingsShowFilter) !== null && _b !== void 0 ? _b : true,
|
|
245
|
+
showRadio: false,
|
|
246
|
+
showCheckbox: false,
|
|
247
|
+
data: data,
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
exports.getPropsFilterRange = getPropsFilterRange;
|
|
251
|
+
const getPropsFilterSlider = (filterGroupOption) => {
|
|
252
|
+
return {};
|
|
253
|
+
};
|
|
254
|
+
exports.getPropsFilterSlider = getPropsFilterSlider;
|
|
255
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.tsx"],"names":[],"mappings":";;;AAAA,8DAA4H;AAC5H,8CAA2C;AAapC,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;IAC9E,OAAO;QACL,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAChH,IAAA,uBAAe,EAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAE,iBAAqC,EAAE,EAAE;IAC3H,IAAI,WAAW,GAA4B,EAAE,CAAC;IAE9C,IAAI,iBAAiB,CAAC,WAAW,KAAK,QAAQ,EAAE;QAC9C,WAAW,GAAG,IAAA,4BAAoB,EAAC,iBAAiB,CAAC,CAAC;KACvD;IAED,IAAI,iBAAiB,CAAC,WAAW,KAAK,QAAQ,IAAI,iBAAiB,CAAC,WAAW,KAAK,OAAO,EAAE;QAC3F,IAAI,iBAAiB,CAAC,WAAW,KAAK,OAAO,EAAE;YAC7C,WAAW,GAAG,IAAA,2BAAmB,EAAC,iBAAiB,CAAC,CAAC;SACtD;aAAM;YACL,WAAW,GAAG,IAAA,0BAAkB,EAAC,iBAAiB,CAAC,CAAC;SACrD;KACF;IAED,MAAM,WAAW,GAAG,IAAA,sBAAc,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAE/D,uCACK,WAAW,GACX,WAAW,EACd;AACJ,CAAC,CAAC;AArBW,QAAA,yBAAyB,6BAqBpC;AAEK,MAAM,eAAe,GAAG,CAAC,OAAwC,EAAE,EAAE;;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CAAI,IAAI;QAC1D,UAAU,EAAE,MAAA,iBAAiB,CAAC,kBAAkB,mCAAI,IAAI;QACxD,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,mBAAmB,uBAqB9B;AAEK,MAAM,oBAAoB,GAAG,CAAC,iBAAqC,EAAE,EAAE;IAC5E,OAAO,EAAE,CAAA;AACX,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@appbaseio/reactivesearch\";\nimport { SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterOption } from \"../types\";\n\nexport type GeneratePropsFilterGroupOptions = {\n mode: \"search\" | \"instant-search\" | \"collection\";\n config: Config;\n filterGroup: ConfigFilter;\n\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n filterProps = getPropsFilterSlider(filterGroupOption);\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.excludeFields ?? [])];\n })();\n\n return {\n size: options.filterGroup.pageSize,\n URLParams: true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n // scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterOption) => {\n const sensorIds = SENSOR_IDS(options.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterOption) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterOption) => {\n const data = (() => {\n return (\n filterGroupOption.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 return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterOption) => {\n return {}\n};"]}
|