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

Commit 04cebef

Browse files
oktay-senleMaik
authored andcommitted
Pass the dataSource object directly in chipRenderer (#130)
* Added chip as input to chipRenderer * Small lint * Added chip to chipRenderer description on README.md * Made chip input in chipRenderer a bit more clear * Update the readme again.
1 parent f95da57 commit 04cebef

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import ChipInput from 'material-ui-chip-input'
3535
| --- | --- | --- | --- |
3636
| allowDuplicates | `bool` | `false` | Allows duplicate chips if set to true. |
3737
| chipContainerStyle | `object` | | Override the inline-styles of the chip container element. |
38-
| 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. Each item in the `dataSource` array will be passed to `chipRenderer` as arguments `value` and `text`. If `dataSource` is an array of objects and `dataSourceConfig` is present, then `value` and `text` will instead correspond to the object values defined in `dataSourceConfig`. If `dataSourceConfig` is not set and `dataSource` is an array of objects, then a custom `chipRenderer` must be set.|
38+
| chipRenderer | `function` | | A function of the type `({ value, text, chip, isFocused, isDisabled, handleClick, handleRequestDelete, defaultStyle }, key) => node` that returns a chip based on the given properties. This can be used to customize chip styles. Each item in the `dataSource` array will be passed to `chipRenderer` as arguments `chip`, `value` and `text`. If `dataSource` is an array of objects and `dataSourceConfig` is present, then `value` and `text` will instead correspond to the object values defined in `dataSourceConfig`. If `dataSourceConfig` is not set and `dataSource` is an array of objects, then a custom `chipRenderer` must be set. `chip` is always the raw value from `dataSource`, either an object or a string.|
3939
| clearOnBlur | `bool` | `true` | If true, clears the input value after the component loses focus. |
4040
| dataSource | `array` | | Data source for auto complete. This should be an array of strings or objects.|
4141
| dataSourceConfig | `object` | | Config for objects list dataSource, e.g. `{ text: 'text', value: 'value' }`. If not specified, the `dataSource` must be a flat array of strings or a custom `chipRenderer` must be set to handle the objects. |

src/ChipInput.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ class ChipInput extends React.Component {
508508
return chipRenderer({
509509
value,
510510
text: dataSourceConfig ? tag[dataSourceConfig.text] : tag,
511+
chip: tag,
511512
isDisabled: disabled,
512513
isFocused: dataSourceConfig ? (this.state.focusedChip && this.state.focusedChip[dataSourceConfig.value] === value) : (this.state.focusedChip === value),
513514
handleClick: () => this.setState({ focusedChip: value }),

0 commit comments

Comments
 (0)