@linzjs/lui 17.5.9 → 17.5.12

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,24 @@
1
+ ## [17.5.12](https://github.com/linz/lui/compare/v17.5.11...v17.5.12) (2022-07-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **LogoutLink:** SEARCH-3373 Add a callback to LogoutLink, so app can do something before logout. ([#709](https://github.com/linz/lui/issues/709)) ([67c7030](https://github.com/linz/lui/commit/67c703059ad8903b090bc36a487ed034938d23f2))
7
+
8
+ ## [17.5.11](https://github.com/linz/lui/compare/v17.5.10...v17.5.11) (2022-07-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * fixed btn icon colour on hover ([#708](https://github.com/linz/lui/issues/708)) ([90a1d7e](https://github.com/linz/lui/commit/90a1d7eb2c74b0e499f6b6ea8768e0f56bfdf773))
14
+
15
+ ## [17.5.10](https://github.com/linz/lui/compare/v17.5.9...v17.5.10) (2022-07-11)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **LuiSearchBox:** search 3306 search box auto focus. ([#704](https://github.com/linz/lui/issues/704)) ([c9b9938](https://github.com/linz/lui/commit/c9b9938714cdb5949525ece17314eb15668f8ea3))
21
+
1
22
  ## [17.5.9](https://github.com/linz/lui/compare/v17.5.8...v17.5.9) (2022-07-10)
2
23
 
3
24
  ## [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>;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export interface Props {
3
3
  redirectPath: () => string;
4
+ callBackBeforeLogout?: () => Promise<void>;
4
5
  }
5
6
  export declare const LOLLogoutLink: (props: Props) => JSX.Element | null;
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" }),
@@ -56581,8 +56601,14 @@ var LOLLogoutLink = function (props) {
56581
56601
  var res;
56582
56602
  return __generator(this, function (_a) {
56583
56603
  switch (_a.label) {
56584
- case 0: return [4 /*yield*/, fetch('/auth/api/logout')];
56604
+ case 0:
56605
+ if (!props.callBackBeforeLogout) return [3 /*break*/, 2];
56606
+ return [4 /*yield*/, props.callBackBeforeLogout()];
56585
56607
  case 1:
56608
+ _a.sent();
56609
+ _a.label = 2;
56610
+ case 2: return [4 /*yield*/, fetch('/auth/api/logout')];
56611
+ case 3:
56586
56612
  res = _a.sent();
56587
56613
  if (res.status === 200) {
56588
56614
  window.location.assign("/auth/login?redirectPath=" + redirectPathString);