@alfresco/adf-core 8.4.0-19535580979 → 8.4.0-19535715289

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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Input, ChangeDetectionStrategy, ViewEncapsulation, Component, inject, Injectable, TemplateRef, ContentChild, Directive, ContentChildren, RendererFactory2, Optional, Inject, NgModule, HostBinding, Pipe, InjectionToken, provideAppInitializer, EventEmitter, HostListener, ViewChild, Output, ViewChildren, DestroyRef, QueryList, Self, signal, computed, DEFAULT_CURRENCY_CODE, SecurityContext, ElementRef, ChangeDetectorRef, ViewContainerRef, forwardRef, Compiler, Injector } from '@angular/core';
2
+ import { Input, ChangeDetectionStrategy, ViewEncapsulation, Component, inject, Injectable, TemplateRef, ContentChild, Directive, ContentChildren, RendererFactory2, effect, Optional, Inject, NgModule, HostBinding, Pipe, InjectionToken, provideAppInitializer, EventEmitter, HostListener, ViewChild, Output, ViewChildren, DestroyRef, QueryList, Self, signal, computed, DEFAULT_CURRENCY_CODE, SecurityContext, ElementRef, ChangeDetectorRef, ViewContainerRef, forwardRef, Compiler, Injector } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { CommonModule, DOCUMENT, NgIf, NgClass, NgForOf, AsyncPipe, NgTemplateOutlet, NgStyle, DecimalPipe, DatePipe, CurrencyPipe, NgFor } from '@angular/common';
5
5
  import * as i2 from '@angular/material/table';
@@ -9,7 +9,7 @@ import { TranslatePipe, provideTranslateService, TranslateLoader } from '@ngx-tr
9
9
  import * as i1$8 from '@angular/common/http';
10
10
  import { HttpClient, HttpHeaders, HttpResponse, provideHttpClient, HTTP_INTERCEPTORS, withInterceptorsFromDi, withXsrfConfiguration } from '@angular/common/http';
11
11
  import { ReplaySubject, BehaviorSubject, of, Subject, switchMap as switchMap$1, from, fromEvent, Observable, throwError, firstValueFrom, combineLatest, defer, EMPTY, race, forkJoin, merge, isObservable, filter as filter$1 } from 'rxjs';
12
- import { map, distinctUntilChanged, take, switchMap, delay, catchError, skipWhile, filter, first, timeout, shareReplay, mergeMap, tap, retry, takeUntil, debounceTime, share, pairwise, buffer } from 'rxjs/operators';
12
+ import { map, distinctUntilChanged, take, switchMap, delay, catchError, skipWhile, filter, first, timeout, shareReplay, mergeMap, tap, retry, debounceTime, share, pairwise, takeUntil, buffer } from 'rxjs/operators';
13
13
  import * as i1$4 from '@alfresco/adf-extensions';
14
14
  import { ExtensionService, mergeObjects, ExtensionsModule, PreviewExtensionComponent } from '@alfresco/adf-extensions';
15
15
  import * as i9 from '@angular/material/card';
@@ -19,6 +19,7 @@ import { MatExpansionModule } from '@angular/material/expansion';
19
19
  import * as i1$2 from '@angular/material/core';
20
20
  import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS, MatLineModule, MatNativeDateModule, MatOptionModule, MatRippleModule } from '@angular/material/core';
21
21
  import { Directionality } from '@angular/cdk/bidi';
22
+ import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
22
23
  import { parseISO, format, parse, isValid, isBefore, isAfter, addHours, addMinutes, differenceInDays, formatDistance, fromUnixTime } from 'date-fns';
23
24
  import { enUS, zhCN, sv, ru, ptBR, pl, nl, nb, ja, it, fr, fi, es, de, da, cs, ar } from 'date-fns/locale';
24
25
  import { DateFnsAdapter } from '@angular/material-date-fns-adapter';
@@ -54,7 +55,6 @@ import * as pdfjsLib$1 from 'pdfjs-dist/build/pdf.min.mjs';
54
55
  import { PDFViewer, EventBus } from 'pdfjs-dist/web/pdf_viewer.mjs';
55
56
  import * as i7 from '@angular/material/menu';
56
57
  import { MatMenuModule, MatMenuItem, MatMenuTrigger } from '@angular/material/menu';
57
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
58
58
  import * as i1$9 from '@angular/router';
59
59
  import { RouterModule, Router, provideRouter } from '@angular/router';
60
60
  import * as i2$6 from '@angular/material/checkbox';
@@ -1102,6 +1102,14 @@ class UserPreferencesService {
1102
1102
  this.userPreferenceStatus = this.defaults;
1103
1103
  this.onChangeSubject = new BehaviorSubject(this.userPreferenceStatus);
1104
1104
  this.onChange = this.onChangeSubject.asObservable();
1105
+ // Initialize convenience observables
1106
+ this.locale$ = this.select(UserPreferenceValues.Locale);
1107
+ this.paginationSize$ = this.select(UserPreferenceValues.PaginationSize);
1108
+ this.supportedPageSizes$ = this.select(UserPreferenceValues.SupportedPageSizes).pipe(map((value) => (value ? JSON.parse(value) : this.defaults.supportedPageSizes)));
1109
+ // Initialize convenience signals (automatically handle cleanup)
1110
+ this.localeSignal = toSignal(this.locale$, { initialValue: this.defaults.locale });
1111
+ this.paginationSizeSignal = toSignal(this.paginationSize$, { initialValue: this.defaults.paginationSize });
1112
+ this.supportedPageSizesSignal = toSignal(this.supportedPageSizes$, { initialValue: this.defaults.supportedPageSizes });
1105
1113
  this.appConfig.onLoad.subscribe(() => {
1106
1114
  this.initUserPreferenceStatus();
1107
1115
  });
@@ -1310,7 +1318,10 @@ class MomentDateAdapter extends DateAdapter {
1310
1318
  constructor(preferences) {
1311
1319
  super();
1312
1320
  this.localeData = moment.localeData();
1313
- preferences.select(UserPreferenceValues.Locale).subscribe((locale) => {
1321
+ // Use effect to reactively update locale when signal changes
1322
+ // Note: This adapter is a singleton service, so no cleanup needed
1323
+ effect(() => {
1324
+ const locale = preferences.localeSignal();
1314
1325
  this.setLocale(locale);
1315
1326
  });
1316
1327
  }
@@ -1812,11 +1823,24 @@ class AdfDateFnsAdapter extends DateFnsAdapter {
1812
1823
  this._displayFormat = value ? DateFnsUtils.convertMomentToDateFnsFormat(value) : null;
1813
1824
  }
1814
1825
  constructor(matDateLocale, formats, preferences) {
1815
- super(matDateLocale);
1826
+ // Ensure we have a valid locale for the base class
1827
+ // If matDateLocale is not provided, use enUS as default
1828
+ super(matDateLocale || enUS);
1816
1829
  this.formats = formats;
1817
1830
  this._displayFormat = null;
1818
- preferences.select(UserPreferenceValues.Locale).subscribe((locale) => {
1819
- this.setLocale(DateFnsUtils.getLocaleFromString(locale));
1831
+ // Initialize locale synchronously from signal's initial value
1832
+ // This ensures locale is set before any format() calls
1833
+ const initialLocale = preferences.localeSignal();
1834
+ if (initialLocale) {
1835
+ this.setLocale(DateFnsUtils.getLocaleFromString(initialLocale));
1836
+ }
1837
+ // Use effect to reactively update locale when signal changes
1838
+ // Note: This adapter is a singleton service, so no cleanup needed
1839
+ effect(() => {
1840
+ const locale = preferences.localeSignal();
1841
+ if (locale) {
1842
+ this.setLocale(DateFnsUtils.getLocaleFromString(locale));
1843
+ }
1820
1844
  });
1821
1845
  }
1822
1846
  parse(value, parseFormat) {
@@ -3115,7 +3139,10 @@ class TranslationService {
3115
3139
  this.addTranslationFolder(provider.name, provider.source);
3116
3140
  }
3117
3141
  }
3118
- userPreferencesService.select(UserPreferenceValues.Locale).subscribe((locale) => {
3142
+ // Use effect to reactively update translations when locale signal changes
3143
+ // Note: This is a singleton service, so no cleanup needed
3144
+ effect(() => {
3145
+ const locale = userPreferencesService.localeSignal();
3119
3146
  if (locale) {
3120
3147
  this.userLang = locale;
3121
3148
  this.use(this.userLang);
@@ -12156,20 +12183,9 @@ class DecimalNumberPipe {
12156
12183
  constructor(userPreferenceService, appConfig) {
12157
12184
  this.userPreferenceService = userPreferenceService;
12158
12185
  this.appConfig = appConfig;
12159
- this.defaultLocale = DecimalNumberPipe.DEFAULT_LOCALE;
12160
12186
  this.defaultMinIntegerDigits = DecimalNumberPipe.DEFAULT_MIN_INTEGER_DIGITS;
12161
12187
  this.defaultMinFractionDigits = DecimalNumberPipe.DEFAULT_MIN_FRACTION_DIGITS;
12162
12188
  this.defaultMaxFractionDigits = DecimalNumberPipe.DEFAULT_MAX_FRACTION_DIGITS;
12163
- if (this.userPreferenceService) {
12164
- this.userPreferenceService
12165
- .select(UserPreferenceValues.Locale)
12166
- .pipe(takeUntilDestroyed())
12167
- .subscribe((locale) => {
12168
- if (locale) {
12169
- this.defaultLocale = locale;
12170
- }
12171
- });
12172
- }
12173
12189
  if (this.appConfig) {
12174
12190
  this.defaultMinIntegerDigits = this.appConfig.get('decimalValues.minIntegerDigits', DecimalNumberPipe.DEFAULT_MIN_INTEGER_DIGITS);
12175
12191
  this.defaultMinFractionDigits = this.appConfig.get('decimalValues.minFractionDigits', DecimalNumberPipe.DEFAULT_MIN_FRACTION_DIGITS);
@@ -12181,7 +12197,9 @@ class DecimalNumberPipe {
12181
12197
  const actualMinFractionDigits = digitsInfo?.minFractionDigits ? digitsInfo.minFractionDigits : this.defaultMinFractionDigits;
12182
12198
  const actualMaxFractionDigits = digitsInfo?.maxFractionDigits ? digitsInfo.maxFractionDigits : this.defaultMaxFractionDigits;
12183
12199
  const actualDigitsInfo = `${actualMinIntegerDigits}.${actualMinFractionDigits}-${actualMaxFractionDigits}`;
12184
- const actualLocale = locale || this.defaultLocale;
12200
+ // Use signal directly - no subscription needed!
12201
+ const defaultLocale = this.userPreferenceService?.localeSignal() || DecimalNumberPipe.DEFAULT_LOCALE;
12202
+ const actualLocale = locale || defaultLocale;
12185
12203
  const decimalPipe = new DecimalPipe(actualLocale);
12186
12204
  if (value instanceof Array) {
12187
12205
  return value.map((val) => decimalPipe.transform(val, actualDigitsInfo));
@@ -12385,33 +12403,19 @@ class LocalizedDatePipe {
12385
12403
  constructor(userPreferenceService, appConfig) {
12386
12404
  this.userPreferenceService = userPreferenceService;
12387
12405
  this.appConfig = appConfig;
12388
- this.defaultLocale = LocalizedDatePipe.DEFAULT_LOCALE;
12389
12406
  this.defaultFormat = LocalizedDatePipe.DEFAULT_DATE_FORMAT;
12390
- this.onDestroy$ = new Subject();
12391
- if (this.userPreferenceService) {
12392
- this.userPreferenceService
12393
- .select(UserPreferenceValues.Locale)
12394
- .pipe(takeUntil(this.onDestroy$))
12395
- .subscribe((locale) => {
12396
- if (locale) {
12397
- this.defaultLocale = locale;
12398
- }
12399
- });
12400
- }
12401
12407
  if (this.appConfig) {
12402
12408
  this.defaultFormat = this.appConfig.get('dateValues.defaultDateFormat', LocalizedDatePipe.DEFAULT_DATE_FORMAT);
12403
12409
  }
12404
12410
  }
12405
12411
  transform(value, format, locale, timezone) {
12406
12412
  const actualFormat = format || this.defaultFormat;
12407
- const actualLocale = locale || this.defaultLocale;
12413
+ // Use signal directly - no subscription needed!
12414
+ const defaultLocale = this.userPreferenceService?.localeSignal() || LocalizedDatePipe.DEFAULT_LOCALE;
12415
+ const actualLocale = locale || defaultLocale;
12408
12416
  const datePipe = timezone ? new DatePipe(actualLocale, timezone) : new DatePipe(actualLocale);
12409
12417
  return datePipe.transform(value, actualFormat);
12410
12418
  }
12411
- ngOnDestroy() {
12412
- this.onDestroy$.next(true);
12413
- this.onDestroy$.complete();
12414
- }
12415
12419
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: LocalizedDatePipe, deps: [{ token: UserPreferencesService }, { token: AppConfigService }], target: i0.ɵɵFactoryTarget.Pipe }); }
12416
12420
  static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: LocalizedDatePipe, isStandalone: true, name: "adfLocalizedDate", pure: false }); }
12417
12421
  }
@@ -12514,17 +12518,13 @@ class TimeAgoPipe {
12514
12518
  constructor(userPreferenceService, appConfig) {
12515
12519
  this.userPreferenceService = userPreferenceService;
12516
12520
  this.appConfig = appConfig;
12517
- this.userPreferenceService
12518
- .select(UserPreferenceValues.Locale)
12519
- .pipe(takeUntilDestroyed())
12520
- .subscribe((locale) => {
12521
- this.defaultLocale = locale || TimeAgoPipe.DEFAULT_LOCALE;
12522
- });
12523
12521
  this.defaultDateTimeFormat = this.appConfig.get('dateValues.defaultDateTimeFormat', TimeAgoPipe.DEFAULT_DATE_TIME_FORMAT);
12524
12522
  }
12525
12523
  transform(value, locale) {
12526
12524
  if (value !== null && value !== undefined) {
12527
- const actualLocale = locale || this.defaultLocale;
12525
+ // Use signal directly - no subscription needed!
12526
+ const defaultLocale = this.userPreferenceService.localeSignal() || TimeAgoPipe.DEFAULT_LOCALE;
12527
+ const actualLocale = locale || defaultLocale;
12528
12528
  const diff = differenceInDays(new Date(), new Date(value));
12529
12529
  if (diff > 7) {
12530
12530
  const datePipe = new DatePipe(actualLocale);
@@ -15993,7 +15993,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
15993
15993
  */
15994
15994
  class DateCellComponent extends DataTableCellComponent {
15995
15995
  constructor() {
15996
- super(...arguments);
15996
+ super();
15997
15997
  this.config = {};
15998
15998
  this.appConfig = inject(AppConfigService);
15999
15999
  this.localizedDatePipe = inject(LocalizedDatePipe);
@@ -16005,19 +16005,15 @@ class DateCellComponent extends DataTableCellComponent {
16005
16005
  tooltipFormat: 'medium',
16006
16006
  locale: undefined
16007
16007
  };
16008
- }
16009
- ngOnInit() {
16010
- // Subscribe to locale changes
16011
- this.userPreferencesService
16012
- .select(UserPreferenceValues.Locale)
16013
- .pipe(takeUntilDestroyed(this.destroyRef))
16014
- .subscribe((locale) => {
16015
- this.userLocale = locale || 'en';
16008
+ // Use effect to react to locale signal changes (must be in injection context)
16009
+ effect(() => {
16010
+ this.userLocale = this.userPreferencesService.localeSignal() || 'en';
16016
16011
  this.setConfig();
16017
16012
  this.updateValue(); // Recalculate computedTitle with new locale
16018
16013
  this.cdr.markForCheck();
16019
16014
  });
16020
- this.setConfig();
16015
+ }
16016
+ ngOnInit() {
16021
16017
  super.ngOnInit();
16022
16018
  }
16023
16019
  computeTitle(value) {
@@ -16069,13 +16065,13 @@ class DateCellComponent extends DataTableCellComponent {
16069
16065
  getAppConfigPropertyValue(key, defaultValue) {
16070
16066
  return this.appConfig.get(key, defaultValue);
16071
16067
  }
16072
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DateCellComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
16068
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DateCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
16073
16069
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: DateCellComponent, isStandalone: true, selector: "adf-date-cell", inputs: { dateConfig: "dateConfig" }, host: { classAttribute: "adf-datatable-content-cell" }, providers: [LocalizedDatePipe], usesInheritance: true, ngImport: i0, template: "@let date = value$ | async;\n\n@if (date) {\n <span [title]=\"title()\" class=\"adf-datatable-cell-value\">\n @if (config.format === 'timeAgo') {\n @if (config.locale) {\n {{ date | adfTimeAgo: config.locale }}\n } @else {\n {{ date | adfTimeAgo }}\n }\n } @else {\n @if (config.locale) {\n {{ date | adfLocalizedDate: config.format: config.locale }}\n } @else {\n {{ date | adfLocalizedDate: config.format }}\n }\n }\n </span>\n}\n", dependencies: [{ kind: "pipe", type: LocalizedDatePipe, name: "adfLocalizedDate" }, { kind: "pipe", type: TimeAgoPipe, name: "adfTimeAgo" }, { kind: "pipe", type: AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
16074
16070
  }
16075
16071
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DateCellComponent, decorators: [{
16076
16072
  type: Component,
16077
16073
  args: [{ imports: [LocalizedDatePipe, TimeAgoPipe, AsyncPipe], selector: 'adf-date-cell', encapsulation: ViewEncapsulation.None, host: { class: 'adf-datatable-content-cell' }, changeDetection: ChangeDetectionStrategy.OnPush, providers: [LocalizedDatePipe], template: "@let date = value$ | async;\n\n@if (date) {\n <span [title]=\"title()\" class=\"adf-datatable-cell-value\">\n @if (config.format === 'timeAgo') {\n @if (config.locale) {\n {{ date | adfTimeAgo: config.locale }}\n } @else {\n {{ date | adfTimeAgo }}\n }\n } @else {\n @if (config.locale) {\n {{ date | adfLocalizedDate: config.format: config.locale }}\n } @else {\n {{ date | adfLocalizedDate: config.format }}\n }\n }\n </span>\n}\n" }]
16078
- }], propDecorators: { dateConfig: [{
16074
+ }], ctorParameters: () => [], propDecorators: { dateConfig: [{
16079
16075
  type: Input
16080
16076
  }] } });
16081
16077
 
@@ -18248,15 +18244,12 @@ class CardViewDateItemComponent extends BaseCardView {
18248
18244
  this.displayEmpty = true;
18249
18245
  this.displayClearAction = true;
18250
18246
  this.cardViewDateTimeControl = new FormControl(null);
18251
- this.destroyRef = inject(DestroyRef);
18247
+ // Use effect to react to locale signal changes (must be in injection context)
18248
+ effect(() => {
18249
+ this.property.locale = this.userPreferencesService.localeSignal();
18250
+ });
18252
18251
  }
18253
18252
  ngOnInit() {
18254
- this.userPreferencesService
18255
- .select(UserPreferenceValues.Locale)
18256
- .pipe(takeUntilDestroyed(this.destroyRef))
18257
- .subscribe((locale) => {
18258
- this.property.locale = locale;
18259
- });
18260
18253
  this.dateAdapter.displayFormat = 'MMM DD';
18261
18254
  if (this.property.multivalued) {
18262
18255
  this.initMultivaluedProperty();