UNPKG

igniteui-webcomponents

Version:

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.

18 lines 765 B
export default class FilterDataOperation { normalize(string, { caseSensitive, matchDiacritics }) { const str = caseSensitive ? string : string.toLocaleLowerCase(); return matchDiacritics ? str : str.normalize('NFKD').replace(/\p{M}/gu, ''); } apply(data, controller) { const { searchTerm, filteringOptions } = controller; const { filterKey: key } = filteringOptions; if (!searchTerm) return data; const term = this.normalize(searchTerm, filteringOptions); return data.filter(({ value }) => { const string = key ? `${value[key]}` : `${value}`; return this.normalize(string, filteringOptions).includes(term); }); } } //# sourceMappingURL=filter.js.map