@pro6pp/infer-react 0.0.2-beta.11 → 0.0.2-beta.12

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 CHANGED
@@ -199,9 +199,10 @@ var InferCore = class {
199
199
  if (this.state.stage === "final" || isFullResult) {
200
200
  let finalQuery = label;
201
201
  if (valueObj && Object.keys(valueObj).length > 0) {
202
- const { street, street_number, city } = valueObj;
202
+ const { street, street_number, city, addition } = valueObj;
203
203
  if (street && street_number && city) {
204
- finalQuery = `${street} ${street_number}, ${city}`;
204
+ const suffix = addition ? ` ${addition}` : "";
205
+ finalQuery = `${street} ${street_number}${suffix}, ${city}`;
205
206
  }
206
207
  }
207
208
  this.finishSelection(finalQuery, valueObj);
@@ -241,7 +242,12 @@ var InferCore = class {
241
242
  nextQuery = `${subtitle}, ${text}, `;
242
243
  } else {
243
244
  const prefix = this.getQueryPrefix(query);
244
- nextQuery = prefix ? `${prefix} ${text}, ${subtitle}, ` : `${text}, ${subtitle}, `;
245
+ const shouldAddSubtitle = !prefix || !prefix.includes(subtitle);
246
+ if (shouldAddSubtitle) {
247
+ nextQuery = prefix ? `${prefix} ${text}, ${subtitle}, ` : `${text}, ${subtitle}, `;
248
+ } else {
249
+ nextQuery = prefix ? `${prefix} ${text}, ` : `${text}, `;
250
+ }
245
251
  }
246
252
  this.updateQueryAndFetch(nextQuery);
247
253
  return;
@@ -341,6 +347,9 @@ var InferCore = class {
341
347
  }
342
348
  newState.isValid = data.stage === "final";
343
349
  this.updateState(newState);
350
+ if (newState.isValid && uniqueSuggestions.length === 1) {
351
+ this.selectItem(uniqueSuggestions[0]);
352
+ }
344
353
  }
345
354
  updateQueryAndFetch(nextQuery) {
346
355
  this.updateState({ query: nextQuery, suggestions: [], cities: [], streets: [] });
package/dist/index.js CHANGED
@@ -173,9 +173,10 @@ var InferCore = class {
173
173
  if (this.state.stage === "final" || isFullResult) {
174
174
  let finalQuery = label;
175
175
  if (valueObj && Object.keys(valueObj).length > 0) {
176
- const { street, street_number, city } = valueObj;
176
+ const { street, street_number, city, addition } = valueObj;
177
177
  if (street && street_number && city) {
178
- finalQuery = `${street} ${street_number}, ${city}`;
178
+ const suffix = addition ? ` ${addition}` : "";
179
+ finalQuery = `${street} ${street_number}${suffix}, ${city}`;
179
180
  }
180
181
  }
181
182
  this.finishSelection(finalQuery, valueObj);
@@ -215,7 +216,12 @@ var InferCore = class {
215
216
  nextQuery = `${subtitle}, ${text}, `;
216
217
  } else {
217
218
  const prefix = this.getQueryPrefix(query);
218
- nextQuery = prefix ? `${prefix} ${text}, ${subtitle}, ` : `${text}, ${subtitle}, `;
219
+ const shouldAddSubtitle = !prefix || !prefix.includes(subtitle);
220
+ if (shouldAddSubtitle) {
221
+ nextQuery = prefix ? `${prefix} ${text}, ${subtitle}, ` : `${text}, ${subtitle}, `;
222
+ } else {
223
+ nextQuery = prefix ? `${prefix} ${text}, ` : `${text}, `;
224
+ }
219
225
  }
220
226
  this.updateQueryAndFetch(nextQuery);
221
227
  return;
@@ -315,6 +321,9 @@ var InferCore = class {
315
321
  }
316
322
  newState.isValid = data.stage === "final";
317
323
  this.updateState(newState);
324
+ if (newState.isValid && uniqueSuggestions.length === 1) {
325
+ this.selectItem(uniqueSuggestions[0]);
326
+ }
318
327
  }
319
328
  updateQueryAndFetch(nextQuery) {
320
329
  this.updateState({ query: nextQuery, suggestions: [], cities: [], streets: [] });
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.11",
23
+ "version": "0.0.2-beta.12",
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.9"
49
+ "@pro6pp/infer-core": "0.0.2-beta.10"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@testing-library/dom": "^10.4.1",