UNPKG

md2

Version:

Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Chips(Tags), Collapse, Colorpicker, Data Table, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.

37 lines 1.55 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { Pipe } from '@angular/core'; var HighlightPipe = (function () { function HighlightPipe() { } /** * Transform function * @param value string * @param query string filter value * @return filtered string with markup */ HighlightPipe.prototype.transform = function (value, query) { if (query.length < 1) { return value; } return query ? value.replace(new RegExp(this._escapeRegexp(query), 'gi'), '<span class="highlight">$&</span>') : value; }; /** * filter pipe * @param queryToEscape * @return queryToEscape with replace string */ HighlightPipe.prototype._escapeRegexp = function (queryToEscape) { return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'); }; return HighlightPipe; }()); HighlightPipe = __decorate([ Pipe({ name: 'highlight' }) ], HighlightPipe); export { HighlightPipe }; //# sourceMappingURL=autocomplete-pipe.js.map