@alfresco/adf-core 8.4.0-19126740914 → 8.4.0-19133056716
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.
- package/fesm2022/adf-core.mjs +105 -11
- package/fesm2022/adf-core.mjs.map +1 -1
- package/lib/form/components/widgets/amount/amount.widget.d.ts +43 -4
- package/lib/mock/translation.service.mock.d.ts +1 -0
- package/lib/testing/noop-translate.module.d.ts +1 -0
- package/lib/translation/translation.service.d.ts +6 -0
- package/package.json +3 -3
package/fesm2022/adf-core.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
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, DEFAULT_CURRENCY_CODE, SecurityContext, ElementRef, ViewContainerRef, forwardRef, Compiler, ChangeDetectorRef, Injector } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
|
-
import { CommonModule, DOCUMENT, NgIf, NgClass, NgForOf, AsyncPipe, NgTemplateOutlet, NgStyle, DecimalPipe, DatePipe, NgFor } from '@angular/common';
|
|
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';
|
|
6
6
|
import { MatTableModule, MatTableDataSource } from '@angular/material/table';
|
|
7
7
|
import * as i1$1 from '@ngx-translate/core';
|
|
8
8
|
import { TranslatePipe, provideTranslateService, TranslateLoader } from '@ngx-translate/core';
|
|
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
|
-
import { ReplaySubject, BehaviorSubject, of, Subject, switchMap as switchMap$1, from, fromEvent, Observable, throwError, firstValueFrom, combineLatest, defer, EMPTY, race, forkJoin, merge } from 'rxjs';
|
|
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
12
|
import { map, distinctUntilChanged, take, switchMap, delay, catchError, skipWhile, filter, first, timeout, shareReplay, mergeMap, tap, retry, takeUntil, debounceTime, share, pairwise, 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';
|
|
@@ -3186,6 +3186,21 @@ class TranslationService {
|
|
|
3186
3186
|
get(key, interpolateParams) {
|
|
3187
3187
|
return this.translate.get(key, interpolateParams);
|
|
3188
3188
|
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Determines the preferred locale for the current user.
|
|
3191
|
+
*
|
|
3192
|
+
* @returns Locale identifier resolved from the browser or the default translation locale
|
|
3193
|
+
*/
|
|
3194
|
+
getLocale() {
|
|
3195
|
+
const defaultLocale = this.userLang || this.defaultLang;
|
|
3196
|
+
if (typeof window?.navigator === 'undefined') {
|
|
3197
|
+
return defaultLocale;
|
|
3198
|
+
}
|
|
3199
|
+
const wn = window.navigator;
|
|
3200
|
+
let lang = wn.languages ? wn.languages[0] : defaultLocale;
|
|
3201
|
+
lang = lang || wn.language;
|
|
3202
|
+
return lang;
|
|
3203
|
+
}
|
|
3189
3204
|
/**
|
|
3190
3205
|
* Directly returns the translation for the supplied key.
|
|
3191
3206
|
*
|
|
@@ -22732,25 +22747,102 @@ class AmountWidgetComponent extends WidgetComponent {
|
|
|
22732
22747
|
get placeholder() {
|
|
22733
22748
|
return this.showPlaceholder ? this.field.placeholder : '';
|
|
22734
22749
|
}
|
|
22735
|
-
constructor(formService, settings) {
|
|
22750
|
+
constructor(formService, settings, currencyPipe, translationService) {
|
|
22736
22751
|
super(formService);
|
|
22737
22752
|
this.formService = formService;
|
|
22738
|
-
this.
|
|
22753
|
+
this.currencyPipe = currencyPipe;
|
|
22754
|
+
this.translationService = translationService;
|
|
22739
22755
|
this.showPlaceholder = true;
|
|
22756
|
+
this.destroyRef = inject(DestroyRef);
|
|
22740
22757
|
this.currency = AmountWidgetComponent.DEFAULT_CURRENCY;
|
|
22758
|
+
this.currencyDisplay = 'symbol';
|
|
22759
|
+
this.isInputInFocus = false;
|
|
22760
|
+
this.notShowDecimalDigits = '1.0-0';
|
|
22761
|
+
this.showDecimalDigits = '1.2-2';
|
|
22762
|
+
if (isObservable(settings)) {
|
|
22763
|
+
settings.pipe(takeUntilDestroyed()).subscribe((data) => {
|
|
22764
|
+
this.updateSettingsBasedProperties(data);
|
|
22765
|
+
});
|
|
22766
|
+
}
|
|
22767
|
+
else {
|
|
22768
|
+
this.updateSettingsBasedProperties(settings);
|
|
22769
|
+
}
|
|
22741
22770
|
}
|
|
22742
22771
|
ngOnInit() {
|
|
22743
22772
|
if (this.field) {
|
|
22744
22773
|
if (this.field.currency) {
|
|
22745
22774
|
this.currency = this.field.currency;
|
|
22746
22775
|
}
|
|
22776
|
+
else {
|
|
22777
|
+
if (this.enableDisplayBasedOnLocale) {
|
|
22778
|
+
this.currency = '';
|
|
22779
|
+
this.currencyDisplay = '';
|
|
22780
|
+
}
|
|
22781
|
+
}
|
|
22747
22782
|
if (this.field.readOnly) {
|
|
22748
|
-
this.showPlaceholder = this.
|
|
22783
|
+
this.showPlaceholder = this.showReadonlyPlaceholder;
|
|
22784
|
+
}
|
|
22785
|
+
this.subscribeToFieldChanges();
|
|
22786
|
+
this.setInitialValues();
|
|
22787
|
+
}
|
|
22788
|
+
}
|
|
22789
|
+
amountWidgetOnBlur() {
|
|
22790
|
+
this.isInputInFocus = false;
|
|
22791
|
+
if (this.enableDisplayBasedOnLocale) {
|
|
22792
|
+
if (this.amountWidgetValue) {
|
|
22793
|
+
this.valueAsNumber = parseFloat(this.amountWidgetValue);
|
|
22794
|
+
this.amountWidgetValue = this.currencyPipe.transform(this.amountWidgetValue, this.currency, this.currencyDisplay, this.decimalProperty);
|
|
22795
|
+
}
|
|
22796
|
+
else {
|
|
22797
|
+
this.valueAsNumber = null;
|
|
22798
|
+
this.amountWidgetValue = null;
|
|
22749
22799
|
}
|
|
22750
22800
|
}
|
|
22801
|
+
this.markAsTouched();
|
|
22802
|
+
}
|
|
22803
|
+
amountWidgetOnFocus() {
|
|
22804
|
+
this.isInputInFocus = true;
|
|
22805
|
+
if (this.enableDisplayBasedOnLocale) {
|
|
22806
|
+
const hasValue = this.valueAsNumber === 0 || this.valueAsNumber;
|
|
22807
|
+
this.amountWidgetValue = hasValue ? this.valueAsNumber.toString() : null;
|
|
22808
|
+
}
|
|
22809
|
+
}
|
|
22810
|
+
onFieldChangedAmountWidget() {
|
|
22811
|
+
this.field.value = this.amountWidgetValue;
|
|
22812
|
+
super.onFieldChanged(this.field);
|
|
22813
|
+
}
|
|
22814
|
+
setInitialValues() {
|
|
22815
|
+
if (this.enableDisplayBasedOnLocale) {
|
|
22816
|
+
this.decimalProperty = this.field.enableFractions ? this.showDecimalDigits : this.notShowDecimalDigits;
|
|
22817
|
+
this.locale = this.translationService.getLocale();
|
|
22818
|
+
this.updateValue(this.field.value);
|
|
22819
|
+
}
|
|
22820
|
+
else {
|
|
22821
|
+
this.amountWidgetValue = this.field.value;
|
|
22822
|
+
}
|
|
22751
22823
|
}
|
|
22752
|
-
|
|
22753
|
-
|
|
22824
|
+
subscribeToFieldChanges() {
|
|
22825
|
+
this.formService.formFieldValueChanged
|
|
22826
|
+
.pipe(filter$1((ev) => ev.field.id === this.field.id), takeUntilDestroyed(this.destroyRef))
|
|
22827
|
+
.subscribe((ev) => {
|
|
22828
|
+
if (!this.isInputInFocus && this.enableDisplayBasedOnLocale) {
|
|
22829
|
+
this.updateValue(ev.field.value);
|
|
22830
|
+
}
|
|
22831
|
+
else if (!this.isInputInFocus) {
|
|
22832
|
+
this.amountWidgetValue = ev.field.value;
|
|
22833
|
+
}
|
|
22834
|
+
});
|
|
22835
|
+
}
|
|
22836
|
+
updateValue(value) {
|
|
22837
|
+
this.valueAsNumber = value;
|
|
22838
|
+
this.amountWidgetValue = this.currencyPipe.transform(value, this.currency, this.currencyDisplay, this.decimalProperty, this.locale);
|
|
22839
|
+
}
|
|
22840
|
+
updateSettingsBasedProperties(data) {
|
|
22841
|
+
this.enableDisplayBasedOnLocale = data?.enableDisplayBasedOnLocale ?? false;
|
|
22842
|
+
this.showReadonlyPlaceholder = data?.showReadonlyPlaceholder;
|
|
22843
|
+
}
|
|
22844
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AmountWidgetComponent, deps: [{ token: FormService }, { token: ADF_AMOUNT_SETTINGS, optional: true }, { token: i1.CurrencyPipe }, { token: TranslationService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
22845
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: AmountWidgetComponent, isStandalone: true, selector: "amount-widget", host: { listeners: { "click": "event($event)", "blur": "event($event)", "change": "event($event)", "focus": "event($event)", "focusin": "event($event)", "focusout": "event($event)", "input": "event($event)", "invalid": "event($event)", "select": "event($event)" } }, providers: [CurrencyPipe], usesInheritance: true, ngImport: i0, template: "<div\n class=\"adf-amount-widget__container adf-amount-widget {{field.className}}\"\n [class.adf-invalid]=\"!field.isValid && isTouched()\"\n [class.adf-readonly]=\"field.readOnly\"\n [class.adf-left-label-input-container]=\"field.leftLabels\"\n>\n <div *ngIf=\"field.leftLabels\">\n <label class=\"adf-label adf-left-label\" [attr.for]=\"field.id\"\n >{{field.name | translate }}<span class=\"adf-asterisk\" [style.visibility]=\"isRequired() ? 'visible' : 'hidden'\">*</span></label\n >\n </div>\n <div class=\"adf-amount-widget-container\">\n <mat-form-field class=\"adf-amount-widget__input adf-form-field-input\" [floatLabel]=\"placeholder ? 'always' : null\">\n @if ( (field.name || field?.required) && !field.leftLabels) { <mat-label class=\"adf-label\" [attr.for]=\"field.id\">{{field.name | translate }}</mat-label> }\n @if(!enableDisplayBasedOnLocale) {\n <span matTextPrefix class=\"adf-amount-widget__prefix-spacing\">{{ currency }} </span>\n }\n <input\n matInput\n [title]=\"field.tooltip\"\n class=\"adf-input\"\n type=\"text\"\n [id]=\"field.id\"\n [required]=\"field.required && field.isVisible\"\n [placeholder]=\"placeholder\"\n [value]=\"amountWidgetValue\"\n [(ngModel)]=\"amountWidgetValue\"\n (ngModelChange)=\"onFieldChangedAmountWidget()\"\n [disabled]=\"field.readOnly\"\n (focus)=\"amountWidgetOnFocus()\"\n (blur)=\"amountWidgetOnBlur()\"\n />\n </mat-form-field>\n <div class=\"adf-error-messages-container\">\n <error-widget [error]=\"field.validationSummary\" />\n <error-widget\n *ngIf=\"isInvalidFieldRequired() && isTouched()\"\n required=\"{{ 'FORM.FIELD.REQUIRED' | translate }}\"\n />\n </div>\n </div>\n</div>\n", styles: [".adf-amount-widget{width:100%}.adf-amount-widget .adf-left-label{line-height:36px}.adf-amount-widget-container{display:grid;align-items:flex-start}.adf-amount-widget__input .mat-focused{transition:none}.adf-amount-widget__input .adf-input{margin-top:3px}.adf-amount-widget__input:not(.mat-focused):not(.mat-form-field-invalid) .adf-amount-widget__prefix-spacing{color:var(--adf-theme-foreground-secondary-text-color)}\n"], dependencies: [{ kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2$4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2$4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i2$4.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i4.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: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ErrorWidgetComponent, selector: "error-widget", inputs: ["error", "required"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
22754
22846
|
}
|
|
22755
22847
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: AmountWidgetComponent, decorators: [{
|
|
22756
22848
|
type: Component,
|
|
@@ -22764,13 +22856,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
|
|
|
22764
22856
|
'(input)': 'event($event)',
|
|
22765
22857
|
'(invalid)': 'event($event)',
|
|
22766
22858
|
'(select)': 'event($event)'
|
|
22767
|
-
}, imports: [MatFormFieldModule, MatInputModule, FormsModule, ErrorWidgetComponent, TranslatePipe, NgIf], encapsulation: ViewEncapsulation.None, template: "<div\n class=\"adf-amount-widget__container adf-amount-widget {{field.className}}\"\n [class.adf-invalid]=\"!field.isValid && isTouched()\"\n [class.adf-readonly]=\"field.readOnly\"\n [class.adf-left-label-input-container]=\"field.leftLabels\"\n>\n <div *ngIf=\"field.leftLabels\">\n <label class=\"adf-label adf-left-label\" [attr.for]=\"field.id\"\n >{{field.name | translate }}<span class=\"adf-asterisk\" [style.visibility]=\"isRequired() ? 'visible' : 'hidden'\">*</span></label\n >\n </div>\n <div class=\"adf-amount-widget-container\">\n <mat-form-field class=\"adf-amount-widget__input adf-form-field-input\" [floatLabel]=\"placeholder ? 'always' : null\">\n @if ( (field.name || field?.required) && !field.leftLabels) { <mat-label class=\"adf-label\" [attr.for]=\"field.id\">{{field.name | translate }}</mat-label> }\n <span matTextPrefix class=\"adf-amount-widget__prefix-spacing\">{{ currency }} </span>\n <input\n matInput\n [title]=\"field.tooltip\"\n class=\"adf-input\"\n type=\"text\"\n [id]=\"field.id\"\n [required]=\"field.required && field.isVisible\"\n [placeholder]=\"placeholder\"\n [value]=\"
|
|
22859
|
+
}, imports: [MatFormFieldModule, MatInputModule, FormsModule, ErrorWidgetComponent, TranslatePipe, NgIf], providers: [CurrencyPipe], encapsulation: ViewEncapsulation.None, template: "<div\n class=\"adf-amount-widget__container adf-amount-widget {{field.className}}\"\n [class.adf-invalid]=\"!field.isValid && isTouched()\"\n [class.adf-readonly]=\"field.readOnly\"\n [class.adf-left-label-input-container]=\"field.leftLabels\"\n>\n <div *ngIf=\"field.leftLabels\">\n <label class=\"adf-label adf-left-label\" [attr.for]=\"field.id\"\n >{{field.name | translate }}<span class=\"adf-asterisk\" [style.visibility]=\"isRequired() ? 'visible' : 'hidden'\">*</span></label\n >\n </div>\n <div class=\"adf-amount-widget-container\">\n <mat-form-field class=\"adf-amount-widget__input adf-form-field-input\" [floatLabel]=\"placeholder ? 'always' : null\">\n @if ( (field.name || field?.required) && !field.leftLabels) { <mat-label class=\"adf-label\" [attr.for]=\"field.id\">{{field.name | translate }}</mat-label> }\n @if(!enableDisplayBasedOnLocale) {\n <span matTextPrefix class=\"adf-amount-widget__prefix-spacing\">{{ currency }} </span>\n }\n <input\n matInput\n [title]=\"field.tooltip\"\n class=\"adf-input\"\n type=\"text\"\n [id]=\"field.id\"\n [required]=\"field.required && field.isVisible\"\n [placeholder]=\"placeholder\"\n [value]=\"amountWidgetValue\"\n [(ngModel)]=\"amountWidgetValue\"\n (ngModelChange)=\"onFieldChangedAmountWidget()\"\n [disabled]=\"field.readOnly\"\n (focus)=\"amountWidgetOnFocus()\"\n (blur)=\"amountWidgetOnBlur()\"\n />\n </mat-form-field>\n <div class=\"adf-error-messages-container\">\n <error-widget [error]=\"field.validationSummary\" />\n <error-widget\n *ngIf=\"isInvalidFieldRequired() && isTouched()\"\n required=\"{{ 'FORM.FIELD.REQUIRED' | translate }}\"\n />\n </div>\n </div>\n</div>\n", styles: [".adf-amount-widget{width:100%}.adf-amount-widget .adf-left-label{line-height:36px}.adf-amount-widget-container{display:grid;align-items:flex-start}.adf-amount-widget__input .mat-focused{transition:none}.adf-amount-widget__input .adf-input{margin-top:3px}.adf-amount-widget__input:not(.mat-focused):not(.mat-form-field-invalid) .adf-amount-widget__prefix-spacing{color:var(--adf-theme-foreground-secondary-text-color)}\n"] }]
|
|
22768
22860
|
}], ctorParameters: () => [{ type: FormService }, { type: undefined, decorators: [{
|
|
22861
|
+
type: Optional
|
|
22862
|
+
}, {
|
|
22769
22863
|
type: Inject,
|
|
22770
22864
|
args: [ADF_AMOUNT_SETTINGS]
|
|
22771
|
-
}, {
|
|
22772
|
-
type: Optional
|
|
22773
|
-
}] }] });
|
|
22865
|
+
}] }, { type: i1.CurrencyPipe }, { type: TranslationService }] });
|
|
22774
22866
|
|
|
22775
22867
|
/*!
|
|
22776
22868
|
* @license
|
|
@@ -28524,6 +28616,7 @@ class TranslationMock {
|
|
|
28524
28616
|
get(key) {
|
|
28525
28617
|
return of(key);
|
|
28526
28618
|
}
|
|
28619
|
+
getLocale() { }
|
|
28527
28620
|
instant(key) {
|
|
28528
28621
|
return key;
|
|
28529
28622
|
}
|
|
@@ -30674,6 +30767,7 @@ class NoopTranslationService {
|
|
|
30674
30767
|
get(key) {
|
|
30675
30768
|
return of(key);
|
|
30676
30769
|
}
|
|
30770
|
+
getLocale() { }
|
|
30677
30771
|
instant(key) {
|
|
30678
30772
|
return key;
|
|
30679
30773
|
}
|