adb-shared 22.0.0-beta.1 → 22.0.0-beta.3

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.
@@ -1,7 +1,7 @@
1
1
  import * as i1$4 from "@angular/common";
2
2
  import { CommonModule, DOCUMENT, DatePipe, formatDate } from "@angular/common";
3
3
  import * as i0 from "@angular/core";
4
- import { ChangeDetectionStrategy, Component, ContentChild, Directive, EventEmitter, HostBinding, HostListener, Inject, Injectable, InjectionToken, Input, NgModule, Output, Pipe, TemplateRef, afterNextRender, contentChild, createComponent, forwardRef, input, model, output, signal } from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, ContentChild, Directive, EventEmitter, HostBinding, HostListener, Inject, Injectable, InjectionToken, Input, NgModule, Optional, Output, Pipe, TemplateRef, afterNextRender, contentChild, createComponent, forwardRef, input, model, output, signal } from "@angular/core";
5
5
  import * as i1$1 from "@angular/common/http";
6
6
  import { HTTP_INTERCEPTORS, HttpHeaders, provideHttpClient, withInterceptorsFromDi } from "@angular/common/http";
7
7
  import * as i1$3 from "@angular/router";
@@ -24,11 +24,11 @@ var ScrollService = class ScrollService {
24
24
  }
25
25
  scrollToAnchor(anchor, center = false) {
26
26
  afterNextRender({ write: () => {
27
- if (center) this.document.getElementById(anchor)?.scrollIntoView({
27
+ if (center && anchor !== "topp") this.document.getElementById(anchor)?.scrollIntoView({
28
28
  block: "center",
29
29
  behavior: "instant"
30
30
  });
31
- else this.viewportScroller.scrollToAnchor(anchor);
31
+ else this.viewportScroller.scrollToAnchor(anchor, { behavior: "instant" });
32
32
  } }, { injector: this.injector });
33
33
  }
34
34
  scrollToTop(anchor = "topp") {
@@ -321,6 +321,65 @@ i0.ɵɵngDeclareClassMetadata({
321
321
  }]
322
322
  }
323
323
  });
324
+ var RedListColorClassDirective = class RedListColorClassDirective {
325
+ redlistId = null;
326
+ get colorClass() {
327
+ switch (this.redlistId?.replace("°", "").trim().toUpperCase()) {
328
+ case "EX":
329
+ case "RE": return "text-redlist-re";
330
+ case "DD":
331
+ case "NE":
332
+ case "NA": return "text-redlist-dd";
333
+ case "CR": return "text-redlist-cr";
334
+ case "EN": return "text-redlist-en";
335
+ case "VU": return "text-redlist-vu";
336
+ case "NT": return "text-redlist-nt";
337
+ case "LC": return "text-redlist-lc";
338
+ default: return null;
339
+ }
340
+ }
341
+ static ɵfac = i0.ɵɵngDeclareFactory({
342
+ minVersion: "12.0.0",
343
+ version: "22.2.4",
344
+ ngImport: i0,
345
+ type: RedListColorClassDirective,
346
+ deps: [],
347
+ target: i0.ɵɵFactoryTarget.Directive
348
+ });
349
+ static ɵdir = i0.ɵɵngDeclareDirective({
350
+ minVersion: "14.0.0",
351
+ version: "22.2.4",
352
+ type: RedListColorClassDirective,
353
+ isStandalone: false,
354
+ selector: "[adbRedListColorClass]",
355
+ inputs: { redlistId: ["adbRedListColorClass", "redlistId"] },
356
+ host: { properties: { "class": "this.colorClass" } },
357
+ ngImport: i0
358
+ });
359
+ };
360
+ i0.ɵɵngDeclareClassMetadata({
361
+ minVersion: "12.0.0",
362
+ version: "22.2.4",
363
+ ngImport: i0,
364
+ type: RedListColorClassDirective,
365
+ decorators: [{
366
+ type: Directive,
367
+ args: [{
368
+ selector: "[adbRedListColorClass]",
369
+ standalone: false
370
+ }]
371
+ }],
372
+ propDecorators: {
373
+ redlistId: [{
374
+ type: Input,
375
+ args: ["adbRedListColorClass"]
376
+ }],
377
+ colorClass: [{
378
+ type: HostBinding,
379
+ args: ["class"]
380
+ }]
381
+ }
382
+ });
324
383
  var RiskClassDirective = class RiskClassDirective {
325
384
  category;
326
385
  get hostClasses() {
@@ -592,6 +651,7 @@ var AdbDirectivesModule = class AdbDirectivesModule {
592
651
  FocusDirective,
593
652
  FileUploadDirective,
594
653
  RedListBadgeClassDirective,
654
+ RedListColorClassDirective,
595
655
  RiskClassDirective,
596
656
  ImageLoaderDirective,
597
657
  RouterLinkActiveFragmentDirective
@@ -601,6 +661,7 @@ var AdbDirectivesModule = class AdbDirectivesModule {
601
661
  FocusDirective,
602
662
  FileUploadDirective,
603
663
  RedListBadgeClassDirective,
664
+ RedListColorClassDirective,
604
665
  RiskClassDirective,
605
666
  ImageLoaderDirective,
606
667
  RouterLinkActiveFragmentDirective
@@ -627,6 +688,7 @@ i0.ɵɵngDeclareClassMetadata({
627
688
  FocusDirective,
628
689
  FileUploadDirective,
629
690
  RedListBadgeClassDirective,
691
+ RedListColorClassDirective,
630
692
  RiskClassDirective,
631
693
  ImageLoaderDirective,
632
694
  RouterLinkActiveFragmentDirective
@@ -636,6 +698,7 @@ i0.ɵɵngDeclareClassMetadata({
636
698
  FocusDirective,
637
699
  FileUploadDirective,
638
700
  RedListBadgeClassDirective,
701
+ RedListColorClassDirective,
639
702
  RiskClassDirective,
640
703
  ImageLoaderDirective,
641
704
  RouterLinkActiveFragmentDirective
@@ -1876,7 +1939,7 @@ var RichTextComponent = class RichTextComponent {
1876
1939
  parts = [];
1877
1940
  taxonUrl;
1878
1941
  constructor(config) {
1879
- this.taxonUrl = config.taxonUrl;
1942
+ this.taxonUrl = config?.taxonUrl ?? null;
1880
1943
  }
1881
1944
  ngOnChanges() {
1882
1945
  this.parts = this.text ? this.parseCustomMarkdown(this.text) : [];
@@ -1964,7 +2027,10 @@ var RichTextComponent = class RichTextComponent {
1964
2027
  version: "22.2.4",
1965
2028
  ngImport: i0,
1966
2029
  type: RichTextComponent,
1967
- deps: [{ token: RICH_MODULE_CONFIG }],
2030
+ deps: [{
2031
+ token: RICH_MODULE_CONFIG,
2032
+ optional: true
2033
+ }],
1968
2034
  target: i0.ɵɵFactoryTarget.Component
1969
2035
  });
1970
2036
  static ɵcmp = i0.ɵɵngDeclareComponent({
@@ -1976,7 +2042,7 @@ var RichTextComponent = class RichTextComponent {
1976
2042
  inputs: { text: "text" },
1977
2043
  usesOnChanges: true,
1978
2044
  ngImport: i0,
1979
- template: "<div style=\"white-space: pre-wrap;\">\n @for (part of parts; track $index) {\n @switch (part.type) {\n @case ('text') { <span>{{ part.content }}</span> }\n @case ('italic') { <em>{{ part.content }}</em> }\n @case ('bold') { <b>{{ part.content }}</b> }\n @case ('taxon') { <a [href]=\"taxonUrl + part.id\">{{ part.content }}</a> }\n @case ('link') { <a [href]=\"part.url\">{{ part.content }}</a> }\n @default { <span>{{ part.content }}</span> }\n }\n}\n</div>\n",
2045
+ template: "<div style=\"white-space: pre-wrap;\">\n @for (part of parts; track $index) {\n @switch (part.type) {\n @case ('text') { <span>{{ part.content }}</span> }\n @case ('italic') { <em>{{ part.content }}</em> }\n @case ('bold') { <b>{{ part.content }}</b> }\n @case ('taxon') {\n @if (taxonUrl) {\n <a [href]=\"taxonUrl + part.id\">{{ part.content }}</a>\n } @else {\n <span>{{ part.content }}</span>\n }\n }\n @case ('link') { <a [href]=\"part.url\">{{ part.content }}</a> }\n @default { <span>{{ part.content }}</span> }\n }\n}\n</div>\n",
1980
2046
  changeDetection: i0.ChangeDetectionStrategy.Eager
1981
2047
  });
1982
2048
  };
@@ -1991,12 +2057,12 @@ i0.ɵɵngDeclareClassMetadata({
1991
2057
  selector: "adb-rich-text",
1992
2058
  changeDetection: ChangeDetectionStrategy.Eager,
1993
2059
  standalone: false,
1994
- template: "<div style=\"white-space: pre-wrap;\">\n @for (part of parts; track $index) {\n @switch (part.type) {\n @case ('text') { <span>{{ part.content }}</span> }\n @case ('italic') { <em>{{ part.content }}</em> }\n @case ('bold') { <b>{{ part.content }}</b> }\n @case ('taxon') { <a [href]=\"taxonUrl + part.id\">{{ part.content }}</a> }\n @case ('link') { <a [href]=\"part.url\">{{ part.content }}</a> }\n @default { <span>{{ part.content }}</span> }\n }\n}\n</div>\n"
2060
+ template: "<div style=\"white-space: pre-wrap;\">\n @for (part of parts; track $index) {\n @switch (part.type) {\n @case ('text') { <span>{{ part.content }}</span> }\n @case ('italic') { <em>{{ part.content }}</em> }\n @case ('bold') { <b>{{ part.content }}</b> }\n @case ('taxon') {\n @if (taxonUrl) {\n <a [href]=\"taxonUrl + part.id\">{{ part.content }}</a>\n } @else {\n <span>{{ part.content }}</span>\n }\n }\n @case ('link') { <a [href]=\"part.url\">{{ part.content }}</a> }\n @default { <span>{{ part.content }}</span> }\n }\n}\n</div>\n"
1995
2061
  }]
1996
2062
  }],
1997
2063
  ctorParameters: () => [{
1998
2064
  type: void 0,
1999
- decorators: [{
2065
+ decorators: [{ type: Optional }, {
2000
2066
  type: Inject,
2001
2067
  args: [RICH_MODULE_CONFIG]
2002
2068
  }]
@@ -2138,10 +2204,10 @@ var AdbRichEditorComponent = class AdbRichEditorComponent {
2138
2204
  const marker = DEFAULT_MARKER[type];
2139
2205
  const newValue = value.slice(0, start) + marker + marker + value.slice(start);
2140
2206
  this.updateValue(newValue);
2141
- start + marker.length;
2207
+ const cursor = start + marker.length;
2142
2208
  requestAnimationFrame(() => {
2143
2209
  textarea.focus();
2144
- textarea.setSelectionRange(cursorStart, cursorEnd);
2210
+ textarea.setSelectionRange(cursor, cursor);
2145
2211
  });
2146
2212
  return;
2147
2213
  }
@@ -2159,13 +2225,16 @@ var AdbRichEditorComponent = class AdbRichEditorComponent {
2159
2225
  findWrappingMarker(value, start, end, markers) {
2160
2226
  return markers.find((marker) => value.substring(start - marker.length, start) === marker && value.substring(end, end + marker.length) === marker) ?? null;
2161
2227
  }
2228
+ onLinkClick() {
2229
+ this.replaceMarked("[namn](https://)", "namn");
2230
+ }
2162
2231
  onTaxonClick() {
2163
2232
  this.replaceMarked("[Name](taxon:0)");
2164
2233
  }
2165
2234
  onReferenceClick() {
2166
2235
  this.replaceMarked("[Name](reference:0)");
2167
2236
  }
2168
- replaceMarked(replaceTag) {
2237
+ replaceMarked(replaceTag, placeholder = "Name") {
2169
2238
  const textarea = this.getTextarea();
2170
2239
  if (!textarea) return;
2171
2240
  const start = textarea.selectionStart;
@@ -2177,9 +2246,9 @@ var AdbRichEditorComponent = class AdbRichEditorComponent {
2177
2246
  const spaceAfter = after && !/\s/.test(after) ? " " : "";
2178
2247
  const newValue = value.slice(0, start) + spaceBefore + replaceTag + spaceAfter + value.slice(end);
2179
2248
  this.updateValue(newValue);
2180
- const nameStart = newValue.indexOf("Name", start);
2249
+ const nameStart = newValue.indexOf(placeholder, start);
2181
2250
  if (nameStart === -1) return;
2182
- const nameEnd = nameStart + 4;
2251
+ const nameEnd = nameStart + placeholder.length;
2183
2252
  requestAnimationFrame(() => {
2184
2253
  textarea.focus();
2185
2254
  textarea.setSelectionRange(nameStart, nameEnd);
@@ -2234,7 +2303,7 @@ var AdbRichEditorComponent = class AdbRichEditorComponent {
2234
2303
  multi: true
2235
2304
  }],
2236
2305
  ngImport: i0,
2237
- template: "<div>\n <div class=\"d-flex justify-content-end align-items-end gap-3 mb-1\">\n <label class=\"me-auto\" [for]=\"id\">{{label|translate}}</label>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onItalicClick()\" title=\"Italic\" aria-label=\"Italic\" type=\"button\"><span class=\"bi bi-type-italic\"></span></button>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onBoldClick()\" title=\"Italic\" aria-label=\"strong\" type=\"button\"><span class=\"bi bi-type-bold\"></span></button>\n @if (hasTaxon) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onTaxonClick()\" title=\"Taxon\" aria-label=\"Taxon\" type=\"button\"><span class=\"bi bi-bug\"></span></button>\n }\n @if (hasReference) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onReferenceClick()\" title=\"Reference\" aria-label=\"Reference\" type=\"button\"><span class=\"bi bi-asterisk\"></span></button>\n }\n </div>\n <textarea [id]=\"id\" class=\"form-control\" [(ngModel)]=\"text\" (ngModelChange)=\"onTextChange()\" [rows]=\"rows\" (dblclick)=\"onDoubleClick()\"></textarea>\n</div>\n",
2306
+ template: "<div>\n <div class=\"d-flex justify-content-end align-items-end gap-3 mb-1\">\n <label class=\"me-auto\" [for]=\"id\">{{label|translate}}</label>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onItalicClick()\" title=\"Italic\" aria-label=\"Italic\" type=\"button\"><span class=\"bi bi-type-italic\"></span></button>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onBoldClick()\" title=\"Italic\" aria-label=\"strong\" type=\"button\"><span class=\"bi bi-type-bold\"></span></button>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onLinkClick()\" title=\"Länk\" aria-label=\"Länk\" type=\"button\"><span class=\"bi bi-link-45deg\" aria-hidden=\"true\"></span></button>\n @if (hasTaxon) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onTaxonClick()\" title=\"Taxon\" aria-label=\"Taxon\" type=\"button\"><span class=\"bi bi-bug\"></span></button>\n }\n @if (hasReference) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onReferenceClick()\" title=\"Reference\" aria-label=\"Reference\" type=\"button\"><span class=\"bi bi-asterisk\"></span></button>\n }\n </div>\n <textarea [id]=\"id\" class=\"form-control\" [(ngModel)]=\"text\" (ngModelChange)=\"onTextChange()\" [rows]=\"rows\" (dblclick)=\"onDoubleClick()\"></textarea>\n</div>\n",
2238
2307
  dependencies: [
2239
2308
  {
2240
2309
  kind: "directive",
@@ -2284,7 +2353,7 @@ i0.ɵɵngDeclareClassMetadata({
2284
2353
  }],
2285
2354
  changeDetection: ChangeDetectionStrategy.Eager,
2286
2355
  standalone: false,
2287
- template: "<div>\n <div class=\"d-flex justify-content-end align-items-end gap-3 mb-1\">\n <label class=\"me-auto\" [for]=\"id\">{{label|translate}}</label>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onItalicClick()\" title=\"Italic\" aria-label=\"Italic\" type=\"button\"><span class=\"bi bi-type-italic\"></span></button>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onBoldClick()\" title=\"Italic\" aria-label=\"strong\" type=\"button\"><span class=\"bi bi-type-bold\"></span></button>\n @if (hasTaxon) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onTaxonClick()\" title=\"Taxon\" aria-label=\"Taxon\" type=\"button\"><span class=\"bi bi-bug\"></span></button>\n }\n @if (hasReference) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onReferenceClick()\" title=\"Reference\" aria-label=\"Reference\" type=\"button\"><span class=\"bi bi-asterisk\"></span></button>\n }\n </div>\n <textarea [id]=\"id\" class=\"form-control\" [(ngModel)]=\"text\" (ngModelChange)=\"onTextChange()\" [rows]=\"rows\" (dblclick)=\"onDoubleClick()\"></textarea>\n</div>\n"
2356
+ template: "<div>\n <div class=\"d-flex justify-content-end align-items-end gap-3 mb-1\">\n <label class=\"me-auto\" [for]=\"id\">{{label|translate}}</label>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onItalicClick()\" title=\"Italic\" aria-label=\"Italic\" type=\"button\"><span class=\"bi bi-type-italic\"></span></button>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onBoldClick()\" title=\"Italic\" aria-label=\"strong\" type=\"button\"><span class=\"bi bi-type-bold\"></span></button>\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onLinkClick()\" title=\"Länk\" aria-label=\"Länk\" type=\"button\"><span class=\"bi bi-link-45deg\" aria-hidden=\"true\"></span></button>\n @if (hasTaxon) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onTaxonClick()\" title=\"Taxon\" aria-label=\"Taxon\" type=\"button\"><span class=\"bi bi-bug\"></span></button>\n }\n @if (hasReference) {\n <button class=\"btn btn-sm btn-secondary\" (click)=\"onReferenceClick()\" title=\"Reference\" aria-label=\"Reference\" type=\"button\"><span class=\"bi bi-asterisk\"></span></button>\n }\n </div>\n <textarea [id]=\"id\" class=\"form-control\" [(ngModel)]=\"text\" (ngModelChange)=\"onTextChange()\" [rows]=\"rows\" (dblclick)=\"onDoubleClick()\"></textarea>\n</div>\n"
2288
2357
  }]
2289
2358
  }],
2290
2359
  ctorParameters: () => [{ type: i0.ElementRef }],
@@ -2296,7 +2365,7 @@ i0.ɵɵngDeclareClassMetadata({
2296
2365
  }
2297
2366
  });
2298
2367
  var AdbRichEditorModule = class AdbRichEditorModule {
2299
- static forRoot(config) {
2368
+ static forRoot(config = {}) {
2300
2369
  return {
2301
2370
  ngModule: AdbRichEditorModule,
2302
2371
  providers: [{
@@ -4562,7 +4631,7 @@ var AdbAreaPickerComponent = class AdbAreaPickerComponent {
4562
4631
  return this.http.get(url).pipe(tap(() => this.loading = false));
4563
4632
  };
4564
4633
  onSelect(area) {
4565
- const value = this.useObject ? area : area?.id ?? null;
4634
+ const value = this.useObject ? area : area?.identifier ?? area?.id ?? null;
4566
4635
  this.onChange(value);
4567
4636
  }
4568
4637
  onFocus() {
@@ -4574,7 +4643,8 @@ var AdbAreaPickerComponent = class AdbAreaPickerComponent {
4574
4643
  return;
4575
4644
  }
4576
4645
  if (this.useObject) {
4577
- if (value.id) this.loadAreaId(value.id).subscribe((area) => {
4646
+ const id = value.identifier ?? value.id;
4647
+ if (id) this.loadAreaId(id).subscribe((area) => {
4578
4648
  this.initialValue.set(area);
4579
4649
  });
4580
4650
  else this.initialValue.set(value);
@@ -4769,6 +4839,6 @@ i0.ɵɵngDeclareClassMetadata({
4769
4839
  }]
4770
4840
  }]
4771
4841
  });
4772
- export { ADB_ALERT_CONFIG, ADB_PICKER_CONFIG, ADB_USER_SERVICE_CONFIG, AdbAlertComponent, AdbAlertModule, AdbAreaPickerComponent, AdbButtonsModule, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbFilterSectionModule, AdbHelpButtonComponent, AdbModalModule, AdbModalService, AdbPagersModule, AdbPickerConfigService, AdbPickerModule, AdbPipesModule, AdbRichEditorComponent, AdbRichEditorModule, AdbTaxonPickerComponent, AdbToast, AdbToastModule, AdbToastService, AdbUserInterceptor, AdbUserModule, AdbUserService, ArtportalenFooterComponent, ArtportalenNavComponent, ArtportalenNavModule, AuthCallbackComponent, ClickOutsideDirective, DEFAULT_ADB_USER_SERVICE_CONFIG, EmptyValuePipe, EnvironmentService, FileUploadDirective, FilterSectionComponent, FocusDirective, GenericPickerComponent, HighlightHtmlPipe, HighlightPipe, ImageLoaderDirective, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, PagerInlineComponent, RedListBadgeClassDirective, RichTextComponent, RiskClassDirective, RouterLinkActiveFragmentDirective, ScrollService, ToastType, UserModuleConstants };
4842
+ export { ADB_ALERT_CONFIG, ADB_PICKER_CONFIG, ADB_USER_SERVICE_CONFIG, AdbAlertComponent, AdbAlertModule, AdbAreaPickerComponent, AdbButtonsModule, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbFilterSectionModule, AdbHelpButtonComponent, AdbModalModule, AdbModalService, AdbPagersModule, AdbPickerConfigService, AdbPickerModule, AdbPipesModule, AdbRichEditorComponent, AdbRichEditorModule, AdbTaxonPickerComponent, AdbToast, AdbToastModule, AdbToastService, AdbUserInterceptor, AdbUserModule, AdbUserService, ArtportalenFooterComponent, ArtportalenNavComponent, ArtportalenNavModule, AuthCallbackComponent, ClickOutsideDirective, DEFAULT_ADB_USER_SERVICE_CONFIG, EmptyValuePipe, EnvironmentService, FileUploadDirective, FilterSectionComponent, FocusDirective, GenericPickerComponent, HighlightHtmlPipe, HighlightPipe, ImageLoaderDirective, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, PagerInlineComponent, RedListBadgeClassDirective, RedListColorClassDirective, RichTextComponent, RiskClassDirective, RouterLinkActiveFragmentDirective, ScrollService, ToastType, UserModuleConstants };
4773
4843
 
4774
4844
  //# sourceMappingURL=adb-shared.mjs.map