@linzjs/lui 17.5.9 → 17.5.10
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 +2 -1
- package/dist/components/LuiSearchInput/LuiSearchInput.d.ts +1 -0
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/lui.esm.js +22 -2
- package/dist/lui.esm.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [17.5.10](https://github.com/linz/lui/compare/v17.5.9...v17.5.10) (2022-07-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **LuiSearchBox:** search 3306 search box auto focus. ([#704](https://github.com/linz/lui/issues/704)) ([c9b9938](https://github.com/linz/lui/commit/c9b9938714cdb5949525ece17314eb15668f8ea3))
|
|
7
|
+
|
|
1
8
|
## [17.5.9](https://github.com/linz/lui/compare/v17.5.8...v17.5.9) (2022-07-10)
|
|
2
9
|
|
|
3
10
|
## [17.5.8](https://github.com/linz/lui/compare/v17.5.7...v17.5.8) (2022-07-05)
|
|
@@ -17,11 +17,12 @@ export interface ILuiSearchBoxProps {
|
|
|
17
17
|
searchBoxOptions: ISearchMenuOption[];
|
|
18
18
|
initOptionValue?: string;
|
|
19
19
|
onMenuSelect?: (e: Event) => void;
|
|
20
|
+
autoFocus?: boolean;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* LuiSearchBox is a search input with select menu.
|
|
23
24
|
* The options of the menu and input can be passed in as an array.
|
|
24
25
|
* See examples in SearchBox in storybook.
|
|
25
26
|
*/
|
|
26
|
-
export declare const LuiSearchBox: ({ searchBoxOptions, initOptionValue, onMenuSelect, }: ILuiSearchBoxProps) => JSX.Element;
|
|
27
|
+
export declare const LuiSearchBox: ({ searchBoxOptions, initOptionValue, onMenuSelect, autoFocus, }: ILuiSearchBoxProps) => JSX.Element;
|
|
27
28
|
export declare const LuiSearchBoxButton: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<LuiButtonProps>, "href" | "openInNewTab" | "level" | "type" | "size" | "disabled" | "style" | "onClick" | "name" | "title" | "data-testid" | "className" | "buttonProps" | "children"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -20,6 +20,7 @@ export interface ISearchInputProps {
|
|
|
20
20
|
initialValue?: string;
|
|
21
21
|
inputTransformer?: (input: string) => string;
|
|
22
22
|
name?: string;
|
|
23
|
+
focusUpdate?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export declare function isGroupedResult(result: ISearchResult[] | ISearchGroupedResult[]): result is ISearchGroupedResult[];
|
|
25
26
|
export declare const LuiSearchInput: React.FC<ISearchInputProps>;
|
package/dist/index.js
CHANGED
|
@@ -55927,6 +55927,12 @@ var LuiSearchInput = function (props) {
|
|
|
55927
55927
|
var _e = React.useState(false), isLoading = _e[0], setIsLoading = _e[1];
|
|
55928
55928
|
var inputRef = React.useRef(null);
|
|
55929
55929
|
var selectedRef = React.useRef(null);
|
|
55930
|
+
//set focus to inut box
|
|
55931
|
+
React.useEffect(function () {
|
|
55932
|
+
var _a;
|
|
55933
|
+
if (props.focusUpdate !== undefined)
|
|
55934
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
55935
|
+
}, [props.focusUpdate]);
|
|
55930
55936
|
//clear result after search types changed
|
|
55931
55937
|
React.useEffect(function () {
|
|
55932
55938
|
setResults([]);
|
|
@@ -56086,16 +56092,30 @@ var resultStyle$1 = { verticalAlign: 'middle' };
|
|
|
56086
56092
|
* See examples in SearchBox in storybook.
|
|
56087
56093
|
*/
|
|
56088
56094
|
var LuiSearchBox = function (_a) {
|
|
56089
|
-
var searchBoxOptions = _a.searchBoxOptions, initOptionValue = _a.initOptionValue, onMenuSelect = _a.onMenuSelect;
|
|
56095
|
+
var searchBoxOptions = _a.searchBoxOptions, initOptionValue = _a.initOptionValue, onMenuSelect = _a.onMenuSelect, autoFocus = _a.autoFocus;
|
|
56090
56096
|
var initOption = searchBoxOptions.find(function (_a) {
|
|
56091
56097
|
var value = _a.value;
|
|
56092
56098
|
return value === initOptionValue;
|
|
56093
56099
|
});
|
|
56094
56100
|
var _b = React.useState(initOption ? initOption : searchBoxOptions[0]), selectedMenuOption = _b[0], setSelectedMenuOption = _b[1];
|
|
56101
|
+
//auto focus every time select a menu item
|
|
56102
|
+
var _c = React.useState(false), focusUpdate = _c[0], setFocusUpdate = _c[1];
|
|
56103
|
+
//don't focus when first time display
|
|
56104
|
+
var _d = React.useState(false), isFocus = _d[0], setIsFocus = _d[1];
|
|
56105
|
+
React.useEffect(function () {
|
|
56106
|
+
var updatedOption = searchBoxOptions.find(function (_a) {
|
|
56107
|
+
var value = _a.value;
|
|
56108
|
+
return value === initOptionValue;
|
|
56109
|
+
});
|
|
56110
|
+
if (updatedOption)
|
|
56111
|
+
setSelectedMenuOption(updatedOption);
|
|
56112
|
+
}, [initOptionValue]);
|
|
56095
56113
|
var handleMenuSelected = function (e) {
|
|
56096
56114
|
setSelectedMenuOption(findSelectedOption(e.value));
|
|
56097
56115
|
if (onMenuSelect !== undefined)
|
|
56098
56116
|
onMenuSelect(e);
|
|
56117
|
+
setIsFocus(true);
|
|
56118
|
+
setFocusUpdate(!focusUpdate);
|
|
56099
56119
|
};
|
|
56100
56120
|
var findSelectedOption = function (v) {
|
|
56101
56121
|
var selectedOption = searchBoxOptions.find(function (_a) {
|
|
@@ -56111,7 +56131,7 @@ var LuiSearchBox = function (_a) {
|
|
|
56111
56131
|
? selectedMenuOption.renderItem
|
|
56112
56132
|
: function (item) {
|
|
56113
56133
|
return React__default["default"].createElement("span", { style: resultStyle$1 }, item.description);
|
|
56114
|
-
}, disclaimer: selectedMenuOption.disclaimer }))));
|
|
56134
|
+
}, disclaimer: selectedMenuOption.disclaimer, focusUpdate: autoFocus && isFocus ? focusUpdate : undefined }))));
|
|
56115
56135
|
};
|
|
56116
56136
|
var LuiSearchBoxButton = React__default["default"].forwardRef(function (props, ref) {
|
|
56117
56137
|
return (React__default["default"].createElement(LuiButton, __assign({ level: "tertiary" }, props, { ref: ref, className: "LuiSearchBox-button" }),
|