@searchspring/snap-controller 0.36.0 → 0.37.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/dist/cjs/Autocomplete/AutocompleteController.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteController.js +18 -3
- package/dist/cjs/Search/SearchController.d.ts.map +1 -1
- package/dist/cjs/Search/SearchController.js +130 -73
- package/dist/cjs/utils/getParams.d.ts.map +1 -1
- package/dist/cjs/utils/getParams.js +4 -0
- package/dist/esm/Autocomplete/AutocompleteController.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteController.js +18 -3
- package/dist/esm/Search/SearchController.d.ts.map +1 -1
- package/dist/esm/Search/SearchController.js +85 -23
- package/dist/esm/utils/getParams.d.ts.map +1 -1
- package/dist/esm/utils/getParams.js +4 -0
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,4BAA4B,EAAkD,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnJ,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,WAAW,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAk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AG,IAAI;;;;uBA8CpB,UAAU,KAAG,IAAI;;MAS5B;IAEF,MAAM,IAAI,IAAI;IAgBR,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwE3B,cAAc,QAAa,QAAQ,IAAI,CAAC,CAuBtC;IAEF,MAAM,QAAa,QAAQ,IAAI,CAAC,CAiH9B;CACF"}
|
|
@@ -76,12 +76,14 @@ exports.INPUT_DELAY = 200;
|
|
|
76
76
|
var KEY_ENTER = 13;
|
|
77
77
|
var KEY_ESCAPE = 27;
|
|
78
78
|
var PARAM_ORIGINAL_QUERY = 'oq';
|
|
79
|
+
var PARAM_FALLBACK_QUERY = 'fallbackQuery';
|
|
79
80
|
var defaultConfig = {
|
|
80
81
|
id: 'autocomplete',
|
|
81
82
|
selector: '',
|
|
82
83
|
action: '',
|
|
83
84
|
globals: {},
|
|
84
85
|
settings: {
|
|
86
|
+
integratedSpellCorrection: false,
|
|
85
87
|
initializeFromUrl: true,
|
|
86
88
|
syncInputs: true,
|
|
87
89
|
serializeForm: false,
|
|
@@ -133,8 +135,14 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
133
135
|
_e.sent();
|
|
134
136
|
return [3 /*break*/, 2];
|
|
135
137
|
case 4:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
if (this.config.settings.integratedSpellCorrection) {
|
|
139
|
+
// if integratedSpellCorrection is set, set fallbackQuery to the first suggestion as long as its value differs
|
|
140
|
+
if (input && this.store.terms.length && this.store.terms[0].value != input.value) {
|
|
141
|
+
actionUrl = actionUrl === null || actionUrl === void 0 ? void 0 : actionUrl.set(PARAM_FALLBACK_QUERY, this.store.terms[0].value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (this.store.search.originalQuery) {
|
|
145
|
+
// use corrected query and originalQuery
|
|
138
146
|
input.value = (_d = this.store.search.query) === null || _d === void 0 ? void 0 : _d.string;
|
|
139
147
|
actionUrl = actionUrl === null || actionUrl === void 0 ? void 0 : actionUrl.set(PARAM_ORIGINAL_QUERY, this.store.search.originalQuery.string);
|
|
140
148
|
}
|
|
@@ -207,7 +215,14 @@ var AutocompleteController = /** @class */ (function (_super) {
|
|
|
207
215
|
_e.sent();
|
|
208
216
|
return [3 /*break*/, 2];
|
|
209
217
|
case 4:
|
|
210
|
-
if (this.
|
|
218
|
+
if (this.config.settings.integratedSpellCorrection) {
|
|
219
|
+
// if integratedSpellCorrection is set, set fallbackQuery to the first suggestion as long as its value differs
|
|
220
|
+
if (input && this.store.terms.length && this.store.terms[0].value != input.value) {
|
|
221
|
+
addHiddenFormInput(form, PARAM_FALLBACK_QUERY, this.store.terms[0].value);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else if (this.store.search.originalQuery) {
|
|
225
|
+
// use corrected query and originalQuery
|
|
211
226
|
if (input) {
|
|
212
227
|
input.value = (_d = this.store.search.query) === null || _d === void 0 ? void 0 : _d.string;
|
|
213
228
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAkD,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7I,OAAO,KAAK,EAAE,kBAAkB,EAA2E,MAAM,2BAA2B,CAAC;AAoB7I,aAAK,kBAAkB,GAAG;IACzB,OAAO,EAAE;QACR,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,WAAW,GAAG,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0B;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,sBAAsB,CAAC;IACvC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,eAAe,CAAwC;gBAG9D,MAAM,EAAE,sBAAsB,EAC9B,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IA2F3B,KAAK,EAAE,kBAAkB,CA+BvB;IAEF,IAAI,MAAM,IAAI,kBAAkB,CAgD/B;IAED,MAAM,QAAa,QAAQ,IAAI,CAAC,CA6N9B;CACF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAiBxF"}
|
|
@@ -134,33 +134,34 @@ var SearchController = /** @class */ (function (_super) {
|
|
|
134
134
|
},
|
|
135
135
|
};
|
|
136
136
|
_this.search = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
137
|
-
var params, err_1, stringyParams, prevStringyParams, preventBackfill, dontBackfill,
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
var params, err_1, stringyParams, prevStringyParams, searchProfile, meta_1, response_1, preventBackfill, dontBackfill, previousResults, backfills, pageSize, pagesNeeded1, totalResultsNeeded, apiLimit, backfillParams, pagesNeeded, lastPageCount, i, backfillParams, backfillResults_1, backfillResponses, afterSearchProfile, err_2, afterStoreProfile, err_3, err_4;
|
|
138
|
+
var _a, _b;
|
|
139
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
140
|
+
return __generator(this, function (_u) {
|
|
141
|
+
switch (_u.label) {
|
|
141
142
|
case 0:
|
|
142
143
|
if (!!this.initialized) return [3 /*break*/, 2];
|
|
143
144
|
return [4 /*yield*/, this.init()];
|
|
144
145
|
case 1:
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
_u.sent();
|
|
147
|
+
_u.label = 2;
|
|
147
148
|
case 2:
|
|
148
149
|
params = this.params;
|
|
149
|
-
|
|
150
|
+
_u.label = 3;
|
|
150
151
|
case 3:
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
_u.trys.push([3, 23, , 24]);
|
|
153
|
+
_u.label = 4;
|
|
153
154
|
case 4:
|
|
154
|
-
|
|
155
|
+
_u.trys.push([4, 6, , 7]);
|
|
155
156
|
return [4 /*yield*/, this.eventManager.fire('beforeSearch', {
|
|
156
157
|
controller: this,
|
|
157
158
|
request: params,
|
|
158
159
|
})];
|
|
159
160
|
case 5:
|
|
160
|
-
|
|
161
|
+
_u.sent();
|
|
161
162
|
return [3 /*break*/, 7];
|
|
162
163
|
case 6:
|
|
163
|
-
err_1 =
|
|
164
|
+
err_1 = _u.sent();
|
|
164
165
|
if ((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) == 'cancelled') {
|
|
165
166
|
this.log.warn("'beforeSearch' middleware cancelled");
|
|
166
167
|
return [2 /*return*/];
|
|
@@ -177,64 +178,120 @@ var SearchController = /** @class */ (function (_super) {
|
|
|
177
178
|
// no param change - not searching
|
|
178
179
|
return [2 /*return*/];
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
searchProfile = this.profiler.create({ type: 'event', name: 'search', context: params }).start();
|
|
182
|
+
if (!(((_c = this.config.settings) === null || _c === void 0 ? void 0 : _c.infinite) && ((_d = params.pagination) === null || _d === void 0 ? void 0 : _d.page) > 1)) return [3 /*break*/, 12];
|
|
183
|
+
preventBackfill = ((_e = this.config.settings.infinite) === null || _e === void 0 ? void 0 : _e.backfill) && !this.store.results.length && ((_f = params.pagination) === null || _f === void 0 ? void 0 : _f.page) > this.config.settings.infinite.backfill;
|
|
184
|
+
dontBackfill = !((_g = this.config.settings.infinite) === null || _g === void 0 ? void 0 : _g.backfill) && !this.store.results.length && ((_h = params.pagination) === null || _h === void 0 ? void 0 : _h.page) > 1;
|
|
185
|
+
//if the page is higher than the backfill setting redirect back to page 1
|
|
186
|
+
if (preventBackfill || dontBackfill) {
|
|
187
|
+
this.storage.set('scrollMap', {});
|
|
188
|
+
this.urlManager.set('page', 1).go();
|
|
189
|
+
return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
previousResults = this.previousResults;
|
|
192
|
+
backfills = [];
|
|
193
|
+
if (((_j = this.config.settings) === null || _j === void 0 ? void 0 : _j.infinite.backfill) && !previousResults.length) {
|
|
194
|
+
pageSize = ((_k = params.pagination) === null || _k === void 0 ? void 0 : _k.pageSize) || this.store.pagination.pageSize || this.store.pagination.defaultPageSize;
|
|
195
|
+
pagesNeeded1 = ((_l = params.pagination) === null || _l === void 0 ? void 0 : _l.page) && ((_m = params.pagination) === null || _m === void 0 ? void 0 : _m.page) > ((_o = this.config.settings) === null || _o === void 0 ? void 0 : _o.infinite.backfill)
|
|
196
|
+
? (_p = this.config.settings) === null || _p === void 0 ? void 0 : _p.infinite.backfill
|
|
197
|
+
: (_q = params.pagination) === null || _q === void 0 ? void 0 : _q.page;
|
|
198
|
+
totalResultsNeeded = pageSize * (pagesNeeded1 || 1);
|
|
199
|
+
apiLimit = 500;
|
|
200
|
+
// our search api is limited to a certain amount per request.
|
|
201
|
+
//so we will need to make more than one request if totalresultsneeded is greater.
|
|
202
|
+
if (totalResultsNeeded < apiLimit) {
|
|
203
|
+
backfillParams = (0, deepmerge_1.default)(__assign({}, params), { pagination: { pageSize: totalResultsNeeded, page: 1 } });
|
|
204
|
+
backfills.push(this.client.search(backfillParams));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
pagesNeeded = Math.ceil(totalResultsNeeded / apiLimit);
|
|
208
|
+
lastPageCount = apiLimit - (pagesNeeded * apiLimit - totalResultsNeeded);
|
|
209
|
+
for (i = 1; i <= pagesNeeded; i++) {
|
|
210
|
+
backfillParams = (0, deepmerge_1.default)(__assign({}, params), { pagination: { pageSize: i < pagesNeeded ? apiLimit : lastPageCount, page: i } });
|
|
211
|
+
backfills.push(this.client.search(backfillParams));
|
|
212
|
+
}
|
|
187
213
|
}
|
|
188
214
|
}
|
|
189
|
-
|
|
190
|
-
|
|
215
|
+
if (!(backfills && backfills.length)) return [3 /*break*/, 9];
|
|
216
|
+
backfillResults_1 = [];
|
|
217
|
+
return [4 /*yield*/, Promise.all(backfills)];
|
|
191
218
|
case 8:
|
|
192
|
-
|
|
219
|
+
backfillResponses = _u.sent();
|
|
220
|
+
backfillResponses.map(function (_a) {
|
|
221
|
+
var Bmeta = _a[0], Bresponse = _a[1];
|
|
222
|
+
if (!meta_1) {
|
|
223
|
+
meta_1 = Bmeta;
|
|
224
|
+
}
|
|
225
|
+
if (!response_1) {
|
|
226
|
+
response_1 = Bresponse;
|
|
227
|
+
backfillResults_1 = response_1.results;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
backfillResults_1 = backfillResults_1.concat(Bresponse.results);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (!response_1.meta) {
|
|
234
|
+
/**
|
|
235
|
+
* MockClient will overwrite the client search() method and use
|
|
236
|
+
* SearchData to return mock data which already contains meta data
|
|
237
|
+
*/
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
response_1.meta = meta_1;
|
|
240
|
+
}
|
|
241
|
+
//we need to overwrite the pagination params so the ui doesnt get confused.
|
|
242
|
+
response_1.pagination.pageSize = ((_r = params.pagination) === null || _r === void 0 ? void 0 : _r.pageSize) || this.store.pagination.pageSize || this.store.pagination.defaultPageSize;
|
|
243
|
+
response_1.pagination.page = (_s = params.pagination) === null || _s === void 0 ? void 0 : _s.page;
|
|
244
|
+
//set the response results after all backfill promises are resolved.
|
|
245
|
+
response_1.results = backfillResults_1;
|
|
246
|
+
return [3 /*break*/, 11];
|
|
247
|
+
case 9: return [4 /*yield*/, this.client.search(params)];
|
|
248
|
+
case 10:
|
|
249
|
+
// infinite with no backfills.
|
|
250
|
+
_a = _u.sent(), meta_1 = _a[0], response_1 = _a[1];
|
|
193
251
|
// @ts-ignore
|
|
194
|
-
if (!
|
|
252
|
+
if (!response_1.meta) {
|
|
195
253
|
/**
|
|
196
254
|
* MockClient will overwrite the client search() method and use
|
|
197
255
|
* SearchData to return mock data which already contains meta data
|
|
198
256
|
*/
|
|
199
257
|
// @ts-ignore
|
|
200
|
-
|
|
258
|
+
response_1.meta = meta_1;
|
|
201
259
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
260
|
+
//append new results to previous results
|
|
261
|
+
response_1.results = __spreadArray(__spreadArray([], previousResults, true), (response_1.results || []), true);
|
|
262
|
+
_u.label = 11;
|
|
263
|
+
case 11: return [3 /*break*/, 14];
|
|
264
|
+
case 12: return [4 /*yield*/, this.client.search(params)];
|
|
265
|
+
case 13:
|
|
266
|
+
//standard.
|
|
267
|
+
_b = _u.sent(), meta_1 = _b[0], response_1 = _b[1];
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
if (!response_1.meta) {
|
|
270
|
+
/**
|
|
271
|
+
* MockClient will overwrite the client search() method and use
|
|
272
|
+
* SearchData to return mock data which already contains meta data
|
|
273
|
+
*/
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
response_1.meta = meta_1;
|
|
209
276
|
}
|
|
210
|
-
|
|
211
|
-
case
|
|
212
|
-
backfillResponses = _m.sent();
|
|
213
|
-
backfillResponses.map(function (_a) {
|
|
214
|
-
var meta = _a[0], data = _a[1];
|
|
215
|
-
previousResults_1 = previousResults_1.concat(data.results);
|
|
216
|
-
});
|
|
217
|
-
_m.label = 10;
|
|
218
|
-
case 10:
|
|
219
|
-
response.results = __spreadArray(__spreadArray([], previousResults_1, true), (response.results || []), true);
|
|
220
|
-
_m.label = 11;
|
|
221
|
-
case 11:
|
|
277
|
+
_u.label = 14;
|
|
278
|
+
case 14:
|
|
222
279
|
searchProfile.stop();
|
|
223
280
|
this.log.profile(searchProfile);
|
|
224
281
|
afterSearchProfile = this.profiler.create({ type: 'event', name: 'afterSearch', context: params }).start();
|
|
225
|
-
|
|
226
|
-
case
|
|
227
|
-
|
|
282
|
+
_u.label = 15;
|
|
283
|
+
case 15:
|
|
284
|
+
_u.trys.push([15, 17, , 18]);
|
|
228
285
|
return [4 /*yield*/, this.eventManager.fire('afterSearch', {
|
|
229
286
|
controller: this,
|
|
230
287
|
request: params,
|
|
231
|
-
response:
|
|
288
|
+
response: response_1,
|
|
232
289
|
})];
|
|
233
|
-
case
|
|
234
|
-
|
|
235
|
-
return [3 /*break*/,
|
|
236
|
-
case
|
|
237
|
-
err_2 =
|
|
290
|
+
case 16:
|
|
291
|
+
_u.sent();
|
|
292
|
+
return [3 /*break*/, 18];
|
|
293
|
+
case 17:
|
|
294
|
+
err_2 = _u.sent();
|
|
238
295
|
if ((err_2 === null || err_2 === void 0 ? void 0 : err_2.message) == 'cancelled') {
|
|
239
296
|
this.log.warn("'afterSearch' middleware cancelled");
|
|
240
297
|
afterSearchProfile.stop();
|
|
@@ -244,29 +301,29 @@ var SearchController = /** @class */ (function (_super) {
|
|
|
244
301
|
this.log.error("error in 'afterSearch' middleware");
|
|
245
302
|
throw err_2;
|
|
246
303
|
}
|
|
247
|
-
return [3 /*break*/,
|
|
248
|
-
case
|
|
304
|
+
return [3 /*break*/, 18];
|
|
305
|
+
case 18:
|
|
249
306
|
afterSearchProfile.stop();
|
|
250
307
|
this.log.profile(afterSearchProfile);
|
|
251
|
-
if ((
|
|
252
|
-
this.previousResults = JSON.parse(JSON.stringify(
|
|
308
|
+
if ((_t = this.config.settings) === null || _t === void 0 ? void 0 : _t.infinite) {
|
|
309
|
+
this.previousResults = JSON.parse(JSON.stringify(response_1.results));
|
|
253
310
|
}
|
|
254
311
|
// update the store
|
|
255
|
-
this.store.update(
|
|
312
|
+
this.store.update(response_1);
|
|
256
313
|
afterStoreProfile = this.profiler.create({ type: 'event', name: 'afterStore', context: params }).start();
|
|
257
|
-
|
|
258
|
-
case
|
|
259
|
-
|
|
314
|
+
_u.label = 19;
|
|
315
|
+
case 19:
|
|
316
|
+
_u.trys.push([19, 21, , 22]);
|
|
260
317
|
return [4 /*yield*/, this.eventManager.fire('afterStore', {
|
|
261
318
|
controller: this,
|
|
262
319
|
request: params,
|
|
263
|
-
response:
|
|
320
|
+
response: response_1,
|
|
264
321
|
})];
|
|
265
|
-
case
|
|
266
|
-
|
|
267
|
-
return [3 /*break*/,
|
|
268
|
-
case
|
|
269
|
-
err_3 =
|
|
322
|
+
case 20:
|
|
323
|
+
_u.sent();
|
|
324
|
+
return [3 /*break*/, 22];
|
|
325
|
+
case 21:
|
|
326
|
+
err_3 = _u.sent();
|
|
270
327
|
if ((err_3 === null || err_3 === void 0 ? void 0 : err_3.message) == 'cancelled') {
|
|
271
328
|
this.log.warn("'afterStore' middleware cancelled");
|
|
272
329
|
afterStoreProfile.stop();
|
|
@@ -276,13 +333,13 @@ var SearchController = /** @class */ (function (_super) {
|
|
|
276
333
|
this.log.error("error in 'afterStore' middleware");
|
|
277
334
|
throw err_3;
|
|
278
335
|
}
|
|
279
|
-
return [3 /*break*/,
|
|
280
|
-
case
|
|
336
|
+
return [3 /*break*/, 22];
|
|
337
|
+
case 22:
|
|
281
338
|
afterStoreProfile.stop();
|
|
282
339
|
this.log.profile(afterStoreProfile);
|
|
283
|
-
return [3 /*break*/,
|
|
284
|
-
case
|
|
285
|
-
err_4 =
|
|
340
|
+
return [3 /*break*/, 24];
|
|
341
|
+
case 23:
|
|
342
|
+
err_4 = _u.sent();
|
|
286
343
|
if (err_4) {
|
|
287
344
|
switch (err_4) {
|
|
288
345
|
case 429:
|
|
@@ -308,8 +365,8 @@ var SearchController = /** @class */ (function (_super) {
|
|
|
308
365
|
this.store.loading = false;
|
|
309
366
|
this.handleError(err_4);
|
|
310
367
|
}
|
|
311
|
-
return [3 /*break*/,
|
|
312
|
-
case
|
|
368
|
+
return [3 /*break*/, 24];
|
|
369
|
+
case 24: return [2 /*return*/];
|
|
313
370
|
}
|
|
314
371
|
});
|
|
315
372
|
}); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getParams.d.ts","sourceRoot":"","sources":["../../../src/utils/getParams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getParams.d.ts","sourceRoot":"","sources":["../../../src/utils/getParams.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqF7E"}
|
|
@@ -20,6 +20,10 @@ function getSearchParams(state) {
|
|
|
20
20
|
params.search = params.search || {};
|
|
21
21
|
params.search.originalQuery = state.oq;
|
|
22
22
|
}
|
|
23
|
+
if (state.fallbackQuery) {
|
|
24
|
+
params.search = params.search || {};
|
|
25
|
+
params.search.fallbackQuery = state.fallbackQuery;
|
|
26
|
+
}
|
|
23
27
|
if (state.page) {
|
|
24
28
|
params.pagination = params.pagination || {};
|
|
25
29
|
params.pagination.page = state.page;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,4BAA4B,EAAkD,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnJ,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,WAAW,M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pD,aAAa,KAAG,IAAI;uBAMrB,UAAU,KAAG,IAAI;4BAQN,MAAM,SAAS,CAAC,gBAAgB,CAAC,KAAG,QAAQ,IAAI,CAAC;mCAgDhD,MAAM,WAAW,CAAC,gBAAgB,CAAC,KAAG,IAAI;uBAqBtD,aAAa,KAAG,IAAI;;;;uBA8CpB,UAAU,KAAG,IAAI;;MAS5B;IAEF,MAAM,IAAI,IAAI;IAgBR,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwE3B,cAAc,QAAa,QAAQ,IAAI,CAAC,CAuBtC;IAEF,MAAM,QAAa,QAAQ,IAAI,CAAC,CAiH9B;CACF"}
|
|
@@ -8,12 +8,14 @@ export const INPUT_DELAY = 200;
|
|
|
8
8
|
const KEY_ENTER = 13;
|
|
9
9
|
const KEY_ESCAPE = 27;
|
|
10
10
|
const PARAM_ORIGINAL_QUERY = 'oq';
|
|
11
|
+
const PARAM_FALLBACK_QUERY = 'fallbackQuery';
|
|
11
12
|
const defaultConfig = {
|
|
12
13
|
id: 'autocomplete',
|
|
13
14
|
selector: '',
|
|
14
15
|
action: '',
|
|
15
16
|
globals: {},
|
|
16
17
|
settings: {
|
|
18
|
+
integratedSpellCorrection: false,
|
|
17
19
|
initializeFromUrl: true,
|
|
18
20
|
syncInputs: true,
|
|
19
21
|
serializeForm: false,
|
|
@@ -50,8 +52,14 @@ export class AutocompleteController extends AbstractController {
|
|
|
50
52
|
while (this.store.loading) {
|
|
51
53
|
await timeout(INPUT_DELAY);
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
if (this.config.settings.integratedSpellCorrection) {
|
|
56
|
+
// if integratedSpellCorrection is set, set fallbackQuery to the first suggestion as long as its value differs
|
|
57
|
+
if (input && this.store.terms.length && this.store.terms[0].value != input.value) {
|
|
58
|
+
actionUrl = actionUrl?.set(PARAM_FALLBACK_QUERY, this.store.terms[0].value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (this.store.search.originalQuery) {
|
|
62
|
+
// use corrected query and originalQuery
|
|
55
63
|
input.value = this.store.search.query?.string;
|
|
56
64
|
actionUrl = actionUrl?.set(PARAM_ORIGINAL_QUERY, this.store.search.originalQuery.string);
|
|
57
65
|
}
|
|
@@ -102,7 +110,14 @@ export class AutocompleteController extends AbstractController {
|
|
|
102
110
|
while (this.store.loading) {
|
|
103
111
|
await timeout(INPUT_DELAY);
|
|
104
112
|
}
|
|
105
|
-
if (this.
|
|
113
|
+
if (this.config.settings.integratedSpellCorrection) {
|
|
114
|
+
// if integratedSpellCorrection is set, set fallbackQuery to the first suggestion as long as its value differs
|
|
115
|
+
if (input && this.store.terms.length && this.store.terms[0].value != input.value) {
|
|
116
|
+
addHiddenFormInput(form, PARAM_FALLBACK_QUERY, this.store.terms[0].value);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (this.store.search.originalQuery) {
|
|
120
|
+
// use corrected query and originalQuery
|
|
106
121
|
if (input) {
|
|
107
122
|
input.value = this.store.search.query?.string;
|
|
108
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAA0B,MAAM,+BAA+B,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAkD,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7I,OAAO,KAAK,EAAE,kBAAkB,EAA2E,MAAM,2BAA2B,CAAC;AAoB7I,aAAK,kBAAkB,GAAG;IACzB,OAAO,EAAE;QACR,KAAK,EAAE,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;CACF,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,kBAAkB;IAChD,IAAI,kBAA0B;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,sBAAsB,CAAC;IACvC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,eAAe,CAAwC;gBAG9D,MAAM,EAAE,sBAAsB,EAC9B,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IA2F3B,KAAK,EAAE,kBAAkB,CA+BvB;IAEF,IAAI,MAAM,IAAI,kBAAkB,CAgD/B;IAED,MAAM,QAAa,QAAQ,IAAI,CAAC,CA6N9B;CACF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAiBxF"}
|
|
@@ -79,45 +79,107 @@ export class SearchController extends AbstractController {
|
|
|
79
79
|
// no param change - not searching
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const searchProfile = this.profiler.create({ type: 'event', name: 'search', context: params }).start();
|
|
83
|
+
let meta;
|
|
84
|
+
let response;
|
|
85
|
+
// infinite functionality
|
|
86
|
+
// if params.page > 1 and infinite setting exists we should append results
|
|
87
|
+
if (this.config.settings?.infinite && params.pagination?.page > 1) {
|
|
84
88
|
const preventBackfill = this.config.settings.infinite?.backfill && !this.store.results.length && params.pagination?.page > this.config.settings.infinite.backfill;
|
|
85
89
|
const dontBackfill = !this.config.settings.infinite?.backfill && !this.store.results.length && params.pagination?.page > 1;
|
|
90
|
+
//if the page is higher than the backfill setting redirect back to page 1
|
|
86
91
|
if (preventBackfill || dontBackfill) {
|
|
87
92
|
this.storage.set('scrollMap', {});
|
|
88
93
|
this.urlManager.set('page', 1).go();
|
|
89
94
|
return;
|
|
90
95
|
}
|
|
91
|
-
}
|
|
92
|
-
const searchProfile = this.profiler.create({ type: 'event', name: 'search', context: params }).start();
|
|
93
|
-
const [meta, response] = await this.client.search(params);
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
if (!response.meta) {
|
|
96
|
-
/**
|
|
97
|
-
* MockClient will overwrite the client search() method and use
|
|
98
|
-
* SearchData to return mock data which already contains meta data
|
|
99
|
-
*/
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
response.meta = meta;
|
|
102
|
-
}
|
|
103
|
-
// infinite functionality
|
|
104
|
-
// if params.page > 1 and infinite setting exists we should append results
|
|
105
|
-
if (this.config.settings?.infinite && params.pagination?.page > 1) {
|
|
106
96
|
// if no results fetch results...
|
|
107
97
|
let previousResults = this.previousResults;
|
|
98
|
+
const backfills = [];
|
|
108
99
|
if (this.config.settings?.infinite.backfill && !previousResults.length) {
|
|
109
100
|
// figure out how many pages of results to backfill and wait on all responses
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
const pageSize = params.pagination?.pageSize || this.store.pagination.pageSize || this.store.pagination.defaultPageSize;
|
|
102
|
+
let pagesNeeded1 = params.pagination?.page && params.pagination?.page > this.config.settings?.infinite.backfill
|
|
103
|
+
? this.config.settings?.infinite.backfill
|
|
104
|
+
: params.pagination?.page;
|
|
105
|
+
let totalResultsNeeded = pageSize * (pagesNeeded1 || 1);
|
|
106
|
+
const apiLimit = 500;
|
|
107
|
+
// our search api is limited to a certain amount per request.
|
|
108
|
+
//so we will need to make more than one request if totalresultsneeded is greater.
|
|
109
|
+
if (totalResultsNeeded < apiLimit) {
|
|
110
|
+
const backfillParams = deepmerge({ ...params }, { pagination: { pageSize: totalResultsNeeded, page: 1 } });
|
|
113
111
|
backfills.push(this.client.search(backfillParams));
|
|
114
112
|
}
|
|
113
|
+
else {
|
|
114
|
+
//how many pages are needed?
|
|
115
|
+
let pagesNeeded = Math.ceil(totalResultsNeeded / apiLimit);
|
|
116
|
+
// we dont want to get the full apiLimit # of results on the last page, so lets find out how many are left.
|
|
117
|
+
let lastPageCount = apiLimit - (pagesNeeded * apiLimit - totalResultsNeeded);
|
|
118
|
+
for (let i = 1; i <= pagesNeeded; i++) {
|
|
119
|
+
const backfillParams = deepmerge({ ...params }, { pagination: { pageSize: i < pagesNeeded ? apiLimit : lastPageCount, page: i } });
|
|
120
|
+
backfills.push(this.client.search(backfillParams));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//infinite backfill and prev results
|
|
125
|
+
// use the previous results and only make request for new result
|
|
126
|
+
if (backfills && backfills.length) {
|
|
127
|
+
let backfillResults = [];
|
|
115
128
|
const backfillResponses = await Promise.all(backfills);
|
|
116
|
-
backfillResponses.map(([
|
|
117
|
-
|
|
129
|
+
backfillResponses.map(([Bmeta, Bresponse]) => {
|
|
130
|
+
if (!meta) {
|
|
131
|
+
meta = Bmeta;
|
|
132
|
+
}
|
|
133
|
+
if (!response) {
|
|
134
|
+
response = Bresponse;
|
|
135
|
+
backfillResults = response.results;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
backfillResults = backfillResults.concat(Bresponse.results);
|
|
139
|
+
}
|
|
118
140
|
});
|
|
141
|
+
if (!response.meta) {
|
|
142
|
+
/**
|
|
143
|
+
* MockClient will overwrite the client search() method and use
|
|
144
|
+
* SearchData to return mock data which already contains meta data
|
|
145
|
+
*/
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
response.meta = meta;
|
|
148
|
+
}
|
|
149
|
+
//we need to overwrite the pagination params so the ui doesnt get confused.
|
|
150
|
+
response.pagination.pageSize = params.pagination?.pageSize || this.store.pagination.pageSize || this.store.pagination.defaultPageSize;
|
|
151
|
+
response.pagination.page = params.pagination?.page;
|
|
152
|
+
//set the response results after all backfill promises are resolved.
|
|
153
|
+
response.results = backfillResults;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// infinite with no backfills.
|
|
157
|
+
[meta, response] = await this.client.search(params);
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
if (!response.meta) {
|
|
160
|
+
/**
|
|
161
|
+
* MockClient will overwrite the client search() method and use
|
|
162
|
+
* SearchData to return mock data which already contains meta data
|
|
163
|
+
*/
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
response.meta = meta;
|
|
166
|
+
}
|
|
167
|
+
//append new results to previous results
|
|
168
|
+
response.results = [...previousResults, ...(response.results || [])];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
//standard.
|
|
173
|
+
[meta, response] = await this.client.search(params);
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
if (!response.meta) {
|
|
176
|
+
/**
|
|
177
|
+
* MockClient will overwrite the client search() method and use
|
|
178
|
+
* SearchData to return mock data which already contains meta data
|
|
179
|
+
*/
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
response.meta = meta;
|
|
119
182
|
}
|
|
120
|
-
response.results = [...previousResults, ...(response.results || [])];
|
|
121
183
|
}
|
|
122
184
|
searchProfile.stop();
|
|
123
185
|
this.log.profile(searchProfile);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getParams.d.ts","sourceRoot":"","sources":["../../../src/utils/getParams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getParams.d.ts","sourceRoot":"","sources":["../../../src/utils/getParams.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqF7E"}
|
|
@@ -17,6 +17,10 @@ export function getSearchParams(state) {
|
|
|
17
17
|
params.search = params.search || {};
|
|
18
18
|
params.search.originalQuery = state.oq;
|
|
19
19
|
}
|
|
20
|
+
if (state.fallbackQuery) {
|
|
21
|
+
params.search = params.search || {};
|
|
22
|
+
params.search.fallbackQuery = state.fallbackQuery;
|
|
23
|
+
}
|
|
20
24
|
if (state.page) {
|
|
21
25
|
params.pagination = params.pagination || {};
|
|
22
26
|
params.pagination.page = state.page;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchspring/snap-controller",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "Snap Controllers",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
"test:watch": "jest --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@searchspring/snap-toolbox": "^0.
|
|
23
|
+
"@searchspring/snap-toolbox": "^0.37.1",
|
|
24
24
|
"deepmerge": "4.2.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@searchspring/snap-client": "^0.
|
|
28
|
-
"@searchspring/snap-event-manager": "^0.
|
|
29
|
-
"@searchspring/snap-logger": "^0.
|
|
30
|
-
"@searchspring/snap-profiler": "^0.
|
|
31
|
-
"@searchspring/snap-store-mobx": "^0.
|
|
32
|
-
"@searchspring/snap-tracker": "^0.
|
|
33
|
-
"@searchspring/snap-url-manager": "^0.
|
|
27
|
+
"@searchspring/snap-client": "^0.37.1",
|
|
28
|
+
"@searchspring/snap-event-manager": "^0.37.1",
|
|
29
|
+
"@searchspring/snap-logger": "^0.37.1",
|
|
30
|
+
"@searchspring/snap-profiler": "^0.37.1",
|
|
31
|
+
"@searchspring/snap-store-mobx": "^0.37.1",
|
|
32
|
+
"@searchspring/snap-tracker": "^0.37.1",
|
|
33
|
+
"@searchspring/snap-url-manager": "^0.37.1"
|
|
34
34
|
},
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"files": [
|
|
37
37
|
"dist/**/*"
|
|
38
38
|
],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "aa7796aaea7e111ac70cb3f3349d4a096a64faf6"
|
|
40
40
|
}
|