Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
26 changes: 18 additions & 8 deletions src/MaterialChips/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: [],
Expand Down Expand Up @@ -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(
Expand All @@ -611,6 +619,8 @@ class MaterialChips extends Component {
classes.formControl
)

const mergedInputLabelProps = Object.assign({}, { shrink: labelShrinked }, InputLabelProps)

return (
<div
className={classes.container}
Expand All @@ -625,7 +635,7 @@ class MaterialChips extends Component {

<FormControl className={formClasses} error={error && error.length > 0} fullWidth margin="dense">

<InputLabel shrink={labelShrinked} margin="dense" focused={labelFocused}>
<InputLabel margin="dense" focused={labelFocused} {...mergedInputLabelProps}>
{label}
</InputLabel>

Expand All @@ -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)}
/>
</div>

</div>
</div>

{ error &&
{error &&
<FormHelperText className={classes.errorText}>
{error}
</FormHelperText>
Expand Down