2.0.0 • Published 6 years ago

material-ui-enhanced-fields v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

material-ui-enhanced-fields

A collection of enhanced fields for use with material-ui (v1 beta).

demo2.gif

See storybook for live demos.

Install

yarn add material-ui-enhanced-fields@next
npm i material-ui-enhanced-fields@next

Components

ComboboxField

A customisable 'combobox' field that allows both text input and selection from a drop-down menu. With multiple set to false (default) the selected value is displayed as text in the <input/> element. With multiple set to true selectedItems are stored in a prefix. The default rendering is Chip's. Items can be grouped into sublist by supplying the a groupField prop (default is 'group'). Based on the Downshift library.

Basic Examples

const DATA = ['apples', 'oranges'];

<ComboboxField
  items={DATA}
  TextFieldProps={{ floatingLabelText: 'Pick a food' }}
/>
const DATA = [{text: 'apple', type: 'fruit'}, {text: 'tomato', type: 'veg'}];
<ComboboxField
  items={DATA}
  itemToString={item => item === null ? '' : item.text}
  groupField={'type'}
  TextFieldProps={{ floatingLabelText: 'Pick a food' }}
/>

Props

proptypedefaultdescription
classesObjectOverride the CSS classes (see implementation).
className'string'CSS class for the root element.
filterFuncfunction(items: Array, query: string)Override the default function for filtering the items based on the field's input value.
itemsArray[]The array of possible items to select.
groupFieldstring'group'The name of the key to group each item object by. (Optional, if items aren't objects or don't have a field to group by, they won't be grouped.)
menuBottomElementObjectAn element to display at the bottom of the menu.
menuBottomFixedbooleantrueFix the menuBottom element so it's reachable without scrolling.
MenuPropsObjectProps to be merged into the Menu component.
multiplebooleanfalseAllow multiple selected items.
noMatchPropsObjectProps to be merged to the component displayed when there are no matched items.
noMatchTextnodeText to be displayed if there are no matched items to display in the menu.
renderMenuItemfunction({downShiftProps: {}, index: number, item: any, key: string, selectedItems: Array})Override the default rendering of each menu item. Should return an element that employ's the Downshift getItemProps 'prop getter' function. See source code and Downshift.
renderSelectedItemfunction({deselect: function, hasFocus: boolean, item: any, itemToString: function})Override the default rendering (uses Chips) of each selected item. (Only applies when the multiple is true.) deselect: A callback that will deselect the item. hasFocus: True if item has been focused with keyboard. item: The item to render. itemToString: The itemToString prop supplied for convenience.
SubheaderPropsObjectProps to be merged ino each Subheader.
TextFieldPropsObjectProps for the TextField component.

In addtion, you can pass all the props of the Downshift component, except the inputValue. See here.