@linzjs/lui 21.41.0 → 21.42.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/LuiSearchBox/LuiSearchBox.d.ts +5 -1
- package/dist/components/LuiSearchInput/LuiSearchInput.d.ts +2 -0
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/lui.css +14 -6
- package/dist/lui.css.map +1 -1
- package/dist/lui.esm.js +12 -7
- package/dist/lui.esm.js.map +1 -1
- package/dist/scss/Components/LuiSearchBox/LuiSearchBox.scss +6 -2
- package/dist/scss/Components/LuiSearchInput/LuiSearchInput.scss +11 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [21.42.0](https://github.com/linz/lui/compare/v21.41.0...v21.42.0) (2024-07-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Updates search box to support searching using external inputs ([#1147](https://github.com/linz/lui/issues/1147)) ([d944764](https://github.com/linz/lui/commit/d9447649200edcef3e3bc16f049465cec75303e1))
|
|
7
|
+
|
|
1
8
|
# [21.41.0](https://github.com/linz/lui/compare/v21.40.5...v21.41.0) (2024-07-23)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -20,11 +20,15 @@ export interface ILuiSearchBoxProps {
|
|
|
20
20
|
initOptionValue?: string;
|
|
21
21
|
onMenuSelect?: (e: Event) => void;
|
|
22
22
|
autoFocus?: boolean;
|
|
23
|
+
externalSearch?: boolean;
|
|
24
|
+
searchString?: string;
|
|
25
|
+
onClickInput?: () => void;
|
|
26
|
+
onClearInput?: () => void;
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* LuiSearchBox is a search input with select menu.
|
|
26
30
|
* The options of the menu and input can be passed in as an array.
|
|
27
31
|
* See examples in SearchBox in storybook.
|
|
28
32
|
*/
|
|
29
|
-
export declare const LuiSearchBox: ({ searchBoxOptions, initOptionValue, onMenuSelect, autoFocus, }: ILuiSearchBoxProps) => JSX.Element;
|
|
33
|
+
export declare const LuiSearchBox: ({ searchBoxOptions, initOptionValue, onMenuSelect, autoFocus, externalSearch, searchString, onClickInput, onClearInput, }: ILuiSearchBoxProps) => JSX.Element;
|
|
30
34
|
export declare const LuiSearchBoxButton: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<LuiButtonProps>, "type" | "href" | "openInNewTab" | "level" | "size" | "disabled" | "style" | "onClick" | "name" | "title" | "data-testid" | "className" | "buttonProps" | "children"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -13,5 +13,7 @@ export interface ISearchInputProps<SearchResult extends ISearchResult = ISearchR
|
|
|
13
13
|
name?: string;
|
|
14
14
|
focusUpdate?: boolean;
|
|
15
15
|
onClearCallback?: () => void;
|
|
16
|
+
onClickInput?: () => void;
|
|
17
|
+
externalSearch?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export declare const LuiSearchInput: <SearchResult extends ISearchResult = ISearchResult>(props: React.PropsWithChildren<ISearchInputProps<SearchResult>>) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -42469,7 +42469,7 @@ var LuiSearchInput = function (props) {
|
|
|
42469
42469
|
var _e = React.useState(false), isLoading = _e[0], setIsLoading = _e[1];
|
|
42470
42470
|
var inputRef = React.useRef(null);
|
|
42471
42471
|
var selectedRef = React.useRef(null);
|
|
42472
|
-
//set focus to
|
|
42472
|
+
// set focus to input box
|
|
42473
42473
|
React.useEffect(function () {
|
|
42474
42474
|
var _a;
|
|
42475
42475
|
if (props.focusUpdate !== undefined)
|
|
@@ -42479,6 +42479,11 @@ var LuiSearchInput = function (props) {
|
|
|
42479
42479
|
React.useEffect(function () {
|
|
42480
42480
|
setResults([]);
|
|
42481
42481
|
}, [props.getOptions]);
|
|
42482
|
+
React.useEffect(function () {
|
|
42483
|
+
if (props.externalSearch) {
|
|
42484
|
+
setTypedValue(props.initialValue ? props.initialValue : '');
|
|
42485
|
+
}
|
|
42486
|
+
}, [props.initialValue, props.externalSearch]);
|
|
42482
42487
|
function setInputValue(value) {
|
|
42483
42488
|
setTypedValue(props.inputTransformer ? props.inputTransformer(value) : value);
|
|
42484
42489
|
}
|
|
@@ -42584,7 +42589,7 @@ var LuiSearchInput = function (props) {
|
|
|
42584
42589
|
setResults([]);
|
|
42585
42590
|
}
|
|
42586
42591
|
} })) : null;
|
|
42587
|
-
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(); } } }));
|
|
42592
|
+
var searchIcon = props.externalSearch ? (React__default["default"].createElement(LuiIcon, { className: "LuiSearchInput-startIconPosition ".concat(typedValue ? 'LuiSearchInput-startIconPosition-enabled' : ''), name: "ic_create", size: "md", alt: "edit", spanProps: { onClick: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } } })) : (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(); } } }));
|
|
42588
42593
|
var typeMore = 'You need to type a few more characters';
|
|
42589
42594
|
function enoughChars(input) {
|
|
42590
42595
|
if (typeof props.minCharactersForSearch === 'number')
|
|
@@ -42604,16 +42609,16 @@ var LuiSearchInput = function (props) {
|
|
|
42604
42609
|
else
|
|
42605
42610
|
return null;
|
|
42606
42611
|
}
|
|
42607
|
-
return (React__default["default"].createElement("div", { className: "LuiSearchInput" },
|
|
42612
|
+
return (React__default["default"].createElement("div", { className: "LuiSearchInput", onClick: props.onClickInput },
|
|
42608
42613
|
React__default["default"].createElement("span", { className: "LuiSearchInput-inputWrapper" },
|
|
42609
42614
|
searchIcon,
|
|
42610
42615
|
React__default["default"].createElement("input", { type: "text", className: clsx('LuiSearchInput-input'), ref: inputRef, value: typedValue, placeholder: props.placeholderText, "aria-label": "Search", onChange: function (e) { return setInputValue(e.target.value); }, onKeyDown: handleKeyDown, onFocus: function (e) {
|
|
42611
42616
|
e.target.select();
|
|
42612
42617
|
retrieveResults(typedValue);
|
|
42613
42618
|
setHaveFocus(true);
|
|
42614
|
-
},
|
|
42619
|
+
}, style: { pointerEvents: props.externalSearch ? 'none' : 'auto' },
|
|
42615
42620
|
// This timeout could be a little brittle but allows the menu to stay open long enough to click it
|
|
42616
|
-
onBlur: function () { return setTimeout(function () { return setHaveFocus(false); }, 200); } }),
|
|
42621
|
+
onBlur: function () { return setTimeout(function () { return setHaveFocus(false); }, 200); }, disabled: props.externalSearch }),
|
|
42617
42622
|
cancelIcon),
|
|
42618
42623
|
(isLoading || results.length > 0) && haveFocus && (React__default["default"].createElement("div", null,
|
|
42619
42624
|
React__default["default"].createElement(ResultsDisplay, { results: results, selectedId: selectedId, setSelectedId: setSelectedId, selectedRef: selectedRef, onClick: selectItem, isLoading: isLoading, renderItem: props.renderItem }))),
|
|
@@ -42638,7 +42643,7 @@ var resultStyle = { verticalAlign: 'middle' };
|
|
|
42638
42643
|
var LuiSearchBox = function (_a) {
|
|
42639
42644
|
var _b;
|
|
42640
42645
|
var _c;
|
|
42641
|
-
var searchBoxOptions = _a.searchBoxOptions, initOptionValue = _a.initOptionValue, onMenuSelect = _a.onMenuSelect, autoFocus = _a.autoFocus;
|
|
42646
|
+
var searchBoxOptions = _a.searchBoxOptions, initOptionValue = _a.initOptionValue, onMenuSelect = _a.onMenuSelect, autoFocus = _a.autoFocus, externalSearch = _a.externalSearch, searchString = _a.searchString, onClickInput = _a.onClickInput, onClearInput = _a.onClearInput;
|
|
42642
42647
|
var initOption = searchBoxOptions.find(function (_a) {
|
|
42643
42648
|
var value = _a.value;
|
|
42644
42649
|
return value === initOptionValue;
|
|
@@ -42707,7 +42712,7 @@ var LuiSearchBox = function (_a) {
|
|
|
42707
42712
|
? selectedMenuOption.renderItem
|
|
42708
42713
|
: function (item) {
|
|
42709
42714
|
return React__default["default"].createElement("span", { style: resultStyle }, item.description);
|
|
42710
|
-
}, disclaimer: selectedMenuOption.disclaimer, focusUpdate: autoFocus && isFocus ? focusUpdate : undefined }))));
|
|
42715
|
+
}, disclaimer: selectedMenuOption.disclaimer, focusUpdate: autoFocus && isFocus ? focusUpdate : undefined, externalSearch: externalSearch, initialValue: !!externalSearch ? searchString : undefined, onClickInput: onClickInput, onClearCallback: onClearInput }))));
|
|
42711
42716
|
};
|
|
42712
42717
|
var LuiSearchBoxButton = React__default["default"].forwardRef(function (props, ref) {
|
|
42713
42718
|
var button = React.useMemo(function () {
|