material-ui-fields v1.0.2
Material UI - Simple React Form
Simple React Form is a powerful framework that simplifies the use of forms in React and React Native. This is a set of components that use Material UI Forked From Simple React From | Material-UI.
To use this fields, import the field and pass it as type to the Field component.
<Form state={this.state} onChange={changes => this.setState(changes)}>
<Field fieldName='name' label='Name' type={Text}/>
<Field fieldName='date' label='A Date' type={DatePicker}/>
</Form>Components
List of the components
Checkbox
import Checkbox from 'material-ui-fields/lib/checkbox'Type: Boolean
Date Picker
Renders the material-ui date picker
import DatePicker from 'material-ui-fields/lib/date-picker'Type: Date
Multiple Checkbox
Select multiple items from a array
import MultipleCheckbox from 'material-ui-fields/lib/multiple-checkbox'Type: [String|Number]
Props:
options: A array oflabelString: The label of the optionvalueString|Number: The valuedescriptionStringOptional: A description that will be rendered below the option
Radio
Select one item from a array
import Radio from 'material-ui-fields/lib/radio'Type: String|Number
Props:
options: A array oflabelString: The label of the optionvalueString|Number: The valuedescriptionStringOptional: A description that will be rendered below the option
Select With Method
A text field that searchs items with meteor methods
import SelectWithMethod from 'material-ui-fields/lib/select-with-method'Type: String|Number
Props:
multiBooleanOptional: Allow to select multiple items.methodNameString: Meteor method that recieves the search string and returns an array oflabelString: The visible text.valueString|Number: The value.colorStringOptional: The background color of the chipimageStringOptional: The url of the imageinitalsStringOptional: The initals of the chip. Don't provide this if image is present.
labelMethodNameString: Meteor method that recieves the value and must return the item description. Ifmultiis set to true, this will recieve an array of the values and must return an array with the items descriptions in the same order. Item description is the same as the one returned inmethodName:labelString: The visible text.valueString|Number: The value.colorStringOptional: The background color of the chipimageStringOptional: The url of the imageinitalsStringOptional: The initals of the chip. Don't provide this if image is present.
connectionOptional, defaults toMeteor: A Meteor connection.waitTimeOptional, defaults to400: Time with no changes that activates the search.createFunctionOptional: A function that creates a document and pass the value in a callback.createLabelFunctionOptional: A function that recieves the search input and returns the create label.canCreateFunctionOptional, defaults to() => true: A function that recieves the search input and returns aBooleanindicating ifcreatecan be called.
Select
Select one item from a array in a select field
import Select from 'material-ui-fields/lib/select'Type: String|Number
Props:
options: A array oflabelString: The label of the optionvalueString|Number: The value
Tags
Create a array of Strings.
import Tags from 'material-ui-fields/lib/tags'Type: [String]
Text
import Text from 'material-ui-fields/lib/text'Type: String
Props:
fieldTypeStringOptional: The type of the input. Example: number, email, password.
Textarea
A String with multiple lunes
import Textarea from 'material-ui-fields/lib/textarea'Type: String
Toggle
import Toggle from 'material-ui-fields/lib/toggle'Type: Boolean
Object
import ObjectComponent from 'material-ui-fields/lib/object'Type: Object
Usage:
<Form>
<Field fieldName='myObject' type={ObjectComponent}>
<Field fieldName='myField' type={Text}/>
<Field fieldName='myField2' type={Text}/>
</Field>
</Form>Array
import ArrayComponent from 'material-ui-fields/lib/array'Type: Array
Usage:
<Form>
<Field fieldName='myArray' type={ArrayComponent}>
<Field fieldName='myField' type={Text}/>
<Field fieldName='myField2' type={Text}/>
</Field>
</Form>