diff --git a/package.json b/package.json index e32fed9..5e12686 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "material-input-chips", - "version": "1.5.0", + "version": "1.5.1", "description": "A chip input field using Material-UI@next.", "homepage": "https://rodrigonehring.github.io/material-input-chips/styleguide/", "main": "dist/material-input-chips.js", diff --git a/src/MaterialChips/index.js b/src/MaterialChips/index.js index 2246f84..18bde65 100644 --- a/src/MaterialChips/index.js +++ b/src/MaterialChips/index.js @@ -45,8 +45,11 @@ class MaterialChips extends Component { /** disable input field */ inputDisabled: PropTypes.bool, - /** Props wich will be passed directly to component */ - inputProps: PropTypes.object, + /** Props which will be passed directly to Input component */ + InputProps: PropTypes.object, + + /** Props which will be passed directly to InputLabel component */ + InputLabelProps: PropTypes.object, /** label for input */ label: PropTypes.string, @@ -91,7 +94,8 @@ class MaterialChips extends Component { submitKeyCodes: [13, 9, 191], clearAfterAdd: true, fields: { label: 'label', value: 'value' }, - inputProps: {}, + InputProps: {}, + InputLabelProps: {}, makeChip: chip => chip, chipComponent: Chip, selected: [], @@ -597,9 +601,13 @@ class MaterialChips extends Component { } render() { - const { classes, disabled, selected, label, inputDisabled, inputProps } = this.props + const { + classes, disabled, selected, label, + inputDisabled, InputProps, InputLabelProps, + } = this.props const { input, error, containerFocus, chipFocus, optionsOpen, inputFocus } = this.state - const labelShrinked = !!inputProps.placeholder || (selected.length > 0) || (input.length > 0) + + const labelShrinked = !!InputProps.placeholder || (selected.length > 0) || (input.length > 0) const labelFocused = containerFocus || chipFocus || inputFocus const formClasses = cx( @@ -611,6 +619,8 @@ class MaterialChips extends Component { classes.formControl ) + const mergedInputLabelProps = Object.assign({}, { shrink: labelShrinked }, InputLabelProps) + return (
0} fullWidth margin="dense"> - + {label} @@ -645,14 +655,14 @@ class MaterialChips extends Component { margin="dense" inputRef={this.registerRef('input')} value={input} - inputProps={Object.assign({}, { spellCheck: false }, inputProps)} + inputProps={Object.assign({}, { spellCheck: false }, InputProps)} />
- { error && + {error && {error}