1 | ;
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = canShowCreate;
|
5 |
|
6 | function canShowCreate(allowCreate, {
|
7 | searchTerm = '',
|
8 | data,
|
9 | dataItems,
|
10 | accessors
|
11 | }) {
|
12 | const eq = v => accessors.text(v).toLowerCase() === searchTerm.toLowerCase(); // if there is an exact match on textFields:
|
13 | // "john" => { name: "john" }, don't show
|
14 |
|
15 |
|
16 | const hasExtactMatch = () => dataItems && dataItems.some(eq) || data.some(eq);
|
17 |
|
18 | return !!((allowCreate === true || allowCreate === 'onFilter' && searchTerm) && !hasExtactMatch());
|
19 | } |
\ | No newline at end of file |