@linzjs/lui 21.44.0 → 21.44.2

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,17 @@
1
+ ## [21.44.2](https://github.com/linz/lui/compare/v21.44.1...v21.44.2) (2024-08-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **SearchInput:** use onMouseDown instead of onClick for search results display ([#1153](https://github.com/linz/lui/issues/1153)) ([ece2812](https://github.com/linz/lui/commit/ece281248f78a7e78bbd817bd5d444a828a521b0))
7
+
8
+ ## [21.44.1](https://github.com/linz/lui/compare/v21.44.0...v21.44.1) (2024-08-20)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * 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))
14
+
1
15
  # [21.44.0](https://github.com/linz/lui/compare/v21.43.0...v21.44.0) (2024-08-11)
2
16
 
3
17
 
package/dist/index.js CHANGED
@@ -42436,7 +42436,7 @@ var ResultsDisplay = function (_a) {
42436
42436
  var isLoading = _a.isLoading, onClick = _a.onClick, children = _a.children, selectedId = _a.selectedId, selectedRef = _a.selectedRef, setSelectedId = _a.setSelectedId, results = _a.results, renderItem = _a.renderItem;
42437
42437
  var ResultLine = function (result) {
42438
42438
  var isSelected = result.id === selectedId;
42439
- return (React__default["default"].createElement("div", { className: clsx('LuiSearchInput-resultEntry', isSelected && 'selected'), key: result.id, ref: isSelected ? selectedRef : null, onClick: function () { return onClick(result.id); }, onMouseEnter: function () { return setSelectedId(result.id); } }, renderItem(result)));
42439
+ return (React__default["default"].createElement("div", { className: clsx('LuiSearchInput-resultEntry', isSelected && 'selected'), key: result.id, ref: isSelected ? selectedRef : null, onMouseDown: function () { return onClick(result.id); }, onMouseEnter: function () { return setSelectedId(result.id); } }, renderItem(result)));
42440
42440
  };
42441
42441
  var GroupedResult = function (result) {
42442
42442
  return (React__default["default"].createElement("div", null,
@@ -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
  });