Dropdown component #388
Description
Add basic implementation for Dropdown component.
API
For now, use an API similar to SUIR (example):
<Dropdown multiple search items={[ ... ]} />
Based on prototype in #334:
Since we only support "search" and "multiple", make these required for now.
Dropdown will only include the Input and associated List (menu), no buttons, field label, etc.
Separate active
items from selected
:
active
means the item is in input box as an active valueselected
means the item is highlighted in the menu
More keyboard handlers:
- click to open
- esc to close
API Proposal
className
Additional classes.
fluid
Boolean to make it stretch as much as container allows.
items
Shorthand to provide items in the dropdown. Similar to providing ListItems as shorthand inside list.
label
Shorthand to provide a label before the dropdown.
multiple
Boolean to provide multi-selection functionality. Will add the active shorthands as Labels before the Input, each with 'X' icon for removal.
onChange
Callback provided to allow user to handle change. Invoked with the props and also with the active option(s), which can be either the shorthand for the active item, or the shorthand collection for the active items.
onInput
Callback provided to allow user to handle input change in the edit text. Only makes sense if dropdown is a search. Invoked with both the props and the new value of the text in the input.
placeholder
Text to act as placeholder, optional, in case the dropdown is a search (with text field). Makes sense only if dropdown is a search.
search
Boolean to make the dropdown able to search through the options, with autosuggestions. If false, the search input will be replaced by trigger button.
styles
Styles that are applied on top of the default ones.
variables
Variables that are applied on top of the default ones.