1 | import getOptionLabel from './getOptionLabel';
|
2 | import { isFunction } from './nodash';
|
3 |
|
4 | function addCustomOption(results, props) {
|
5 | var allowNew = props.allowNew,
|
6 | labelKey = props.labelKey,
|
7 | text = props.text;
|
8 |
|
9 | if (!allowNew || !text.trim()) {
|
10 | return false;
|
11 | }
|
12 |
|
13 |
|
14 |
|
15 | if (isFunction(allowNew)) {
|
16 | return allowNew(results, props);
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 | return !results.some(function (o) {
|
22 | return getOptionLabel(o, labelKey) === text;
|
23 | });
|
24 | }
|
25 |
|
26 | export default addCustomOption; |
\ | No newline at end of file |