adb-shared 3.0.23 → 3.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -727,11 +727,17 @@ class HighlightPipe {
727
727
  const normalizedSearch = this.normalizeText(search);
728
728
  const normalizedValue = this.normalizeText(value);
729
729
  const start = normalizedValue ? normalizedValue.indexOf(normalizedSearch) : -1;
730
+ console.log('start', start);
730
731
  if (start !== -1) {
731
- const matched = value.substring(start, start + search.length);
732
- value = value.replace('<mark>', '');
733
- value = value.replace('</mark>', '');
734
- value = value.replace(matched, `<mark>${matched}</mark>`);
732
+ const regex = new RegExp(search + '|<[^>]*?(?:"[^"]*?"|\'[^\']*?\'|[^\'">]*?)+>|<\/[^>]*?>', 'gi');
733
+ value = value.replace(regex, (match) => {
734
+ if (match.startsWith('<')) {
735
+ return match; // ignore HTML tags and their attributes
736
+ }
737
+ else {
738
+ return `<mark>${match}</mark>`; // add <mark> tag around match
739
+ }
740
+ });
735
741
  }
736
742
  }
737
743
  }
@@ -750,6 +756,55 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
750
756
  }]
751
757
  }] });
752
758
 
759
+ class HighlightPipe2 {
760
+ constructor() {
761
+ this.forbiddenSymbols = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
762
+ }
763
+ transform(value, searchs) {
764
+ if (!value) {
765
+ return value;
766
+ }
767
+ value = value + '';
768
+ if (searchs) {
769
+ if (!Array.isArray(searchs)) {
770
+ searchs = searchs.split(' ').filter(s => s);
771
+ }
772
+ for (let search of searchs) {
773
+ if (this.forbiddenSymbols.test(search)) {
774
+ search = search.replace(this.forbiddenSymbols, '');
775
+ }
776
+ const normalizedSearch = this.normalizeText(search);
777
+ const normalizedValue = this.normalizeText(value);
778
+ const start = normalizedValue ? normalizedValue.indexOf(normalizedSearch) : -1;
779
+ console.log('start', start);
780
+ if (start !== -1) {
781
+ const regex = new RegExp(search + '|<[^>]*?(?:"[^"]*?"|\'[^\']*?\'|[^\'">]*?)+>|<\/[^>]*?>', 'gi');
782
+ value = value.replace(regex, (match) => {
783
+ if (match.startsWith('<')) {
784
+ return match; // ignore HTML tags and their attributes
785
+ }
786
+ else {
787
+ return `<mark>${match}</mark>`; // add <mark> tag around match
788
+ }
789
+ });
790
+ }
791
+ }
792
+ }
793
+ return value;
794
+ }
795
+ normalizeText(text) {
796
+ return text?.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLocaleLowerCase();
797
+ }
798
+ }
799
+ /** @nocollapse */ HighlightPipe2.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: HighlightPipe2, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
800
+ /** @nocollapse */ HighlightPipe2.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: HighlightPipe2, name: "adbHighlight2" });
801
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: HighlightPipe2, decorators: [{
802
+ type: Pipe,
803
+ args: [{
804
+ name: 'adbHighlight2'
805
+ }]
806
+ }] });
807
+
753
808
  class NumberSpacingPipe {
754
809
  transform(value) {
755
810
  // If value is empty, 0 is falsy so perform an extra check to not make '0' to an empty string
@@ -772,14 +827,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
772
827
  class AdbPipesModule {
773
828
  }
774
829
  /** @nocollapse */ AdbPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
775
- /** @nocollapse */ AdbPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbPipesModule, declarations: [HighlightPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe], exports: [HighlightPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe] });
830
+ /** @nocollapse */ AdbPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbPipesModule, declarations: [HighlightPipe, HighlightPipe2, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe], exports: [HighlightPipe, HighlightPipe2, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe] });
776
831
  /** @nocollapse */ AdbPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbPipesModule, imports: [[]] });
777
832
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbPipesModule, decorators: [{
778
833
  type: NgModule,
779
834
  args: [{
780
835
  imports: [],
781
- declarations: [HighlightPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe],
782
- exports: [HighlightPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe]
836
+ declarations: [HighlightPipe, HighlightPipe2, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe],
837
+ exports: [HighlightPipe, HighlightPipe2, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe]
783
838
  }]
784
839
  }] });
785
840
 
@@ -1337,5 +1392,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
1337
1392
  * Generated bundle index. Do not edit.
1338
1393
  */
1339
1394
 
1340
- export { ADBHeaderComponent, ADBHeaderModule, ADBNavComponent, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbModalModule, AdbModalService, AdbPagersModule, AdbPipesModule, AdbToast, AdbToastModule, AdbToastService, ClickOutsideDirective, EmptyValuePipe, FileUploadDirective, FocusDirective, HighlightPipe, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, RedListBadgeClassDirective, ToastType };
1395
+ export { ADBHeaderComponent, ADBHeaderModule, ADBNavComponent, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbModalModule, AdbModalService, AdbPagersModule, AdbPipesModule, AdbToast, AdbToastModule, AdbToastService, ClickOutsideDirective, EmptyValuePipe, FileUploadDirective, FocusDirective, HighlightPipe, HighlightPipe2, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, RedListBadgeClassDirective, ToastType };
1341
1396
  //# sourceMappingURL=adb-shared.mjs.map