@searchspring/snap-controller 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Autocomplete/AutocompleteController.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteController.js +18 -3
- 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/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,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAA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,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":"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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AK,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,CAAC,EAAE,gBAAgB;IAoD3B,KAAK,EAAE,wBAAwB,CAO7B;IAEF,IAAI,MAAM,IAAI,wBAAwB,CA0CrC;IAEK,UAAU,CAAC,YAAY,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsChE,KAAK,IAAI,IAAI;IASb,QAAQ;;0BAEc,aAAa,KAAG,QAAQ,OAAO,GAAG,SAAS,CAAC;wBAkDpD,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":"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.0",
|
|
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.0",
|
|
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.0",
|
|
28
|
+
"@searchspring/snap-event-manager": "^0.37.0",
|
|
29
|
+
"@searchspring/snap-logger": "^0.37.0",
|
|
30
|
+
"@searchspring/snap-profiler": "^0.37.0",
|
|
31
|
+
"@searchspring/snap-store-mobx": "^0.37.0",
|
|
32
|
+
"@searchspring/snap-tracker": "^0.37.0",
|
|
33
|
+
"@searchspring/snap-url-manager": "^0.37.0"
|
|
34
34
|
},
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"files": [
|
|
37
37
|
"dist/**/*"
|
|
38
38
|
],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "d917c5638aa9a0d7eba3e453e70ff36278c96afa"
|
|
40
40
|
}
|