adb-shared 6.0.1 → 6.0.2

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.
@@ -9,8 +9,10 @@ import { HttpClientModule } from '@angular/common/http';
9
9
  import * as i2 from '@angular/router';
10
10
  import { NavigationEnd, RouterModule } from '@angular/router';
11
11
  import { Subscription, Subject, of } from 'rxjs';
12
+ import * as i1$2 from '@angular/platform-browser';
12
13
  import { startOfDay, subYears, endOfDay, addYears, getMonth, subMonths, addMonths, isSameYear, startOfMonth, endOfMonth, eachWeekOfInterval, getISOWeek, addDays, eachDayOfInterval, getHours, getMinutes, isSameDay, isSameMonth, isWithinInterval, isValid, parseISO } from 'date-fns';
13
- import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
14
+ import * as i1$3 from '@angular/forms';
15
+ import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule } from '@angular/forms';
14
16
  import { delay } from 'rxjs/operators';
15
17
 
16
18
  let EnvironmentService$1 = class EnvironmentService {
@@ -420,17 +422,133 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
420
422
  args: ['document:click', ['$event.target']]
421
423
  }] } });
422
424
 
425
+ class AdbDropdown2Directive {
426
+ constructor(elementRef, adbDropdownService) {
427
+ this.elementRef = elementRef;
428
+ this.adbDropdownService = adbDropdownService;
429
+ this.adbDropdown = new EventEmitter();
430
+ this.insideClick = false;
431
+ this.dataToggle = "dropdown";
432
+ this.haspPopup = true;
433
+ this.expanded = false;
434
+ this.id = this.getId();
435
+ this.dropId = this.getId();
436
+ }
437
+ onClick() {
438
+ this.adbDropdownService.currentMenuId = this.id;
439
+ const node = this.elementRef.nativeElement.parentNode;
440
+ const menu = node.querySelector('.dropdown-menu');
441
+ if (menu) {
442
+ this.adbDropdownService.currentMenu = this.elementRef.nativeElement;
443
+ this.setMenuPosition(node, menu);
444
+ menu.setAttribute('id', this.dropId);
445
+ if (menu.classList.contains('show')) {
446
+ menu.classList.remove('show');
447
+ this.expanded = false;
448
+ }
449
+ else {
450
+ this.adbDropdown.emit();
451
+ menu.classList.add('show');
452
+ this.expanded = true;
453
+ }
454
+ }
455
+ }
456
+ onCheckOutSideClick(target) {
457
+ if (this.adbDropdownService.currentMenuId === this.id) {
458
+ const parent = this.insideClick ? this.elementRef.nativeElement.parentNode : this.elementRef.nativeElement;
459
+ const clickedInside = parent.contains(target);
460
+ if (!clickedInside) {
461
+ const parent = this.elementRef.nativeElement.parentNode.querySelector('.dropdown-menu');
462
+ parent?.classList.remove('show');
463
+ this.expanded = false;
464
+ }
465
+ }
466
+ else {
467
+ const parent = this.elementRef.nativeElement.parentNode.querySelector('.dropdown-menu');
468
+ parent?.classList.remove('show');
469
+ this.expanded = false;
470
+ }
471
+ }
472
+ onWindowScroll() {
473
+ const node = this.elementRef.nativeElement.parentNode;
474
+ const menu = node.querySelector('.dropdown-menu');
475
+ if (menu.classList?.contains('show')) {
476
+ this.setMenuPosition(node, menu);
477
+ }
478
+ }
479
+ setMenuPosition(dropdownNode, menu) {
480
+ const toggleButton = dropdownNode.querySelector('.dropdown-toggle');
481
+ menu.setAttribute('style', 'visibility:hidden');
482
+ menu.setAttribute('style', 'display:block');
483
+ const menuWidth = menu.offsetWidth;
484
+ menu.setAttribute('style', 'visibility:visible');
485
+ menu.setAttribute('style', 'display:none');
486
+ const buttonRect = toggleButton.getBoundingClientRect();
487
+ let menuPosition = `top:${buttonRect.bottom}px;left:${buttonRect.left}px;position:fixed;`;
488
+ if (menu.classList?.contains('dropdown-menu-end')) {
489
+ menuPosition = `top:${buttonRect.bottom}px;left:${buttonRect.right - menuWidth}px;position:fixed;`;
490
+ }
491
+ menu.setAttribute('style', menuPosition);
492
+ }
493
+ close() {
494
+ const node = this.elementRef.nativeElement.parentNode;
495
+ const menu = node.querySelector('.dropdown-menu');
496
+ menu.classList.remove('show');
497
+ this.expanded = false;
498
+ }
499
+ getId() {
500
+ return '' + Math.floor(Math.random() * Date.now());
501
+ }
502
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdown2Directive, deps: [{ token: i0.ElementRef }, { token: AdbDropdownService }], target: i0.ɵɵFactoryTarget.Directive }); }
503
+ /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: AdbDropdown2Directive, selector: "[adbDropdown2]", inputs: { insideClick: "insideClick" }, outputs: { adbDropdown: "adbDropdown" }, host: { listeners: { "click": "onClick()", "document:click": "onCheckOutSideClick($event.target)", "window:scroll": "onWindowScroll()" }, properties: { "id": "this.id", "attr.data-toggle": "this.dataToggle", "attr.aria-haspopup": "this.haspPopup", "attr.aria-expanded": "this.expanded", "attr.aria-controls": "this.dropId" } }, exportAs: ["adbDropdown"], ngImport: i0 }); }
504
+ }
505
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdown2Directive, decorators: [{
506
+ type: Directive,
507
+ args: [{
508
+ selector: '[adbDropdown2]',
509
+ exportAs: 'adbDropdown'
510
+ }]
511
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: AdbDropdownService }]; }, propDecorators: { adbDropdown: [{
512
+ type: Output
513
+ }], insideClick: [{
514
+ type: Input
515
+ }], id: [{
516
+ type: HostBinding,
517
+ args: ['id']
518
+ }], dataToggle: [{
519
+ type: HostBinding,
520
+ args: ['attr.data-toggle']
521
+ }], haspPopup: [{
522
+ type: HostBinding,
523
+ args: ['attr.aria-haspopup']
524
+ }], expanded: [{
525
+ type: HostBinding,
526
+ args: ['attr.aria-expanded']
527
+ }], dropId: [{
528
+ type: HostBinding,
529
+ args: ['attr.aria-controls']
530
+ }], onClick: [{
531
+ type: HostListener,
532
+ args: ['click']
533
+ }], onCheckOutSideClick: [{
534
+ type: HostListener,
535
+ args: ['document:click', ['$event.target']]
536
+ }], onWindowScroll: [{
537
+ type: HostListener,
538
+ args: ['window:scroll']
539
+ }] } });
540
+
423
541
  class AdbDropdownModule {
424
542
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
425
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdownModule, declarations: [AdbDropdownDirective], imports: [CommonModule, i1$1.TranslateModule, AdbDirectivesModule], exports: [AdbDropdownDirective] }); }
543
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdownModule, declarations: [AdbDropdownDirective, AdbDropdown2Directive], imports: [CommonModule, i1$1.TranslateModule, AdbDirectivesModule], exports: [AdbDropdownDirective, AdbDropdown2Directive] }); }
426
544
  /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdownModule, providers: [AdbDropdownService], imports: [CommonModule, TranslateModule.forChild(), AdbDirectivesModule] }); }
427
545
  }
428
546
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbDropdownModule, decorators: [{
429
547
  type: NgModule,
430
548
  args: [{
431
549
  imports: [CommonModule, TranslateModule.forChild(), AdbDirectivesModule],
432
- declarations: [AdbDropdownDirective],
433
- exports: [AdbDropdownDirective],
550
+ declarations: [AdbDropdownDirective, AdbDropdown2Directive],
551
+ exports: [AdbDropdownDirective, AdbDropdown2Directive],
434
552
  providers: [AdbDropdownService]
435
553
  }]
436
554
  }] });
@@ -1047,17 +1165,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1047
1165
  }]
1048
1166
  }] });
1049
1167
 
1168
+ class RichPipe {
1169
+ constructor(sanitizer) {
1170
+ this.sanitizer = sanitizer;
1171
+ }
1172
+ transform(value) {
1173
+ if (!value) {
1174
+ return '';
1175
+ }
1176
+ const htmlContent = this.parseCustomMarkdown(value);
1177
+ return this.sanitizer.bypassSecurityTrustHtml(htmlContent);
1178
+ }
1179
+ parseCustomMarkdown(input) {
1180
+ const italicRegex = /_([^_]+)_/g;
1181
+ const taxonRegex = /\[([^\]]+)\]\(taxon:([^)]+)\)/g;
1182
+ const termRegex = /\[([^\]]+)\]\(term:([^)]+)\)/g;
1183
+ const referenceRegex = /\[([^\]]+)\]\(reference:([^)]+)\)/g;
1184
+ // Replace patterns with HTML tags
1185
+ input = input.replace(italicRegex, '<em>$1</em>');
1186
+ input = input.replace(taxonRegex, '<span class="taxon" data-id="$2">$1</span>');
1187
+ input = input.replace(termRegex, '<span class="term" data-id="$2">$1</span>');
1188
+ input = input.replace(referenceRegex, '<span class="reference" data-id="$2">$1</span>');
1189
+ return input;
1190
+ }
1191
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RichPipe, deps: [{ token: i1$2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe }); }
1192
+ /** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: RichPipe, name: "rich" }); }
1193
+ }
1194
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RichPipe, decorators: [{
1195
+ type: Pipe,
1196
+ args: [{
1197
+ name: 'rich'
1198
+ }]
1199
+ }], ctorParameters: function () { return [{ type: i1$2.DomSanitizer }]; } });
1200
+
1050
1201
  class AdbPipesModule {
1051
1202
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1052
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: AdbPipesModule, declarations: [HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe], exports: [HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe] }); }
1203
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: AdbPipesModule, declarations: [RichPipe, HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe], exports: [RichPipe, HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe] }); }
1053
1204
  /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbPipesModule }); }
1054
1205
  }
1055
1206
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbPipesModule, decorators: [{
1056
1207
  type: NgModule,
1057
1208
  args: [{
1058
1209
  imports: [],
1059
- declarations: [HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe],
1060
- exports: [HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe]
1210
+ declarations: [RichPipe, HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe],
1211
+ exports: [RichPipe, HighlightPipe, HighlightHtmlPipe, NumberSpacingPipe, LocaleDatePipe, EmptyValuePipe]
1061
1212
  }]
1062
1213
  }] });
1063
1214
 
@@ -1251,10 +1402,10 @@ class AdbDatePickerDirective {
1251
1402
  this.adbBlur = new EventEmitter();
1252
1403
  this.format = 'yyyy-MM-dd';
1253
1404
  this.settings = null;
1254
- this.onValidationChange = () => { };
1255
1405
  //ControlValueAccessor
1256
1406
  this.onChange = () => { };
1257
1407
  this.onTouched = () => { };
1408
+ this.onValidationChange = () => { };
1258
1409
  }
1259
1410
  ngOnInit() {
1260
1411
  this.elementRef.nativeElement.setAttribute("placeholder", this.format);
@@ -1675,6 +1826,81 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1675
1826
  }]
1676
1827
  }] });
1677
1828
 
1829
+ class AdbRichEditorComponent {
1830
+ constructor(renderer, el) {
1831
+ this.renderer = renderer;
1832
+ this.el = el;
1833
+ //ControlValueAccessor
1834
+ this.onChange = () => { };
1835
+ this.onTouched = () => { };
1836
+ }
1837
+ ngAfterViewInit() {
1838
+ }
1839
+ onDoubleClick() {
1840
+ console.log('what');
1841
+ const textarea = this.el.nativeElement.querySelector('textarea');
1842
+ const selectionStart = textarea.selectionStart;
1843
+ let selectionEnd = textarea.selectionEnd;
1844
+ while (selectionEnd > selectionStart && textarea.value[selectionEnd - 1] === ' ') {
1845
+ selectionEnd--;
1846
+ }
1847
+ textarea.setSelectionRange(selectionStart, selectionEnd);
1848
+ }
1849
+ onItalicClick() {
1850
+ const textarea = this.el.nativeElement.querySelector('textarea');
1851
+ if (textarea) {
1852
+ const selectionStart = textarea.selectionStart;
1853
+ const selectionEnd = textarea.selectionEnd;
1854
+ let currentValue = textarea.value;
1855
+ let modifiedText = `${currentValue.substring(0, selectionStart)}_${currentValue.substring(selectionStart, selectionEnd)}_${currentValue.substring(selectionEnd)}`;
1856
+ this.text = modifiedText;
1857
+ this.onChange(this.text);
1858
+ }
1859
+ }
1860
+ onTextChange() {
1861
+ this.onChange(this.text);
1862
+ }
1863
+ writeValue(value) {
1864
+ this.text = value;
1865
+ }
1866
+ registerOnChange(fn) {
1867
+ this.onChange = fn;
1868
+ }
1869
+ registerOnTouched(fn) {
1870
+ this.onTouched = fn;
1871
+ }
1872
+ setDisabledState(isDisabled) {
1873
+ }
1874
+ ngOnDestroy() {
1875
+ }
1876
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbRichEditorComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
1877
+ /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: AdbRichEditorComponent, selector: "adb-rich-editor", providers: [{
1878
+ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((() => AdbRichEditorComponent)),
1879
+ multi: true
1880
+ }], ngImport: i0, template: "<div>\r\n <div class=\"d-flex justify-content-end gap-3 mb-1\">\r\n <button class=\"btn btn-secondary\" (click)=\"onItalicClick()\"><span class=\"fas fa-italic\"></span></button>\r\n </div>\r\n <textarea class=\"form-control\" [(ngModel)]=\"text\" (ngModelChange)=\"onTextChange()\" (dblclick)=\"onDoubleClick()\"></textarea>\r\n</div>\r\n", dependencies: [{ kind: "directive", type: i1$3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
1881
+ }
1882
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbRichEditorComponent, decorators: [{
1883
+ type: Component,
1884
+ args: [{ selector: 'adb-rich-editor', providers: [{
1885
+ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef((() => AdbRichEditorComponent)),
1886
+ multi: true
1887
+ }], template: "<div>\r\n <div class=\"d-flex justify-content-end gap-3 mb-1\">\r\n <button class=\"btn btn-secondary\" (click)=\"onItalicClick()\"><span class=\"fas fa-italic\"></span></button>\r\n </div>\r\n <textarea class=\"form-control\" [(ngModel)]=\"text\" (ngModelChange)=\"onTextChange()\" (dblclick)=\"onDoubleClick()\"></textarea>\r\n</div>\r\n" }]
1888
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; } });
1889
+
1890
+ class AdbRichEditorModule {
1891
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbRichEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1892
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: AdbRichEditorModule, declarations: [AdbRichEditorComponent], imports: [CommonModule, FormsModule], exports: [AdbRichEditorComponent] }); }
1893
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbRichEditorModule, imports: [CommonModule, FormsModule] }); }
1894
+ }
1895
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AdbRichEditorModule, decorators: [{
1896
+ type: NgModule,
1897
+ args: [{
1898
+ imports: [CommonModule, FormsModule],
1899
+ declarations: [AdbRichEditorComponent],
1900
+ exports: [AdbRichEditorComponent]
1901
+ }]
1902
+ }] });
1903
+
1678
1904
  /*
1679
1905
  * Public API Surface of artdata-shared
1680
1906
  */
@@ -1683,5 +1909,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1683
1909
  * Generated bundle index. Do not edit.
1684
1910
  */
1685
1911
 
1686
- export { ADBHeaderModule, ADBNavComponent, AdbButtonsModule, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbHelpButtonComponent, AdbModalModule, AdbModalService, AdbPagersModule, AdbPipesModule, AdbToast, AdbToastModule, AdbToastService, ArtportalenFooterComponent, ArtportalenNavComponent, ArtportalenNavModule, ClickOutsideDirective, EmptyValuePipe, FileUploadDirective, FocusDirective, HighlightHtmlPipe, HighlightPipe, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, PagerInlineComponent, RedListBadgeClassDirective, RiskClassDirective, ToastType };
1912
+ export { ADBHeaderModule, ADBNavComponent, AdbButtonsModule, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdown2Directive, AdbDropdownDirective, AdbDropdownModule, AdbHelpButtonComponent, AdbModalModule, AdbModalService, AdbPagersModule, AdbPipesModule, AdbRichEditorComponent, AdbRichEditorModule, AdbToast, AdbToastModule, AdbToastService, ArtportalenFooterComponent, ArtportalenNavComponent, ArtportalenNavModule, ClickOutsideDirective, EmptyValuePipe, FileUploadDirective, FocusDirective, HighlightHtmlPipe, HighlightPipe, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, PagerInlineComponent, RedListBadgeClassDirective, RichPipe, RiskClassDirective, ToastType };
1687
1913
  //# sourceMappingURL=adb-shared.mjs.map