@linzjs/lui 17.4.0 → 17.5.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/CHANGELOG.md +7 -0
- package/dist/components/LuiSearchInput/LuiSearchInput.d.ts +1 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/lui.esm.js +26 -1
- package/dist/lui.esm.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [17.5.0](https://github.com/linz/lui/compare/v17.4.0...v17.5.0) (2022-06-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **LuiSearchInput:** Add no result message to LuiSearchInput component. ([#689](https://github.com/linz/lui/issues/689)) ([f7d23c3](https://github.com/linz/lui/commit/f7d23c3107c8a87db179fb869c43537b7d634c05))
|
|
7
|
+
|
|
1
8
|
# [17.4.0](https://github.com/linz/lui/compare/v17.3.3...v17.4.0) (2022-06-01)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -19,6 +19,7 @@ export interface ISearchInputProps {
|
|
|
19
19
|
disclaimer?: string;
|
|
20
20
|
initialValue?: string;
|
|
21
21
|
inputTransformer?: (input: string) => string;
|
|
22
|
+
name?: string;
|
|
22
23
|
}
|
|
23
24
|
export declare function isGroupedResult(result: ISearchResult[] | ISearchGroupedResult[]): result is ISearchGroupedResult[];
|
|
24
25
|
export declare const LuiSearchInput: React.FC<ISearchInputProps>;
|
package/dist/index.js
CHANGED
|
@@ -56014,6 +56014,25 @@ var LuiSearchInput = function (props) {
|
|
|
56014
56014
|
},
|
|
56015
56015
|
} })) : null;
|
|
56016
56016
|
var searchIcon = (React__default["default"].createElement(LuiIcon, { className: 'LuiSearchInput-startIconPosition', name: "ic_search", size: "md", alt: "search", spanProps: { onClick: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } } }));
|
|
56017
|
+
var typeMore = 'You need to type a few more characters';
|
|
56018
|
+
function enoughChars(input) {
|
|
56019
|
+
if (typeof props.minCharactersForSearch === 'number')
|
|
56020
|
+
return input.length >= props.minCharactersForSearch;
|
|
56021
|
+
else
|
|
56022
|
+
return false;
|
|
56023
|
+
}
|
|
56024
|
+
function noOptionsMessage(inputValue) {
|
|
56025
|
+
if (inputValue === '') {
|
|
56026
|
+
return null;
|
|
56027
|
+
}
|
|
56028
|
+
if (!enoughChars(inputValue)) {
|
|
56029
|
+
return typeMore;
|
|
56030
|
+
}
|
|
56031
|
+
if (props.name)
|
|
56032
|
+
return "The " + props.name + " could not be displayed or does not exist.";
|
|
56033
|
+
else
|
|
56034
|
+
return null;
|
|
56035
|
+
}
|
|
56017
56036
|
return (React__default["default"].createElement("div", { className: "LuiSearchInput" },
|
|
56018
56037
|
React__default["default"].createElement("span", { className: "LuiSearchInput-inputWrapper" },
|
|
56019
56038
|
searchIcon,
|
|
@@ -56022,10 +56041,16 @@ var LuiSearchInput = function (props) {
|
|
|
56022
56041
|
setHaveFocus(true);
|
|
56023
56042
|
},
|
|
56024
56043
|
// This timeout could be a little brittle but allows the menu to stay open long enough to click it
|
|
56025
|
-
onBlur: function () { return setTimeout(function () { return setHaveFocus(false); },
|
|
56044
|
+
onBlur: function () { return setTimeout(function () { return setHaveFocus(false); }, 200); } }),
|
|
56026
56045
|
cancelIcon),
|
|
56027
56046
|
(isLoading || results.length > 0) && haveFocus && (React__default["default"].createElement("div", null,
|
|
56028
56047
|
React__default["default"].createElement(ResultsDisplay, { results: results, selectedId: selectedId, setSelectedId: setSelectedId, selectedRef: selectedRef, onClick: selectItem, isLoading: isLoading, renderItem: props.renderItem }))),
|
|
56048
|
+
props.name &&
|
|
56049
|
+
haveFocus &&
|
|
56050
|
+
results.length === 0 &&
|
|
56051
|
+
noOptionsMessage(typedValue) && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
56052
|
+
React__default["default"].createElement("hr", { className: "LuiSearchInput-resultSeparator" }),
|
|
56053
|
+
React__default["default"].createElement("div", { "data-testid": "no-result-msg", className: "LuiSearchInput-disclaimer" }, noOptionsMessage(typedValue)))),
|
|
56029
56054
|
props.disclaimer && haveFocus && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
56030
56055
|
React__default["default"].createElement("hr", { className: "LuiSearchInput-resultSeparator" }),
|
|
56031
56056
|
React__default["default"].createElement("div", { "data-testid": "disclaimer", className: "LuiSearchInput-disclaimer" }, props.disclaimer)))));
|