@bloomreach/react-banana-ui 1.11.0 → 1.12.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/dist/bloomreach-react-banana-ui.es.js +5080 -4316
- package/dist/bloomreach-react-banana-ui.es.js.map +1 -1
- package/dist/bloomreach-react-banana-ui.umd.js +19 -15
- package/dist/bloomreach-react-banana-ui.umd.js.map +1 -1
- package/dist/components/foundations/icon/icon.stories.d.ts +1 -0
- package/dist/components/inputs/autocomplete/autocomplete.d.ts +23 -0
- package/dist/components/inputs/autocomplete/autocomplete.qa.stories.d.ts +19 -0
- package/dist/components/inputs/autocomplete/autocomplete.stories.d.ts +26 -0
- package/dist/components/inputs/autocomplete/autocomplete.types.d.ts +114 -0
- package/dist/components/inputs/autocomplete/index.d.ts +2 -0
- package/dist/components/inputs/base-input/base-input.types.d.ts +7 -11
- package/dist/components/inputs/index.d.ts +2 -1
- package/dist/components/inputs/select-option/select-option.d.ts +0 -1
- package/dist/components/lists/internal.d.ts +2 -0
- package/dist/components/lists/listbox-group/index.d.ts +2 -0
- package/dist/components/lists/listbox-group/listbox-group.d.ts +33 -0
- package/dist/components/lists/listbox-group/listbox-group.types.d.ts +11 -0
- package/dist/components/lists/listbox-group-label/index.d.ts +2 -0
- package/dist/components/lists/listbox-group-label/listbox-group-label.d.ts +33 -0
- package/dist/components/lists/listbox-group-label/listbox-group-label.types.d.ts +11 -0
- package/dist/style.css +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AutocompleteComponentType } from './autocomplete.types';
|
|
2
|
+
import './autocomplete.scss';
|
|
3
|
+
/**
|
|
4
|
+
* Autocomplete allows a user to search for value(s) to select from a list.
|
|
5
|
+
*
|
|
6
|
+
* ### Usage
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { Autocomplete } from '@bloomreach/react-banana-ui';
|
|
10
|
+
*
|
|
11
|
+
* export default function MyAutocomplete() {
|
|
12
|
+
* return (
|
|
13
|
+
* <Autocomplete
|
|
14
|
+
* options={['Banana', 'Apple', 'Orange', 'Pineapple', 'Strawberry', 'Grape', 'Watermelon']}
|
|
15
|
+
* placeholder="Select a fruit"
|
|
16
|
+
* onChange={(_, newValue) => console.log(newValue)}
|
|
17
|
+
* />
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare const _default: AutocompleteComponentType;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { ControlledMultipleValue as ControlledMultipleValueStory, ControlledSingleValue as ControlledSingleValueStory, CustomOptionLabel as CustomOptionLabelStory, HideSelectedOptions as HideSelectedOptionsStory, Multiple as MultipleStory, type Story } from './autocomplete.stories';
|
|
3
|
+
import Autocomplete from './autocomplete';
|
|
4
|
+
declare const meta: Meta<typeof Autocomplete>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const DifferentStates: Story;
|
|
8
|
+
export declare const Single: Story;
|
|
9
|
+
export declare const ControlledSingleValue: typeof ControlledSingleValueStory;
|
|
10
|
+
export declare const Multiple: typeof MultipleStory;
|
|
11
|
+
export declare const ControlledMultipleValue: typeof ControlledMultipleValueStory;
|
|
12
|
+
export declare const HideSelectedOptions: typeof HideSelectedOptionsStory;
|
|
13
|
+
export declare const GroupedOptions: Story<{
|
|
14
|
+
group: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const DisabledOptions: Story;
|
|
18
|
+
export declare const CustomOptionLabel: typeof CustomOptionLabelStory;
|
|
19
|
+
export declare const Loading: Story;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Autocomplete from './autocomplete';
|
|
3
|
+
declare const meta: Meta<typeof Autocomplete>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export type Story<Value extends NonNullable<unknown> = string, Multiple extends boolean = false> = StoryObj<typeof Autocomplete<Value, Multiple>>;
|
|
6
|
+
declare const fruits: string[];
|
|
7
|
+
export declare const Basic: Story;
|
|
8
|
+
export declare const DefaultValue: Story;
|
|
9
|
+
export declare const ControlledSingleValue: Story;
|
|
10
|
+
export declare const Multiple: Story<typeof fruits[0], true>;
|
|
11
|
+
export declare const DefaultValueMultiple: Story<typeof fruits[0], true>;
|
|
12
|
+
export declare const ControlledMultipleValue: Story<typeof fruits[0], true>;
|
|
13
|
+
export declare const HideSelectedOptions: Story<string, true>;
|
|
14
|
+
export declare const GroupedOptions: Story<{
|
|
15
|
+
label: string;
|
|
16
|
+
firstLetter: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const DisabledOptions: Story<{
|
|
19
|
+
label: string;
|
|
20
|
+
id: number;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const CustomOptionLabel: Story<{
|
|
23
|
+
fruitName: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const NoOptionsText: Story<string>;
|
|
26
|
+
export declare const Loading: Story;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { AutocompleteGroupedOption as MuiBaseAutocompleteGroupedOption } from '@mui/base';
|
|
2
|
+
import { ForwardedRef, ReactElement, ReactNode, SyntheticEvent } from 'react';
|
|
3
|
+
export type AutocompleteValue<Value, Multiple> = Multiple extends true ? Value[] : Value | null;
|
|
4
|
+
export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknown>, Multiple extends boolean> {
|
|
5
|
+
/**
|
|
6
|
+
* Custom class name for the container of the component.
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Clear the selected value when clicking the clear icon.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* If `true`, the popup closes after a selection is made.
|
|
16
|
+
* It is `false` by default when `multiple` is `true`.
|
|
17
|
+
*/
|
|
18
|
+
closeOnSelect?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The default selected value. Use when the component is not controlled.
|
|
21
|
+
* The value must be an array when `multiple` is `true`.
|
|
22
|
+
*/
|
|
23
|
+
defaultValue?: AutocompleteValue<AutocompleteOption, Multiple>;
|
|
24
|
+
/**
|
|
25
|
+
* If `true`, the component is disabled.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Used to determine if an option is disabled.
|
|
31
|
+
*/
|
|
32
|
+
getOptionDisabled?: (option: AutocompleteOption) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Used to determine the string value for a given option.
|
|
35
|
+
* @default (option) => option
|
|
36
|
+
*/
|
|
37
|
+
getOptionLabel?: (option: AutocompleteOption) => string;
|
|
38
|
+
/**
|
|
39
|
+
* If provided, the options will be grouped under the returned string.
|
|
40
|
+
* The groupBy value is also used as the text for group headings
|
|
41
|
+
*/
|
|
42
|
+
groupBy?: (option: AutocompleteOption) => string;
|
|
43
|
+
/**
|
|
44
|
+
* If `true`, the selected options are not displayed.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
hideSelectedOptions?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* If `true`, the component is in a loading state.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
loading?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The text to display when the component is in a loading state.
|
|
55
|
+
* @default "Loading..."
|
|
56
|
+
*/
|
|
57
|
+
loadingText?: string;
|
|
58
|
+
/**
|
|
59
|
+
* If `true`, the component allows multiple selections.
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
multiple?: Multiple;
|
|
63
|
+
/**
|
|
64
|
+
* Text to display when there are no options.
|
|
65
|
+
* @default "No options"
|
|
66
|
+
*/
|
|
67
|
+
noOptionsText?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Callback fired when the value changes.
|
|
70
|
+
*/
|
|
71
|
+
onChange?: (event: SyntheticEvent, value: AutocompleteValue<AutocompleteOption, Multiple>) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Callback fired when the popup closes.
|
|
74
|
+
*/
|
|
75
|
+
onClose?: () => void;
|
|
76
|
+
/**
|
|
77
|
+
* Callback fired when the popup opens.
|
|
78
|
+
*/
|
|
79
|
+
onOpen?: () => void;
|
|
80
|
+
/**
|
|
81
|
+
* Array ot options to display.
|
|
82
|
+
*/
|
|
83
|
+
options: AutocompleteOption[];
|
|
84
|
+
/**
|
|
85
|
+
* The input placeholder.
|
|
86
|
+
*/
|
|
87
|
+
placeholder?: string;
|
|
88
|
+
/**
|
|
89
|
+
* If `true`, the autocomplete is readonly.
|
|
90
|
+
*/
|
|
91
|
+
readOnly?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* If `true`, the autocomplete is required.
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
required?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The selected value.
|
|
99
|
+
* Set to `null` in case of single select and `[]` in case of multiple select to clear the selection.
|
|
100
|
+
* If the value is an object it must have reference equality with the option in order to be selected.
|
|
101
|
+
*/
|
|
102
|
+
value?: AutocompleteValue<AutocompleteOption, Multiple>;
|
|
103
|
+
}
|
|
104
|
+
export interface AutocompleteGroupedOption<AutocompleteOption extends NonNullable<unknown>> extends MuiBaseAutocompleteGroupedOption<AutocompleteOption> {
|
|
105
|
+
}
|
|
106
|
+
export interface AutocompleteRenderGroupParams extends AutocompleteGroupedOption<object> {
|
|
107
|
+
children: ReactNode;
|
|
108
|
+
}
|
|
109
|
+
export interface AutocompleteComponentType {
|
|
110
|
+
<AutocompleteOption extends NonNullable<unknown>, Multiple extends boolean = false>(props: AutocompleteProps<AutocompleteOption, Multiple> & {
|
|
111
|
+
ref?: ForwardedRef<HTMLElement>;
|
|
112
|
+
}): ReactElement | null;
|
|
113
|
+
displayName?: string | undefined;
|
|
114
|
+
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { ChangeEventHandler, FocusEventHandler, ForwardedRef, InputHTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import { ChangeEventHandler, FocusEventHandler, ForwardedRef, InputHTMLAttributes, ReactNode, Ref, RefCallback } from 'react';
|
|
2
2
|
export interface BaseInputProps {
|
|
3
|
-
/**
|
|
4
|
-
* Automatically adjusts textarea height to match the length of the content within.
|
|
5
|
-
* When `multiline` is `false`, this prop is ignored.
|
|
6
|
-
*/
|
|
7
|
-
autoSize?: boolean;
|
|
8
3
|
/**
|
|
9
4
|
* Custom class name for the container of this component.
|
|
10
5
|
*/
|
|
@@ -39,7 +34,7 @@ export interface BaseInputProps {
|
|
|
39
34
|
/**
|
|
40
35
|
* The ref to the `input` or `textarea` element.
|
|
41
36
|
*/
|
|
42
|
-
inputRef?: ForwardedRef<HTMLInputElement> |
|
|
37
|
+
inputRef?: ForwardedRef<HTMLInputElement | HTMLTextAreaElement> | Ref<HTMLInputElement | HTMLTextAreaElement>;
|
|
43
38
|
/**
|
|
44
39
|
* Icon or any element displayed at the end of the `input` or `textarea`.
|
|
45
40
|
*/
|
|
@@ -54,10 +49,6 @@ export interface BaseInputProps {
|
|
|
54
49
|
* Works only when `multiline` is `true`.
|
|
55
50
|
*/
|
|
56
51
|
minRows?: number;
|
|
57
|
-
/**
|
|
58
|
-
* If `true`, a `textarea` element is rendered.
|
|
59
|
-
*/
|
|
60
|
-
multiline?: boolean;
|
|
61
52
|
/**
|
|
62
53
|
* The `name` attribute of the `input` or `textarea` element.
|
|
63
54
|
*/
|
|
@@ -90,6 +81,11 @@ export interface BaseInputProps {
|
|
|
90
81
|
* If `true`, the `input` or `textarea` will be required.
|
|
91
82
|
*/
|
|
92
83
|
required?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Custom render function for the `input` or `textarea` element.
|
|
86
|
+
* Use this to render a custom `input` or `textarea` element.
|
|
87
|
+
*/
|
|
88
|
+
renderInput?: (props: InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>, ref: RefCallback<HTMLInputElement | HTMLTextAreaElement> | null) => JSX.Element;
|
|
93
89
|
/**
|
|
94
90
|
* Icon or any element displayed at the start of the `input` or `textarea`.
|
|
95
91
|
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ListboxGroupProps } from './listbox-group.types';
|
|
3
|
+
import './listbox-group.scss';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* The `ListboxGroup` component is used to display a list of grouped items aligned with design system styles.
|
|
7
|
+
* Use the `ListboxItem` component to define the items of the list and `ListboxGroupLabel` to define the group label.
|
|
8
|
+
*
|
|
9
|
+
* ### Usage
|
|
10
|
+
*
|
|
11
|
+
* import { Listbox, ListboxItem, ListboxGroup, ListboxGroupLabel } from '@bloomreach/react-banana-ui';
|
|
12
|
+
*
|
|
13
|
+
* export default function MyList() {
|
|
14
|
+
* return (
|
|
15
|
+
* <Listbox>
|
|
16
|
+
* <ListboxGroup>
|
|
17
|
+
* <ListboxGroupLabel>Group one</ListboxGroupLabel>
|
|
18
|
+
* <ListboxItem>Item 1</ListboxItem>
|
|
19
|
+
* <ListboxItem>Item 2</ListboxItem>
|
|
20
|
+
* <ListboxItem>Item 3</ListboxItem>
|
|
21
|
+
* </ListboxGroup>
|
|
22
|
+
* <ListboxGroup>
|
|
23
|
+
* <ListboxGroupLabel>Group two</ListboxGroupLabel>
|
|
24
|
+
* <ListboxItem>Item 1</ListboxItem>
|
|
25
|
+
* <ListboxItem>Item 2</ListboxItem>
|
|
26
|
+
* <ListboxItem>Item 3</ListboxItem>
|
|
27
|
+
* </ListboxGroup>
|
|
28
|
+
* </Listbox>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
*/
|
|
32
|
+
declare const ListboxGroup: import("react").ForwardRefExoticComponent<ListboxGroupProps & import("react").RefAttributes<HTMLUListElement>>;
|
|
33
|
+
export default ListboxGroup;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ListboxGroupLabelProps } from './listbox-group-label.types';
|
|
3
|
+
import './listbox-group-label.scss';
|
|
4
|
+
/**
|
|
5
|
+
* The `ListboxGroupLabel` component is used to display label inside list group.
|
|
6
|
+
*
|
|
7
|
+
* ### Usage
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { Listbox, ListboxItem, ListboxGroup, ListboxGroupLabel } from '@bloomreach/react-banana-ui';
|
|
11
|
+
*
|
|
12
|
+
* export default function MyGroupedList() {
|
|
13
|
+
* return (
|
|
14
|
+
* <Listbox>
|
|
15
|
+
* <ListboxGroup>
|
|
16
|
+
* <ListboxGroupLabel>Group one</ListboxGroupLabel>
|
|
17
|
+
* <ListboxItem>Item 1</ListboxItem>
|
|
18
|
+
* <ListboxItem>Item 2</ListboxItem>
|
|
19
|
+
* <ListboxItem>Item 3</ListboxItem>
|
|
20
|
+
* </ListboxGroup>
|
|
21
|
+
* <ListboxGroup>
|
|
22
|
+
* <ListboxGroupLabel>Group two</ListboxGroupLabel>
|
|
23
|
+
* <ListboxItem>Item 1</ListboxItem>
|
|
24
|
+
* <ListboxItem>Item 2</ListboxItem>
|
|
25
|
+
* <ListboxItem>Item 3</ListboxItem>
|
|
26
|
+
* </ListboxGroup>
|
|
27
|
+
* </Listbox>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const ListboxGroupLabel: import("react").ForwardRefExoticComponent<ListboxGroupLabelProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
33
|
+
export default ListboxGroupLabel;
|