@ngx-formly/core 5.10.28 → 5.10.32

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.
Files changed (46) hide show
  1. package/bundles/ngx-formly-core-json-schema.umd.js +6 -2
  2. package/bundles/ngx-formly-core-json-schema.umd.js.map +1 -1
  3. package/bundles/ngx-formly-core-json-schema.umd.min.js +1 -1
  4. package/bundles/ngx-formly-core-json-schema.umd.min.js.map +1 -1
  5. package/bundles/ngx-formly-core.umd.js +105 -147
  6. package/bundles/ngx-formly-core.umd.js.map +1 -1
  7. package/bundles/ngx-formly-core.umd.min.js +1 -1
  8. package/bundles/ngx-formly-core.umd.min.js.map +1 -1
  9. package/esm2015/json-schema/formly-json-schema.service.js +8 -4
  10. package/esm2015/lib/components/formly.attributes.js +33 -24
  11. package/esm2015/lib/core.js +2 -2
  12. package/esm2015/lib/extensions/core/core.js +2 -1
  13. package/esm2015/lib/extensions/field-expression/field-expression.js +3 -6
  14. package/esm2015/lib/extensions/field-form/field-form.js +23 -55
  15. package/esm2015/lib/extensions/field-form/utils.js +9 -3
  16. package/esm2015/lib/services/formly.form.builder.js +3 -3
  17. package/esm2015/lib/templates/formly.validation-message.js +14 -3
  18. package/esm2015/lib/utils.js +21 -42
  19. package/esm2015/ngx-formly-core.js +2 -2
  20. package/esm2015/public_api.js +2 -2
  21. package/esm5/json-schema/formly-json-schema.service.js +8 -4
  22. package/esm5/lib/components/formly.attributes.js +32 -21
  23. package/esm5/lib/core.js +2 -2
  24. package/esm5/lib/extensions/core/core.js +2 -1
  25. package/esm5/lib/extensions/field-expression/field-expression.js +3 -6
  26. package/esm5/lib/extensions/field-form/field-form.js +25 -55
  27. package/esm5/lib/extensions/field-form/utils.js +10 -3
  28. package/esm5/lib/services/formly.form.builder.js +3 -3
  29. package/esm5/lib/templates/formly.validation-message.js +15 -3
  30. package/esm5/lib/utils.js +24 -59
  31. package/esm5/ngx-formly-core.js +2 -2
  32. package/esm5/public_api.js +2 -2
  33. package/fesm2015/ngx-formly-core-json-schema.js +7 -3
  34. package/fesm2015/ngx-formly-core-json-schema.js.map +1 -1
  35. package/fesm2015/ngx-formly-core.js +98 -128
  36. package/fesm2015/ngx-formly-core.js.map +1 -1
  37. package/fesm5/ngx-formly-core-json-schema.js +7 -3
  38. package/fesm5/ngx-formly-core-json-schema.js.map +1 -1
  39. package/fesm5/ngx-formly-core.js +104 -142
  40. package/fesm5/ngx-formly-core.js.map +1 -1
  41. package/json-schema/ngx-formly-core-json-schema.metadata.json +1 -1
  42. package/lib/core.d.ts +1 -1
  43. package/lib/extensions/field-form/utils.d.ts +1 -1
  44. package/lib/utils.d.ts +1 -2
  45. package/ngx-formly-core.metadata.json +1 -1
  46. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { __assign, __rest, __read, __spread } from 'tslib';
2
2
  import { Injectable, defineInjectable } from '@angular/core';
3
3
  import { FormGroup } from '@angular/forms';
4
- import { ɵreverseDeepMerge, ɵgetFieldInitialValue, ɵclone } from '@ngx-formly/core';
4
+ import { ɵreverseDeepMerge, ɵgetFieldValue, ɵclone } from '@ngx-formly/core';
5
5
  import { tap } from 'rxjs/operators';
6
6
 
7
7
  /**
@@ -54,14 +54,18 @@ function isConst(schema) {
54
54
  */
55
55
  function totalMatchedFields(field) {
56
56
  if (!field.fieldGroup) {
57
- return field.key && ɵgetFieldInitialValue(field) !== undefined ? 1 : 0;
57
+ return field.key && ɵgetFieldValue(field) !== undefined ? 1 : 0;
58
58
  }
59
- return field.fieldGroup.reduce((/**
59
+ /** @type {?} */
60
+ var total = field.fieldGroup.reduce((/**
60
61
  * @param {?} s
61
62
  * @param {?} f
62
63
  * @return {?}
63
64
  */
64
65
  function (s, f) { return totalMatchedFields(f) + s; }), 0);
66
+ return total === 0
67
+ ? field.key && ɵgetFieldValue(field) !== undefined ? 1 : 0
68
+ : total;
65
69
  }
66
70
  var FormlyJsonschema = /** @class */ (function () {
67
71
  function FormlyJsonschema() {
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-formly-core-json-schema.js.map","sources":["ng://@ngx-formly/core/json-schema/formly-json-schema.service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { FormlyFieldConfig } from '@ngx-formly/core';\nimport { JSONSchema7, JSONSchema7TypeName } from 'json-schema';\nimport { AbstractControl, FormGroup } from '@angular/forms';\nimport {\n ɵreverseDeepMerge as reverseDeepMerge,\n ɵgetFieldInitialValue as getFieldInitialValue,\n ɵclone as clone,\n} from '@ngx-formly/core';\nimport { tap } from 'rxjs/operators';\n\nexport interface FormlyJsonschemaOptions {\n /**\n * allows to intercept the mapping, taking the already mapped\n * formly field and the original JSONSchema source from which it\n * was mapped.\n */\n map?: (mappedField: FormlyFieldConfig, mapSource: JSONSchema7) => FormlyFieldConfig;\n}\n\n// https://stackoverflow.com/a/27865285\nfunction decimalPlaces(a: number) {\n if (!isFinite(a)) {\n return 0;\n }\n\n let e = 1, p = 0;\n while (Math.round(a * e) / e !== a) { e *= 10; p++; }\n\n return p;\n}\n\nfunction isEmpty(v: any) {\n return v === '' || v === undefined || v === null;\n}\n\nfunction isObject(v: any) {\n return v != null && typeof v === 'object' && !Array.isArray(v);\n}\n\nfunction isConst(schema: JSONSchema7) {\n return schema.hasOwnProperty('const') || (schema.enum && schema.enum.length === 1);\n}\n\nfunction totalMatchedFields(field: FormlyFieldConfig): number {\n if (!field.fieldGroup) {\n return field.key && getFieldInitialValue(field) !== undefined ? 1 : 0;\n }\n\n return field.fieldGroup.reduce((s, f) => totalMatchedFields(f) + s, 0);\n}\n\ninterface IOptions extends FormlyJsonschemaOptions {\n schema: JSONSchema7;\n resetOnHide?: boolean;\n shareFormControl?: boolean;\n ignoreDefault?: boolean;\n readOnly?: boolean;\n key?: FormlyFieldConfig['key'];\n}\n\n@Injectable({ providedIn: 'root' })\nexport class FormlyJsonschema {\n toFieldConfig(schema: JSONSchema7, options?: FormlyJsonschemaOptions): FormlyFieldConfig {\n return this._toFieldConfig(schema, { schema, ...(options || {}) });\n }\n\n private _toFieldConfig(schema: JSONSchema7, { key, ...options }: IOptions): FormlyFieldConfig {\n schema = this.resolveSchema(schema, options);\n\n let field: FormlyFieldConfig = {\n type: this.guessType(schema),\n defaultValue: schema.default,\n templateOptions: {\n label: schema.title,\n readonly: schema.readOnly,\n description: schema.description,\n },\n };\n\n if (key != null) {\n field.key = key;\n }\n\n if (!options.ignoreDefault && (schema.readOnly || options.readOnly)) {\n field.templateOptions.disabled = true;\n options = { ...options, readOnly: true };\n }\n\n if (options.resetOnHide) {\n field['resetOnHide'] = true;\n }\n\n if (options.shareFormControl === false) {\n field['shareFormControl'] = false;\n }\n\n if (options.ignoreDefault) {\n delete field.defaultValue;\n }\n\n switch (field.type) {\n case 'null': {\n this.addValidator(field, 'null', ({ value }) => value === null);\n break;\n }\n case 'number':\n case 'integer': {\n field.parsers = [v => isEmpty(v) ? (v === '' ? null : v) : Number(v)];\n if (schema.hasOwnProperty('minimum')) {\n field.templateOptions.min = schema.minimum;\n }\n\n if (schema.hasOwnProperty('maximum')) {\n field.templateOptions.max = schema.maximum;\n }\n\n if (schema.hasOwnProperty('exclusiveMinimum')) {\n field.templateOptions.exclusiveMinimum = schema.exclusiveMinimum;\n this.addValidator(field, 'exclusiveMinimum', ({ value }) => isEmpty(value) || (value > schema.exclusiveMinimum));\n }\n\n if (schema.hasOwnProperty('exclusiveMaximum')) {\n field.templateOptions.exclusiveMaximum = schema.exclusiveMaximum;\n this.addValidator(field, 'exclusiveMaximum', ({ value }) => isEmpty(value) || (value < schema.exclusiveMaximum));\n }\n\n if (schema.hasOwnProperty('multipleOf')) {\n field.templateOptions.step = schema.multipleOf;\n this.addValidator(field, 'multipleOf', ({ value }) => {\n if (isEmpty(value) || typeof value !== 'number' || value === 0 || schema.multipleOf <= 0) {\n return true;\n }\n\n // https://github.com/ajv-validator/ajv/issues/652#issue-283610859\n const multiplier = Math.pow(10, decimalPlaces(schema.multipleOf));\n return Math.round(value * multiplier) % Math.round(schema.multipleOf * multiplier) === 0;\n });\n }\n break;\n }\n case 'string': {\n const schemaType = schema.type as JSONSchema7TypeName;\n if (Array.isArray(schemaType) && (schemaType.indexOf('null') !== -1)) {\n field.parsers = [v => isEmpty(v) ? null : v];\n }\n\n ['minLength', 'maxLength', 'pattern'].forEach(prop => {\n if (schema.hasOwnProperty(prop)) {\n field.templateOptions[prop] = schema[prop];\n }\n });\n break;\n }\n case 'object': {\n field.fieldGroup = [];\n\n const [propDeps, schemaDeps] = this.resolveDependencies(schema);\n Object.keys(schema.properties || {}).forEach(property => {\n const f = this._toFieldConfig(<JSONSchema7> schema.properties[property], { ...options, key: property });\n field.fieldGroup.push(f);\n if (\n (Array.isArray(schema.required) && schema.required.indexOf(property) !== -1)\n || propDeps[property]\n ) {\n f.expressionProperties = {\n ...(f.expressionProperties || {}),\n 'templateOptions.required': (m, s, f) => {\n let parent = f.parent;\n const model = f.fieldGroup && f.key != null ? parent.model : f.model;\n while (parent.key == null && parent.parent) {\n parent = parent.parent;\n }\n\n const required = parent && parent.templateOptions ? parent.templateOptions.required : false;\n if (!model && !required) {\n return false;\n }\n\n if (Array.isArray(schema.required) && schema.required.indexOf(property) !== -1) {\n return true;\n }\n\n return propDeps[property] && (m && propDeps[property].some(k => !isEmpty(m[k])));\n },\n };\n }\n\n if (schemaDeps[property]) {\n const getConstValue = (s: JSONSchema7) => {\n return s.hasOwnProperty('const') ? s.const : s.enum[0];\n };\n\n const oneOfSchema = schemaDeps[property].oneOf;\n if (\n oneOfSchema\n && oneOfSchema.every(o => o.properties && o.properties[property] && isConst(o.properties[property]))\n ) {\n oneOfSchema.forEach(oneOfSchemaItem => {\n const { [property]: constSchema, ...properties } = oneOfSchemaItem.properties;\n field.fieldGroup.push({\n ...this._toFieldConfig({ ...oneOfSchemaItem, properties }, { ...options, resetOnHide: true }),\n hideExpression: m => !m || getConstValue(constSchema) !== m[property],\n });\n });\n } else {\n field.fieldGroup.push({\n ...this._toFieldConfig(schemaDeps[property], options),\n hideExpression: m => !m || isEmpty(m[property]),\n });\n }\n\n }\n });\n\n if (schema.oneOf) {\n field.fieldGroup.push(this.resolveMultiSchema(\n 'oneOf',\n <JSONSchema7[]> schema.oneOf,\n { ...options, shareFormControl: false },\n ));\n }\n\n if (schema.anyOf) {\n field.fieldGroup.push(this.resolveMultiSchema(\n 'anyOf',\n <JSONSchema7[]> schema.anyOf,\n options,\n ));\n }\n break;\n }\n case 'array': {\n if (schema.hasOwnProperty('minItems')) {\n field.templateOptions.minItems = schema.minItems;\n this.addValidator(field, 'minItems', ({ value }) => isEmpty(value) || (value.length >= schema.minItems));\n }\n if (schema.hasOwnProperty('maxItems')) {\n field.templateOptions.maxItems = schema.maxItems;\n this.addValidator(field, 'maxItems', ({ value }) => isEmpty(value) || (value.length <= schema.maxItems));\n }\n if (schema.hasOwnProperty('uniqueItems')) {\n field.templateOptions.uniqueItems = schema.uniqueItems;\n this.addValidator(field, 'uniqueItems', ({ value }) => {\n if (isEmpty(value) || !schema.uniqueItems) {\n return true;\n }\n\n const uniqueItems = Array.from(\n new Set(value.map((v: any) => JSON.stringify(v))),\n );\n\n return uniqueItems.length === value.length;\n });\n }\n\n // resolve items schema needed for isEnum check\n if (schema.items && !Array.isArray(schema.items)) {\n schema.items = this.resolveSchema(<JSONSchema7> schema.items, options);\n }\n\n // TODO: remove isEnum check once adding an option to skip extension\n if (!this.isEnum(schema)) {\n const _this = this;\n Object.defineProperty(field, 'fieldArray', {\n get: function () {\n if (schema.items && !Array.isArray(schema.items)) {\n // When items is a single schema, the additionalItems keyword is meaningless, and it should not be used.\n return _this._toFieldConfig(<JSONSchema7> schema.items, options);\n }\n\n const length = this.fieldGroup ? this.fieldGroup.length : 0;\n if (schema.items && schema.items[length]) {\n const f = _this._toFieldConfig(<JSONSchema7> schema.items[length], { ...options});\n f.templateOptions.removable = false;\n\n return f;\n }\n\n return schema.additionalItems\n ? _this._toFieldConfig(<JSONSchema7> schema.additionalItems, options)\n : {};\n },\n enumerable: true,\n configurable: true,\n });\n }\n\n break;\n }\n }\n\n if (schema.hasOwnProperty('const')) {\n field.templateOptions.const = schema.const;\n this.addValidator(field, 'const', ({ value }) => value === schema.const);\n if (!field.type) {\n field.defaultValue = schema.const;\n }\n }\n\n if (this.isEnum(schema)) {\n field.templateOptions.multiple = field.type === 'array';\n field.type = 'enum';\n field.templateOptions.options = this.toEnumOptions(schema);\n }\n\n // map in possible formlyConfig options from the widget property\n if (schema['widget'] && schema['widget'].formlyConfig) {\n field = this.mergeFields(field, schema['widget'].formlyConfig);\n }\n\n // if there is a map function passed in, use it to allow the user to\n // further customize how fields are being mapped\n return options.map ? options.map(field, schema) : field;\n }\n\n private resolveSchema(schema: JSONSchema7, options: IOptions) {\n if (schema && schema.$ref) {\n schema = this.resolveDefinition(schema, options);\n }\n\n if (schema && schema.allOf) {\n schema = this.resolveAllOf(schema, options);\n }\n\n return schema;\n }\n\n private resolveAllOf({ allOf, ...baseSchema }: JSONSchema7, options: IOptions) {\n if (!allOf.length) {\n throw Error(`allOf array can not be empty ${allOf}.`);\n }\n\n return allOf.reduce((base: JSONSchema7, schema: JSONSchema7) => {\n schema = this.resolveSchema(schema, options);\n if (base.required && schema.required) {\n base.required = [...base.required, ...schema.required];\n }\n\n if (schema.uniqueItems) {\n base.uniqueItems = schema.uniqueItems;\n }\n\n // resolve to min value\n ['maxLength', 'maximum', 'exclusiveMaximum', 'maxItems', 'maxProperties']\n .forEach(prop => {\n if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {\n base[prop] = base[prop] < schema[prop] ? base[prop] : schema[prop];\n }\n });\n\n // resolve to max value\n ['minLength', 'minimum', 'exclusiveMinimum', 'minItems', 'minProperties']\n .forEach(prop => {\n if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {\n base[prop] = base[prop] > schema[prop] ? base[prop] : schema[prop];\n }\n });\n\n return reverseDeepMerge(base, schema);\n }, baseSchema);\n }\n\n private resolveMultiSchema(\n mode: 'oneOf' | 'anyOf',\n schemas: JSONSchema7[],\n options: IOptions,\n ): FormlyFieldConfig {\n return {\n type: 'multischema',\n fieldGroup: [\n {\n type: 'enum',\n defaultValue: -1,\n templateOptions: {\n multiple: mode === 'anyOf',\n options: schemas\n .map((s, i) => ({ label: s.title, value: i, disabled: s.readOnly })),\n },\n hooks: {\n onInit: f => f.formControl.valueChanges.pipe(\n tap(() => (f.options as any)._checkField(f.parent)),\n ),\n },\n },\n {\n fieldGroup: schemas.map((s, i) => ({\n ...this._toFieldConfig(s, { ...options, resetOnHide: true }),\n hideExpression: (m, fs, f, forceUpdate?: boolean) => {\n const control = f.parent.parent.fieldGroup[0].formControl;\n if ((control.value === -1) || forceUpdate) {\n let value = f.parent.fieldGroup\n .map((f, i) => [f, i] as [FormlyFieldConfig, number])\n .filter(([f, i]) => {\n return this.isFieldValid(f, schemas[i], options);\n })\n .sort(([f1], [f2]) => {\n const matchedFields1 = totalMatchedFields(f1);\n const matchedFields2 = totalMatchedFields(f2);\n if (matchedFields1 === matchedFields2) {\n if (f1.templateOptions.disabled === f2.templateOptions.disabled) {\n return 0;\n }\n\n return f1.templateOptions.disabled ? 1 : -1;\n }\n\n return matchedFields2 > matchedFields1 ? 1 : -1;\n })\n .map(([, i]) => i)\n ;\n\n if (mode === 'anyOf') {\n const definedValue = value.filter(i => totalMatchedFields(f.parent.fieldGroup[i]));\n value = definedValue.length > 0 ? definedValue : [value[0] || 0];\n }\n\n value = value.length > 0 ? value : [0];\n control.setValue(mode === 'anyOf' ? value : value[0]);\n }\n\n return Array.isArray(control.value)\n ? control.value.indexOf(i) === -1\n : control.value !== i;\n },\n })),\n },\n ],\n };\n }\n\n private resolveDefinition(schema: JSONSchema7, options: IOptions): JSONSchema7 {\n const [uri, pointer] = schema.$ref.split('#/');\n if (uri) {\n throw Error(`Remote schemas for ${schema.$ref} not supported yet.`);\n }\n\n const definition = !pointer ? null : pointer.split('/').reduce(\n (def, path) => def && def.hasOwnProperty(path) ? def[path] : null,\n options.schema,\n );\n\n if (!definition) {\n throw Error(`Cannot find a definition for ${schema.$ref}.`);\n }\n\n if (definition.$ref) {\n return this.resolveDefinition(definition, options);\n }\n\n return {\n ...definition,\n ...['title', 'description', 'default', 'widget'].reduce((annotation, p) => {\n if (schema.hasOwnProperty(p)) {\n annotation[p] = schema[p];\n }\n\n return annotation;\n }, {}),\n };\n }\n\n private resolveDependencies(schema: JSONSchema7) {\n const deps = {};\n const schemaDeps = {};\n\n Object.keys(schema.dependencies || {}).forEach(prop => {\n const dependency = schema.dependencies[prop] as JSONSchema7;\n if (Array.isArray(dependency)) {\n // Property dependencies\n dependency.forEach(dep => {\n if (!deps[dep]) {\n deps[dep] = [prop];\n } else {\n deps[dep].push(prop);\n }\n });\n } else {\n // schema dependencies\n schemaDeps[prop] = dependency;\n }\n });\n\n return [deps, schemaDeps];\n }\n\n private guessType(schema: JSONSchema7) {\n const type = schema ? schema.type as JSONSchema7TypeName : null;\n if (!type && schema && schema.properties) {\n return 'object';\n }\n\n if (Array.isArray(type)) {\n if (type.length === 1) {\n return type[0];\n }\n\n if (type.length === 2 && type.indexOf('null') !== -1) {\n return type[type[0] === 'null' ? 1 : 0];\n }\n }\n\n return type;\n }\n\n private addValidator(field: FormlyFieldConfig, name: string, validator: (control: AbstractControl) => boolean) {\n field.validators = field.validators || {};\n field.validators[name] = validator;\n }\n\n private isEnum(schema: JSONSchema7) {\n return schema.enum\n || (schema.anyOf && schema.anyOf.every(isConst))\n || (schema.oneOf && schema.oneOf.every(isConst))\n || schema.uniqueItems && schema.items && !Array.isArray(schema.items) && this.isEnum(<JSONSchema7> schema.items);\n }\n\n private toEnumOptions(schema: JSONSchema7) {\n if (schema.enum) {\n return schema.enum.map(value => ({ value, label: value }));\n }\n\n const toEnum = (s: JSONSchema7) => {\n const value = s.hasOwnProperty('const') ? s.const : s.enum[0];\n const option: any = { value: value, label: s.title || value };\n if (s.readOnly) {\n option.disabled = true;\n }\n\n return option;\n };\n\n if (schema.anyOf) {\n return schema.anyOf.map(toEnum);\n }\n\n if (schema.oneOf) {\n return schema.oneOf.map(toEnum);\n }\n\n return this.toEnumOptions(<JSONSchema7> schema.items);\n }\n\n private isFieldValid(field: FormlyFieldConfig, schema: JSONSchema7, options: IOptions): boolean {\n const { form } = (field.options as any)._buildField({\n form: new FormGroup({}),\n fieldGroup: [this._toFieldConfig(schema, { ...options, resetOnHide: true, ignoreDefault: true, map: null })],\n model: field.model ? clone(field.model) : (field.fieldArray ? [] : {}),\n });\n\n return form.valid;\n }\n\n private mergeFields(f1: FormlyFieldConfig, f2: FormlyFieldConfig) {\n for (let prop in f2) {\n if (isObject(f1[prop]) && isObject(f2[prop])) {\n f1[prop] = this.mergeFields(f1[prop], f2[prop]);\n } else if (f2[prop] != null) {\n f1[prop] = f2[prop];\n }\n }\n\n return f1;\n }\n}\n"],"names":["getFieldInitialValue","reverseDeepMerge"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAS,aAAa,CAAC,CAAS;IAC9B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;QAChB,OAAO,CAAC,CAAC;KACV;;QAEG,CAAC,GAAG,CAAC;;QAAE,CAAC,GAAG,CAAC;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,CAAC;QAAC,CAAC,EAAE,CAAC;KAAE;IAErD,OAAO,CAAC,CAAC;CACV;;;;;AAED,SAAS,OAAO,CAAC,CAAM;IACrB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;CAClD;;;;;AAED,SAAS,QAAQ,CAAC,CAAM;IACtB,OAAO,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CAChE;;;;;AAED,SAAS,OAAO,CAAC,MAAmB;IAClC,OAAO,MAAM,CAAC,cAAc,CAA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C,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;aACjD;iBAAM,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;gBAC3B,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;aACrB;SACF;QAED,OAAO,EAAE,CAAC;KACX;;gBAtfF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;2BA7DlC;CA6DA;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ngx-formly-core-json-schema.js.map","sources":["ng://@ngx-formly/core/json-schema/formly-json-schema.service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { FormlyFieldConfig } from '@ngx-formly/core';\nimport { JSONSchema7, JSONSchema7TypeName } from 'json-schema';\nimport { AbstractControl, FormGroup } from '@angular/forms';\nimport {\n ɵreverseDeepMerge as reverseDeepMerge,\n ɵgetFieldValue as getFieldValue,\n ɵclone as clone,\n} from '@ngx-formly/core';\nimport { tap } from 'rxjs/operators';\n\nexport interface FormlyJsonschemaOptions {\n /**\n * allows to intercept the mapping, taking the already mapped\n * formly field and the original JSONSchema source from which it\n * was mapped.\n */\n map?: (mappedField: FormlyFieldConfig, mapSource: JSONSchema7) => FormlyFieldConfig;\n}\n\n// https://stackoverflow.com/a/27865285\nfunction decimalPlaces(a: number) {\n if (!isFinite(a)) {\n return 0;\n }\n\n let e = 1, p = 0;\n while (Math.round(a * e) / e !== a) { e *= 10; p++; }\n\n return p;\n}\n\nfunction isEmpty(v: any) {\n return v === '' || v === undefined || v === null;\n}\n\nfunction isObject(v: any) {\n return v != null && typeof v === 'object' && !Array.isArray(v);\n}\n\nfunction isConst(schema: JSONSchema7) {\n return schema.hasOwnProperty('const') || (schema.enum && schema.enum.length === 1);\n}\n\nfunction totalMatchedFields(field: FormlyFieldConfig): number {\n if (!field.fieldGroup) {\n return field.key && getFieldValue(field) !== undefined ? 1 : 0;\n }\n\n const total = field.fieldGroup.reduce((s, f) => totalMatchedFields(f) + s, 0);\n return total === 0\n ? field.key && getFieldValue(field) !== undefined ? 1 : 0\n : total;\n}\n\ninterface IOptions extends FormlyJsonschemaOptions {\n schema: JSONSchema7;\n resetOnHide?: boolean;\n shareFormControl?: boolean;\n ignoreDefault?: boolean;\n readOnly?: boolean;\n key?: FormlyFieldConfig['key'];\n}\n\n@Injectable({ providedIn: 'root' })\nexport class FormlyJsonschema {\n toFieldConfig(schema: JSONSchema7, options?: FormlyJsonschemaOptions): FormlyFieldConfig {\n return this._toFieldConfig(schema, { schema, ...(options || {}) });\n }\n\n private _toFieldConfig(schema: JSONSchema7, { key, ...options }: IOptions): FormlyFieldConfig {\n schema = this.resolveSchema(schema, options);\n\n let field: FormlyFieldConfig = {\n type: this.guessType(schema),\n defaultValue: schema.default,\n templateOptions: {\n label: schema.title,\n readonly: schema.readOnly,\n description: schema.description,\n },\n };\n\n if (key != null) {\n field.key = key;\n }\n\n if (!options.ignoreDefault && (schema.readOnly || options.readOnly)) {\n field.templateOptions.disabled = true;\n options = { ...options, readOnly: true };\n }\n\n if (options.resetOnHide) {\n field['resetOnHide'] = true;\n }\n\n if (options.shareFormControl === false) {\n field['shareFormControl'] = false;\n }\n\n if (options.ignoreDefault) {\n delete field.defaultValue;\n }\n\n switch (field.type) {\n case 'null': {\n this.addValidator(field, 'null', ({ value }) => value === null);\n break;\n }\n case 'number':\n case 'integer': {\n field.parsers = [v => isEmpty(v) ? (v === '' ? null : v) : Number(v)];\n if (schema.hasOwnProperty('minimum')) {\n field.templateOptions.min = schema.minimum;\n }\n\n if (schema.hasOwnProperty('maximum')) {\n field.templateOptions.max = schema.maximum;\n }\n\n if (schema.hasOwnProperty('exclusiveMinimum')) {\n field.templateOptions.exclusiveMinimum = schema.exclusiveMinimum;\n this.addValidator(field, 'exclusiveMinimum', ({ value }) => isEmpty(value) || (value > schema.exclusiveMinimum));\n }\n\n if (schema.hasOwnProperty('exclusiveMaximum')) {\n field.templateOptions.exclusiveMaximum = schema.exclusiveMaximum;\n this.addValidator(field, 'exclusiveMaximum', ({ value }) => isEmpty(value) || (value < schema.exclusiveMaximum));\n }\n\n if (schema.hasOwnProperty('multipleOf')) {\n field.templateOptions.step = schema.multipleOf;\n this.addValidator(field, 'multipleOf', ({ value }) => {\n if (isEmpty(value) || typeof value !== 'number' || value === 0 || schema.multipleOf <= 0) {\n return true;\n }\n\n // https://github.com/ajv-validator/ajv/issues/652#issue-283610859\n const multiplier = Math.pow(10, decimalPlaces(schema.multipleOf));\n return Math.round(value * multiplier) % Math.round(schema.multipleOf * multiplier) === 0;\n });\n }\n break;\n }\n case 'string': {\n const schemaType = schema.type as JSONSchema7TypeName;\n if (Array.isArray(schemaType) && (schemaType.indexOf('null') !== -1)) {\n field.parsers = [v => isEmpty(v) ? null : v];\n }\n\n ['minLength', 'maxLength', 'pattern'].forEach(prop => {\n if (schema.hasOwnProperty(prop)) {\n field.templateOptions[prop] = schema[prop];\n }\n });\n break;\n }\n case 'object': {\n field.fieldGroup = [];\n\n const [propDeps, schemaDeps] = this.resolveDependencies(schema);\n Object.keys(schema.properties || {}).forEach(property => {\n const f = this._toFieldConfig(<JSONSchema7> schema.properties[property], { ...options, key: property });\n field.fieldGroup.push(f);\n if (\n (Array.isArray(schema.required) && schema.required.indexOf(property) !== -1)\n || propDeps[property]\n ) {\n f.expressionProperties = {\n ...(f.expressionProperties || {}),\n 'templateOptions.required': (m, s, f) => {\n let parent = f.parent;\n const model = f.fieldGroup && f.key != null ? parent.model : f.model;\n while (parent.key == null && parent.parent) {\n parent = parent.parent;\n }\n\n const required = parent && parent.templateOptions ? parent.templateOptions.required : false;\n if (!model && !required) {\n return false;\n }\n\n if (Array.isArray(schema.required) && schema.required.indexOf(property) !== -1) {\n return true;\n }\n\n return propDeps[property] && (m && propDeps[property].some(k => !isEmpty(m[k])));\n },\n };\n }\n\n if (schemaDeps[property]) {\n const getConstValue = (s: JSONSchema7) => {\n return s.hasOwnProperty('const') ? s.const : s.enum[0];\n };\n\n const oneOfSchema = schemaDeps[property].oneOf;\n if (\n oneOfSchema\n && oneOfSchema.every(o => o.properties && o.properties[property] && isConst(o.properties[property]))\n ) {\n oneOfSchema.forEach(oneOfSchemaItem => {\n const { [property]: constSchema, ...properties } = oneOfSchemaItem.properties;\n field.fieldGroup.push({\n ...this._toFieldConfig({ ...oneOfSchemaItem, properties }, { ...options, resetOnHide: true }),\n hideExpression: m => !m || getConstValue(constSchema) !== m[property],\n });\n });\n } else {\n field.fieldGroup.push({\n ...this._toFieldConfig(schemaDeps[property], options),\n hideExpression: m => !m || isEmpty(m[property]),\n });\n }\n\n }\n });\n\n if (schema.oneOf) {\n field.fieldGroup.push(this.resolveMultiSchema(\n 'oneOf',\n <JSONSchema7[]> schema.oneOf,\n { ...options, shareFormControl: false },\n ));\n }\n\n if (schema.anyOf) {\n field.fieldGroup.push(this.resolveMultiSchema(\n 'anyOf',\n <JSONSchema7[]> schema.anyOf,\n options,\n ));\n }\n break;\n }\n case 'array': {\n if (schema.hasOwnProperty('minItems')) {\n field.templateOptions.minItems = schema.minItems;\n this.addValidator(field, 'minItems', ({ value }) => isEmpty(value) || (value.length >= schema.minItems));\n }\n if (schema.hasOwnProperty('maxItems')) {\n field.templateOptions.maxItems = schema.maxItems;\n this.addValidator(field, 'maxItems', ({ value }) => isEmpty(value) || (value.length <= schema.maxItems));\n }\n if (schema.hasOwnProperty('uniqueItems')) {\n field.templateOptions.uniqueItems = schema.uniqueItems;\n this.addValidator(field, 'uniqueItems', ({ value }) => {\n if (isEmpty(value) || !schema.uniqueItems) {\n return true;\n }\n\n const uniqueItems = Array.from(\n new Set(value.map((v: any) => JSON.stringify(v))),\n );\n\n return uniqueItems.length === value.length;\n });\n }\n\n // resolve items schema needed for isEnum check\n if (schema.items && !Array.isArray(schema.items)) {\n schema.items = this.resolveSchema(<JSONSchema7> schema.items, options);\n }\n\n // TODO: remove isEnum check once adding an option to skip extension\n if (!this.isEnum(schema)) {\n const _this = this;\n Object.defineProperty(field, 'fieldArray', {\n get: function () {\n if (schema.items && !Array.isArray(schema.items)) {\n // When items is a single schema, the additionalItems keyword is meaningless, and it should not be used.\n return _this._toFieldConfig(<JSONSchema7> schema.items, options);\n }\n\n const length = this.fieldGroup ? this.fieldGroup.length : 0;\n if (schema.items && schema.items[length]) {\n const f = _this._toFieldConfig(<JSONSchema7> schema.items[length], { ...options});\n f.templateOptions.removable = false;\n\n return f;\n }\n\n return schema.additionalItems\n ? _this._toFieldConfig(<JSONSchema7> schema.additionalItems, options)\n : {};\n },\n enumerable: true,\n configurable: true,\n });\n }\n\n break;\n }\n }\n\n if (schema.hasOwnProperty('const')) {\n field.templateOptions.const = schema.const;\n this.addValidator(field, 'const', ({ value }) => value === schema.const);\n if (!field.type) {\n field.defaultValue = schema.const;\n }\n }\n\n if (this.isEnum(schema)) {\n field.templateOptions.multiple = field.type === 'array';\n field.type = 'enum';\n field.templateOptions.options = this.toEnumOptions(schema);\n }\n\n // map in possible formlyConfig options from the widget property\n if (schema['widget'] && schema['widget'].formlyConfig) {\n field = this.mergeFields(field, schema['widget'].formlyConfig);\n }\n\n // if there is a map function passed in, use it to allow the user to\n // further customize how fields are being mapped\n return options.map ? options.map(field, schema) : field;\n }\n\n private resolveSchema(schema: JSONSchema7, options: IOptions) {\n if (schema && schema.$ref) {\n schema = this.resolveDefinition(schema, options);\n }\n\n if (schema && schema.allOf) {\n schema = this.resolveAllOf(schema, options);\n }\n\n return schema;\n }\n\n private resolveAllOf({ allOf, ...baseSchema }: JSONSchema7, options: IOptions) {\n if (!allOf.length) {\n throw Error(`allOf array can not be empty ${allOf}.`);\n }\n\n return allOf.reduce((base: JSONSchema7, schema: JSONSchema7) => {\n schema = this.resolveSchema(schema, options);\n if (base.required && schema.required) {\n base.required = [...base.required, ...schema.required];\n }\n\n if (schema.uniqueItems) {\n base.uniqueItems = schema.uniqueItems;\n }\n\n // resolve to min value\n ['maxLength', 'maximum', 'exclusiveMaximum', 'maxItems', 'maxProperties']\n .forEach(prop => {\n if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {\n base[prop] = base[prop] < schema[prop] ? base[prop] : schema[prop];\n }\n });\n\n // resolve to max value\n ['minLength', 'minimum', 'exclusiveMinimum', 'minItems', 'minProperties']\n .forEach(prop => {\n if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {\n base[prop] = base[prop] > schema[prop] ? base[prop] : schema[prop];\n }\n });\n\n return reverseDeepMerge(base, schema);\n }, baseSchema);\n }\n\n private resolveMultiSchema(\n mode: 'oneOf' | 'anyOf',\n schemas: JSONSchema7[],\n options: IOptions,\n ): FormlyFieldConfig {\n return {\n type: 'multischema',\n fieldGroup: [\n {\n type: 'enum',\n defaultValue: -1,\n templateOptions: {\n multiple: mode === 'anyOf',\n options: schemas\n .map((s, i) => ({ label: s.title, value: i, disabled: s.readOnly })),\n },\n hooks: {\n onInit: f => f.formControl.valueChanges.pipe(\n tap(() => (f.options as any)._checkField(f.parent)),\n ),\n },\n },\n {\n fieldGroup: schemas.map((s, i) => ({\n ...this._toFieldConfig(s, { ...options, resetOnHide: true }),\n hideExpression: (m, fs, f, forceUpdate?: boolean) => {\n const control = f.parent.parent.fieldGroup[0].formControl;\n if ((control.value === -1) || forceUpdate) {\n let value = f.parent.fieldGroup\n .map((f, i) => [f, i] as [FormlyFieldConfig, number])\n .filter(([f, i]) => {\n return this.isFieldValid(f, schemas[i], options);\n })\n .sort(([f1], [f2]) => {\n const matchedFields1 = totalMatchedFields(f1);\n const matchedFields2 = totalMatchedFields(f2);\n if (matchedFields1 === matchedFields2) {\n if (f1.templateOptions.disabled === f2.templateOptions.disabled) {\n return 0;\n }\n\n return f1.templateOptions.disabled ? 1 : -1;\n }\n\n return matchedFields2 > matchedFields1 ? 1 : -1;\n })\n .map(([, i]) => i)\n ;\n\n if (mode === 'anyOf') {\n const definedValue = value.filter(i => totalMatchedFields(f.parent.fieldGroup[i]));\n value = definedValue.length > 0 ? definedValue : [value[0] || 0];\n }\n\n value = value.length > 0 ? value : [0];\n control.setValue(mode === 'anyOf' ? value : value[0]);\n }\n\n return Array.isArray(control.value)\n ? control.value.indexOf(i) === -1\n : control.value !== i;\n },\n })),\n },\n ],\n };\n }\n\n private resolveDefinition(schema: JSONSchema7, options: IOptions): JSONSchema7 {\n const [uri, pointer] = schema.$ref.split('#/');\n if (uri) {\n throw Error(`Remote schemas for ${schema.$ref} not supported yet.`);\n }\n\n const definition = !pointer ? null : pointer.split('/').reduce(\n (def, path) => def && def.hasOwnProperty(path) ? def[path] : null,\n options.schema,\n );\n\n if (!definition) {\n throw Error(`Cannot find a definition for ${schema.$ref}.`);\n }\n\n if (definition.$ref) {\n return this.resolveDefinition(definition, options);\n }\n\n return {\n ...definition,\n ...['title', 'description', 'default', 'widget'].reduce((annotation, p) => {\n if (schema.hasOwnProperty(p)) {\n annotation[p] = schema[p];\n }\n\n return annotation;\n }, {}),\n };\n }\n\n private resolveDependencies(schema: JSONSchema7) {\n const deps = {};\n const schemaDeps = {};\n\n Object.keys(schema.dependencies || {}).forEach(prop => {\n const dependency = schema.dependencies[prop] as JSONSchema7;\n if (Array.isArray(dependency)) {\n // Property dependencies\n dependency.forEach(dep => {\n if (!deps[dep]) {\n deps[dep] = [prop];\n } else {\n deps[dep].push(prop);\n }\n });\n } else {\n // schema dependencies\n schemaDeps[prop] = dependency;\n }\n });\n\n return [deps, schemaDeps];\n }\n\n private guessType(schema: JSONSchema7) {\n const type = schema ? schema.type as JSONSchema7TypeName : null;\n if (!type && schema && schema.properties) {\n return 'object';\n }\n\n if (Array.isArray(type)) {\n if (type.length === 1) {\n return type[0];\n }\n\n if (type.length === 2 && type.indexOf('null') !== -1) {\n return type[type[0] === 'null' ? 1 : 0];\n }\n }\n\n return type;\n }\n\n private addValidator(field: FormlyFieldConfig, name: string, validator: (control: AbstractControl) => boolean) {\n field.validators = field.validators || {};\n field.validators[name] = validator;\n }\n\n private isEnum(schema: JSONSchema7) {\n return schema.enum\n || (schema.anyOf && schema.anyOf.every(isConst))\n || (schema.oneOf && schema.oneOf.every(isConst))\n || schema.uniqueItems && schema.items && !Array.isArray(schema.items) && this.isEnum(<JSONSchema7> schema.items);\n }\n\n private toEnumOptions(schema: JSONSchema7) {\n if (schema.enum) {\n return schema.enum.map(value => ({ value, label: value }));\n }\n\n const toEnum = (s: JSONSchema7) => {\n const value = s.hasOwnProperty('const') ? s.const : s.enum[0];\n const option: any = { value: value, label: s.title || value };\n if (s.readOnly) {\n option.disabled = true;\n }\n\n return option;\n };\n\n if (schema.anyOf) {\n return schema.anyOf.map(toEnum);\n }\n\n if (schema.oneOf) {\n return schema.oneOf.map(toEnum);\n }\n\n return this.toEnumOptions(<JSONSchema7> schema.items);\n }\n\n private isFieldValid(field: FormlyFieldConfig, schema: JSONSchema7, options: IOptions): boolean {\n const { form } = (field.options as any)._buildField({\n form: new FormGroup({}),\n fieldGroup: [this._toFieldConfig(schema, { ...options, resetOnHide: true, ignoreDefault: true, map: null })],\n model: field.model ? clone(field.model) : (field.fieldArray ? [] : {}),\n });\n\n return form.valid;\n }\n\n private mergeFields(f1: FormlyFieldConfig, f2: FormlyFieldConfig) {\n for (let prop in f2) {\n if (isObject(f1[prop]) && isObject(f2[prop])) {\n f1[prop] = this.mergeFields(f1[prop], f2[prop]);\n } else if (f2[prop] != null) {\n f1[prop] = f2[prop];\n }\n }\n\n return f1;\n }\n}\n"],"names":["getFieldValue","reverseDeepMerge"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAS,aAAa,CAAC,CAAS;IAC9B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;QAChB,OAAO,CAAC,CAAC;KACV;;QAEG,CAAC,GAAG,CAAC;;QAAE,CAAC,GAAG,CAAC;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,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AC;SACjC;QAED,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SACjC;QAED,OAAO,IAAI,CAAC,aAAa,oBAAe,MAAM,CAAC,KAAK,GAAC,CAAC;KACvD;;;;;;;;IAEO,uCAAY;;;;;;;IAApB,UAAqB,KAAwB,EAAE,MAAmB,EAAE,OAAiB;QAC3E,IAAA;;;;eAAI;QAMZ,OAAO,IAAI,CAAC,KAAK,CAAC;KACnB;;;;;;;IAEO,sCAAW;;;;;;IAAnB,UAAoB,EAAqB,EAAE,EAAqB;QAC9D,KAAK,IAAI,IAAI,IAAI,EAAE,EAAE;YACnB,IAAI,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;gBAC5C,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;aACjD;iBAAM,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;gBAC3B,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;aACrB;SACF;QAED,OAAO,EAAE,CAAC;KACX;;gBAtfF,UAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;2BAhElC;CAgEA;;;;;;;;;;;;;;"}
@@ -1,15 +1,30 @@
1
1
  import { DOCUMENT, CommonModule } from '@angular/common';
2
2
  import { TemplateRef, Injectable, InjectionToken, NgModule, ANALYZE_FOR_ENTRY_COMPONENTS, Inject, Optional, Component, Input, ChangeDetectionStrategy, ComponentFactoryResolver, Injector, ChangeDetectorRef, Directive, EventEmitter, NgZone, Attribute, Output, ViewChild, Renderer2, ElementRef, ViewContainerRef, defineInjectable, inject, INJECTOR } from '@angular/core';
3
3
  import { DomSanitizer } from '@angular/platform-browser';
4
- import { debounceTime, switchMap, distinctUntilChanged, take, startWith, map } from 'rxjs/operators';
4
+ import { debounceTime, switchMap, distinctUntilChanged, take, startWith, filter, map } from 'rxjs/operators';
5
5
  import { AbstractControl, FormArray, FormGroup, FormControl, FormGroupDirective, Validators } from '@angular/forms';
6
- import { isObservable, Subject, of, Observable } from 'rxjs';
6
+ import { isObservable, Subject, of, merge, Observable } from 'rxjs';
7
7
  import { __extends, __assign, __spread, __rest, __values, __read } from 'tslib';
8
8
 
9
9
  /**
10
10
  * @fileoverview added by tsickle
11
11
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
12
12
  */
13
+ /**
14
+ * @param {?} form
15
+ * @param {?} callback
16
+ * @return {?}
17
+ */
18
+ function disableTreeValidityCall(form, callback) {
19
+ /** @type {?} */
20
+ var _updateTreeValidity = form._updateTreeValidity.bind(form);
21
+ form._updateTreeValidity = (/**
22
+ * @return {?}
23
+ */
24
+ function () { });
25
+ callback();
26
+ form._updateTreeValidity = _updateTreeValidity;
27
+ }
13
28
  /**
14
29
  * @param {?} formId
15
30
  * @param {?} field
@@ -21,8 +36,12 @@ function getFieldId(formId, field, index) {
21
36
  return field.id;
22
37
  /** @type {?} */
23
38
  var type = field.type;
24
- if (!type && field.template)
39
+ if (!type && field.template) {
25
40
  type = 'template';
41
+ }
42
+ if (isFunction(type)) {
43
+ type = ((/** @type {?} */ (type))).prototype.constructor.name;
44
+ }
26
45
  return [formId, type, field.key, index].join('_');
27
46
  }
28
47
  /**
@@ -105,44 +124,12 @@ function assignModelValue(model, paths, value) {
105
124
  }
106
125
  model[paths[paths.length - 1]] = clone(value);
107
126
  }
108
- /**
109
- * @param {?} field
110
- * @return {?}
111
- */
112
- function getFieldInitialValue(field) {
113
- var e_1, _a;
114
- /** @type {?} */
115
- var value = field.options['_initialModel'];
116
- /** @type {?} */
117
- var paths = getKeyPath(field);
118
- while (field.parent) {
119
- field = field.parent;
120
- paths = __spread(getKeyPath(field), paths);
121
- }
122
- try {
123
- for (var paths_1 = __values(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) {
124
- var path = paths_1_1.value;
125
- if (!value) {
126
- return undefined;
127
- }
128
- value = value[path];
129
- }
130
- }
131
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
132
- finally {
133
- try {
134
- if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return)) _a.call(paths_1);
135
- }
136
- finally { if (e_1) throw e_1.error; }
137
- }
138
- return value;
139
- }
140
127
  /**
141
128
  * @param {?} field
142
129
  * @return {?}
143
130
  */
144
131
  function getFieldValue(field) {
145
- var e_2, _a;
132
+ var e_1, _a;
146
133
  /** @type {?} */
147
134
  var model = field.parent.model;
148
135
  try {
@@ -154,12 +141,12 @@ function getFieldValue(field) {
154
141
  model = model[path];
155
142
  }
156
143
  }
157
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
144
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
158
145
  finally {
159
146
  try {
160
147
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
161
148
  }
162
- finally { if (e_2) throw e_2.error; }
149
+ finally { if (e_1) throw e_1.error; }
163
150
  }
164
151
  return model;
165
152
  }
@@ -363,28 +350,6 @@ function wrapProperty(o, prop, setFn) {
363
350
  */
364
351
  function () { return fns.splice(fns.indexOf(setFn), 1); });
365
352
  }
366
- /**
367
- * @param {?} form
368
- * @param {?} action
369
- * @return {?}
370
- */
371
- function reduceFormUpdateValidityCalls(form, action) {
372
- /** @type {?} */
373
- var updateValidity = form._updateTreeValidity.bind(form);
374
- /** @type {?} */
375
- var updateValidityArgs = { called: false, emitEvent: false };
376
- form._updateTreeValidity = (/**
377
- * @param {?=} __0
378
- * @return {?}
379
- */
380
- function (_a) {
381
- var emitEvent = (_a === void 0 ? { emitEvent: true } : _a).emitEvent;
382
- return updateValidityArgs = { called: true, emitEvent: emitEvent || updateValidityArgs.emitEvent };
383
- });
384
- action();
385
- updateValidityArgs.called && updateValidity({ emitEvent: updateValidityArgs.emitEvent });
386
- form._updateTreeValidity = updateValidity;
387
- }
388
353
 
389
354
  /**
390
355
  * @fileoverview added by tsickle
@@ -773,7 +738,7 @@ var FormlyFormBuilder = /** @class */ (function () {
773
738
  }
774
739
  /** @type {?} */
775
740
  var field = { fieldGroup: fieldGroup, model: model, formControl: formControl, options: this._setOptions(options) };
776
- reduceFormUpdateValidityCalls(formControl, (/**
741
+ disableTreeValidityCall(formControl, (/**
777
742
  * @return {?}
778
743
  */
779
744
  function () { return _this._buildForm(field); }));
@@ -1060,15 +1025,22 @@ function registerControl(field, control, emitEvent) {
1060
1025
  }
1061
1026
  /**
1062
1027
  * @param {?} c
1028
+ * @param {?=} onlySelf
1063
1029
  * @return {?}
1064
1030
  */
1065
- function updateValidity(c) {
1031
+ function updateValidity(c, onlySelf) {
1032
+ if (onlySelf === void 0) { onlySelf = false; }
1066
1033
  /** @type {?} */
1067
1034
  var status = c.status;
1068
- c.updateValueAndValidity({ emitEvent: false });
1035
+ /** @type {?} */
1036
+ var value = c.value;
1037
+ c.updateValueAndValidity({ emitEvent: false, onlySelf: onlySelf });
1069
1038
  if (status !== c.status) {
1070
1039
  ((/** @type {?} */ (c.statusChanges))).emit(c.status);
1071
1040
  }
1041
+ if (value !== c.value) {
1042
+ ((/** @type {?} */ (c.valueChanges))).emit(c.value);
1043
+ }
1072
1044
  }
1073
1045
  /**
1074
1046
  * @param {?} form
@@ -1892,16 +1864,11 @@ var FormlyField = /** @class */ (function () {
1892
1864
  */
1893
1865
  var FormlyAttributes = /** @class */ (function () {
1894
1866
  function FormlyAttributes(renderer, elementRef, _document) {
1867
+ var _this = this;
1895
1868
  this.renderer = renderer;
1896
1869
  this.elementRef = elementRef;
1897
1870
  this.uiAttributesCache = {};
1898
- this.uiAttributes = __spread(FORMLY_VALIDATORS, [
1899
- 'tabindex',
1900
- 'placeholder',
1901
- 'readonly',
1902
- 'disabled',
1903
- 'step',
1904
- ]);
1871
+ this.uiAttributes = null;
1905
1872
  /**
1906
1873
  * HostBinding doesn't register listeners conditionally which may produce some perf issues.
1907
1874
  *
@@ -1909,12 +1876,24 @@ var FormlyAttributes = /** @class */ (function () {
1909
1876
  */
1910
1877
  this.uiEvents = {
1911
1878
  listeners: [],
1912
- events: [
1913
- 'click',
1914
- 'keyup',
1915
- 'keydown',
1916
- 'keypress',
1917
- ],
1879
+ events: ['click', 'keyup', 'keydown', 'keypress', 'focus', 'blur', 'change'],
1880
+ callback: (/**
1881
+ * @param {?} eventName
1882
+ * @param {?} $event
1883
+ * @return {?}
1884
+ */
1885
+ function (eventName, $event) {
1886
+ switch (eventName) {
1887
+ case 'focus':
1888
+ return _this.onFocus($event);
1889
+ case 'blur':
1890
+ return _this.onBlur($event);
1891
+ case 'change':
1892
+ return _this.onChange($event);
1893
+ default:
1894
+ return _this.to[eventName](_this.field, $event);
1895
+ }
1896
+ }),
1918
1897
  };
1919
1898
  this.document = _document;
1920
1899
  }
@@ -1957,12 +1936,12 @@ var FormlyAttributes = /** @class */ (function () {
1957
1936
  * @return {?}
1958
1937
  */
1959
1938
  function (eventName) {
1960
- if (_this.to && _this.to[eventName]) {
1939
+ if ((_this.to && _this.to[eventName]) || ['focus', 'blur', 'change'].indexOf(eventName) !== -1) {
1961
1940
  _this.uiEvents.listeners.push(_this.renderer.listen(_this.elementRef.nativeElement, eventName, (/**
1962
1941
  * @param {?} e
1963
1942
  * @return {?}
1964
1943
  */
1965
- function (e) { return _this.to[eventName](_this.field, e); })));
1944
+ function (e) { return _this.uiEvents.callback(eventName, e); })));
1966
1945
  }
1967
1946
  }));
1968
1947
  if (this.to && this.to.attributes) {
@@ -2038,6 +2017,15 @@ var FormlyAttributes = /** @class */ (function () {
2038
2017
  */
2039
2018
  function () {
2040
2019
  var _this = this;
2020
+ if (!this.uiAttributes) {
2021
+ /** @type {?} */
2022
+ var element_1 = (/** @type {?} */ (this.elementRef.nativeElement));
2023
+ this.uiAttributes = __spread(FORMLY_VALIDATORS, ['tabindex', 'placeholder', 'readonly', 'disabled', 'step']).filter((/**
2024
+ * @param {?} attr
2025
+ * @return {?}
2026
+ */
2027
+ function (attr) { return !element_1.hasAttribute || !element_1.hasAttribute(attr); }));
2028
+ }
2041
2029
  this.uiAttributes.forEach((/**
2042
2030
  * @param {?} attr
2043
2031
  * @return {?}
@@ -2217,11 +2205,6 @@ var FormlyAttributes = /** @class */ (function () {
2217
2205
  FormlyAttributes.decorators = [
2218
2206
  { type: Directive, args: [{
2219
2207
  selector: '[formlyAttributes]',
2220
- host: {
2221
- '(focus)': 'onFocus($event)',
2222
- '(blur)': 'onBlur($event)',
2223
- '(change)': 'onChange($event)',
2224
- },
2225
2208
  },] }
2226
2209
  ];
2227
2210
  /** @nocollapse */
@@ -2538,7 +2521,18 @@ var FormlyValidationMessage = /** @class */ (function () {
2538
2521
  */
2539
2522
  function () {
2540
2523
  var _this = this;
2541
- this.errorMessage$ = this.field.formControl.statusChanges.pipe(startWith(null), switchMap((/**
2524
+ this.errorMessage$ = merge(this.field.formControl.statusChanges, (!this.field.options
2525
+ ? of(null)
2526
+ : this.field.options.fieldChanges.pipe(filter((/**
2527
+ * @param {?} __0
2528
+ * @return {?}
2529
+ */
2530
+ function (_a) {
2531
+ var field = _a.field, type = _a.type, property = _a.property;
2532
+ return (field === _this.field)
2533
+ && (type === 'expressionChanges')
2534
+ && (property.indexOf('validation') !== -1);
2535
+ }))))).pipe(startWith(null), switchMap((/**
2542
2536
  * @return {?}
2543
2537
  */
2544
2538
  function () { return isObservable(_this.errorMessage)
@@ -2714,10 +2708,7 @@ FieldExpressionExtension = /** @class */ (function () {
2714
2708
  function (f, ignoreCache) {
2715
2709
  if (!checkLocked) {
2716
2710
  checkLocked = true;
2717
- reduceFormUpdateValidityCalls(f.formControl, (/**
2718
- * @return {?}
2719
- */
2720
- function () { return _this.checkField(f, ignoreCache); }));
2711
+ _this.checkField(f, ignoreCache);
2721
2712
  checkLocked = false;
2722
2713
  }
2723
2714
  });
@@ -3519,22 +3510,7 @@ FieldFormExtension = /** @class */ (function () {
3519
3510
  if (field.parent) {
3520
3511
  return;
3521
3512
  }
3522
- /** @type {?} */
3523
- var fieldsToUpdate = this.setValidators(field);
3524
- if (fieldsToUpdate.length === 0) {
3525
- return;
3526
- }
3527
- if (fieldsToUpdate.length === 1) {
3528
- /** @type {?} */
3529
- var control = fieldsToUpdate[0].formControl;
3530
- while (control) {
3531
- ((/** @type {?} */ (control)))._updateTreeValidity({ onlySelf: true });
3532
- control = control.parent;
3533
- }
3534
- }
3535
- else {
3536
- ((/** @type {?} */ (field.formControl)))._updateTreeValidity();
3537
- }
3513
+ this.setValidators(field);
3538
3514
  };
3539
3515
  /**
3540
3516
  * @private
@@ -3575,39 +3551,39 @@ FieldFormExtension = /** @class */ (function () {
3575
3551
  /**
3576
3552
  * @private
3577
3553
  * @param {?} field
3554
+ * @param {?=} disabled
3578
3555
  * @return {?}
3579
3556
  */
3580
3557
  FieldFormExtension.prototype.setValidators = /**
3581
3558
  * @private
3582
3559
  * @param {?} field
3560
+ * @param {?=} disabled
3583
3561
  * @return {?}
3584
3562
  */
3585
- function (field) {
3563
+ function (field, disabled) {
3586
3564
  var _this = this;
3565
+ if (disabled === void 0) { disabled = false; }
3587
3566
  /** @type {?} */
3588
- var updateValidity$$1 = false;
3567
+ var markForCheck = false;
3568
+ if (disabled === false && field.key && field.templateOptions && field.templateOptions.disabled) {
3569
+ disabled = true;
3570
+ }
3571
+ (field.fieldGroup || []).forEach((/**
3572
+ * @param {?} f
3573
+ * @return {?}
3574
+ */
3575
+ function (f) { return _this.setValidators(f, disabled) && (markForCheck = true); }));
3589
3576
  if (field.key || !field.parent || (!field.key && !field.fieldGroup)) {
3590
3577
  var c_1 = field.formControl;
3591
- /** @type {?} */
3592
- var disabled = field.templateOptions ? field.templateOptions.disabled : false;
3593
- if (field.key && c_1) {
3578
+ field.templateOptions = field.templateOptions || {};
3579
+ if (field.key && c_1 && c_1 instanceof FormControl) {
3594
3580
  if (disabled && c_1.enabled) {
3595
3581
  c_1.disable({ emitEvent: false, onlySelf: true });
3596
- if (!c_1.parent) {
3597
- updateValidity(c_1);
3598
- }
3599
- else {
3600
- updateValidity$$1 = true;
3601
- }
3582
+ markForCheck = true;
3602
3583
  }
3603
3584
  if (!disabled && c_1.disabled) {
3604
3585
  c_1.enable({ emitEvent: false, onlySelf: true });
3605
- if (!c_1.parent) {
3606
- updateValidity(c_1);
3607
- }
3608
- else {
3609
- updateValidity$$1 = true;
3610
- }
3586
+ markForCheck = true;
3611
3587
  }
3612
3588
  }
3613
3589
  if (c_1 && (null === c_1.validator || null === c_1.asyncValidator)) {
@@ -3627,28 +3603,13 @@ FieldFormExtension = /** @class */ (function () {
3627
3603
  var v = Validators.composeAsync(_this.mergeValidators(field, '_asyncValidators'));
3628
3604
  return v ? v(c_1) : of(null);
3629
3605
  }));
3630
- if (!c_1.parent) {
3631
- updateValidity(c_1);
3632
- }
3633
- else {
3634
- updateValidity$$1 = true;
3635
- }
3606
+ markForCheck = true;
3636
3607
  }
3637
- }
3638
- /** @type {?} */
3639
- var fieldsToUpdate = updateValidity$$1 ? [field] : [];
3640
- (field.fieldGroup || []).forEach((/**
3641
- * @param {?} f
3642
- * @return {?}
3643
- */
3644
- function (f) {
3645
- /** @type {?} */
3646
- var childrenToUpdate = _this.setValidators(f);
3647
- if (!updateValidity$$1) {
3648
- fieldsToUpdate.push.apply(fieldsToUpdate, __spread(childrenToUpdate));
3608
+ if (markForCheck) {
3609
+ updateValidity(c_1, true);
3649
3610
  }
3650
- }));
3651
- return fieldsToUpdate;
3611
+ }
3612
+ return markForCheck;
3652
3613
  };
3653
3614
  /**
3654
3615
  * @private
@@ -3826,6 +3787,7 @@ CoreExtension = /** @class */ (function () {
3826
3787
  id: getFieldId("formly_" + this.formId, field, field['index']),
3827
3788
  hooks: {},
3828
3789
  modelOptions: {},
3790
+ validation: { messages: {} },
3829
3791
  templateOptions: !field.type || !field.key ? {} : {
3830
3792
  label: '',
3831
3793
  placeholder: '',
@@ -4058,6 +4020,6 @@ var FormlyModule = /** @class */ (function () {
4058
4020
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4059
4021
  */
4060
4022
 
4061
- export { FormlyForm, FormlyField, FormlyAttributes, FORMLY_CONFIG, FormlyConfig, FormlyFormBuilder, FieldType, Field, FieldArrayType, FieldWrapper, FormlyModule, defineHiddenProp as ɵdefineHiddenProp, reverseDeepMerge as ɵreverseDeepMerge, getFieldInitialValue as ɵgetFieldInitialValue, clone as ɵclone, wrapProperty as ɵwrapProperty, defaultFormlyConfig as ɵa, CoreExtension as ɵe, FieldExpressionExtension as ɵh, FieldFormExtension as ɵg, FieldValidationExtension as ɵf, FormlyTemplateType as ɵd, FormlyGroup as ɵb, FormlyValidationMessage as ɵc };
4023
+ export { FormlyForm, FormlyField, FormlyAttributes, FORMLY_CONFIG, FormlyConfig, FormlyFormBuilder, FieldType, Field, FieldArrayType, FieldWrapper, FormlyModule, defineHiddenProp as ɵdefineHiddenProp, reverseDeepMerge as ɵreverseDeepMerge, getFieldValue as ɵgetFieldValue, clone as ɵclone, wrapProperty as ɵwrapProperty, defaultFormlyConfig as ɵa, CoreExtension as ɵe, FieldExpressionExtension as ɵh, FieldFormExtension as ɵg, FieldValidationExtension as ɵf, FormlyTemplateType as ɵd, FormlyGroup as ɵb, FormlyValidationMessage as ɵc };
4062
4024
 
4063
4025
  //# sourceMappingURL=ngx-formly-core.js.map