@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.
Files changed (57) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/components/Filter/Filter.js +45 -10
  4. package/dist/src/components/Filter/Filter.js.map +1 -1
  5. package/dist/src/components/Result/Results.d.ts +0 -2
  6. package/dist/src/components/Result/Results.js +9 -21
  7. package/dist/src/components/Result/Results.js.map +1 -1
  8. package/dist/src/components/Sensor/SensorCollection.js +8 -80
  9. package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
  10. package/dist/src/components/Sensor/SensorCustom.js +6 -2
  11. package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
  12. package/dist/src/components/Sensor/SensorInventoryAvailable.js +8 -44
  13. package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
  14. package/dist/src/components/Sensor/SensorPublished.js +7 -27
  15. package/dist/src/components/Sensor/SensorPublished.js.map +1 -1
  16. package/dist/src/components/Sensor/SensorSort.js +10 -203
  17. package/dist/src/components/Sensor/SensorSort.js.map +1 -1
  18. package/dist/src/hooks/reactivesearch/index.d.ts +0 -6
  19. package/dist/src/hooks/reactivesearch/index.js +0 -6
  20. package/dist/src/hooks/reactivesearch/index.js.map +1 -1
  21. package/dist/src/hooks/usePagination.js +1 -1
  22. package/dist/src/hooks/usePagination.js.map +1 -1
  23. package/dist/src/hooks/useSortBy.js +14 -17
  24. package/dist/src/hooks/useSortBy.js.map +1 -1
  25. package/dist/src/utility/curation.d.ts +7 -0
  26. package/dist/src/utility/curation.js +85 -0
  27. package/dist/src/utility/curation.js.map +1 -0
  28. package/dist/src/utility/filters.d.ts +6 -0
  29. package/dist/src/utility/filters.js +36 -0
  30. package/dist/src/utility/filters.js.map +1 -0
  31. package/dist/src/utility/props.d.ts +143 -10
  32. package/dist/src/utility/props.js +241 -25
  33. package/dist/src/utility/props.js.map +1 -1
  34. package/dist/src/utility/server.js +1 -1
  35. package/dist/src/utility/server.js.map +1 -1
  36. package/dist/src/utility/sortOption.d.ts +22 -0
  37. package/dist/src/utility/sortOption.js +198 -0
  38. package/dist/src/utility/sortOption.js.map +1 -0
  39. package/package.json +1 -1
  40. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -84
  41. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +0 -21
  42. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +0 -1
  43. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +0 -86
  44. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +0 -32
  45. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +0 -1
  46. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +0 -77
  47. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +0 -124
  48. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +0 -1
  49. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +0 -83
  50. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +0 -28
  51. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +0 -1
  52. package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -4
  53. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +0 -32
  54. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +0 -1
  55. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +0 -6
  56. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js +0 -38
  57. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../src/utility/filters.ts"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,CAAC,OAG9B,EAAE,E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AM,KAAK,SAAS,CAClD,CAAC;IACF,IAAI,eAAe,EAAE;QACnB,OAAO,eAAe,CAAC;KACxB;IAED,+CAA+C;IAC/C,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5C,OAAO,eAAe,CAAC;AACzB,CAAC,CAAA;AAjDY,QAAA,cAAc,kBAiD1B","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config } from \"../types\";\n\nexport const getFilterStack = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n}) => {\n // select filters by type\n const matchingFilterss = options.config.filters.filter(\n (filter) => filter.type === options.provider.mode\n );\n\n // select filter stack by handle if provided\n if (options.provider.filtersHandle) {\n const matchingFilters = matchingFilterss.find(\n (filterStack) => options.provider.filtersHandle === filterStack.handle\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter stack by collection if provided\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n const matchingFilters = matchingFilterss.find((filterStack) =>\n filterStack.collections?.includes(options.provider.mode === \"collection\" ? options.provider.collectionHandle : \"\")\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter with \"default\" handle\n let matchingFilters = matchingFilterss.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any filter with \"default\" handle\n matchingFilters = options.config.filters.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any available filter as a last resort\n matchingFilters = options.config.filters[0];\n\n return matchingFilters;\n}"]}
@@ -1,13 +1,15 @@
1
1
  /// <reference types="react" />
2
2
  import { ReactiveList } from "@appbaseio/reactivesearch";
3
+ import { ReactifySearchProviderProps } from "../components";
3
4
  import { Config, ConfigFilter, ConfigFilterOption } from "../types";
4
5
  export declare type GeneratePropsFilterGroupOptions = {
5
- mode: "search" | "instant-search" | "collection";
6
+ provider: ReactifySearchProviderProps;
7
+ config: Config;
8
+ filterGroup?: ConfigFilter;
9
+ };
10
+ export declare type GeneratePropsSensorOptions = {
11
+ provider: ReactifySearchProviderProps;
6
12
  config: Config;
7
- filterGroup: ConfigFilter;
8
- additionalComponentIds?: Array<string>;
9
- includeFields?: Array<string>;
10
- excludeFields?: Array<string>;
11
13
  };
12
14
  export declare const getPropsFilterGroup: (options: GeneratePropsFilterGroupOptions) => ({
13
15
  URLParams: boolean;
@@ -78,10 +80,14 @@ export declare const getPropsFilterGroup: (options: GeneratePropsFilterGroupOpti
78
80
  };
79
81
  };
80
82
  }) | 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;
83
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | undefined;
82
84
  react: {
83
85
  and: string[];
84
86
  };
87
+ } | {
88
+ componentId: string;
89
+ customQuery: () => unknown;
90
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
85
91
  } | {
86
92
  size: number;
87
93
  URLParams: boolean;
@@ -93,13 +99,14 @@ export declare const getPropsFilterGroup: (options: GeneratePropsFilterGroupOpti
93
99
  };
94
100
  includeFields: string[];
95
101
  excludeFields: string[];
102
+ scrollTarget: string | Element | HTMLDocument | undefined;
96
103
  componentId: string;
97
104
  scrollOnChange: boolean;
98
105
  pagination: boolean;
99
106
  infiniteScroll: boolean;
100
107
  renderNoResults: () => null;
101
108
  source: typeof ReactiveList;
102
- })[];
109
+ } | null)[];
103
110
  export declare const getPropsFilterGroupOption: (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {
104
111
  URLParams: boolean;
105
112
  componentId: string;
@@ -169,12 +176,137 @@ export declare const getPropsFilterGroupOption: (options: GeneratePropsFilterGro
169
176
  };
170
177
  };
171
178
  }) | 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;
179
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | undefined;
173
180
  react: {
174
181
  and: string[];
175
182
  };
176
183
  };
177
- export declare const getPropsResults: (options: GeneratePropsFilterGroupOptions) => {
184
+ export declare const getPropsSensors: (options: GeneratePropsSensorOptions) => ({
185
+ componentId: string;
186
+ customQuery: () => unknown;
187
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
188
+ } | null)[];
189
+ export declare const getPropsSensorCustom: (options: GeneratePropsSensorOptions) => {
190
+ componentId: string;
191
+ customQuery: () => unknown;
192
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
193
+ }[];
194
+ export declare const getPropsSensorCollection: (options: GeneratePropsSensorOptions) => {
195
+ componentId: string;
196
+ customQuery: () => {
197
+ query: {
198
+ bool: {
199
+ should: ({
200
+ nested: {
201
+ path: string;
202
+ query: {
203
+ term: {
204
+ "collections.handle.keyword": string;
205
+ "curations.collectionHandle.keyword"?: undefined;
206
+ };
207
+ };
208
+ };
209
+ } | {
210
+ nested: {
211
+ path: string;
212
+ query: {
213
+ term: {
214
+ "curations.collectionHandle.keyword": string;
215
+ "collections.handle.keyword"?: undefined;
216
+ };
217
+ };
218
+ };
219
+ })[];
220
+ };
221
+ };
222
+ } | null;
223
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
224
+ } | null;
225
+ export declare const getPropsSensorPublished: (options: GeneratePropsSensorOptions) => {
226
+ componentId: string;
227
+ customQuery: () => {
228
+ query: {
229
+ bool: {
230
+ must: ({
231
+ match: {
232
+ markets: string;
233
+ published?: undefined;
234
+ };
235
+ } | {
236
+ match: {
237
+ published: boolean;
238
+ markets?: undefined;
239
+ };
240
+ })[];
241
+ };
242
+ match?: undefined;
243
+ };
244
+ } | {
245
+ query: {
246
+ match: {
247
+ published: boolean;
248
+ };
249
+ bool?: undefined;
250
+ };
251
+ };
252
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
253
+ };
254
+ export declare const getPropsSensorInventoryAvailable: (options: GeneratePropsSensorOptions) => {
255
+ componentId: string;
256
+ customQuery: () => {
257
+ query: {
258
+ bool: {
259
+ should: ({
260
+ bool: {
261
+ must: ({
262
+ term: {
263
+ type: {
264
+ value: string;
265
+ };
266
+ };
267
+ nested?: undefined;
268
+ } | {
269
+ nested: {
270
+ path: string;
271
+ query: {
272
+ match: {
273
+ "variants.available": boolean;
274
+ };
275
+ };
276
+ };
277
+ term?: undefined;
278
+ })[];
279
+ };
280
+ term?: undefined;
281
+ } | {
282
+ term: {
283
+ type: {
284
+ value: string;
285
+ };
286
+ };
287
+ bool?: undefined;
288
+ })[];
289
+ minimum_should_match: string;
290
+ };
291
+ };
292
+ };
293
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
294
+ } | null;
295
+ export declare const getPropsSensorSort: (options: GeneratePropsSensorOptions & {
296
+ searchTerm?: string;
297
+ sortOption?: string;
298
+ }) => {
299
+ componentId: string;
300
+ customQuery: () => {
301
+ sort: any[];
302
+ query: Record<string, any> | undefined;
303
+ };
304
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
305
+ };
306
+ export declare const getPropsResults: (options: GeneratePropsFilterGroupOptions & {
307
+ scrollTarget?: string | Element | HTMLDocument;
308
+ pageSize?: number;
309
+ }) => {
178
310
  size: number;
179
311
  URLParams: boolean;
180
312
  showLoader: boolean;
@@ -185,6 +317,7 @@ export declare const getPropsResults: (options: GeneratePropsFilterGroupOptions)
185
317
  };
186
318
  includeFields: string[];
187
319
  excludeFields: string[];
320
+ scrollTarget: string | Element | HTMLDocument | undefined;
188
321
  componentId: string;
189
322
  scrollOnChange: boolean;
190
323
  pagination: boolean;
@@ -264,7 +397,7 @@ export declare const getPropsShared: (options: GeneratePropsFilterGroupOptions,
264
397
  };
265
398
  };
266
399
  }) | 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;
400
+ source: import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/SingleRange").SingleRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/SingleList").SingleList, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/range/MultiRange").MultiRangeProps, any> | import("react").ComponentClass<import("@appbaseio/reactivesearch/lib/components/list/MultiList").MultiList, any> | undefined;
268
401
  react: {
269
402
  and: string[];
270
403
  };
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
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;
3
+ exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsSensorSort = exports.getPropsSensorInventoryAvailable = exports.getPropsSensorPublished = exports.getPropsSensorCollection = exports.getPropsSensorCustom = exports.getPropsSensors = exports.getPropsFilterGroupOption = exports.getPropsFilterGroup = void 0;
4
4
  const reactivesearch_1 = require("@appbaseio/reactivesearch");
5
5
  const components_1 = require("../components");
6
+ const curation_1 = require("./curation");
7
+ const sortOption_1 = require("./sortOption");
8
+ const filters_1 = require("./filters");
6
9
  const getPropsFilterGroup = (options) => {
10
+ var _a, _b;
7
11
  return [
8
- ...options.filterGroup.options.map((filterGroupOption) => (0, exports.getPropsFilterGroupOption)(options, filterGroupOption)),
12
+ ...(_b = (_a = options.filterGroup) === null || _a === void 0 ? void 0 : _a.options.map((filterGroupOption) => (0, exports.getPropsFilterGroupOption)(options, filterGroupOption))) !== null && _b !== void 0 ? _b : [],
13
+ ...(0, exports.getPropsSensors)(options),
9
14
  (0, exports.getPropsResults)(options),
10
15
  ];
11
16
  };
@@ -27,12 +32,226 @@ const getPropsFilterGroupOption = (options, filterGroupOption) => {
27
32
  return Object.assign(Object.assign({}, sharedProps), filterProps);
28
33
  };
29
34
  exports.getPropsFilterGroupOption = getPropsFilterGroupOption;
35
+ const getPropsSensors = (options) => {
36
+ return [
37
+ ...(0, exports.getPropsSensorCustom)(options),
38
+ (0, exports.getPropsSensorCollection)(options),
39
+ (0, exports.getPropsSensorPublished)(options),
40
+ (0, exports.getPropsSensorInventoryAvailable)(options),
41
+ (0, exports.getPropsSensorSort)(options),
42
+ ].filter(Boolean);
43
+ };
44
+ exports.getPropsSensors = getPropsSensors;
45
+ const getPropsSensorCustom = (options) => {
46
+ const sensors = options.provider.mode === "collection" ? options.config.sensors.collection : options.config.sensors.search;
47
+ return sensors.map((sensor, index) => ({
48
+ componentId: `SensorCustom_${index}`,
49
+ customQuery: () => sensor,
50
+ source: reactivesearch_1.ReactiveComponent,
51
+ }));
52
+ };
53
+ exports.getPropsSensorCustom = getPropsSensorCustom;
54
+ const getPropsSensorCollection = (options) => {
55
+ if (options.provider.mode !== "collection") {
56
+ return null;
57
+ }
58
+ return {
59
+ componentId: "SensorCollection",
60
+ customQuery: () => {
61
+ if (options.provider.mode !== "collection") {
62
+ return null;
63
+ }
64
+ const conditions = [];
65
+ if (options.provider.market) {
66
+ conditions.push({
67
+ nested: {
68
+ path: "curations",
69
+ query: {
70
+ bool: {
71
+ should: [
72
+ {
73
+ nested: {
74
+ path: "collections",
75
+ query: {
76
+ term: {
77
+ "collections.handle.keyword": options.provider.collectionHandle,
78
+ },
79
+ },
80
+ },
81
+ },
82
+ {
83
+ nested: {
84
+ path: "curations",
85
+ query: {
86
+ term: {
87
+ "curations.collectionHandle.keyword": options.provider.collectionHandle,
88
+ },
89
+ },
90
+ },
91
+ },
92
+ ],
93
+ must: [{
94
+ nested: {
95
+ path: "curations",
96
+ query: {
97
+ term: {
98
+ "curations.markets.keyword": options.provider.market,
99
+ },
100
+ },
101
+ },
102
+ }]
103
+ },
104
+ },
105
+ },
106
+ });
107
+ }
108
+ return {
109
+ query: {
110
+ bool: {
111
+ should: [
112
+ {
113
+ nested: {
114
+ path: "collections",
115
+ query: {
116
+ term: {
117
+ "collections.handle.keyword": options.provider.collectionHandle,
118
+ },
119
+ },
120
+ },
121
+ },
122
+ {
123
+ nested: {
124
+ path: "curations",
125
+ query: {
126
+ term: {
127
+ "curations.collectionHandle.keyword": options.provider.collectionHandle,
128
+ },
129
+ },
130
+ },
131
+ },
132
+ ],
133
+ },
134
+ },
135
+ };
136
+ },
137
+ source: reactivesearch_1.ReactiveComponent,
138
+ };
139
+ };
140
+ exports.getPropsSensorCollection = getPropsSensorCollection;
141
+ const getPropsSensorPublished = (options) => {
142
+ return {
143
+ componentId: "SensorPublished",
144
+ customQuery: () => {
145
+ if (options.provider.market) {
146
+ return {
147
+ query: {
148
+ bool: {
149
+ must: [{
150
+ match: {
151
+ markets: options.provider.market,
152
+ },
153
+ }, {
154
+ match: {
155
+ published: true,
156
+ },
157
+ }]
158
+ },
159
+ },
160
+ };
161
+ }
162
+ return {
163
+ query: {
164
+ match: {
165
+ published: true,
166
+ },
167
+ },
168
+ };
169
+ },
170
+ source: reactivesearch_1.ReactiveComponent,
171
+ };
172
+ };
173
+ exports.getPropsSensorPublished = getPropsSensorPublished;
174
+ const getPropsSensorInventoryAvailable = (options) => {
175
+ const filterStack = (0, filters_1.getFilterStack)(options);
176
+ if (!filterStack || "show_all" === filterStack.inventoryVisibility) {
177
+ return null;
178
+ }
179
+ return {
180
+ componentId: "SensorInventoryAvailable",
181
+ customQuery: () => ({
182
+ query: {
183
+ bool: {
184
+ should: [
185
+ {
186
+ bool: {
187
+ must: [
188
+ {
189
+ term: {
190
+ type: {
191
+ value: "product",
192
+ },
193
+ },
194
+ },
195
+ {
196
+ nested: {
197
+ path: "variants",
198
+ query: {
199
+ match: { "variants.available": true },
200
+ },
201
+ },
202
+ },
203
+ ],
204
+ },
205
+ },
206
+ ...(options.provider.mode === "instant-search"
207
+ ? []
208
+ : [
209
+ {
210
+ term: {
211
+ type: {
212
+ value: "callout",
213
+ },
214
+ },
215
+ },
216
+ ]),
217
+ ],
218
+ minimum_should_match: "1",
219
+ },
220
+ },
221
+ }),
222
+ source: reactivesearch_1.ReactiveComponent,
223
+ };
224
+ };
225
+ exports.getPropsSensorInventoryAvailable = getPropsSensorInventoryAvailable;
226
+ const getPropsSensorSort = (options) => {
227
+ const curation = (0, curation_1.getCuration)(options);
228
+ const sortOption = (0, sortOption_1.getSortOption)(options);
229
+ const sort = (0, sortOption_1.generateSortSort)({
230
+ provider: options.provider,
231
+ config: options.config,
232
+ curation: curation,
233
+ sortOption: sortOption,
234
+ });
235
+ const query = (0, sortOption_1.generateSortQuery)({
236
+ sortOption: sortOption,
237
+ curation: curation,
238
+ });
239
+ return {
240
+ componentId: "SensorInventoryAvailable",
241
+ customQuery: () => ({
242
+ sort,
243
+ query,
244
+ }),
245
+ source: reactivesearch_1.ReactiveComponent,
246
+ };
247
+ };
248
+ exports.getPropsSensorSort = getPropsSensorSort;
30
249
  const getPropsResults = (options) => {
31
- var _a, _b;
250
+ var _a, _b, _c, _d, _e;
32
251
  const includeFieldsProp = (() => {
33
252
  var _a;
34
253
  return [
35
- ...((_a = options.includeFields) !== null && _a !== void 0 ? _a : []),
254
+ ...((_a = options.provider.includeFields) !== null && _a !== void 0 ? _a : []),
36
255
  "id",
37
256
  "title",
38
257
  "type",
@@ -45,10 +264,10 @@ const getPropsResults = (options) => {
45
264
  })();
46
265
  const excludeFieldsProp = (() => {
47
266
  var _a;
48
- return [...((_a = options.excludeFields) !== null && _a !== void 0 ? _a : [])];
267
+ return [...((_a = options.provider.excludeFields) !== null && _a !== void 0 ? _a : [])];
49
268
  })();
50
269
  return {
51
- size: options.filterGroup.pageSize,
270
+ size: (_c = (_a = options.pageSize) !== null && _a !== void 0 ? _a : (_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.pageSize) !== null && _c !== void 0 ? _c : 20,
52
271
  URLParams: true,
53
272
  showLoader: false,
54
273
  dataField: "title",
@@ -56,18 +275,18 @@ const getPropsResults = (options) => {
56
275
  react: (0, exports.getPropsReact)(options),
57
276
  includeFields: includeFieldsProp,
58
277
  excludeFields: excludeFieldsProp,
59
- // scrollTarget: options.scrollTarget,
278
+ scrollTarget: options.scrollTarget,
60
279
  componentId: "page",
61
280
  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",
281
+ pagination: ((_d = options.filterGroup) === null || _d === void 0 ? void 0 : _d.paginationType) !== "infinite_scroll",
282
+ infiniteScroll: ((_e = options.filterGroup) === null || _e === void 0 ? void 0 : _e.paginationType) === "infinite_scroll",
64
283
  renderNoResults: () => null,
65
284
  source: reactivesearch_1.ReactiveList,
66
285
  };
67
286
  };
68
287
  exports.getPropsResults = getPropsResults;
69
288
  const getPropsReact = (options, filterGroupOption) => {
70
- const sensorIds = (0, components_1.SENSOR_IDS)(options.mode, options.config);
289
+ const sensorIds = (0, components_1.SENSOR_IDS)(options.provider.mode, options.config);
71
290
  const reactProp = (() => {
72
291
  var _a, _b, _c;
73
292
  if (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.settingsShowEmptyValues) {
@@ -78,7 +297,7 @@ const getPropsReact = (options, filterGroupOption) => {
78
297
  return {
79
298
  and: [
80
299
  ...sensorIds,
81
- ...((_a = options.additionalComponentIds) !== null && _a !== void 0 ? _a : []),
300
+ ...((_a = options.provider.additionalComponentIds) !== null && _a !== void 0 ? _a : []),
82
301
  ...((_c = (_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.options.map((filter) => filter.handle)) !== null && _c !== void 0 ? _c : []),
83
302
  ].filter((handle) => handle !== (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.handle)),
84
303
  };
@@ -227,21 +446,18 @@ const getPropsFilterList = (filterGroupOption) => {
227
446
  };
228
447
  exports.getPropsFilterList = getPropsFilterList;
229
448
  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
- })();
449
+ var _a, _b, _c, _d;
450
+ const data = (_b = (_a = filterGroupOption.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
451
+ const [label, start, end] = option.split(":");
452
+ return {
453
+ label: label,
454
+ start: start ? parseInt(start) : 0,
455
+ end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
456
+ };
457
+ })) !== null && _b !== void 0 ? _b : [];
242
458
  return {
243
- queryFormat: (_a = filterGroupOption.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or",
244
- showFilter: (_b = filterGroupOption.settingsShowFilter) !== null && _b !== void 0 ? _b : true,
459
+ queryFormat: (_c = filterGroupOption.settingsFilterLogic) !== null && _c !== void 0 ? _c : "or",
460
+ showFilter: (_d = filterGroupOption.settingsShowFilter) !== null && _d !== void 0 ? _d : true,
245
461
  showRadio: false,
246
462
  showCheckbox: false,
247
463
  data: data,
@@ -1 +1 @@
1
- {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.tsx"],"names":[],"mappings":";;;AAAA,8DAA4H;AA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9B;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};"]}
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.ts"],"names":[],"mappings":";;;AAAA,8DAA4H;AAC5H,8CAAwE;AAExE,yCAAyC;AACzC,6CAAkF;AAClF,uCAA2C;AAapC,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;;IAC9E,OAAO;QACL,GAAG,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,mCAAI,EAAE;QACvH,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC;QAC3B,IAAA,uBAAe,EAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;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,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MAAM,CAAC,gBAAgB;SACnD,CAAC;IACJ,CAAC,CAAC,mCAAI,EAAE,CAAC;IAET,OAAO;QACL,WAAW,EAAE,MAAA,iBAAiB,CAAC,mBAAmB,mCAAI,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;AAjBW,QAAA,mBAAmB,uBAiB9B;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 { ReactifySearchProviderProps, SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterOption } from \"../types\";\nimport { getCuration } from \"./curation\";\nimport { generateSortQuery, generateSortSort, getSortOption } from \"./sortOption\";\nimport { getFilterStack } from \"./filters\";\n\nexport type GeneratePropsFilterGroupOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n filterGroup?: ConfigFilter;\n};\n\nexport type GeneratePropsSensorOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup?.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)) ?? [],\n ...getPropsSensors(options),\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 getPropsSensors = (options: GeneratePropsSensorOptions) => {\n return [\n ...getPropsSensorCustom(options),\n getPropsSensorCollection(options),\n getPropsSensorPublished(options),\n getPropsSensorInventoryAvailable(options),\n getPropsSensorSort(options),\n ].filter(Boolean);\n}\n\nexport const getPropsSensorCustom = (options: GeneratePropsSensorOptions) => {\n const sensors = options.provider.mode === \"collection\" ? options.config.sensors.collection : options.config.sensors.search;\n\n return sensors.map((sensor, index) => ({\n componentId: `SensorCustom_${index}`,\n customQuery: () => sensor,\n source: ReactiveComponent,\n }));\n}\n\nexport const getPropsSensorCollection = (options: GeneratePropsSensorOptions) => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n \n return {\n componentId: \"SensorCollection\",\n customQuery: () => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n\n const conditions: Array<unknown> = [];\n\n if (options.provider.market) {\n conditions.push({\n nested: {\n path: \"curations\",\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n must: [{\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n },\n },\n }]\n },\n },\n },\n });\n }\n \n return {\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n } \n },\n source: ReactiveComponent,\n };\n}\n\nexport const getPropsSensorPublished = (options: GeneratePropsSensorOptions) => {\n return {\n componentId: \"SensorPublished\",\n customQuery: () => {\n if (options.provider.market) {\n return {\n query: {\n bool: {\n must:[{\n match: {\n markets: options.provider.market,\n },\n },{\n match: {\n published: true,\n },\n }]\n },\n },\n };\n }\n\n return {\n query: {\n match: {\n published: true,\n },\n },\n }\n },\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorInventoryAvailable = (options: GeneratePropsSensorOptions) => {\n const filterStack = getFilterStack(options);\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility) {\n return null;\n }\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n ...(options.provider.mode === \"instant-search\"\n ? []\n : [\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ]),\n ],\n minimum_should_match: \"1\",\n },\n },\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorSort = (options: GeneratePropsSensorOptions & { searchTerm?: string; sortOption?: string; }) => {\n const curation = getCuration(options);\n const sortOption = getSortOption(options);\n\n const sort = generateSortSort({\n provider: options.provider,\n config: options.config,\n curation: curation,\n sortOption: sortOption,\n });\n const query = generateSortQuery({\n sortOption: sortOption,\n curation: curation,\n });\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n sort,\n query,\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions & { scrollTarget?: string | Element | HTMLDocument; pageSize?: number; }) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.provider.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.provider.excludeFields ?? [])];\n })();\n\n return {\n size: options.pageSize ?? options.filterGroup?.pageSize ?? 20,\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.provider.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.provider.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 = 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 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};"]}
@@ -20,7 +20,7 @@ const props_1 = require("./props");
20
20
  const generateProviderProps = (options) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  const config = yield (0, config_1.getConfig)(options.shopifyPermanentDomain);
22
22
  const props = (0, props_1.getPropsFilterGroup)({
23
- mode: options.mode,
23
+ provider: options,
24
24
  config: config,
25
25
  filterGroup: config.filters[0],
26
26
  });