@pro6pp/infer-react 0.0.2-beta.14 → 0.0.2-beta.15
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/index.cjs +21 -5
- package/dist/index.js +21 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -47,7 +47,8 @@ var DEFAULTS = {
|
|
|
47
47
|
MAX_RETRIES: 0
|
|
48
48
|
};
|
|
49
49
|
var PATTERNS = {
|
|
50
|
-
DIGITS_1_3: /^[0-9]{1,3}
|
|
50
|
+
DIGITS_1_3: /^[0-9]{1,3}$/,
|
|
51
|
+
STREET_NUMBER_PREFIX: /^(\d+)\s*,\s*$/
|
|
51
52
|
};
|
|
52
53
|
var INITIAL_STATE = {
|
|
53
54
|
query: "",
|
|
@@ -115,7 +116,8 @@ var InferCore = class {
|
|
|
115
116
|
value: null,
|
|
116
117
|
isLoading: !!value.trim(),
|
|
117
118
|
selectedSuggestionIndex: -1,
|
|
118
|
-
hasMore: false
|
|
119
|
+
hasMore: false,
|
|
120
|
+
stage: isEditingFinal ? null : this.state.stage
|
|
119
121
|
});
|
|
120
122
|
if (isEditingFinal) {
|
|
121
123
|
this.onSelect(null);
|
|
@@ -246,10 +248,20 @@ var InferCore = class {
|
|
|
246
248
|
} else {
|
|
247
249
|
const prefix = this.getQueryPrefix(query);
|
|
248
250
|
const shouldAddSubtitle = !prefix || !prefix.includes(subtitle);
|
|
251
|
+
let effectivePrefix = prefix;
|
|
252
|
+
if (prefix && subtitle) {
|
|
253
|
+
const prefixNumMatch = prefix.match(PATTERNS.STREET_NUMBER_PREFIX);
|
|
254
|
+
if (prefixNumMatch) {
|
|
255
|
+
const num = prefixNumMatch[1];
|
|
256
|
+
if (subtitle.startsWith(num)) {
|
|
257
|
+
effectivePrefix = "";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
249
261
|
if (shouldAddSubtitle) {
|
|
250
|
-
nextQuery =
|
|
262
|
+
nextQuery = effectivePrefix ? `${effectivePrefix} ${text}, ${subtitle}, ` : `${text}, ${subtitle}, `;
|
|
251
263
|
} else {
|
|
252
|
-
nextQuery =
|
|
264
|
+
nextQuery = effectivePrefix ? `${effectivePrefix} ${text}, ` : `${text}, `;
|
|
253
265
|
}
|
|
254
266
|
}
|
|
255
267
|
this.updateQueryAndFetch(nextQuery);
|
|
@@ -344,7 +356,11 @@ var InferCore = class {
|
|
|
344
356
|
if (data.stage === "mixed") {
|
|
345
357
|
newState.cities = data.cities || [];
|
|
346
358
|
newState.streets = data.streets || [];
|
|
347
|
-
newState.
|
|
359
|
+
if (newState.cities?.length === 0 && newState.streets?.length === 0) {
|
|
360
|
+
newState.suggestions = uniqueSuggestions;
|
|
361
|
+
} else {
|
|
362
|
+
newState.suggestions = [];
|
|
363
|
+
}
|
|
348
364
|
} else {
|
|
349
365
|
newState.suggestions = uniqueSuggestions;
|
|
350
366
|
newState.cities = [];
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,8 @@ var DEFAULTS = {
|
|
|
21
21
|
MAX_RETRIES: 0
|
|
22
22
|
};
|
|
23
23
|
var PATTERNS = {
|
|
24
|
-
DIGITS_1_3: /^[0-9]{1,3}
|
|
24
|
+
DIGITS_1_3: /^[0-9]{1,3}$/,
|
|
25
|
+
STREET_NUMBER_PREFIX: /^(\d+)\s*,\s*$/
|
|
25
26
|
};
|
|
26
27
|
var INITIAL_STATE = {
|
|
27
28
|
query: "",
|
|
@@ -89,7 +90,8 @@ var InferCore = class {
|
|
|
89
90
|
value: null,
|
|
90
91
|
isLoading: !!value.trim(),
|
|
91
92
|
selectedSuggestionIndex: -1,
|
|
92
|
-
hasMore: false
|
|
93
|
+
hasMore: false,
|
|
94
|
+
stage: isEditingFinal ? null : this.state.stage
|
|
93
95
|
});
|
|
94
96
|
if (isEditingFinal) {
|
|
95
97
|
this.onSelect(null);
|
|
@@ -220,10 +222,20 @@ var InferCore = class {
|
|
|
220
222
|
} else {
|
|
221
223
|
const prefix = this.getQueryPrefix(query);
|
|
222
224
|
const shouldAddSubtitle = !prefix || !prefix.includes(subtitle);
|
|
225
|
+
let effectivePrefix = prefix;
|
|
226
|
+
if (prefix && subtitle) {
|
|
227
|
+
const prefixNumMatch = prefix.match(PATTERNS.STREET_NUMBER_PREFIX);
|
|
228
|
+
if (prefixNumMatch) {
|
|
229
|
+
const num = prefixNumMatch[1];
|
|
230
|
+
if (subtitle.startsWith(num)) {
|
|
231
|
+
effectivePrefix = "";
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
223
235
|
if (shouldAddSubtitle) {
|
|
224
|
-
nextQuery =
|
|
236
|
+
nextQuery = effectivePrefix ? `${effectivePrefix} ${text}, ${subtitle}, ` : `${text}, ${subtitle}, `;
|
|
225
237
|
} else {
|
|
226
|
-
nextQuery =
|
|
238
|
+
nextQuery = effectivePrefix ? `${effectivePrefix} ${text}, ` : `${text}, `;
|
|
227
239
|
}
|
|
228
240
|
}
|
|
229
241
|
this.updateQueryAndFetch(nextQuery);
|
|
@@ -318,7 +330,11 @@ var InferCore = class {
|
|
|
318
330
|
if (data.stage === "mixed") {
|
|
319
331
|
newState.cities = data.cities || [];
|
|
320
332
|
newState.streets = data.streets || [];
|
|
321
|
-
newState.
|
|
333
|
+
if (newState.cities?.length === 0 && newState.streets?.length === 0) {
|
|
334
|
+
newState.suggestions = uniqueSuggestions;
|
|
335
|
+
} else {
|
|
336
|
+
newState.suggestions = [];
|
|
337
|
+
}
|
|
322
338
|
} else {
|
|
323
339
|
newState.suggestions = uniqueSuggestions;
|
|
324
340
|
newState.cities = [];
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"url": "https://github.com/pro6pp/infer-sdk/issues"
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false,
|
|
23
|
-
"version": "0.0.2-beta.
|
|
23
|
+
"version": "0.0.2-beta.15",
|
|
24
24
|
"main": "./dist/index.cjs",
|
|
25
25
|
"module": "./dist/index.js",
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react": ">=16"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@pro6pp/infer-core": "0.0.2-beta.
|
|
49
|
+
"@pro6pp/infer-core": "0.0.2-beta.13"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@testing-library/dom": "^10.4.1",
|