UNPKG

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