@anglr/common 23.0.0 → 24.0.0-beta.20260126065643
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/es2022/forms/src/directives/hasError/hasError.directive.js +2 -2
- package/es2022/forms/src/directives/hasError/hasError.directive.js.map +1 -1
- package/es2022/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js +8 -8
- package/es2022/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js.map +1 -1
- package/es2022/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.js.map +1 -1
- package/es2022/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js +5 -7
- package/es2022/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js.map +1 -1
- package/forms/src/directives/hasError/hasError.directive.d.ts.map +1 -1
- package/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.d.ts +3 -4
- package/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.d.ts.map +1 -1
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.d.ts +4 -5
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.d.ts.map +1 -1
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.d.ts +4 -7
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.d.ts.map +1 -1
- package/package.json +1 -1
- package/version.bak +1 -1
|
@@ -84,7 +84,7 @@ export class HasErrorDirective {
|
|
|
84
84
|
* Called when view was initialized
|
|
85
85
|
*/
|
|
86
86
|
ngAfterViewInit() {
|
|
87
|
-
this.renderer = this.rendererFactory.create(this.
|
|
87
|
+
this.renderer = this.rendererFactory.create(this.containerView, this.injector, this.isSubmittedOrDirty);
|
|
88
88
|
this.updateStatus();
|
|
89
89
|
}
|
|
90
90
|
//######################### public methods - implementation of OnDestroy #########################
|
|
@@ -112,7 +112,7 @@ export class HasErrorDirective {
|
|
|
112
112
|
opts.component = this.errorsComponent;
|
|
113
113
|
}
|
|
114
114
|
this.previousDirty = this.control.dirty;
|
|
115
|
-
this.hasErrors = this.renderer.update(opts, this.errorMessages);
|
|
115
|
+
this.hasErrors = this.renderer.update(opts, this.control.errors, this.errorMessages);
|
|
116
116
|
this.toggleGroupHasError();
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasError.directive.js","sourceRoot":"","sources":["../../../../../forms/src/directives/hasError/hasError.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAqB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAiB,IAAI,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC5J,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAe,OAAO,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAqB,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAC,YAAY,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAC,8BAA8B,EAAC,MAAM,wEAAwE,CAAC;AAEtH,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAC,sBAAsB,EAAC,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAC,6BAA6B,EAAC,MAAM,0CAA0C,CAAC;;;;;;;AAEvF,oEAAoE;AAEpE;;GAEG;AAKH,MAAM,OAAO,iBAAiB;IAwB1B,0EAA0E;IAE1E;;OAEG;IACH,IAAc,OAAO;QAEjB,OAAO,IAAI,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;IAC/F,CAAC;IA6BD,iEAAiE;IACjE,YAAsB,eAA+C,EAC/C,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B,QAAQ;;0BAAI,QAAQ;;0BACpB,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;;0BACR,MAAM;2BAAC,mBAAmB;gEAvBhC,aAAa;sBADnB,KAAK;gBAOC,eAAe;sBADrB,KAAK;gBAOC,cAAc;sBADpB,KAAK;gBA6HI,kBAAkB","sourcesContent":["import {Directive, Optional, SkipSelf, OnInit, OnDestroy, Inject, Input, Injector, ViewContainerRef, AfterViewInit, Type, TemplateRef} from '@angular/core';\nimport {FormControlDirective, FormControlName, FormControl, NgModel, PristineChangeEvent} from '@angular/forms';\nimport {StringLocalization, STRING_LOCALIZATION} from '@anglr/common';\nimport {generateId, BindThis, StringDictionary} from '@jscrpt/common';\nimport {Subscription, filter} from 'rxjs';\n\nimport {ValidationErrorRendererFactory} from '../../services/validationErrorRenderer/validationErrorRenderer.service';\nimport {ValidationErrorRenderer, ValidationErrorsComponent, ValidationErrorsRendererOptions, ValidationErrorsTemplateContext} from '../../services/validationErrorRenderer/validationErrorRenderer.interface';\nimport {SubmittedService} from '../../services/submitted/submitted.service';\nimport {GroupHasErrorDirective} from '../groupHasError/groupHasError.directive';\nimport {ValidationErrorsContainerView} from '../../misc/validationErrorsContainerView';\n\n//TODO: add support for setting renderer factory options using input\n\n/**\n * Directive that is attached to control element and handles css classes that are added to this element\n */\n@Directive(\n{\n selector: '[hasError][formControlName],[hasError][formControl],[hasError][ngModel]',\n})\nexport class HasErrorDirective implements OnInit, AfterViewInit, OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Subscriptions that are destroyed with destruction of this directive\n */\n protected subscriptions: Subscription = new Subscription();\n\n /**\n * Unique generated id of control\n */\n protected id: string = generateId(10);\n\n /**\n * Last value of control pristine attribute\n */\n protected previousDirty: boolean = false;\n\n /**\n * Indication whether currently are any errors rendered\n */\n protected hasErrors: boolean = false;\n\n //######################### protected properties #########################\n\n /**\n * Gets control which was assigned to this element\n */\n protected get control(): FormControl\n {\n return this.formControl?.control || this.formControlName?.control || this.ngModel?.control;\n }\n\n //######################### public properties #########################\n\n /**\n * Instance of validation error renderer\n */\n public renderer: ValidationErrorRenderer;\n\n //######################### public propeties - inputs #########################\n\n /**\n * Customized error messages\n */\n @Input()\n public errorMessages: StringDictionary;\n\n /**\n * Custom component used for rendering validation errors\n */\n @Input()\n public errorsComponent?: Type<ValidationErrorsComponent>;\n\n /**\n * Custom template used for rendering validation errors\n */\n @Input()\n public errorsTemplate?: TemplateRef<ValidationErrorsTemplateContext>;\n\n //######################### constructor #########################\n constructor(protected rendererFactory: ValidationErrorRendererFactory,\n protected viewContainer: ViewContainerRef,\n @Optional() @SkipSelf() protected groupHasError: GroupHasErrorDirective,\n @Optional() protected formControl: FormControlDirective,\n @Optional() protected formControlName: FormControlName,\n @Optional() protected ngModel: NgModel,\n @Optional() protected submittedSvc: SubmittedService,\n @Optional() protected containerView: ValidationErrorsContainerView,\n @Inject(STRING_LOCALIZATION) protected stringLocalization: StringLocalization,\n protected injector: Injector,)\n {\n }\n\n //######################### public methods - implementation of OnInit #########################\n \n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this.containerView ??= new ValidationErrorsContainerView();\n this.containerView.viewContainer ??= this.viewContainer;\n\n this.subscriptions.add(this.stringLocalization.textsChange.subscribe(() => this.updateStatus()));\n this.subscriptions.add(this.control.statusChanges.subscribe(() => this.updateStatus()));\n this.subscriptions.add(this.control\n .events\n .pipe(filter(itm => itm instanceof PristineChangeEvent))\n .subscribe(event =>\n {\n const pristineEvent = event as PristineChangeEvent;\n\n //only if dirty(pristine) is different\n if(pristineEvent.pristine == this.previousDirty)\n {\n this.updateStatus();\n }\n }));\n\n if(this.submittedSvc)\n {\n this.subscriptions.add(this.submittedSvc.submittedChange.subscribe(() => this.isSubmittedOrDirty(() => this.updateStatus())));\n }\n }\n\n //######################### public methods - implementation of AfterViewInit #########################\n \n /**\n * Called when view was initialized\n */\n public ngAfterViewInit(): void\n {\n this.renderer = this.rendererFactory.create(this.control,\n this.containerView,\n this.injector,\n this.isSubmittedOrDirty);\n\n this.updateStatus();\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.subscriptions.unsubscribe();\n\n this.groupHasError?.unregisterControl(this.id);\n this.renderer?.destroy();\n }\n\n //######################### protected methods #########################\n\n /**\n * Updates status of control and css classes\n */\n protected updateStatus(): void\n {\n if(!this.renderer)\n {\n return;\n }\n\n const opts: ValidationErrorsRendererOptions = {};\n\n if(this.errorsTemplate)\n {\n opts.template = this.errorsTemplate;\n }\n else if(this.errorsComponent)\n {\n opts.component = this.errorsComponent;\n }\n\n this.previousDirty = this.control.dirty;\n this.hasErrors = this.renderer.update(opts, this.errorMessages);\n this.toggleGroupHasError();\n }\n\n /**\n * Toggles registration of control in parent group\n */\n protected toggleGroupHasError(): void\n {\n if(this.groupHasError)\n {\n this.isSubmittedOrDirty(() => this.groupHasError.registerControl(this.id),\n () => this.groupHasError.unregisterControl(this.id),\n this.hasErrors);\n }\n }\n\n /**\n * Calls action when form is submitted or control is dirty\n * @param action - Action to be called when form is submitted or control dirty\n * @param falseAction - Action to be called when form is not submitted and control is not dirty\n * @param additionalCondition - Additional condition to be evaluated\n */\n @BindThis\n protected isSubmittedOrDirty(action: () => void, falseAction: () => void = () => {}, additionalCondition: boolean = true): void\n {\n //submitted form or dirty control\n if((this.submittedSvc?.submitted ||\n this.control?.dirty) &&\n additionalCondition)\n {\n action();\n }\n else\n {\n falseAction();\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"hasError.directive.js","sourceRoot":"","sources":["../../../../../forms/src/directives/hasError/hasError.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAqB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAiB,IAAI,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC5J,OAAO,EAAC,oBAAoB,E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ACrB,CAAC;YACG,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EAChD,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EACnD,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;IAED;;;;;OAKG;IAEO,kBAAkB,CAAC,MAAkB,EAAE,cAA0B,GAAG,EAAE,GAAE,CAAC,EAAE,sBAA+B,IAAI;QAEpH,iCAAiC;QACjC,IAAG,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS;YAC5B,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;YACrB,mBAAmB,EACtB,CAAC;YACG,MAAM,EAAE,CAAC;QACb,CAAC;aAED,CAAC;YACG,WAAW,EAAE,CAAC;QAClB,CAAC;IACL,CAAC;8GAnMQ,iBAAiB,6ZAsEN,mBAAmB;kGAtE9B,iBAAiB;;AAsLhB;IADT,QAAQ;;;;2DAcR;2FAnMQ,iBAAiB;kBAJ7B,SAAS;mBACV;oBACI,QAAQ,EAAE,yEAAyE;iBACtF;;0BAiEgB,QAAQ;;0BAAI,QAAQ;;0BACpB,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;;0BACR,MAAM;2BAAC,mBAAmB;gEAvBhC,aAAa;sBADnB,KAAK;gBAOC,eAAe;sBADrB,KAAK;gBAOC,cAAc;sBADpB,KAAK;gBA4HI,kBAAkB","sourcesContent":["import {Directive, Optional, SkipSelf, OnInit, OnDestroy, Inject, Input, Injector, ViewContainerRef, AfterViewInit, Type, TemplateRef} from '@angular/core';\nimport {FormControlDirective, FormControlName, FormControl, NgModel, PristineChangeEvent} from '@angular/forms';\nimport {StringLocalization, STRING_LOCALIZATION} from '@anglr/common';\nimport {generateId, BindThis, StringDictionary} from '@jscrpt/common';\nimport {Subscription, filter} from 'rxjs';\n\nimport {ValidationErrorRendererFactory} from '../../services/validationErrorRenderer/validationErrorRenderer.service';\nimport {ValidationErrorRenderer, ValidationErrorsComponent, ValidationErrorsRendererOptions, ValidationErrorsTemplateContext} from '../../services/validationErrorRenderer/validationErrorRenderer.interface';\nimport {SubmittedService} from '../../services/submitted/submitted.service';\nimport {GroupHasErrorDirective} from '../groupHasError/groupHasError.directive';\nimport {ValidationErrorsContainerView} from '../../misc/validationErrorsContainerView';\n\n//TODO: add support for setting renderer factory options using input\n\n/**\n * Directive that is attached to control element and handles css classes that are added to this element\n */\n@Directive(\n{\n selector: '[hasError][formControlName],[hasError][formControl],[hasError][ngModel]',\n})\nexport class HasErrorDirective implements OnInit, AfterViewInit, OnDestroy\n{\n //######################### protected fields #########################\n\n /**\n * Subscriptions that are destroyed with destruction of this directive\n */\n protected subscriptions: Subscription = new Subscription();\n\n /**\n * Unique generated id of control\n */\n protected id: string = generateId(10);\n\n /**\n * Last value of control pristine attribute\n */\n protected previousDirty: boolean = false;\n\n /**\n * Indication whether currently are any errors rendered\n */\n protected hasErrors: boolean = false;\n\n //######################### protected properties #########################\n\n /**\n * Gets control which was assigned to this element\n */\n protected get control(): FormControl\n {\n return this.formControl?.control || this.formControlName?.control || this.ngModel?.control;\n }\n\n //######################### public properties #########################\n\n /**\n * Instance of validation error renderer\n */\n public renderer: ValidationErrorRenderer;\n\n //######################### public propeties - inputs #########################\n\n /**\n * Customized error messages\n */\n @Input()\n public errorMessages: StringDictionary;\n\n /**\n * Custom component used for rendering validation errors\n */\n @Input()\n public errorsComponent?: Type<ValidationErrorsComponent>;\n\n /**\n * Custom template used for rendering validation errors\n */\n @Input()\n public errorsTemplate?: TemplateRef<ValidationErrorsTemplateContext>;\n\n //######################### constructor #########################\n constructor(protected rendererFactory: ValidationErrorRendererFactory,\n protected viewContainer: ViewContainerRef,\n @Optional() @SkipSelf() protected groupHasError: GroupHasErrorDirective,\n @Optional() protected formControl: FormControlDirective,\n @Optional() protected formControlName: FormControlName,\n @Optional() protected ngModel: NgModel,\n @Optional() protected submittedSvc: SubmittedService,\n @Optional() protected containerView: ValidationErrorsContainerView,\n @Inject(STRING_LOCALIZATION) protected stringLocalization: StringLocalization,\n protected injector: Injector,)\n {\n }\n\n //######################### public methods - implementation of OnInit #########################\n\n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this.containerView ??= new ValidationErrorsContainerView();\n this.containerView.viewContainer ??= this.viewContainer;\n\n this.subscriptions.add(this.stringLocalization.textsChange.subscribe(() => this.updateStatus()));\n this.subscriptions.add(this.control.statusChanges.subscribe(() => this.updateStatus()));\n this.subscriptions.add(this.control\n .events\n .pipe(filter(itm => itm instanceof PristineChangeEvent))\n .subscribe(event =>\n {\n const pristineEvent = event as PristineChangeEvent;\n\n //only if dirty(pristine) is different\n if(pristineEvent.pristine == this.previousDirty)\n {\n this.updateStatus();\n }\n }));\n\n if(this.submittedSvc)\n {\n this.subscriptions.add(this.submittedSvc.submittedChange.subscribe(() => this.isSubmittedOrDirty(() => this.updateStatus())));\n }\n }\n\n //######################### public methods - implementation of AfterViewInit #########################\n\n /**\n * Called when view was initialized\n */\n public ngAfterViewInit(): void\n {\n this.renderer = this.rendererFactory.create(this.containerView,\n this.injector,\n this.isSubmittedOrDirty);\n\n this.updateStatus();\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n\n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.subscriptions.unsubscribe();\n\n this.groupHasError?.unregisterControl(this.id);\n this.renderer?.destroy();\n }\n\n //######################### protected methods #########################\n\n /**\n * Updates status of control and css classes\n */\n protected updateStatus(): void\n {\n if(!this.renderer)\n {\n return;\n }\n\n const opts: ValidationErrorsRendererOptions = {};\n\n if(this.errorsTemplate)\n {\n opts.template = this.errorsTemplate;\n }\n else if(this.errorsComponent)\n {\n opts.component = this.errorsComponent;\n }\n\n this.previousDirty = this.control.dirty;\n this.hasErrors = this.renderer.update(opts, this.control.errors, this.errorMessages);\n this.toggleGroupHasError();\n }\n\n /**\n * Toggles registration of control in parent group\n */\n protected toggleGroupHasError(): void\n {\n if(this.groupHasError)\n {\n this.isSubmittedOrDirty(() => this.groupHasError.registerControl(this.id),\n () => this.groupHasError.unregisterControl(this.id),\n this.hasErrors);\n }\n }\n\n /**\n * Calls action when form is submitted or control is dirty\n * @param action - Action to be called when form is submitted or control dirty\n * @param falseAction - Action to be called when form is not submitted and control is not dirty\n * @param additionalCondition - Additional condition to be evaluated\n */\n @BindThis\n protected isSubmittedOrDirty(action: () => void, falseAction: () => void = () => {}, additionalCondition: boolean = true): void\n {\n //submitted form or dirty control\n if((this.submittedSvc?.submitted ||\n this.control?.dirty) &&\n additionalCondition)\n {\n action();\n }\n else\n {\n falseAction();\n }\n }\n}"]}
|
|
@@ -14,7 +14,7 @@ const defaultErrorMessages = {
|
|
|
14
14
|
minValue: 'Value is too small.',
|
|
15
15
|
maxValue: 'Value is too big.',
|
|
16
16
|
minlength: 'Value is short.',
|
|
17
|
-
maxlength: 'Value is too long.'
|
|
17
|
+
maxlength: 'Value is too long.',
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Service used for extracting error messages from form control
|
|
@@ -29,24 +29,24 @@ export class ErrorMessagesExtractor {
|
|
|
29
29
|
//######################### public methods #########################
|
|
30
30
|
/**
|
|
31
31
|
* Gets validation errors result for provided control, or null of no errors are present
|
|
32
|
-
* @param
|
|
32
|
+
* @param errors - Dictionary containing validation errors
|
|
33
33
|
* @param messages - Object containing error messages that should patch existing error messages
|
|
34
34
|
*/
|
|
35
|
-
getErrors(
|
|
35
|
+
getErrors(errors, messages) {
|
|
36
36
|
const errorMessages = extend(true, {}, this._errorMessages, messages);
|
|
37
37
|
//no control or no errors
|
|
38
|
-
if (!
|
|
38
|
+
if (!errors) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
41
|
const result = {
|
|
42
|
-
errors: Object.keys(
|
|
42
|
+
errors: Object.keys(errors).filter(itm => this._ignoredValidationErrors.indexOf(itm) < 0),
|
|
43
43
|
errorMessages: []
|
|
44
44
|
};
|
|
45
45
|
result.errors.forEach(error => {
|
|
46
|
-
const errorData =
|
|
46
|
+
const errorData = errors[error];
|
|
47
47
|
//error message is present for error
|
|
48
48
|
if (errorMessages[error]) {
|
|
49
|
-
result.errorMessages.push(this._stringLocalization.get(errorMessages[error],
|
|
49
|
+
result.errorMessages.push(this._stringLocalization.get(errorMessages[error], errors));
|
|
50
50
|
}
|
|
51
51
|
//display error data if it is string and there is missing translation
|
|
52
52
|
else if (isString(errorData)) {
|
|
@@ -56,7 +56,7 @@ export class ErrorMessagesExtractor {
|
|
|
56
56
|
else if (Array.isArray(errorData)) {
|
|
57
57
|
errorData.forEach(errorItm => {
|
|
58
58
|
if (isString(errorItm)) {
|
|
59
|
-
result.errorMessages.push(this._stringLocalization.get(errorItm,
|
|
59
|
+
result.errorMessages.push(this._stringLocalization.get(errorItm, errors));
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
}
|
package/es2022/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMessagesExtractor.service.js","sourceRoot":"","sources":["../../../../../forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"errorMessagesExtractor.service.js","sourceRoot":"","sources":["../../../../../forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAqB,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACtE,OAAO,EAA+B,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAC,MAAM,EAAC,MAAM,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AAoC;YACpC,IAAG,aAAa,CAAC,KAAK,CAAC,EACvB,CAAC;gBACG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YAC1F,CAAC;YACD,qEAAqE;iBAChE,IAAG,QAAQ,CAAC,SAAS,CAAC,EAC3B,CAAC;gBACG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzC,CAAC;YACD,0EAA0E;iBACrE,IAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAChC,CAAC;gBACG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBAEzB,IAAG,QAAQ,CAAC,QAAQ,CAAC,EACrB,CAAC;wBACG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;oBAC9E,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAClB,CAAC;8GApEQ,sBAAsB,kBAUX,mBAAmB,aACnB,yBAAyB,aACzB,yBAAyB;kHAZpC,sBAAsB,cADV,MAAM;;2FAClB,sBAAsB;kBADlC,UAAU;mBAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;0BAWf,MAAM;2BAAC,mBAAmB;;0BAC1B,MAAM;2BAAC,yBAAyB;;0BAChC,MAAM;2BAAC,yBAAyB;;0BAAG,QAAQ","sourcesContent":["import {Injectable, Inject, Optional} from '@angular/core';\nimport {StringLocalization, STRING_LOCALIZATION} from '@anglr/common';\nimport {Dictionary, StringDictionary, isString} from '@jscrpt/common';\nimport {extend} from '@jscrpt/common/extend';\n\nimport {IGNORED_VALIDATION_ERRORS, VALIDATION_ERROR_MESSAGES} from '../../misc/tokens';\nimport {ValidationErrorsResult} from './errorMessagesExtractor.interface';\n\n/**\n * Default error messages displayed\n */\nconst defaultErrorMessages: StringDictionary =\n{\n required: 'Field is required.',\n number: 'Value must be number.',\n pattern: 'Value is not valid.',\n minValue: 'Value is too small.',\n maxValue: 'Value is too big.',\n minlength: 'Value is short.',\n maxlength: 'Value is too long.',\n};\n\n/**\n * Service used for extracting error messages from form control\n */\n@Injectable({providedIn: 'root'})\nexport class ErrorMessagesExtractor\n{\n //######################### protected fields #########################\n\n /**\n * Dictionary with error names that have defined message\n */\n protected _errorMessages: StringDictionary;\n\n //######################### constructor #########################\n constructor(@Inject(STRING_LOCALIZATION) protected _stringLocalization: StringLocalization,\n @Inject(IGNORED_VALIDATION_ERRORS) protected _ignoredValidationErrors: string[],\n @Inject(VALIDATION_ERROR_MESSAGES) @Optional() globalErrorMessages?: StringDictionary)\n {\n this._errorMessages = extend(true, {}, defaultErrorMessages, globalErrorMessages);\n }\n\n //######################### public methods #########################\n\n /**\n * Gets validation errors result for provided control, or null of no errors are present\n * @param errors - Dictionary containing validation errors\n * @param messages - Object containing error messages that should patch existing error messages\n */\n public getErrors(errors: Dictionary, messages?: StringDictionary): ValidationErrorsResult\n {\n const errorMessages: StringDictionary = extend(true, {}, this._errorMessages, messages);\n\n //no control or no errors\n if(!errors)\n {\n return null;\n }\n\n const result: ValidationErrorsResult =\n {\n errors: Object.keys(errors).filter(itm => this._ignoredValidationErrors.indexOf(itm) < 0),\n errorMessages: []\n };\n\n result.errors.forEach(error =>\n {\n const errorData = errors[error];\n\n //error message is present for error\n if(errorMessages[error])\n {\n result.errorMessages.push(this._stringLocalization.get(errorMessages[error], errors));\n }\n //display error data if it is string and there is missing translation\n else if(isString(errorData))\n {\n result.errorMessages.push(errorData);\n }\n //error data are array of strings, each string is considered error message\n else if(Array.isArray(errorData))\n {\n errorData.forEach(errorItm =>\n {\n if(isString(errorItm))\n {\n result.errorMessages.push(this._stringLocalization.get(errorItm, errors));\n }\n });\n }\n });\n\n return result;\n }\n}"]}
|
package/es2022/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationErrorRenderer.interface.js","sourceRoot":"","sources":["../../../../../forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {Type, TemplateRef, Injector} from '@angular/core';\nimport {
|
|
1
|
+
{"version":3,"file":"validationErrorRenderer.interface.js","sourceRoot":"","sources":["../../../../../forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {Type, TemplateRef, Injector} from '@angular/core';\nimport {Dictionary, StringDictionary} from '@jscrpt/common';\n\nimport {ErrorMessagesExtractor} from '../errorMessagesExtractor/errorMessagesExtractor.service';\nimport {ValidationErrorsResult} from '../errorMessagesExtractor/errorMessagesExtractor.interface';\nimport {ValidationErrorsContainerView} from '../../misc/validationErrorsContainerView';\n\n/**\n * Describes function that is used for performing actions when form is submitted or dirty\n */\nexport interface IsSubmittedOrDirtyFunc\n{\n /**\n * Calls action when form is submitted or control is dirty\n * @param action - Action to be called when form is submitted or control dirty\n * @param falseAction - Action to be called when form is not submitted and control is not dirty\n * @param additionalCondition - Additional condition to be evaluated\n */\n (action: () => void, falseAction?: () => void, additionalCondition?: boolean): void;\n}\n\n/**\n * Component that is used for rendering validation errors\n */\nexport interface ValidationErrorsComponent\n{\n /**\n * Shows validation errors in component\n * @param errors - Errors to be shown\n * @param options - Options used for displaying validation errors\n */\n show(errors: ValidationErrorsResult, options: ValidationErrorsOptions): void;\n}\n\n/**\n * Context passed to template that is used for rendering validation errors\n */\nexport interface ValidationErrorsTemplateContext\n{\n /**\n * Errors to be shown\n */\n $implicit: ValidationErrorsResult;\n\n /**\n * Options used for displaying validation errors\n */\n options: ValidationErrorsOptions;\n}\n\n/**\n * Component that is used for rendering validation errors container\n */\nexport interface ValidationErrorsContainerComponent\n{\n /**\n * Shows validation errors\n * @param errors - Errors to be shown\n * @param options - Options used for displaying validation errors\n */\n show(errors: ValidationErrorsResult, options: ValidationErrorsContainerOptions): void;\n\n /**\n * Hides validation errors\n */\n hide(): void;\n}\n\n/**\n * Options for displayed validation errors\n */\nexport interface ValidationErrorsOptions\n{\n /**\n * Prefix of css classes applied to element\n */\n prefix?: string;\n\n /**\n * Suffix of css classes applied to element\n */\n suffix?: string;\n\n /**\n * Css class attached to wrapper div\n */\n wrapperDivClass?: string;\n}\n\n/**\n * Options for validation errors container\n */\nexport interface ValidationErrorsContainerOptions extends ValidationErrorsOptions\n{\n /**\n * Component used for rendering validation errors\n */\n component?: Type<ValidationErrorsComponent>;\n\n /**\n * Template used for rendering validation errors\n */\n template?: TemplateRef<ValidationErrorsTemplateContext>;\n}\n\n/**\n * Options for ValidationErrorRenderer\n */\nexport interface ValidationErrorsRendererOptions extends ValidationErrorsContainerOptions\n{\n /**\n * Component used for rendering validation errors container\n */\n container?: Type<ValidationErrorsContainerComponent>;\n}\n\n/**\n * Options for ValidationErrorRendererFactory\n */\nexport interface ValidationErrorRendererFactoryOptions extends ValidationErrorsRendererOptions\n{\n /**\n * Type of ValidationErrorRenderer implementation\n */\n rendererType?: ValidationErrorRendererCtor;\n}\n\n/**\n * Describes type that represents ValidationErrorRenderer\n */\nexport interface ValidationErrorRendererCtor\n{\n /**\n * Creates instance of ValidationErrorRenderer\n * @param errorMessagesExtractor - Instance of service used for extracting errors from control\n * @param containerView - Class that stores view container for rendering errors\n * @param injector - Injector used for obtaining dependencies\n * @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty\n * @param options - Options for validation errors renderer\n */\n new(errorMessagesExtractor: ErrorMessagesExtractor,\n containerView: ValidationErrorsContainerView,\n injector: Injector,\n isSubmittedOrDirty: IsSubmittedOrDirtyFunc,\n options: ValidationErrorsRendererOptions): ValidationErrorRenderer;\n}\n\n/**\n * Describes service that is used for rendering validation errors\n */\nexport interface ValidationErrorRenderer\n{\n /**\n * Destroys renderer and everything that was rendered\n */\n destroy(): void;\n\n /**\n * Updates rendered errors for current state and returns true if errors were rendered, otherwise false\n * @param options - Options for validation errors renderer\n * @param errors - Dictionary containing validation errors\n * @param errorMessages - Object storing error messages to be used as override\n */\n update(options: ValidationErrorsRendererOptions, errors: Dictionary, errorMessages?: StringDictionary): boolean;\n}\n"]}
|
package/es2022/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js
CHANGED
|
@@ -17,13 +17,12 @@ export class ValidationErrorRendererFactory {
|
|
|
17
17
|
//######################### public methods #########################
|
|
18
18
|
/**
|
|
19
19
|
* Creates new instance of ValidationErrorRenderer
|
|
20
|
-
* @param control - Control that is being processed for errors
|
|
21
20
|
* @param containerView - Class that stores view container for rendering errors
|
|
22
21
|
* @param injector - Injector for obtaining dependencies
|
|
23
22
|
* @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty
|
|
24
23
|
*/
|
|
25
|
-
create(
|
|
26
|
-
return new this._options.rendererType(this._errorMessagesExtractor,
|
|
24
|
+
create(containerView, injector, isSubmittedOrDirty) {
|
|
25
|
+
return new this._options.rendererType(this._errorMessagesExtractor, containerView, injector, isSubmittedOrDirty, this._options);
|
|
27
26
|
}
|
|
28
27
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: ValidationErrorRendererFactory, deps: [{ token: i1.ErrorMessagesExtractor }, { token: VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
29
28
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.2", ngImport: i0, type: ValidationErrorRendererFactory, providedIn: 'root' }); }
|
|
@@ -42,9 +41,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.2", ngImpor
|
|
|
42
41
|
*/
|
|
43
42
|
export class DefaultValidationErrorRenderer {
|
|
44
43
|
//######################### constructor #########################
|
|
45
|
-
constructor(_errorMessagesExtractor,
|
|
44
|
+
constructor(_errorMessagesExtractor, _containerView, _injector, _isSubmittedOrDirty, _options) {
|
|
46
45
|
this._errorMessagesExtractor = _errorMessagesExtractor;
|
|
47
|
-
this._control = _control;
|
|
48
46
|
this._containerView = _containerView;
|
|
49
47
|
this._injector = _injector;
|
|
50
48
|
this._isSubmittedOrDirty = _isSubmittedOrDirty;
|
|
@@ -62,9 +60,9 @@ export class DefaultValidationErrorRenderer {
|
|
|
62
60
|
/**
|
|
63
61
|
* @inheritdoc
|
|
64
62
|
*/
|
|
65
|
-
update(options, errorMessages) {
|
|
63
|
+
update(options, errors, errorMessages) {
|
|
66
64
|
let result = false;
|
|
67
|
-
this._lastErrors = this._errorMessagesExtractor.getErrors(
|
|
65
|
+
this._lastErrors = this._errorMessagesExtractor.getErrors(errors, errorMessages);
|
|
68
66
|
//has errors
|
|
69
67
|
if (this._lastErrors) {
|
|
70
68
|
this._isSubmittedOrDirty(() => {
|
package/es2022/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationErrorRenderer.service.js","sourceRoot":"","sources":["../../../../../forms/src/services/validationErrorRenderer/validationErrorRenderer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAyB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"validationErrorRenderer.service.js","sourceRoot":"","sources":["../../../../../forms/src/services/validationErrorRenderer/validationErrorRenderer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAEnF,OAAO,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAC,sBAAsB,EAAC,MAAM,0DAA0D,CAAC;AAGhG,OAAO,EAAC,yCAAyC,EAAC,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAC,gCAAgC,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,YAAY,EAAE,8BAA8B;IAC5C,SAAS,EAAE,gCAAgC;IAC3C,SAAS,EAAE,yCAAyC;CACvD,CAAC","sourcesContent":["import {Injectable, Inject, Optional, Injector, ComponentRef} from '@angular/core';\nimport {Dictionary, StringDictionary} from '@jscrpt/common';\nimport {extend} from '@jscrpt/common/extend';\n\nimport {ErrorMessagesExtractor} from '../errorMessagesExtractor/errorMessagesExtractor.service';\nimport {ValidationErrorRenderer, IsSubmittedOrDirtyFunc, ValidationErrorsRendererOptions, ValidationErrorRendererFactoryOptions, ValidationErrorsContainerComponent} from './validationErrorRenderer.interface';\nimport {ValidationErrorsResult} from '../errorMessagesExtractor/errorMessagesExtractor.interface';\nimport {VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS} from '../../misc/tokens';\nimport {ValidationErrorsContainerView} from '../../misc/validationErrorsContainerView';\nimport {DefaultValidationErrorsComponent, DefaultValidationErrorsContainerComponent} from '../../components';\n\n/**\n * Service used for creating validation errors renderer\n */\n@Injectable({providedIn: 'root'})\nexport class ValidationErrorRendererFactory\n{\n //######################### protected fields #########################\n\n /**\n * Options for validation error renderer factory\n */\n protected _options: ValidationErrorRendererFactoryOptions;\n\n //######################### constructor #########################\n constructor(protected _errorMessagesExtractor: ErrorMessagesExtractor,\n @Optional() @Inject(VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS) options: ValidationErrorRendererFactoryOptions)\n {\n this._options = extend(true, {}, DEFAULT_OPTIONS, options);\n }\n\n //######################### public methods #########################\n\n /**\n * Creates new instance of ValidationErrorRenderer\n * @param containerView - Class that stores view container for rendering errors\n * @param injector - Injector for obtaining dependencies\n * @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty\n */\n public create(containerView: ValidationErrorsContainerView,\n injector: Injector,\n isSubmittedOrDirty: IsSubmittedOrDirtyFunc): ValidationErrorRenderer\n {\n return new this._options.rendererType(this._errorMessagesExtractor,\n containerView,\n injector,\n isSubmittedOrDirty,\n this._options);\n }\n}\n\n/**\n * Default implementation of validation error renderer\n */\nexport class DefaultValidationErrorRenderer implements ValidationErrorRenderer\n{\n //######################### protected fields #########################\n\n /**\n * Object storing last obtained errors\n */\n protected _lastErrors: ValidationErrorsResult;\n\n /**\n * Component used as validation errors container\n */\n protected _container: ComponentRef<ValidationErrorsContainerComponent>;\n\n //######################### constructor #########################\n constructor(protected _errorMessagesExtractor: ErrorMessagesExtractor,\n protected _containerView: ValidationErrorsContainerView,\n protected _injector: Injector,\n protected _isSubmittedOrDirty: IsSubmittedOrDirtyFunc,\n protected _options: ValidationErrorsRendererOptions)\n {\n this._initialize();\n }\n\n //######################### public methods - implementation of ValiDationErrorRenderer #########################\n\n /**\n * @inheritdoc\n */\n public destroy(): void\n {\n this._containerView.viewContainer.clear();\n this._container = null;\n }\n\n /**\n * @inheritdoc\n */\n public update(options: ValidationErrorsRendererOptions, errors: Dictionary, errorMessages?: StringDictionary): boolean\n {\n let result = false;\n this._lastErrors = this._errorMessagesExtractor.getErrors(errors, errorMessages);\n\n //has errors\n if(this._lastErrors)\n {\n this._isSubmittedOrDirty(() =>\n {\n // const errorsClasses = this._lastErrors.errors.map(error => `${this._options.prefix}${error.toLowerCase()}${this._options.suffix}`);\n const opts = extend(true, {}, this._options, options);\n\n this._container.instance.show(this._lastErrors, opts);\n result = true;\n },\n () =>\n {\n this._container.instance.hide();\n result = false;\n });\n }\n else\n {\n this._container.instance.hide();\n result = false;\n }\n\n return result;\n }\n\n /**\n * Initialize renderer\n */\n protected _initialize(): void\n {\n this._container = this._containerView.viewContainer.createComponent(this._options.container, {injector: this._injector});\n this._container.instance.hide();\n }\n}\n\n/**\n * Default options for validation error renderer factory\n */\nconst DEFAULT_OPTIONS: ValidationErrorRendererFactoryOptions =\n{\n prefix: 'ng-',\n suffix: '-error',\n wrapperDivClass: 'validation-error-div',\n rendererType: DefaultValidationErrorRenderer,\n component: DefaultValidationErrorsComponent,\n container: DefaultValidationErrorsContainerComponent,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
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CAAC,yBAAyB,CAAC,CAAC;IAEzD;;OAEG;IAEI,cAAc,CAAC,EAAE,WAAW,CAAC,+BAA+B,CAAC,CAAC;gBAG/C,eAAe,EAAE,8BAA8B,EAC/C,aAAa,EAAE,gBAAgB,EACP,aAAa,EAAE,sBAAsB,EACjD,WAAW,EAAE,oBAAoB,EACjC,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,6BAA6B,EAC3B,kBAAkB,EAAE,kBAAkB,EACnE,QAAQ,EAAE,QAAQ;IAMxC;;OAEG;IACI,QAAQ,IAAI,IAAI;IA6BvB;;OAEG;IACI,eAAe,IAAI,IAAI;IAW9B;;OAEG;IACI,WAAW,IAAI,IAAI;IAU1B;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAuB9B;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAUrC;;;;;OAKG;IAEH,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,WAAW,GAAE,MAAM,IAAe,EAAE,mBAAmB,GAAE,OAAc,GAAG,IAAI;yCAtLtH,iBAAiB;2CAAjB,iBAAiB;CAoM7B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FormControl } from '@angular/forms';
|
|
2
1
|
import { StringLocalization } from '@anglr/common';
|
|
3
|
-
import { StringDictionary } from '@jscrpt/common';
|
|
2
|
+
import { Dictionary, StringDictionary } from '@jscrpt/common';
|
|
4
3
|
import { ValidationErrorsResult } from './errorMessagesExtractor.interface';
|
|
5
4
|
import * as i0 from "@angular/core";
|
|
6
5
|
/**
|
|
@@ -16,10 +15,10 @@ export declare class ErrorMessagesExtractor {
|
|
|
16
15
|
constructor(_stringLocalization: StringLocalization, _ignoredValidationErrors: string[], globalErrorMessages?: StringDictionary);
|
|
17
16
|
/**
|
|
18
17
|
* Gets validation errors result for provided control, or null of no errors are present
|
|
19
|
-
* @param
|
|
18
|
+
* @param errors - Dictionary containing validation errors
|
|
20
19
|
* @param messages - Object containing error messages that should patch existing error messages
|
|
21
20
|
*/
|
|
22
|
-
getErrors(
|
|
21
|
+
getErrors(errors: Dictionary, messages?: StringDictionary): ValidationErrorsResult;
|
|
23
22
|
static ɵfac: i0.ɵɵFactoryDeclaration<ErrorMessagesExtractor, [null, null, { optional: true; }]>;
|
|
24
23
|
static ɵprov: i0.ɵɵInjectableDeclaration<ErrorMessagesExtractor>;
|
|
25
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMessagesExtractor.service.d.ts","sourceRoot":"","sources":["errorMessagesExtractor.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"errorMessagesExtractor.service.d.ts","sourceRoot":"","sources":["errorMessagesExtractor.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAsB,MAAM,eAAe,CAAC;AACtE,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAW,MAAM,gBAAgB,CAAC;AAItE,OAAO,EAAC,sBAAsB,EAAC,MAAM,oCAAoC,CAAC;;AAgB1E;;GAEG;AACH,qBACa,sBAAsB;IAUU,SAAS,CAAC,mBAAmB,EAAE,kBAAkB;IAC3C,SAAS,CAAC,wBAAwB,EAAE,MAAM,EAAE;IAP3F;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC;gBAGQ,mBAAmB,EAAE,kBAAkB,EACjC,wBAAwB,EAAE,MAAM,EAAE,EAChC,mBAAmB,CAAC,EAAE,gBAAgB;IAOjG;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,gBAAgB,GAAG,sBAAsB;yCAxBhF,sBAAsB;6CAAtB,sBAAsB;CAqElC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Type, TemplateRef, Injector } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { StringDictionary } from '@jscrpt/common';
|
|
2
|
+
import { Dictionary, StringDictionary } from '@jscrpt/common';
|
|
4
3
|
import { ErrorMessagesExtractor } from '../errorMessagesExtractor/errorMessagesExtractor.service';
|
|
5
4
|
import { ValidationErrorsResult } from '../errorMessagesExtractor/errorMessagesExtractor.interface';
|
|
6
5
|
import { ValidationErrorsContainerView } from '../../misc/validationErrorsContainerView';
|
|
@@ -110,13 +109,12 @@ export interface ValidationErrorRendererCtor {
|
|
|
110
109
|
/**
|
|
111
110
|
* Creates instance of ValidationErrorRenderer
|
|
112
111
|
* @param errorMessagesExtractor - Instance of service used for extracting errors from control
|
|
113
|
-
* @param control - Control that is being processed for errors
|
|
114
112
|
* @param containerView - Class that stores view container for rendering errors
|
|
115
113
|
* @param injector - Injector used for obtaining dependencies
|
|
116
114
|
* @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty
|
|
117
115
|
* @param options - Options for validation errors renderer
|
|
118
116
|
*/
|
|
119
|
-
new (errorMessagesExtractor: ErrorMessagesExtractor,
|
|
117
|
+
new (errorMessagesExtractor: ErrorMessagesExtractor, containerView: ValidationErrorsContainerView, injector: Injector, isSubmittedOrDirty: IsSubmittedOrDirtyFunc, options: ValidationErrorsRendererOptions): ValidationErrorRenderer;
|
|
120
118
|
}
|
|
121
119
|
/**
|
|
122
120
|
* Describes service that is used for rendering validation errors
|
|
@@ -129,8 +127,9 @@ export interface ValidationErrorRenderer {
|
|
|
129
127
|
/**
|
|
130
128
|
* Updates rendered errors for current state and returns true if errors were rendered, otherwise false
|
|
131
129
|
* @param options - Options for validation errors renderer
|
|
130
|
+
* @param errors - Dictionary containing validation errors
|
|
132
131
|
* @param errorMessages - Object storing error messages to be used as override
|
|
133
132
|
*/
|
|
134
|
-
update(options: ValidationErrorsRendererOptions, errorMessages?: StringDictionary): boolean;
|
|
133
|
+
update(options: ValidationErrorsRendererOptions, errors: Dictionary, errorMessages?: StringDictionary): boolean;
|
|
135
134
|
}
|
|
136
135
|
//# sourceMappingURL=validationErrorRenderer.interface.d.ts.map
|
package/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationErrorRenderer.interface.d.ts","sourceRoot":"","sources":["validationErrorRenderer.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"validationErrorRenderer.interface.d.ts","sourceRoot":"","sources":["validationErrorRenderer.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAC,sBAAsB,EAAC,MAAM,4DAA4D,CAAC;AAClG,OAAO,EAAC,6BAA6B,EAAC,MAAM,0CAA0C,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IAEnC;;;;;OAKG;IACH,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,IAAI,EAAE,mBAAmB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACvF;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAEtC;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAChF;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAE5C;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;IAElC;;OAEG;IACH,OAAO,EAAE,uBAAuB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,kCAAkC;IAE/C;;;;OAIG;IACH,IAAI,CAAC,MA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import { Injector, ComponentRef } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { StringDictionary } from '@jscrpt/common';
|
|
2
|
+
import { Dictionary, StringDictionary } from '@jscrpt/common';
|
|
4
3
|
import { ErrorMessagesExtractor } from '../errorMessagesExtractor/errorMessagesExtractor.service';
|
|
5
4
|
import { ValidationErrorRenderer, IsSubmittedOrDirtyFunc, ValidationErrorsRendererOptions, ValidationErrorRendererFactoryOptions, ValidationErrorsContainerComponent } from './validationErrorRenderer.interface';
|
|
6
5
|
import { ValidationErrorsResult } from '../errorMessagesExtractor/errorMessagesExtractor.interface';
|
|
@@ -18,12 +17,11 @@ export declare class ValidationErrorRendererFactory {
|
|
|
18
17
|
constructor(_errorMessagesExtractor: ErrorMessagesExtractor, options: ValidationErrorRendererFactoryOptions);
|
|
19
18
|
/**
|
|
20
19
|
* Creates new instance of ValidationErrorRenderer
|
|
21
|
-
* @param control - Control that is being processed for errors
|
|
22
20
|
* @param containerView - Class that stores view container for rendering errors
|
|
23
21
|
* @param injector - Injector for obtaining dependencies
|
|
24
22
|
* @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty
|
|
25
23
|
*/
|
|
26
|
-
create(
|
|
24
|
+
create(containerView: ValidationErrorsContainerView, injector: Injector, isSubmittedOrDirty: IsSubmittedOrDirtyFunc): ValidationErrorRenderer;
|
|
27
25
|
static ɵfac: i0.ɵɵFactoryDeclaration<ValidationErrorRendererFactory, [null, { optional: true; }]>;
|
|
28
26
|
static ɵprov: i0.ɵɵInjectableDeclaration<ValidationErrorRendererFactory>;
|
|
29
27
|
}
|
|
@@ -32,7 +30,6 @@ export declare class ValidationErrorRendererFactory {
|
|
|
32
30
|
*/
|
|
33
31
|
export declare class DefaultValidationErrorRenderer implements ValidationErrorRenderer {
|
|
34
32
|
protected _errorMessagesExtractor: ErrorMessagesExtractor;
|
|
35
|
-
protected _control: FormControl;
|
|
36
33
|
protected _containerView: ValidationErrorsContainerView;
|
|
37
34
|
protected _injector: Injector;
|
|
38
35
|
protected _isSubmittedOrDirty: IsSubmittedOrDirtyFunc;
|
|
@@ -45,7 +42,7 @@ export declare class DefaultValidationErrorRenderer implements ValidationErrorRe
|
|
|
45
42
|
* Component used as validation errors container
|
|
46
43
|
*/
|
|
47
44
|
protected _container: ComponentRef<ValidationErrorsContainerComponent>;
|
|
48
|
-
constructor(_errorMessagesExtractor: ErrorMessagesExtractor,
|
|
45
|
+
constructor(_errorMessagesExtractor: ErrorMessagesExtractor, _containerView: ValidationErrorsContainerView, _injector: Injector, _isSubmittedOrDirty: IsSubmittedOrDirtyFunc, _options: ValidationErrorsRendererOptions);
|
|
49
46
|
/**
|
|
50
47
|
* @inheritdoc
|
|
51
48
|
*/
|
|
@@ -53,7 +50,7 @@ export declare class DefaultValidationErrorRenderer implements ValidationErrorRe
|
|
|
53
50
|
/**
|
|
54
51
|
* @inheritdoc
|
|
55
52
|
*/
|
|
56
|
-
update(options: ValidationErrorsRendererOptions, errorMessages?: StringDictionary): boolean;
|
|
53
|
+
update(options: ValidationErrorsRendererOptions, errors: Dictionary, errorMessages?: StringDictionary): boolean;
|
|
57
54
|
/**
|
|
58
55
|
* Initialize renderer
|
|
59
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationErrorRenderer.service.d.ts","sourceRoot":"","sources":["validationErrorRenderer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,QAAQ,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"validationErrorRenderer.service.d.ts","sourceRoot":"","sources":["validationErrorRenderer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,QAAQ,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAC,uBAAu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