Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

Commit eb21fcd

Browse files
committed
Add allowDuplicates to propTypes and lint the code.
1 parent 6eecce6 commit eb21fcd

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import ChipInput from 'material-ui-chip-input'
3333
## Properties
3434
| Name | Type | Default | Description |
3535
| --- | --- | --- | --- |
36-
| allowDuplicates | `bool` | `false` | If true allows duplicate chips. |
36+
| allowDuplicates | `bool` | `false` | Allows duplicate chips if set to true. |
3737
| chipRenderer | `function` | | A function of the type `({ value, text, isFocused, isDisabled, handleClick, handleRequestDelete, defaultStyle }, key) => node` that returns a chip based on the given properties. This can be used to customize chip styles. |
3838
| clearOnBlur | `bool` | `true` | If true, clears the input value after the component loses focus. |
3939
| dataSource | `array` | | Data source for auto complete. |

src/ChipInput.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ class ChipInput extends React.Component {
343343
}
344344
} else {
345345
if (this.props.dataSourceConfig) {
346-
const chips = this.state.chips.slice();
347-
let changed = chips.splice(i,1) // remove the chip at index i
346+
const chips = this.state.chips.slice()
347+
let changed = chips.splice(i, 1) // remove the chip at index i
348348
if (changed) {
349349
this.setState({
350350
chips,
@@ -355,8 +355,8 @@ class ChipInput extends React.Component {
355355
}
356356
}
357357
} else {
358-
const chips = this.state.chips.slice();
359-
let changed = chips.splice(i,1) // remove the chip at index i
358+
const chips = this.state.chips.slice()
359+
let changed = chips.splice(i, 1) // remove the chip at index i
360360
if (changed) {
361361
this.setState({
362362
chips,
@@ -424,7 +424,7 @@ class ChipInput extends React.Component {
424424
chipRenderer = defaultChipRenderer,
425425
newChipKeyCodes, // eslint-disable-line no-unused-vars
426426
allowDuplicates, // eslint-disable-line no-unused-vars
427-
...other,
427+
...other
428428
} = this.props
429429

430430
const {prepareStyles} = this.context.muiTheme
@@ -574,13 +574,15 @@ ChipInput.propTypes = {
574574
openOnFocus: PropTypes.bool,
575575
chipRenderer: PropTypes.func,
576576
newChipKeyCodes: PropTypes.arrayOf(PropTypes.number),
577-
clearOnBlur: PropTypes.bool
577+
clearOnBlur: PropTypes.bool,
578+
allowDuplicates: PropTypes.bool
578579
}
579580

580581
ChipInput.defaultProps = {
581582
filter: AutoComplete.caseInsensitiveFilter,
582583
newChipKeyCodes: [13],
583584
clearOnBlur: true,
585+
allowDuplicates: false,
584586
underlineShow: true
585587
}
586588

stories/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ storiesOf('ChipInput', module)
215215
</form>
216216
))
217217
.add('with duplicates allowed', () => themed(
218-
<ChipInput
219-
defaultValue={['foo','bar','foo','bar']}
220-
allowDuplicates
218+
<ChipInput
219+
defaultValue={['foo', 'bar', 'foo', 'bar']}
220+
allowDuplicates
221221
/>
222222
))

0 commit comments

Comments
 (0)