@linzjs/lui 21.44.0 → 21.44.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [21.44.1](https://github.com/linz/lui/compare/v21.44.0...v21.44.1) (2024-08-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * clean the last search result when empty the search input ([#1150](https://github.com/linz/lui/issues/1150)) ([fb5d306](https://github.com/linz/lui/commit/fb5d306d3e13e7e88a3f0c9b327beb3f43ab9768))
7
+
1
8
  # [21.44.0](https://github.com/linz/lui/compare/v21.43.0...v21.44.0) (2024-08-11)
2
9
 
3
10
 
package/dist/index.js CHANGED
@@ -42535,19 +42535,20 @@ var LuiSearchInput = function (props) {
42535
42535
  }
42536
42536
  }
42537
42537
  function retrieveResults(input) {
42538
+ var _a;
42538
42539
  return __awaiter(this, void 0, void 0, function () {
42539
42540
  var results_1, items, selectedIdInResults;
42540
- return __generator(this, function (_a) {
42541
- switch (_a.label) {
42541
+ return __generator(this, function (_b) {
42542
+ switch (_b.label) {
42542
42543
  case 0:
42543
- if (!(input !== '' && input.length >= props.minCharactersForSearch)) return [3 /*break*/, 4];
42544
+ if (!(input !== '' && input.length >= props.minCharactersForSearch)) return [3 /*break*/, 5];
42544
42545
  setIsLoading(true);
42545
- _a.label = 1;
42546
+ _b.label = 1;
42546
42547
  case 1:
42547
- _a.trys.push([1, , 3, 4]);
42548
+ _b.trys.push([1, , 3, 4]);
42548
42549
  return [4 /*yield*/, props.getOptions(input)];
42549
42550
  case 2:
42550
- results_1 = _a.sent();
42551
+ results_1 = _b.sent();
42551
42552
  items = flatten(results_1);
42552
42553
  setResults(results_1);
42553
42554
  selectedIdInResults = items.some(function (item) { return item.id === selectedId; });
@@ -42558,7 +42559,20 @@ var LuiSearchInput = function (props) {
42558
42559
  case 3:
42559
42560
  setIsLoading(false);
42560
42561
  return [7 /*endfinally*/];
42561
- case 4: return [2 /*return*/];
42562
+ case 4: return [3 /*break*/, 6];
42563
+ case 5:
42564
+ if (input !== '' &&
42565
+ input.length < props.minCharactersForSearch &&
42566
+ results.length > 0) {
42567
+ setResults([]);
42568
+ }
42569
+ else if (input === '' && results.length > 0) {
42570
+ setInputValue('');
42571
+ (_a = props.onClearCallback) === null || _a === void 0 ? void 0 : _a.call(props);
42572
+ setResults([]);
42573
+ }
42574
+ _b.label = 6;
42575
+ case 6: return [2 /*return*/];
42562
42576
  }
42563
42577
  });
42564
42578
  });