@anglr/common 12.0.0-beta.20220413104159 → 12.0.0-beta.20220414093434
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/changelog.md +50 -2
- package/es2015/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.js +53 -0
- package/es2015/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.js.map +1 -0
- package/es2015/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.js +75 -0
- package/es2015/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.js.map +1 -0
- package/es2015/forms/src/components/index.js +3 -0
- package/es2015/forms/src/components/index.js.map +1 -0
- package/es2015/forms/src/directives/hasError/hasError.directive.js +16 -6
- package/es2015/forms/src/directives/hasError/hasError.directive.js.map +1 -1
- package/es2015/forms/src/index.js +3 -1
- package/es2015/forms/src/index.js.map +1 -1
- package/es2015/forms/src/misc/formModel/interfaces/modelDecoratorMetadata.js.map +1 -1
- package/es2015/forms/src/misc/formModel/misc/utils.js +11 -8
- package/es2015/forms/src/misc/formModel/misc/utils.js.map +1 -1
- package/es2015/forms/src/misc/tokens.js +14 -0
- package/es2015/forms/src/misc/tokens.js.map +1 -0
- package/es2015/forms/src/misc/validationErrorsContainerView.js +31 -0
- package/es2015/forms/src/misc/validationErrorsContainerView.js.map +1 -0
- package/es2015/forms/src/modules/errorMessage/directives/errorMessage/errorMessage.directive.js +1 -1
- package/es2015/forms/src/modules/errorMessage/directives/errorMessage/errorMessage.directive.js.map +1 -1
- package/es2015/forms/src/modules/errorMessage/pipes/withErrorMessage/withErrorMessage.pipe.js +1 -1
- package/es2015/forms/src/modules/errorMessage/pipes/withErrorMessage/withErrorMessage.pipe.js.map +1 -1
- package/es2015/forms/src/modules/hasError.module.js +15 -4
- package/es2015/forms/src/modules/hasError.module.js.map +1 -1
- package/es2015/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js +18 -9
- package/es2015/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js.map +1 -1
- package/es2015/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.js.map +1 -1
- package/es2015/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js +31 -145
- package/es2015/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js.map +1 -1
- package/es2020/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.js +53 -0
- package/es2020/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.js.map +1 -0
- package/es2020/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.js +75 -0
- package/es2020/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.js.map +1 -0
- package/es2020/forms/src/components/index.js +3 -0
- package/es2020/forms/src/components/index.js.map +1 -0
- package/es2020/forms/src/directives/hasError/hasError.directive.js +15 -6
- package/es2020/forms/src/directives/hasError/hasError.directive.js.map +1 -1
- package/es2020/forms/src/index.js +3 -1
- package/es2020/forms/src/index.js.map +1 -1
- package/es2020/forms/src/misc/formModel/interfaces/modelDecoratorMetadata.js.map +1 -1
- package/es2020/forms/src/misc/formModel/misc/utils.js +8 -5
- package/es2020/forms/src/misc/formModel/misc/utils.js.map +1 -1
- package/es2020/forms/src/misc/tokens.js +14 -0
- package/es2020/forms/src/misc/tokens.js.map +1 -0
- package/es2020/forms/src/misc/validationErrorsContainerView.js +31 -0
- package/es2020/forms/src/misc/validationErrorsContainerView.js.map +1 -0
- package/es2020/forms/src/modules/errorMessage/directives/errorMessage/errorMessage.directive.js +1 -1
- package/es2020/forms/src/modules/errorMessage/directives/errorMessage/errorMessage.directive.js.map +1 -1
- package/es2020/forms/src/modules/errorMessage/pipes/withErrorMessage/withErrorMessage.pipe.js +1 -1
- package/es2020/forms/src/modules/errorMessage/pipes/withErrorMessage/withErrorMessage.pipe.js.map +1 -1
- package/es2020/forms/src/modules/hasError.module.js +15 -4
- package/es2020/forms/src/modules/hasError.module.js.map +1 -1
- package/es2020/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js +18 -9
- package/es2020/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.js.map +1 -1
- package/es2020/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.js.map +1 -1
- package/es2020/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js +31 -143
- package/es2020/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js.map +1 -1
- package/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.css +4 -0
- package/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.d.ts +32 -0
- package/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.d.ts.map +1 -0
- package/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.html +3 -0
- package/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.css +4 -0
- package/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.d.ts +51 -0
- package/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.d.ts.map +1 -0
- package/forms/src/components/defaultValidationErrorsContainer/defaultValidationErrorsContainer.component.html +0 -0
- package/forms/src/components/index.d.ts +3 -0
- package/forms/src/components/index.d.ts.map +1 -0
- package/forms/src/directives/hasError/hasError.directive.d.ts +6 -3
- package/forms/src/directives/hasError/hasError.directive.d.ts.map +1 -1
- package/forms/src/index.d.ts +3 -1
- package/forms/src/index.d.ts.map +1 -1
- package/forms/src/misc/formModel/interfaces/modelDecoratorMetadata.d.ts +6 -1
- package/forms/src/misc/formModel/interfaces/modelDecoratorMetadata.d.ts.map +1 -1
- package/forms/src/misc/formModel/misc/utils.d.ts.map +1 -1
- package/forms/src/misc/tokens.d.ts +16 -0
- package/forms/src/misc/tokens.d.ts.map +1 -0
- package/forms/src/misc/validationErrorsContainerView.d.ts +25 -0
- package/forms/src/misc/validationErrorsContainerView.d.ts.map +1 -0
- package/forms/src/modules/hasError.module.d.ts +4 -1
- package/forms/src/modules/hasError.module.d.ts.map +1 -1
- package/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.d.ts +4 -7
- package/forms/src/services/errorMessagesExtractor/errorMessagesExtractor.service.d.ts.map +1 -1
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.d.ts +43 -12
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.interface.d.ts.map +1 -1
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.d.ts +15 -63
- package/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.d.ts.map +1 -1
- package/package.json +1 -1
- package/version.bak +1 -1
- package/es2015/forms/src/misc/types.js +0 -6
- package/es2015/forms/src/misc/types.js.map +0 -1
- package/es2020/forms/src/misc/types.js +0 -6
- package/es2020/forms/src/misc/types.js.map +0 -1
- package/forms/src/misc/types.d.ts +0 -7
- package/forms/src/misc/types.d.ts.map +0 -1
package/es2020/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,
|
|
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;AAE3D,OAAO,EAAqB,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACtE,OAAO,EAAmB,MAAM,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAC,yBAAyB,EAAE,yBAAyB,EAAC,MAAM,mBAAmB,CAAC;;AAGvF;;GAEG;AACH,MAAM,oBAAoB,GAC1B;IACI,QAAQ,EAAE,oBAAoB;IAC9B,MAAM,EAAE,u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AAa,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;aACjG;YACD,qEAAqE;iBAChE,IAAG,QAAQ,CAAC,SAAS,CAAC,EAC3B;gBACI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACxC;YACD,0EAA0E;iBACrE,IAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAChC;gBACI,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBAEzB,IAAG,QAAQ,CAAC,QAAQ,CAAC,EACrB;wBACI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;qBACrF;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAClB,CAAC;;mHApEQ,sBAAsB,kBAUX,mBAAmB,aACnB,yBAAyB,aACzB,yBAAyB;uHAZpC,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 {FormControl} from '@angular/forms';\nimport {StringLocalization, STRING_LOCALIZATION} from '@anglr/common';\nimport {StringDictionary, extend, isString} from '@jscrpt/common';\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 control - Form control instance that should be inspected for errors\n * @param messages - Object containing error messages that should patch existing error messages\n */\n public getErrors(control: FormControl, messages?: StringDictionary): ValidationErrorsResult\n {\n const errorMessages: StringDictionary = extend(true, {}, this._errorMessages, messages);\n\n //no control or no errors\n if(!control || !control.errors)\n {\n return null;\n }\n\n const result: ValidationErrorsResult =\n {\n errors: Object.keys(control.errors).filter(itm => this._ignoredValidationErrors.indexOf(itm) < 0),\n errorMessages: []\n };\n\n result.errors.forEach(error =>\n {\n const errorData = control.errors[error];\n \n //error message is present for error\n if(errorMessages[error])\n {\n result.errorMessages.push(this._stringLocalization.get(errorMessages[error], control.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, control.errors));\n }\n });\n }\n });\n\n return result;\n }\n}"]}
|
package/es2020/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 {FormControl} from '@angular/forms';\nimport {StringDictionary} from '@jscrpt/common';\n\nimport {ErrorMessagesExtractor} from '../errorMessagesExtractor/errorMessagesExtractor.service';\nimport {ValidationErrorsResult} from '../errorMessagesExtractor/errorMessagesExtractor.interface';\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
|
|
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 {FormControl} from '@angular/forms';\nimport {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 control - Control that is being processed for errors\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 control: FormControl,\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 errorMessages - Object storing error messages to be used as override\n */\n update(options: ValidationErrorsRendererOptions, errorMessages?: StringDictionary): boolean;\n}"]}
|
package/es2020/forms/src/services/validationErrorRenderer/validationErrorRenderer.service.js
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
|
-
import { Injectable, Inject,
|
|
2
|
-
import { DOCUMENT } from '@angular/common';
|
|
1
|
+
import { Injectable, Inject, Optional } from '@angular/core';
|
|
3
2
|
import { extend } from '@jscrpt/common';
|
|
4
3
|
import { ErrorMessagesExtractor } from '../errorMessagesExtractor/errorMessagesExtractor.service';
|
|
4
|
+
import { VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS } from '../../misc/tokens';
|
|
5
|
+
import { DefaultValidationErrorsComponent, DefaultValidationErrorsContainerComponent } from '../../components';
|
|
5
6
|
import * as i0 from "@angular/core";
|
|
6
7
|
import * as i1 from "../errorMessagesExtractor/errorMessagesExtractor.service";
|
|
7
|
-
/**
|
|
8
|
-
* Injection token used for injecting global options for ValidationErrorRendererFactory
|
|
9
|
-
*/
|
|
10
|
-
export const VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS = new InjectionToken('VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS');
|
|
11
|
-
//TODO: div renderer as custom component, wrapper div renderer
|
|
12
8
|
/**
|
|
13
9
|
* Service used for creating validation errors renderer
|
|
14
10
|
*/
|
|
15
11
|
export class ValidationErrorRendererFactory {
|
|
16
12
|
//######################### constructor #########################
|
|
17
|
-
constructor(_errorMessagesExtractor,
|
|
13
|
+
constructor(_errorMessagesExtractor, options) {
|
|
18
14
|
this._errorMessagesExtractor = _errorMessagesExtractor;
|
|
19
|
-
this._document = _document;
|
|
20
15
|
this._options = extend(true, {}, DEFAULT_OPTIONS, options);
|
|
21
16
|
}
|
|
22
17
|
//######################### public methods #########################
|
|
23
18
|
/**
|
|
24
19
|
* Creates new instance of ValidationErrorRenderer
|
|
25
20
|
* @param control - Control that is being processed for errors
|
|
26
|
-
* @param
|
|
21
|
+
* @param containerView - Class that stores view container for rendering errors
|
|
22
|
+
* @param injector - Injector for obtaining dependencies
|
|
27
23
|
* @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty
|
|
28
|
-
* @param options - Options for validation errors renderer factory
|
|
29
24
|
*/
|
|
30
|
-
create(control,
|
|
31
|
-
|
|
32
|
-
return new opts.rendererType(this._errorMessagesExtractor, control, controlElement, this._document, injector, isSubmittedOrDirty, opts);
|
|
25
|
+
create(control, containerView, injector, isSubmittedOrDirty) {
|
|
26
|
+
return new this._options.rendererType(this._errorMessagesExtractor, control, containerView, injector, isSubmittedOrDirty, this._options);
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
|
-
ValidationErrorRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ValidationErrorRendererFactory, deps: [{ token: i1.ErrorMessagesExtractor }, { token:
|
|
29
|
+
ValidationErrorRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ValidationErrorRendererFactory, deps: [{ token: i1.ErrorMessagesExtractor }, { token: VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
36
30
|
ValidationErrorRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ValidationErrorRendererFactory, providedIn: 'root' });
|
|
37
31
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ValidationErrorRendererFactory, decorators: [{
|
|
38
32
|
type: Injectable,
|
|
39
33
|
args: [{ providedIn: 'root' }]
|
|
40
|
-
}], ctorParameters: function () { return [{ type: i1.ErrorMessagesExtractor }, { type:
|
|
41
|
-
type: Inject,
|
|
42
|
-
args: [DOCUMENT]
|
|
43
|
-
}] }, { type: undefined, decorators: [{
|
|
34
|
+
}], ctorParameters: function () { return [{ type: i1.ErrorMessagesExtractor }, { type: undefined, decorators: [{
|
|
44
35
|
type: Optional
|
|
45
36
|
}, {
|
|
46
37
|
type: Inject,
|
|
@@ -51,11 +42,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
51
42
|
*/
|
|
52
43
|
export class DefaultValidationErrorRenderer {
|
|
53
44
|
//######################### constructor #########################
|
|
54
|
-
constructor(_errorMessagesExtractor, _control,
|
|
45
|
+
constructor(_errorMessagesExtractor, _control, _containerView, _injector, _isSubmittedOrDirty, _options) {
|
|
55
46
|
this._errorMessagesExtractor = _errorMessagesExtractor;
|
|
56
47
|
this._control = _control;
|
|
57
|
-
this.
|
|
58
|
-
this._document = _document;
|
|
48
|
+
this._containerView = _containerView;
|
|
59
49
|
this._injector = _injector;
|
|
60
50
|
this._isSubmittedOrDirty = _isSubmittedOrDirty;
|
|
61
51
|
this._options = _options;
|
|
@@ -63,155 +53,53 @@ export class DefaultValidationErrorRenderer {
|
|
|
63
53
|
}
|
|
64
54
|
//######################### public methods - implementation of ValiDationErrorRenderer #########################
|
|
65
55
|
/**
|
|
66
|
-
*
|
|
56
|
+
* @inheritdoc
|
|
67
57
|
*/
|
|
68
58
|
destroy() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this._component.destroy();
|
|
72
|
-
this._component = null;
|
|
73
|
-
}
|
|
74
|
-
this.wrapperElement?.remove();
|
|
75
|
-
this.wrapperElement = null;
|
|
59
|
+
this._containerView.viewContainer.clear();
|
|
60
|
+
this._container = null;
|
|
76
61
|
}
|
|
77
62
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param errorMessages - Object storing error messages to be used as override
|
|
80
|
-
* @param onlyShow - Indication that update performs only displaying of existing errors
|
|
63
|
+
* @inheritdoc
|
|
81
64
|
*/
|
|
82
|
-
update(errorMessages) {
|
|
65
|
+
update(options, errorMessages) {
|
|
83
66
|
let result = false;
|
|
84
|
-
//hides old errors
|
|
85
|
-
this._toggleErrors(false);
|
|
86
67
|
this._lastErrors = this._errorMessagesExtractor.getErrors(this._control, errorMessages);
|
|
68
|
+
//has errors
|
|
87
69
|
if (this._lastErrors) {
|
|
88
70
|
this._isSubmittedOrDirty(() => {
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
71
|
+
// const errorsClasses = this._lastErrors.errors.map(error => `${this._options.prefix}${error.toLowerCase()}${this._options.suffix}`);
|
|
72
|
+
const opts = extend(true, {}, this._options, options);
|
|
73
|
+
this._container.instance.show(this._lastErrors, opts);
|
|
91
74
|
result = true;
|
|
92
75
|
}, () => {
|
|
93
|
-
this.
|
|
76
|
+
this._container.instance.hide();
|
|
94
77
|
result = false;
|
|
95
78
|
});
|
|
96
79
|
}
|
|
97
80
|
else {
|
|
98
|
-
this.
|
|
81
|
+
this._container.instance.hide();
|
|
99
82
|
result = false;
|
|
100
83
|
}
|
|
101
84
|
return result;
|
|
102
85
|
}
|
|
103
|
-
//######################### protected methods #########################
|
|
104
|
-
/**
|
|
105
|
-
* Toggles css classes for errors that are currently set
|
|
106
|
-
* @param add - Indication whether add or remove errors
|
|
107
|
-
*/
|
|
108
|
-
_toggleErrors(add = true) {
|
|
109
|
-
if (!this._lastErrors) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const errorsClasses = this._lastErrors.errors.map(error => `${this._options.prefix}${error.toLowerCase()}${this._options.suffix}`);
|
|
113
|
-
(add ? this._controlElement.classList.add : this._controlElement.classList.remove).apply(this._controlElement.classList, errorsClasses);
|
|
114
|
-
(add ? this.wrapperElement.classList.add : this.wrapperElement.classList.remove).apply(this.wrapperElement.classList, errorsClasses);
|
|
115
|
-
this._errorMessageAttr.value = (add ? this._lastErrors.errorMessages : [])
|
|
116
|
-
.join(' ');
|
|
117
|
-
this._render(add);
|
|
118
|
-
}
|
|
119
86
|
/**
|
|
120
87
|
* Initialize renderer
|
|
121
88
|
*/
|
|
122
89
|
_initialize() {
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
-
this.wrapperElement.classList.add(this._options.wrapperDivClass);
|
|
126
|
-
this._errorMessageAttr = this._document.createAttribute('data-error-message');
|
|
127
|
-
this.wrapperElement.attributes.setNamedItem(this._errorMessageAttr);
|
|
128
|
-
this._controlElement.after(this.wrapperElement);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Renders error messages
|
|
132
|
-
* @param add - Indication whether add or remove errors
|
|
133
|
-
*/
|
|
134
|
-
_render(add) {
|
|
135
|
-
if (this._options.component) {
|
|
136
|
-
this._renderComponent(add);
|
|
137
|
-
}
|
|
138
|
-
else if (this._options.template) {
|
|
139
|
-
this._renderTemplate(add);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this._renderDivs(add);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Renders divs with errors
|
|
147
|
-
* @param add - Indication whether add or remove errors
|
|
148
|
-
*/
|
|
149
|
-
_renderDivs(add = true) {
|
|
150
|
-
if (!add) {
|
|
151
|
-
const children = this.wrapperElement.children;
|
|
152
|
-
//first clean old messages
|
|
153
|
-
for (let x = children.length - 1; x >= 0; x--) {
|
|
154
|
-
children.item(x).remove();
|
|
155
|
-
}
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (this._lastErrors?.errorMessages?.length) {
|
|
159
|
-
this._lastErrors.errorMessages.forEach(message => {
|
|
160
|
-
const errorDiv = this._document.createElement('div');
|
|
161
|
-
errorDiv.innerText = message;
|
|
162
|
-
this.wrapperElement.append(errorDiv);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Renders component with errors
|
|
168
|
-
* @param add - Indication whether add or remove errors
|
|
169
|
-
*/
|
|
170
|
-
_renderComponent(add = true) {
|
|
171
|
-
if (add) {
|
|
172
|
-
//render component
|
|
173
|
-
if (!this._component) {
|
|
174
|
-
// 1. Create a component reference from the component
|
|
175
|
-
this._component = this._injector.get(ComponentFactoryResolver)
|
|
176
|
-
.resolveComponentFactory(this._options.component)
|
|
177
|
-
.create(this._injector);
|
|
178
|
-
// 2. Attach component to the appRef so that it's inside the ng component tree
|
|
179
|
-
this._injector.get(ApplicationRef).attachView(this._component.hostView);
|
|
180
|
-
// 3. Get DOM element from component
|
|
181
|
-
const domElem = this._component.hostView
|
|
182
|
-
.rootNodes[0];
|
|
183
|
-
// 4. Append DOM element to the body
|
|
184
|
-
this.wrapperElement.append(domElem);
|
|
185
|
-
}
|
|
186
|
-
this._component.instance.show(this._lastErrors);
|
|
187
|
-
}
|
|
188
|
-
else if (this._component) {
|
|
189
|
-
this._component.instance.show(null);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Renders template with errors
|
|
194
|
-
* @param add - Indication whether add or remove errors
|
|
195
|
-
*/
|
|
196
|
-
_renderTemplate(_add = true) {
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Shows wrapper element
|
|
200
|
-
*/
|
|
201
|
-
_show() {
|
|
202
|
-
this.wrapperElement.style.display = 'block';
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Hides wrapper element
|
|
206
|
-
*/
|
|
207
|
-
_hide() {
|
|
208
|
-
this.wrapperElement.style.display = 'none';
|
|
90
|
+
this._container = this._containerView.viewContainer.createComponent(this._options.container, { injector: this._injector });
|
|
91
|
+
this._container.instance.hide();
|
|
209
92
|
}
|
|
210
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Default options for validation error renderer factory
|
|
96
|
+
*/
|
|
211
97
|
const DEFAULT_OPTIONS = {
|
|
212
98
|
prefix: 'ng-',
|
|
213
99
|
suffix: '-error',
|
|
214
100
|
wrapperDivClass: 'validation-error-div',
|
|
215
|
-
rendererType: DefaultValidationErrorRenderer
|
|
101
|
+
rendererType: DefaultValidationErrorRenderer,
|
|
102
|
+
component: DefaultValidationErrorsComponent,
|
|
103
|
+
container: DefaultValidationErrorsContainerComponent,
|
|
216
104
|
};
|
|
217
105
|
//# sourceMappingURL=validationErrorRenderer.service.js.map
|
package/es2020/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,cAAc,EAAE,QAAQ,EAAY,wBAAwB,EAAE,cAAc,EAAgC,MAAM,eAAe,CAAC;AAE9J,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAC,MAAM,EAAmB,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0DAA0D,CAAC;;;AAIhG;;GAEG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAA0D,IAAI,cAAc,CAAwC,2CAA2C,CAAC,CAAC;AAEvN,8DAA8D;AAE9D;;GAEG;AAEH,MAAM,OAAO,8BAA8B;IASvC,iEAAiE;IACjE,YAAsB,uBAA+C,EAC7B,SAAmB,EACgB,OAA8C;QAFnG,4BAAuB,GAAvB,uBAAuB,CAAw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eddedViewRef, ComponentRef} from '@angular/core';\nimport {FormControl} from '@angular/forms';\nimport {DOCUMENT} from '@angular/common';\nimport {extend, StringDictionary} from '@jscrpt/common';\n\nimport {ErrorMessagesExtractor} from '../errorMessagesExtractor/errorMessagesExtractor.service';\nimport {ValidationErrorRenderer, IsSubmittedOrDirtyFunc, ValidationErrorsRendererOptions, ValidationErrorRendererFactoryOptions, ValidationErrorsComponent} from './validationErrorRenderer.interface';\nimport {ValidationErrorsResult} from '../errorMessagesExtractor/errorMessagesExtractor.interface';\n\n/**\n * Injection token used for injecting global options for ValidationErrorRendererFactory\n */\nexport const VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS: InjectionToken<ValidationErrorRendererFactoryOptions> = new InjectionToken<ValidationErrorRendererFactoryOptions>('VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS');\n\n//TODO: div renderer as custom component, wrapper div renderer\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 @Inject(DOCUMENT) protected _document: Document,\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 control - Control that is being processed for errors\n * @param controlElement - Html element that represents control that is being processed\n * @param isSubmittedOrDirty - Function used for testing if control is submitted or dirty\n * @param options - Options for validation errors renderer factory\n */\n public create(control: FormControl,\n controlElement: HTMLElement,\n injector: Injector,\n isSubmittedOrDirty: IsSubmittedOrDirtyFunc,\n options: ValidationErrorRendererFactoryOptions): ValidationErrorRenderer\n {\n const opts: ValidationErrorRendererFactoryOptions = extend(true, {}, this._options, options);\n\n return new opts.rendererType(this._errorMessagesExtractor,\n control,\n controlElement,\n this._document,\n injector,\n isSubmittedOrDirty,\n opts);\n }\n}\n\n/**\n * Default implementation of validation error renderer\n */\nexport class DefaultValidationErrorRenderer implements ValidationErrorRenderer\n{\n //######################### protected fields #########################\n\n /**\n * Html element attribute storing error messages\n */\n protected _errorMessageAttr: Attr;\n\n /**\n * Object storing last obtained errors\n */\n protected _lastErrors: ValidationErrorsResult;\n\n /**\n * Component used for displaying errors\n */\n protected _component: ComponentRef<ValidationErrorsComponent>;\n\n //######################### public properties - implementation of ValidationErrorRenderer #########################\n\n /**\n * Html element that is wrapping errors\n */\n public wrapperElement: HTMLElement;\n\n //######################### constructor #########################\n constructor(protected _errorMessagesExtractor: ErrorMessagesExtractor,\n protected _control: FormControl,\n protected _controlElement: HTMLElement,\n protected _document: Document,\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 * Destroys renderer and everything that was rendered\n */\n public destroy(): void\n {\n if(this._component)\n {\n this._injector.get(ApplicationRef).detachView(this._component.hostView);\n this._component.destroy();\n this._component = null;\n }\n\n this.wrapperElement?.remove();\n this.wrapperElement = null;\n }\n\n /**\n * Updates rendered errors for current state and returns true if errors were rendered, otherwise false\n * @param errorMessages - Object storing error messages to be used as override\n * @param onlyShow - Indication that update performs only displaying of existing errors\n */\n public update(errorMessages?: StringDictionary): boolean\n {\n let result = false;\n\n //hides old errors\n this._toggleErrors(false);\n this._lastErrors = this._errorMessagesExtractor.getErrors(this._control, errorMessages);\n\n if(this._lastErrors)\n {\n this._isSubmittedOrDirty(() =>\n {\n this._show();\n this._toggleErrors();\n result = true;\n },\n () =>\n {\n this._hide();\n result = false;\n });\n }\n else\n {\n this._hide();\n result = false;\n }\n\n return result;\n }\n\n //######################### protected methods #########################\n\n /**\n * Toggles css classes for errors that are currently set\n * @param add - Indication whether add or remove errors\n */\n protected _toggleErrors(add: boolean = true): void\n {\n if(!this._lastErrors)\n {\n return;\n }\n\n const errorsClasses = this._lastErrors.errors.map(error => `${this._options.prefix}${error.toLowerCase()}${this._options.suffix}`);\n\n (add ? this._controlElement.classList.add : this._controlElement.classList.remove).apply(this._controlElement.classList, errorsClasses);\n (add ? this.wrapperElement.classList.add : this.wrapperElement.classList.remove).apply(this.wrapperElement.classList, errorsClasses);\n\n this._errorMessageAttr.value = (add ? this._lastErrors.errorMessages : [])\n .join(' ');\n\n this._render(add);\n }\n\n /**\n * Initialize renderer\n */\n protected _initialize(): void\n {\n this.wrapperElement = this._document.createElement('div');\n this._hide();\n this.wrapperElement.classList.add(this._options.wrapperDivClass);\n\n this._errorMessageAttr = this._document.createAttribute('data-error-message');\n\n this.wrapperElement.attributes.setNamedItem(this._errorMessageAttr);\n this._controlElement.after(this.wrapperElement);\n }\n\n /**\n * Renders error messages\n * @param add - Indication whether add or remove errors\n */\n protected _render(add: boolean): void\n {\n if(this._options.component)\n {\n this._renderComponent(add);\n }\n else if(this._options.template)\n {\n this._renderTemplate(add);\n }\n else\n {\n this._renderDivs(add);\n }\n }\n\n /**\n * Renders divs with errors\n * @param add - Indication whether add or remove errors\n */\n protected _renderDivs(add: boolean = true): void\n {\n if(!add)\n {\n const children = this.wrapperElement.children;\n \n //first clean old messages\n for(let x = children.length - 1; x >= 0; x--)\n {\n children.item(x).remove();\n }\n\n return;\n }\n\n if(this._lastErrors?.errorMessages?.length)\n {\n this._lastErrors.errorMessages.forEach(message =>\n {\n const errorDiv = this._document.createElement('div');\n\n errorDiv.innerText = message;\n\n this.wrapperElement.append(errorDiv);\n });\n }\n }\n\n /**\n * Renders component with errors\n * @param add - Indication whether add or remove errors\n */\n protected _renderComponent(add: boolean = true): void\n {\n if(add)\n {\n //render component\n if(!this._component)\n {\n // 1. Create a component reference from the component \n this._component = this._injector.get(ComponentFactoryResolver)\n .resolveComponentFactory(this._options.component)\n .create(this._injector);\n\n // 2. Attach component to the appRef so that it's inside the ng component tree\n this._injector.get(ApplicationRef).attachView(this._component.hostView);\n\n // 3. Get DOM element from component\n const domElem = (this._component.hostView as EmbeddedViewRef<any>)\n .rootNodes[0] as HTMLElement;\n\n // 4. Append DOM element to the body\n this.wrapperElement.append(domElem);\n }\n\n this._component.instance.show(this._lastErrors);\n }\n else if(this._component)\n {\n this._component.instance.show(null);\n }\n }\n\n /**\n * Renders template with errors\n * @param add - Indication whether add or remove errors\n */\n protected _renderTemplate(_add: boolean = true): void\n {\n\n }\n\n /**\n * Shows wrapper element\n */\n protected _show(): void\n {\n this.wrapperElement.style.display = 'block';\n }\n\n /**\n * Hides wrapper element\n */\n protected _hide(): void\n {\n this.wrapperElement.style.display = 'none';\n }\n}\n\nconst DEFAULT_OPTIONS: ValidationErrorRendererFactoryOptions =\n{\n prefix: 'ng-',\n suffix: '-error',\n wrapperDivClass: 'validation-error-div',\n rendererType: DefaultValidationErrorRenderer\n};"]}
|
|
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,EAAmB,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0DAA0D,CAAC;AAGhG,OAAO,EAAC,yCAAyC,EAAC,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAC,gCAAgC,EAAE,yCAAyC,EAAC,MAAM,kBAAkB,CAAC;;;AAE7G;;GAEG;AAEH,MAAM,OAAO,8BAA8B;IASvC,iEAAiE;IACjE,YAAsB,uBAA+C,EACM,OAA8C;QADnG,4BAAuB,GAAvB,uBAAuB,CAAwB;QAGjE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,EA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,EAAE,aAAa,CAAC,CAAC;QAExF,YAAY;QACZ,IAAG,IAAI,CAAC,WAAW,EACnB;YACI,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE;gBAED,sIAAsI;gBACtI,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAEtD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBACtD,MAAM,GAAG,IAAI,CAAC;YAClB,CAAC,EACD,GAAG,EAAE;gBAED,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAChC,MAAM,GAAG,KAAK,CAAC;YACnB,CAAC,CAAC,CAAC;SAC/B;aAED;YACI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM,GAAG,KAAK,CAAC;SAClB;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACO,WAAW;QAEjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAC,CAAC,CAAC;QACzH,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,eAAe,GACrB;IACI,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,QAAQ;IAChB,eAAe,EAAE,sBAAsB;IACvC,YAAY,EAAE,8BAA8B;IAC5C,SAAS,EAAE,gCAAgC;IAC3C,SAAS,EAAE,yCAAyC;CACvD,CAAC","sourcesContent":["import {Injectable, Inject, Optional, Injector, ComponentRef} from '@angular/core';\nimport {FormControl} from '@angular/forms';\nimport {extend, StringDictionary} from '@jscrpt/common';\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 control - Control that is being processed for errors\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(control: FormControl,\n containerView: ValidationErrorsContainerView,\n injector: Injector,\n isSubmittedOrDirty: IsSubmittedOrDirtyFunc): ValidationErrorRenderer\n {\n return new this._options.rendererType(this._errorMessagesExtractor,\n control,\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 _control: FormControl,\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, errorMessages?: StringDictionary): boolean\n {\n let result = false;\n this._lastErrors = this._errorMessagesExtractor.getErrors(this._control, 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};"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { ValidationErrorsResult } from '../../services/errorMessagesExtractor/errorMessagesExtractor.interface';
|
|
3
|
+
import { ValidationErrorsComponent, ValidationErrorsOptions } from '../../services/validationErrorRenderer/validationErrorRenderer.interface';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Default validation errors component, displaying validation errors
|
|
7
|
+
*/
|
|
8
|
+
export declare class DefaultValidationErrorsComponent implements ValidationErrorsComponent {
|
|
9
|
+
protected _changeDetector: ChangeDetectorRef;
|
|
10
|
+
/**
|
|
11
|
+
* Errors to be shown
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
errors: ValidationErrorsResult;
|
|
15
|
+
/**
|
|
16
|
+
* Options used for displaying validation errors
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
options: ValidationErrorsOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Enables leave animations for internal stuff
|
|
22
|
+
*/
|
|
23
|
+
animate: boolean;
|
|
24
|
+
constructor(_changeDetector: ChangeDetectorRef);
|
|
25
|
+
/**
|
|
26
|
+
* @inheritdoc
|
|
27
|
+
*/
|
|
28
|
+
show(errors: ValidationErrorsResult, options: ValidationErrorsOptions): void;
|
|
29
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DefaultValidationErrorsComponent, never>;
|
|
30
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DefaultValidationErrorsComponent, "default-validation-errors", never, {}, {}, never, never>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=defaultValidationErrors.component.d.ts.map
|
package/forms/src/components/defaultValidationErrors/defaultValidationErrors.component.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultValidationErrors.component.d.ts","sourceRoot":"","sources":["defaultValidationErrors.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,iBAAiB,EAAc,MAAM,eAAe,CAAC;AAIjG,OAAO,EAAC,sBAAsB,EAAC,MAAM,wEAAwE,CAAC;AAC9G,OAAO,EAAC,yBAAyB,EAAE,uBAAuB,EAAC,MAAM,0EAA0E,CAAC;;AAI5I;;GAEG;AACH,qBAkBa,gCAAiC,YAAW,yBAAyB;IAyBlE,SAAS,CAAC,eAAe,EAAE,iBAAiB;IArBxD;;;OAGG;IACI,MAAM,EAAE,sBAAsB,CAAC;IAEtC;;;OAGG;IACI,OAAO,EAAE,uBAAuB,CAAC;IAIxC;;OAEG;IAEI,OAAO,EAAE,OAAO,CAAQ;gBAGT,eAAe,EAAE,iBAAiB;IAMxD;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI;yCAlC1E,gCAAgC;2CAAhC,gCAAgC;CAyC5C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ViewContainerRef, ComponentRef, EmbeddedViewRef } from '@angular/core';
|
|
2
|
+
import { ValidationErrorsResult } from '../../services/errorMessagesExtractor/errorMessagesExtractor.interface';
|
|
3
|
+
import { ValidationErrorsComponent, ValidationErrorsContainerComponent, ValidationErrorsContainerOptions, ValidationErrorsTemplateContext } from '../../services/validationErrorRenderer/validationErrorRenderer.interface';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Component that serves as container for validation errors, either component or templates
|
|
7
|
+
*/
|
|
8
|
+
export declare class DefaultValidationErrorsContainerComponent implements ValidationErrorsContainerComponent {
|
|
9
|
+
protected _viewContainer: ViewContainerRef;
|
|
10
|
+
/**
|
|
11
|
+
* Errors to be shown
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
protected _errors: ValidationErrorsResult;
|
|
15
|
+
/**
|
|
16
|
+
* Options used for displaying validation errors
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
protected _options: ValidationErrorsContainerOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Instance of component reference for rendered errors
|
|
22
|
+
*/
|
|
23
|
+
protected _component: ComponentRef<ValidationErrorsComponent>;
|
|
24
|
+
/**
|
|
25
|
+
* Instance of template reference for rendered errors
|
|
26
|
+
*/
|
|
27
|
+
protected _template: EmbeddedViewRef<ValidationErrorsTemplateContext>;
|
|
28
|
+
constructor(_viewContainer: ViewContainerRef);
|
|
29
|
+
/**
|
|
30
|
+
* Shows validation errors
|
|
31
|
+
* @param errors - Errors to be shown
|
|
32
|
+
* @param options - Options used for displaying validation errors
|
|
33
|
+
* @param errorClasses - Array of css error classes
|
|
34
|
+
*/
|
|
35
|
+
show(errors: ValidationErrorsResult, options: ValidationErrorsContainerOptions): void;
|
|
36
|
+
/**
|
|
37
|
+
* Hides validation errors
|
|
38
|
+
*/
|
|
39
|
+
hide(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Renders validation errors component
|
|
42
|
+
*/
|
|
43
|
+
protected _renderComponent(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Renders validation errors template
|
|
46
|
+
*/
|
|
47
|
+
protected _renderTemplate(): void;
|
|
48
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DefaultValidationErrorsContainerComponent, never>;
|
|
49
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DefaultValidationErrorsContainerComponent, "default-validation-errors-container", never, {}, {}, never, never>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=defaultValidationErrorsContainer.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultValidationErrorsContainer.component.d.ts","sourceRoot":"","sources":["defaultValidationErrorsContainer.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAElH,OAAO,EAAC,sBAAsB,EAAC,MAAM,wEAAwE,CAAC;AAC9G,OAAO,EAAC,yBAAyB,EAAE,kCAAkC,EAAE,gCAAgC,EAAE,+BAA+B,EAAC,MAAM,0EAA0E,CAAC;;AAE1N;;GAEG;AACH,qBAOa,yCAA0C,YAAW,kCAAkC;IA2BpF,SAAS,CAAC,cAAc,EAAE,gBAAgB;IAvBtD;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAE1C;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,gCAAgC,CAAC;IAErD;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAC;IAE9D;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,eAAe,CAAC,+BAA+B,CAAC,CAAC;gBAGhD,cAAc,EAAE,gBAAgB;IAMtD;;;;;OAKG;IACI,IAAI,CAAC,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,gCAAgC,GAAG,IAAI;IAmB5F;;OAEG;IACI,IAAI,IAAI,IAAI;IASnB;;OAEG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAUlC;;OAEG;IACH,SAAS,CAAC,eAAe,IAAI,IAAI;yCAtFxB,yCAAyC;2CAAzC,yCAAyC;CA2GrD"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,6DAA6D,CAAC;AAC5E,cAAc,+EAA+E,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementRef, OnInit, OnDestroy, Injector } from '@angular/core';
|
|
1
|
+
import { ElementRef, OnInit, OnDestroy, Injector, ViewContainerRef } from '@angular/core';
|
|
2
2
|
import { FormControlDirective, FormControlName, NgModel } from '@angular/forms';
|
|
3
3
|
import { StringLocalization } from '@anglr/common';
|
|
4
4
|
import { StringDictionary } from '@jscrpt/common';
|
|
@@ -6,6 +6,7 @@ import { ValidationErrorRendererFactory } from '../../services/validationErrorRe
|
|
|
6
6
|
import { ValidationErrorRenderer } from '../../services/validationErrorRenderer/validationErrorRenderer.interface';
|
|
7
7
|
import { SubmittedService } from '../../services/submitted/submitted.service';
|
|
8
8
|
import { GroupHasErrorDirective } from '../groupHasError/groupHasError.directive';
|
|
9
|
+
import { ValidationErrorsContainerView } from '../../misc/validationErrorsContainerView';
|
|
9
10
|
import * as i0 from "@angular/core";
|
|
10
11
|
/**
|
|
11
12
|
* Directive that is attached to control element and handles css classes that are added to this element
|
|
@@ -13,11 +14,13 @@ import * as i0 from "@angular/core";
|
|
|
13
14
|
export declare class HasErrorDirective implements OnInit, OnDestroy {
|
|
14
15
|
private _element;
|
|
15
16
|
private _rendererFactory;
|
|
17
|
+
private _viewContainer;
|
|
16
18
|
private _groupHasError;
|
|
17
19
|
private _formControl;
|
|
18
20
|
private _formControlName;
|
|
19
21
|
private _ngModel;
|
|
20
22
|
private _submittedSvc;
|
|
23
|
+
private _containerView;
|
|
21
24
|
protected _stringLocalization: StringLocalization;
|
|
22
25
|
protected _injector: Injector;
|
|
23
26
|
/**
|
|
@@ -52,7 +55,7 @@ export declare class HasErrorDirective implements OnInit, OnDestroy {
|
|
|
52
55
|
* Customized error messages
|
|
53
56
|
*/
|
|
54
57
|
errorMessages: StringDictionary;
|
|
55
|
-
constructor(_element: ElementRef<HTMLElement>, _rendererFactory: ValidationErrorRendererFactory, _groupHasError: GroupHasErrorDirective, _formControl: FormControlDirective, _formControlName: FormControlName, _ngModel: NgModel, _submittedSvc: SubmittedService, _stringLocalization: StringLocalization, _injector: Injector);
|
|
58
|
+
constructor(_element: ElementRef<HTMLElement>, _rendererFactory: ValidationErrorRendererFactory, _viewContainer: ViewContainerRef, _groupHasError: GroupHasErrorDirective, _formControl: FormControlDirective, _formControlName: FormControlName, _ngModel: NgModel, _submittedSvc: SubmittedService, _containerView: ValidationErrorsContainerView, _stringLocalization: StringLocalization, _injector: Injector);
|
|
56
59
|
/**
|
|
57
60
|
* Initialize component
|
|
58
61
|
*/
|
|
@@ -80,7 +83,7 @@ export declare class HasErrorDirective implements OnInit, OnDestroy {
|
|
|
80
83
|
* Registers mutation observer which watch for changes of class list
|
|
81
84
|
*/
|
|
82
85
|
private _registerMutationObserver;
|
|
83
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<HasErrorDirective, [null, null, { optional: true; skipSelf: true; }, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }, null, null]>;
|
|
86
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HasErrorDirective, [null, null, null, { optional: true; skipSelf: true; }, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }, null, null]>;
|
|
84
87
|
static ɵdir: i0.ɵɵDirectiveDeclaration<HasErrorDirective, "[hasError]", never, { "errorMessages": "errorMessages"; }, {}, never>;
|
|
85
88
|
}
|
|
86
89
|
//# sourceMappingURL=hasError.directive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasError.directive.d.ts","sourceRoot":"","sources":["hasError.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAsB,MAAM,EAAE,SAAS,EAAiB,QAAQ,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"hasError.directive.d.ts","sourceRoot":"","sources":["hasError.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAsB,MAAM,EAAE,SAAS,EAAiB,QAAQ,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACtI,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAe,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAC,kBAAkB,EAAsB,MAAM,eAAe,CAAC;AACtE,OAAO,EAAuB,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAGtE,OAAO,EAAC,8BAA8B,EAAC,MAAM,wEAAwE,CAAC;AACtH,OAAO,EAAC,uBAAuB,EAAC,MAAM,0EAA0E,CAAC;AACjH,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAC,sBAAsB,EAAC,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAC,6BAA6B,EAAC,MAAM,0CAA0C,CAAC;;AAIvF;;GAEG;AACH,qBAIa,iBAAkB,YAAW,MAAM,EAAE,SAAS;IAuD3C,O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AAiB;CAiL7B"}
|
package/forms/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './components';
|
|
1
2
|
export * from './directives/numberInput/maxValueNumberValidator.directive';
|
|
2
3
|
export * from './directives/numberInput/minValueNumberValidator.directive';
|
|
3
4
|
export * from './directives/numberInput/numberInputValidator.directive';
|
|
@@ -12,7 +13,8 @@ export * from './services/validationErrorRenderer/validationErrorRenderer.interf
|
|
|
12
13
|
export * from './services/validationErrorRenderer/validationErrorRenderer.service';
|
|
13
14
|
export * from './misc/validators';
|
|
14
15
|
export * from './misc/utils';
|
|
15
|
-
export * from './misc/
|
|
16
|
+
export * from './misc/tokens';
|
|
17
|
+
export * from './misc/validationErrorsContainerView';
|
|
16
18
|
export * from './modules/numberInput.module';
|
|
17
19
|
export * from './modules/hasError.module';
|
|
18
20
|
export * from './modules/requiredClass.module';
|
package/forms/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,4DAA4D,CAAC;AAC3E,cAAc,4DAA4D,CAAC;AAC3E,cAAc,yDAAyD,CAAC;AACxE,cAAc,oEAAoE,CAAC;AACnF,cAAc,0CAA0C,CAAC;AACzD,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AACnE,cAAc,wCAAwC,CAAC;AACvD,cAAc,oEAAoE,CAAC;AACnF,cAAc,kEAAkE,CAAC;AACjF,cAAc,sEAAsE,CAAC;AACrF,cAAc,oEAAoE,CAAC;AACnF,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,4DAA4D,CAAC;AAC3E,cAAc,4DAA4D,CAAC;AAC3E,cAAc,yDAAyD,CAAC;AACxE,cAAc,oEAAoE,CAAC;AACnF,cAAc,0CAA0C,CAAC;AACzD,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AACnE,cAAc,wCAAwC,CAAC;AACvD,cAAc,oEAAoE,CAAC;AACnF,cAAc,kEAAkE,CAAC;AACjF,cAAc,sEAAsE,CAAC;AACrF,cAAc,oEAAoE,CAAC;AACnF,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AsyncValidatorFn, ValidatorFn } from '@angular/forms';
|
|
2
|
+
import { Dictionary } from '@jscrpt/common';
|
|
2
3
|
import { AsyncValidatorFnFactory, ValidatorFnFactory } from '../misc/validatorFactories';
|
|
3
4
|
import { ModelPropertyDecoratorMetadata } from './modelPropertyDecoratorMetadata';
|
|
4
5
|
/**
|
|
5
6
|
* Metadata describing whole model
|
|
6
7
|
*/
|
|
7
|
-
export interface ModelDecoratorMetadata<TModel = any> {
|
|
8
|
+
export interface ModelDecoratorMetadata<TModel = any, TArgs extends Dictionary<any> = any> {
|
|
8
9
|
/**
|
|
9
10
|
* Array of controls metadata
|
|
10
11
|
*/
|
|
@@ -17,5 +18,9 @@ export interface ModelDecoratorMetadata<TModel = any> {
|
|
|
17
18
|
* Array of async validator functions
|
|
18
19
|
*/
|
|
19
20
|
ɵAsyncValidators?: Array<AsyncValidatorFn | AsyncValidatorFnFactory>;
|
|
21
|
+
/**
|
|
22
|
+
* Object storing additional arguments for customization
|
|
23
|
+
*/
|
|
24
|
+
ɵArgs?: TArgs;
|
|
20
25
|
}
|
|
21
26
|
//# sourceMappingURL=modelDecoratorMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelDecoratorMetadata.d.ts","sourceRoot":"","sources":["modelDecoratorMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"modelDecoratorMetadata.d.ts","sourceRoot":"","sources":["modelDecoratorMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAC,uBAAuB,EAAE,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,GAAG,EAAE,KAAK,SAAS,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG;IAErF;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAEjF;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,WAAW,GAAC,kBAAkB,CAAC,CAAC;IAEpD;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,gBAAgB,GAAC,uBAAuB,CAAC,CAAC;IAEnE;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAiIlF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,SAAS,CAG5G"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { StringDictionary } from '@jscrpt/common';
|
|
3
|
+
import { ValidationErrorRendererFactoryOptions } from '../services/validationErrorRenderer/validationErrorRenderer.interface';
|
|
4
|
+
/**
|
|
5
|
+
* Injection token containing validation error messages
|
|
6
|
+
*/
|
|
7
|
+
export declare const VALIDATION_ERROR_MESSAGES: InjectionToken<StringDictionary>;
|
|
8
|
+
/**
|
|
9
|
+
* Injection token for injecting array of ignored error names when automatically processed
|
|
10
|
+
*/
|
|
11
|
+
export declare const IGNORED_VALIDATION_ERRORS: InjectionToken<string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Injection token used for injecting global options for ValidationErrorRendererFactory
|
|
14
|
+
*/
|
|
15
|
+
export declare const VALIDATION_ERROR_RENDERER_FACTORY_OPTIONS: InjectionToken<ValidationErrorRendererFactoryOptions>;
|
|
16
|
+
//# sourceMappingURL=tokens.d.ts.map
|