@linzjs/lui 21.22.0 → 21.23.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [21.23.0](https://github.com/linz/lui/compare/v21.22.0...v21.23.0) (2024-02-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Extend pros for SearchInput:** TI-1738 ([#1099](https://github.com/linz/lui/issues/1099)) ([794be11](https://github.com/linz/lui/commit/794be111ff52e03a043e043722c0bba0f473bd43))
7
+
1
8
  # [21.22.0](https://github.com/linz/lui/compare/v21.21.0...v21.22.0) (2024-02-15)
2
9
 
3
10
 
@@ -1,6 +1,6 @@
1
1
  import React, { ReactElement } from 'react';
2
2
  import { LuiButtonProps } from '../LuiButton/LuiButton';
3
- import { ISearchResult, ISearchGroupedResult } from '../LuiSearchInput/LuiSearchInput';
3
+ import { ISearchGroupedResult, ISearchResult } from '../LuiSearchInput/ResultsDisplay';
4
4
  export interface ISearchMenuOption {
5
5
  name?: string;
6
6
  groupTitle?: string;
@@ -1,21 +1,12 @@
1
1
  import React, { ReactElement } from 'react';
2
2
  import 'react-loading-skeleton/dist/skeleton.css';
3
- export interface ISearchResult {
4
- id: string;
5
- description: string;
6
- }
7
- export interface ISearchGroupedResult {
8
- id: string;
9
- description: string;
10
- label: string;
11
- items: ISearchResult[];
12
- }
13
- export interface ISearchInputProps {
3
+ import { ISearchGroupedResult, ISearchResult } from './ResultsDisplay';
4
+ export interface ISearchInputProps<SearchResult extends ISearchResult = ISearchResult> {
14
5
  minCharactersForSearch: number;
15
6
  placeholderText: string;
16
- onSelectOption: (selectedOption: ISearchResult) => void;
17
- getOptions: (inputValue: string) => Promise<ISearchResult[] | ISearchGroupedResult[]>;
18
- renderItem: (item: ISearchResult) => ReactElement;
7
+ onSelectOption: (selectedOption: SearchResult) => void;
8
+ getOptions: (inputValue: string) => Promise<SearchResult[] | ISearchGroupedResult<SearchResult>[]>;
9
+ renderItem: (item: SearchResult) => ReactElement;
19
10
  disclaimer?: string;
20
11
  initialValue?: string;
21
12
  inputTransformer?: (input: string) => string;
@@ -23,5 +14,4 @@ export interface ISearchInputProps {
23
14
  focusUpdate?: boolean;
24
15
  onClearCallback?: () => void;
25
16
  }
26
- export declare function isGroupedResult(result: ISearchResult[] | ISearchGroupedResult[]): result is ISearchGroupedResult[];
27
- export declare const LuiSearchInput: React.FC<React.PropsWithChildren<ISearchInputProps>>;
17
+ export declare const LuiSearchInput: <SearchResult extends ISearchResult = ISearchResult>(props: React.PropsWithChildren<ISearchInputProps<SearchResult>>) => JSX.Element;
@@ -1,13 +1,23 @@
1
1
  import React, { ReactElement, RefObject } from 'react';
2
- import { ISearchGroupedResult, ISearchResult } from './LuiSearchInput';
3
- export interface IResultsProps {
2
+ export interface ISearchResult {
3
+ id: string;
4
+ description: string;
5
+ }
6
+ export interface ISearchGroupedResult<SearchResult extends ISearchResult = ISearchResult> {
7
+ id: string;
8
+ description: string;
9
+ label: string;
10
+ items: SearchResult[];
11
+ }
12
+ export interface IResultsProps<SearchResult extends ISearchResult = ISearchResult> {
4
13
  selectedId: string;
5
14
  isLoading: boolean;
6
15
  onClick: (id: string) => void;
7
16
  setSelectedId: (id: string) => void;
8
- renderItem: (item: ISearchResult) => ReactElement;
9
- results: ISearchResult[] | ISearchGroupedResult[];
17
+ renderItem: (item: SearchResult) => ReactElement;
18
+ results: SearchResult[] | ISearchGroupedResult<SearchResult>[];
10
19
  selectedRef: RefObject<HTMLDivElement>;
11
20
  }
12
- declare const ResultsDisplay: React.FC<React.PropsWithChildren<IResultsProps>>;
21
+ export declare function isGroupedResult<SearchResult extends ISearchResult = ISearchResult>(result: SearchResult[] | ISearchGroupedResult<SearchResult>[]): result is ISearchGroupedResult<SearchResult>[];
22
+ declare const ResultsDisplay: <SearchResults extends ISearchResult = ISearchResult>({ isLoading, onClick, children, selectedId, selectedRef, setSelectedId, results, renderItem, }: React.PropsWithChildren<IResultsProps<SearchResults>>) => ReactElement;
13
23
  export default ResultsDisplay;
package/dist/index.d.ts CHANGED
@@ -37,7 +37,8 @@ export * from './components/LuiHeaderMenu/LuiHeaderMenus';
37
37
  export * from './components/LuiHeaderMenuV2/LuiHeaderMenusV2';
38
38
  export { LuiUpdatesSplashModal } from './components/LuiUpdateSplashModal/LuiUpdatesSplashModal';
39
39
  export { LuiModal, LuiAlertModal, LuiAlertModalButtons, } from './components/LuiModal/LuiModal';
40
- export { type ISearchInputProps, type ISearchGroupedResult, type ISearchResult, LuiSearchInput, } from './components/LuiSearchInput/LuiSearchInput';
40
+ export { type ISearchInputProps, LuiSearchInput, } from './components/LuiSearchInput/LuiSearchInput';
41
+ export { type ISearchGroupedResult, type ISearchResult, } from './components/LuiSearchInput/ResultsDisplay';
41
42
  export { type ISearchMenuOption, type ILuiSearchBoxProps, LuiSearchBox, } from './components/LuiSearchBox/LuiSearchBox';
42
43
  export { type ILuiSplitButtonProps, type ILuiSplitButtonMenuItemProps, LuiSplitButtonPosition, LuiSplitButtonMenuItem, LuiSplitButton, } from './components/LuiSplitButton/LuiSplitButton';
43
44
  export { LuiErrorPage } from './components/LuiErrorPage/LuiErrorPage';
package/dist/index.js CHANGED
@@ -42336,6 +42336,12 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
42336
42336
  }
42337
42337
 
42338
42338
  var SKELETON_COUNT = 3;
42339
+ function isGroupedResult(result) {
42340
+ if (result && result.length) {
42341
+ return (result[0].items !== undefined);
42342
+ }
42343
+ return false;
42344
+ }
42339
42345
  var ResultsDisplay = function (_a) {
42340
42346
  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;
42341
42347
  var ResultLine = function (result) {
@@ -42367,12 +42373,6 @@ var ResultsDisplay = function (_a) {
42367
42373
  children));
42368
42374
  };
42369
42375
 
42370
- function isGroupedResult(result) {
42371
- if (result && result.length) {
42372
- return result[0].items !== undefined;
42373
- }
42374
- return false;
42375
- }
42376
42376
  function flatten(items) {
42377
42377
  if (isGroupedResult(items)) {
42378
42378
  return items.flatMap(function (item) { return item.items; });