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

Commit

Permalink
Update the readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Dec 3, 2017
1 parent 8b3db90 commit 57b5d8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Team Wertarbyte
Copyright (c) 2016-2017 Team Wertarbyte

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you want to try the component yourself instead of watching a gif, head over t

## Installation
```shell
npm i --save material-ui-chip-input
npm i --save material-ui-chip-input@next
```

## Usage
Expand All @@ -38,43 +38,51 @@ import ChipInput from 'material-ui-chip-input'
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| allowDuplicates | `bool` | `false` | Allows duplicate chips if set to true. |
| chipContainerStyle | `object` | | Override the inline-styles of the chip container element. |
| 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.|
| chipRenderer | `function` | | A function of the type `({ value, text, chip, isFocused, isDisabled, handleClick, handleRequestDelete, className }, 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.|
| classes | `object` | | Extends the styles applied to this component. |
| clearOnBlur | `bool` | `true` | If true, clears the input value after the component loses focus. |
| dataSource | `array` | | Data source for auto complete. This should be an array of strings or objects.|
| 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. |
| defaultValue | `string[]` | | The chips to display by default (for uncontrolled mode). |
| disabled | `bool` | `false` | Disables the chip input if set to true. |
| errorText | `node` | | The error text to display. |
| floatingLabelText | `node` | | The content of the floating label. |
| helperText | `node` | | The helper text to display. |
| fullWidth | `bool` | `false` | If true, the chip input will fill the available width. |
| fullWidthInput | `bool` | `false` | If true, the input field will always be below the chips and fill the available space. By default, it will try to be beside the chips. |
| hintText | `node` | | The hint text to display. |
| id | `string` | _a unique id_ | The id prop for the text field, should be set to some deterministic value if you use server-side rendering. |
| label | `node` | | The content of the floating label. |
| newChipKeyCodes | `number[]` | `[13]` (enter key) | The key codes used to determine when to create a new chip. |
| onBeforeRequestAdd | `function` | | Callback function that is called with the chip to be added and should return true to add the chip or false to prevent the chip from being added without clearing the text input. |
| onBlur | `function` | | Callback function that is called with `event` when the input loses focus, where `event.target.value` is the current value of the text input. |
| onChange | `function` | | Callback function that is called when the chips change (in uncontrolled mode). |
| onClick | `function` | | Callback function that is called when text input is clicked. |
| onRequestAdd | `function` | | Callback function that is called when a new chip was added (in controlled mode). |
| onRequestDelete | `function` | | Callback function that is called when a new chip was removed (in controlled mode). |
| onUpdateInput | `function` | | Callback function that is called when the input changes (useful for auto complete). |
| openOnFocus | `bool` | `false` | Opens the auto complete list on focus if set to true. |
| style | `object` | | Override the inline-styles of the root element. |
| placeholder | `node` | | A short placeholder that is displayed if the input has no values. |
| value | `string[]` | | The chips to display (enables controlled mode if set). |


Additionally, most other properties of Material UI's [Auto Complete][mui-auto-complete] and [Text Field][mui-text-field] should be supported. Please open an issue if something is missing or does not work as expected.
Any other properties supplied will be [spread to the root element](https://material-ui-next.com/guides/api/#spread). The properties of [<FormControl />](https://material-ui-next.com/api/form-control/) are also available.

## CSS API
You can customize the class names used by `ChipInput` with the `classes` property. It accepts the following keys:
* `root`
* `inputRoot`
* `input`
* `chipContainer`
* `label`
* `helperText`
* `chip`

Have a look at [this guide](https://material-ui-next.com/customization/overrides/#overriding-with-classes) for more detail.

## Credits
The code for the input component was adapted from Material UI's [Auto Complete][mui-auto-complete] and [Text Field][mui-text-field] that we all know and love.
The code for the input component was adapted from Material UI's [Text Field][mui-text-field] that we all know and love.

## License
The files included in this repository are licensed under the MIT license.

[chipspec]: https://material.google.com/components/chips.html#chips-behavior
[mui]: http://www.material-ui.com/#/
[angular-chips]: https://material.angularjs.org/latest/demo/chips
[mui-text-field]: http://www.material-ui.com/#/components/text-field
[mui-auto-complete]: http://www.material-ui.com/#/components/auto-complete
[mui-text-field]: https://material-ui-next.com/api/text-field/
[gh-pages]: https://teamwertarbyte.github.io/material-ui-chip-input/

0 comments on commit 57b5d8e

Please sign in to comment.