UNPKG

527 BJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.default = canShowCreate;
5
6function 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