UNPKG

@sb1/ffe-account-selector-react

Version:

Selector for bank accounts with autocomplete.

22 lines (21 loc) 990 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.searchMatcherIgnoringAccountNumberFormatting = void 0; /** * This matcher function closely resembles the default one of SearchableDropdown, * but it ignores all spaces and periods so that account number formatting won't mess with the search. */ var searchMatcherIgnoringAccountNumberFormatting = function (searchString, searchAttributes) { return function (item) { var cleanString = function (value) { return "".concat(value) .replace(/(\s|\.)/g, '') // Remove all spaces and periods .toLowerCase(); }; var cleanedSearchString = cleanString(searchString); return searchAttributes.some(function (searchAttribute) { return cleanString(item[searchAttribute]).includes(cleanedSearchString); }); }; }; exports.searchMatcherIgnoringAccountNumberFormatting = searchMatcherIgnoringAccountNumberFormatting;