@bloomreach/react-banana-ui 1.27.1 → 1.28.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.
@@ -20,3 +20,8 @@ export declare const Loading: Story;
20
20
  export declare const LongContent: Story;
21
21
  export declare const FreeSoloSingle: typeof FreeSoloSingleStory;
22
22
  export declare const FreeSoloMultiple: typeof FreeSoloMultipleStory;
23
+ export declare const DefaultValueWithInputChangeHandler: Story;
24
+ export declare const CustomOptionRendering: Story<{
25
+ icon: string;
26
+ name: string;
27
+ }, true, true>;
@@ -1,5 +1,6 @@
1
1
  import { default as Autocomplete } from './autocomplete';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
+ import { ReactElement } from 'react';
3
4
  declare const meta: Meta<typeof Autocomplete>;
4
5
  export default meta;
5
6
  export type Story<Value extends NonNullable<unknown> = string, Multiple extends boolean = false, FreeSolo extends boolean = false> = StoryObj<typeof Autocomplete<Value, Multiple, FreeSolo>>;
@@ -26,3 +27,14 @@ export declare const NoOptionsText: Story<string>;
26
27
  export declare const Loading: Story;
27
28
  export declare const FreeSoloSingle: Story<string, false, true>;
28
29
  export declare const FreeSoloMultiple: Story<string, true, true>;
30
+ export declare const DefaultValueWithInputChangeHandler: Story;
31
+ export declare const ControlledInput: Story;
32
+ export declare const CustomOptionRendering: Story<{
33
+ icon: ReactElement;
34
+ name: string;
35
+ }, true, true>;
36
+ export declare const HighlightedOptionRendering: Story;
37
+ export declare const RenderOptionWithFreeSoloWithMultiple: Story<{
38
+ icon: ReactElement;
39
+ name: string;
40
+ }, true, true>;
@@ -1,4 +1,4 @@
1
- import { AutocompleteGroupedOption as MuiBaseAutocompleteGroupedOption } from '@mui/base';
1
+ import { FilterOptionsState, AutocompleteGroupedOption as MuiBaseAutocompleteGroupedOption } from '@mui/base';
2
2
  import { ForwardedRef, ReactElement, ReactNode, SyntheticEvent } from 'react';
3
3
  export interface AutocompleteComponentType {
4
4
  <AutocompleteOption extends NonNullable<unknown>, Multiple extends boolean = false, FreeSolo extends boolean = false>(props: AutocompleteProps<AutocompleteOption, Multiple, FreeSolo> & {
@@ -32,6 +32,12 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
32
32
  * @default false
33
33
  */
34
34
  disabled?: boolean;
35
+ /**
36
+ * Filter function to determine which options to show based on user input.
37
+ * @param options The array of options to filter
38
+ * @param state The current state of the autocomplete
39
+ */
40
+ filterOptions?: (options: AutocompleteOption[], state: FilterOptionsState<AutocompleteOption>) => AutocompleteOption[];
35
41
  /**
36
42
  * If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
37
43
  */
@@ -42,6 +48,7 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
42
48
  getOptionDisabled?: (option: AutocompleteOption) => boolean;
43
49
  /**
44
50
  * Used to determine the string value for a given option.
51
+ * This is used for filtering and input value display.
45
52
  * @default (option) => option
46
53
  */
47
54
  getOptionLabel?: (option: AutocompleteFreeSoloValueMapping<FreeSolo> | AutocompleteOption) => string;
@@ -55,6 +62,10 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
55
62
  * @default false
56
63
  */
57
64
  hideSelectedOptions?: boolean;
65
+ /**
66
+ * The input value.
67
+ */
68
+ inputValue?: string;
58
69
  /**
59
70
  * If `true`, the component is in a loading state.
60
71
  * @default false
@@ -83,6 +94,10 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
83
94
  * Callback fired when the popup closes.
84
95
  */
85
96
  onClose?: () => void;
97
+ /**
98
+ * Callback fired when the input value changes.
99
+ */
100
+ onInputChange?: (event: SyntheticEvent, value: string) => void;
86
101
  /**
87
102
  * Callback fired when the popup opens.
88
103
  */
@@ -99,6 +114,11 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
99
114
  * If `true`, the autocomplete is readonly.
100
115
  */
101
116
  readOnly?: boolean;
117
+ /**
118
+ * Used to render the option in the listbox.
119
+ * If not provided, getOptionLabel will be used.
120
+ */
121
+ renderOption?: (option: AutocompleteOption) => ReactNode;
102
122
  /**
103
123
  * If `true`, the autocomplete is required.
104
124
  * @default false
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bloomreach/react-banana-ui",
3
3
  "type": "module",
4
- "version": "1.27.1",
4
+ "version": "1.28.0",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",