@ngx-formly/core 5.11.2 → 5.12.0

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.
@@ -109,6 +109,13 @@
109
109
  function isObject(v) {
110
110
  return v != null && typeof v === 'object' && !Array.isArray(v);
111
111
  }
112
+ /**
113
+ * @param {?} value
114
+ * @return {?}
115
+ */
116
+ function isInteger(value) {
117
+ return Number.isInteger ? Number.isInteger(value) : typeof value === 'number' && Math.floor(value) === value;
118
+ }
112
119
  /**
113
120
  * @param {?} schema
114
121
  * @return {?}
@@ -130,9 +137,17 @@
130
137
  * @param {?} f
131
138
  * @return {?}
132
139
  */function (s, f) { return totalMatchedFields(f) + s; }), 0);
133
- return total === 0
134
- ? field.key && core.ɵgetFieldValue(field) !== undefined ? 1 : 0
135
- : total;
140
+ if (total === 0 && field.key) {
141
+ /** @type {?} */
142
+ var value = core.ɵgetFieldValue(field);
143
+ if (value === null
144
+ || ((value !== undefined)
145
+ && ((field.fieldArray && Array.isArray(value))
146
+ || (!field.fieldArray && isObject(value))))) {
147
+ return 1;
148
+ }
149
+ }
150
+ return total;
136
151
  }
137
152
  var FormlyJsonschema = /** @class */ (function () {
138
153
  function FormlyJsonschema() {
@@ -186,6 +201,36 @@
186
201
  if (options.resetOnHide) {
187
202
  field['resetOnHide'] = true;
188
203
  }
204
+ if (key && options.strict) {
205
+ this.addValidator(field, 'type', ( /**
206
+ * @param {?} c
207
+ * @param {?} f
208
+ * @return {?}
209
+ */function (c, f) {
210
+ /** @type {?} */
211
+ var value = core.ɵgetFieldValue(f);
212
+ if (value != null) {
213
+ switch (field.type) {
214
+ case 'string': {
215
+ return typeof value === 'string';
216
+ }
217
+ case 'integer': {
218
+ return isInteger(value);
219
+ }
220
+ case 'number': {
221
+ return typeof value === 'number';
222
+ }
223
+ case 'object': {
224
+ return isObject(value);
225
+ }
226
+ case 'array': {
227
+ return Array.isArray(value);
228
+ }
229
+ }
230
+ }
231
+ return true;
232
+ }));
233
+ }
189
234
  if (options.shareFormControl === false) {
190
235
  field['shareFormControl'] = false;
191
236
  }
@@ -273,7 +318,9 @@
273
318
  break;
274
319
  }
275
320
  case 'object': {
276
- field.fieldGroup = [];
321
+ if (!field.fieldGroup) {
322
+ field.fieldGroup = [];
323
+ }
277
324
  var _b = __read(this.resolveDependencies(schema), 2), propDeps_1 = _b[0], schemaDeps_1 = _b[1];
278
325
  Object.keys(schema.properties || {}).forEach(( /**
279
326
  * @param {?} property
@@ -445,6 +492,12 @@
445
492
  field.type = 'enum';
446
493
  field.templateOptions.options = this.toEnumOptions(schema);
447
494
  }
495
+ if (schema.oneOf && !field.type) {
496
+ delete field.key;
497
+ field.fieldGroup = [
498
+ this.resolveMultiSchema('oneOf', ( /** @type {?} */(schema.oneOf)), __assign({}, options, { key: key, shareFormControl: false })),
499
+ ];
500
+ }
448
501
  // map in possible formlyConfig options from the widget property
449
502
  if (schema['widget'] && schema['widget'].formlyConfig) {
450
503
  field = this.mergeFields(field, schema['widget'].formlyConfig);
@@ -591,21 +644,17 @@
591
644
  * @param {?} f
592
645
  * @param {?} i
593
646
  * @return {?}
594
- */function (f, i) { return ( /** @type {?} */([f, i])); }))
595
- .filter(( /**
596
- * @param {?} __0
597
- * @return {?}
598
- */function (_a) {
599
- var _b = __read(_a, 2), f = _b[0], i = _b[1];
600
- return _this_1.isFieldValid(f, schemas[i], options);
601
- }))
647
+ */function (f, i) { return ( /** @type {?} */([f, i, _this_1.isFieldValid(f, schemas[i], options)])); }))
602
648
  .sort(( /**
603
649
  * @param {?} __0
604
650
  * @param {?} __1
605
651
  * @return {?}
606
652
  */function (_a, _b) {
607
- var _c = __read(_a, 1), f1 = _c[0];
608
- var _d = __read(_b, 1), f2 = _d[0];
653
+ var _c = __read(_a, 3), f1 = _c[0], i1 = _c[1], f1Valid = _c[2];
654
+ var _d = __read(_b, 3), f2 = _d[0], i2 = _d[1], f2Valid = _d[2];
655
+ if (f1Valid !== f2Valid) {
656
+ return f2Valid ? 1 : -1;
657
+ }
609
658
  /** @type {?} */
610
659
  var matchedFields1 = totalMatchedFields(f1);
611
660
  /** @type {?} */
@@ -841,10 +890,12 @@
841
890
  * @return {?}
842
891
  */
843
892
  function (field, schema, options) {
893
+ /** @type {?} */
894
+ var model = field.model ? core.ɵclone(field.model) : (field.fieldArray ? [] : {});
844
895
  var form = (( /** @type {?} */(field.options)))._buildField({
845
- form: new forms.FormGroup({}),
846
- fieldGroup: [this._toFieldConfig(schema, __assign({}, options, { resetOnHide: true, ignoreDefault: true, map: null }))],
847
- model: field.model ? core.ɵclone(field.model) : (field.fieldArray ? [] : {}),
896
+ form: Array.isArray(model) ? new forms.FormArray([]) : new forms.FormGroup({}),
897
+ fieldGroup: [this._toFieldConfig(schema, __assign({}, options, { resetOnHide: true, ignoreDefault: true, map: null, strict: true }))],
898
+ model: model,
848
899
  }).form;
849
900
  return form.valid;
850
901
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-formly-core-json-schema.umd.js.map","sources":["node_modules/tslib/tslib.es6.js","ng://@ngx-formly/core/json-schema/formly-json-schema.service.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","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","tap","Injectable"],"mappings":";;;;;;IAAA;;;;;;;;;;;;;;AAcA,IAeO,IAAI,QAAQ,GAAG;QAClB,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC;YAC3C,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACjD,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBACjB,KAAK,IAAI,CAAC,IAAI,CAAC;oBAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;wBAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAChF;YACD,OAAO,CAAC,CAAC;SACZ,CAAA;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC,CAAA;AAED,aAAgB,MAAM,CAAC,CAAC,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,KAAK,IAAI,CAAC,IAAI,CAAC;YAAE,IAAI,MAAM,CAAC,SAA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O,IAAI,CAAC,aAAa,oBAAe,MAAM,CAAC,KAAK,GAAC,CAAC;aACvD;;;;;;;;QAEO,uCAAY;;;;;;;YAApB,UAAqB,KAAwB,EAAE,MAAmB,EAAE,OAAiB;gBAC3E,IAAA;;;;uBAAI;gBAMZ,OAAO,IAAI,CAAC,KAAK,CAAC;aACnB;;;;;;;QAEO,sCAAW;;;;;;YAAnB,UAAoB,EAAqB,EAAE,EAAqB;gBAC9D,KAAK,IAAI,IAAI,IAAI,EAAE,EAAE;oBACnB,IAAI,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;wBAC5C,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;qBACjD;yBAAM,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;wBAC3B,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;qBACrB;iBACF;gBAED,OAAO,EAAE,CAAC;aACX;;oBAtfFC,aAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;+BAhElC;KAgEA;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ngx-formly-core-json-schema.umd.js.map","sources":["node_modules/tslib/tslib.es6.js","ng://@ngx-formly/core/json-schema/formly-json-schema.service.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","import { Injectable } from '@angular/core';\nimport { FormlyFieldConfig } from '@ngx-formly/core';\nimport { JSONSchema7, JSONSchema7TypeName } from 'json-schema';\nimport { AbstractControl, FormArray, 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 isInteger(value: any) {\n return Number.isInteger ? Number.isInteger(value) : typeof value === 'number' && Math.floor(value) === value;\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 if (total === 0 && field.key) {\n const value = getFieldValue(field);\n if (\n value === null\n || (\n (value !== undefined)\n && (\n (field.fieldArray && Array.isArray(value))\n || (!field.fieldArray && isObject(value))\n )\n )\n ) {\n return 1;\n }\n }\n\n return total;\n}\n\ninterface IOptions extends FormlyJsonschemaOptions {\n schema: JSONSchema7;\n resetOnHide?: boolean;\n shareFormControl?: boolean;\n ignoreDefault?: boolean;\n strict?: 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 (key && options.strict) {\n this.addValidator(field, 'type', (c, f) => {\n const value = getFieldValue(f);\n if (value != null) {\n switch (field.type) {\n case 'string': {\n return typeof value === 'string';\n }\n case 'integer': {\n return isInteger(value);\n }\n case 'number': {\n return typeof value === 'number';\n }\n case 'object': {\n return isObject(value);\n }\n case 'array': {\n return Array.isArray(value);\n }\n }\n }\n\n return true;\n });\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 if (!field.fieldGroup) {\n field.fieldGroup = [];\n }\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 if (schema.oneOf && !field.type) {\n delete field.key;\n field.fieldGroup = [\n this.resolveMultiSchema('oneOf', <JSONSchema7[]>schema.oneOf, { ...options, key, shareFormControl: false }),\n ];\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, this.isFieldValid(f, schemas[i], options)] as [FormlyFieldConfig, number, boolean])\n .sort(([f1, i1, f1Valid], [f2, i2, f2Valid]) => {\n if (f1Valid !== f2Valid) {\n return f2Valid ? 1 : -1;\n }\n\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, field: FormlyFieldConfig) => 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 model = field.model ? clone(field.model) : (field.fieldArray ? [] : {});\n const { form } = (field.options as any)._buildField({\n form: Array.isArray(model) ? new FormArray([]) : new FormGroup({}),\n fieldGroup: [this._toFieldConfig(schema, { ...options, resetOnHide: true, ignoreDefault: true, map: null, strict: true })],\n model,\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","tap","clone","Injectable"],"mappings":";;;;;;IAAA;;;;;;;;;;;;;;AAcA,IAeO,IAAI,QAAQ,GAAG;QAClB,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC;YAC3C,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACjD,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;gBACjB,KAAK,IAAI,CAAC,IAAI,CAAC;oBAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;wBAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAChF;YACD,OAAO,CAAC,CAAC;SACZ,CAAA;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC,CAAA;AAED,aAAgB,MAAM,CAAC,CAAC,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,KAAK,IAAI,CAAC,IAAI,CAAC;YAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC/E,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,MAAM,CAAC,qBAAqB,KAAK,UAAU;YAC/D,KAAK,IAAI,CAAC,GAAG,CAAC,E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,CAAC,CAAC;iBACjC;gBAED,OAAO,IAAI,CAAC,aAAa,oBAAe,MAAM,CAAC,KAAK,GAAC,CAAC;aACvD;;;;;;;;QAEO,uCAAY;;;;;;;YAApB,UAAqB,KAAwB,EAAE,MAAmB,EAAE,OAAiB;;oBAC7E,KAAK,GAAG,KAAK,CAAC,KAAK,GAAGC,WAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,GAAG,EAAE,GAAG,EAAE,CAAC;gBACrE,IAAA;;;;uBAAI;gBAMZ,OAAO,IAAI,CAAC,KAAK,CAAC;aACnB;;;;;;;QAEO,sCAAW;;;;;;YAAnB,UAAoB,EAAqB,EAAE,EAAqB;gBAC9D,KAAK,IAAI,IAAI,IAAI,EAAE,EAAE;oBACnB,IAAI,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;wBAC5C,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;qBACjD;yBAAM,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;wBAC3B,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;qBACrB;iBACF;gBAED,OAAO,EAAE,CAAC;aACX;;oBA5hBFC,aAAU,SAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;+BAnFlC;KAmFA;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("@angular/forms"),require("@ngx-formly/core"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@ngx-formly/core/json-schema",["exports","@angular/core","@angular/forms","@ngx-formly/core","rxjs/operators"],r):r((e["ngx-formly"]=e["ngx-formly"]||{},e["ngx-formly"].core=e["ngx-formly"].core||{},e["ngx-formly"].core["json-schema"]={}),e.ng.core,e.ng.forms,e["ngx-formly"].core,e.rxjs.operators)}(this,function(e,r,n,a,t){"use strict";var m=function(){return(m=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)};function p(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]])}return t}function d(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,i,o=t.call(e),a=[];try{for(;(void 0===r||0<r--)&&!(n=o.next()).done;)a.push(n.value)}catch(u){i={error:u}}finally{try{n&&!n.done&&(t=o["return"])&&t.call(o)}finally{if(i)throw i.error}}return a}function c(e){return""===e||e===undefined||null===e}function i(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function y(e){return e.hasOwnProperty("const")||e["enum"]&&1===e["enum"].length}function h(e){if(!e.fieldGroup)return e.key&&a.ɵgetFieldValue(e)!==undefined?1:0;var r=e.fieldGroup.reduce(function(e,r){return h(r)+e},0);return 0===r?e.key&&a.ɵgetFieldValue(e)!==undefined?1:0:r}var o=function(){function e(){}return e.prototype.toFieldConfig=function(e,r){return this._toFieldConfig(e,m({schema:e},r||{}))},e.prototype._toFieldConfig=function(u,e){var o=this,r=e.key,l=p(e,["key"]);u=this.resolveSchema(u,l);var s={type:this.guessType(u),defaultValue:u["default"],templateOptions:{label:u.title,readonly:u.readOnly,description:u.description}};switch(null!=r&&(s.key=r),l.ignoreDefault||!u.readOnly&&!l.readOnly||(s.templateOptions.disabled=!0,l=m({},l,{readOnly:!0})),l.resetOnHide&&(s.resetOnHide=!0),!1===l.shareFormControl&&(s.shareFormControl=!1),l.ignoreDefault&&delete s.defaultValue,s.type){case"null":this.addValidator(s,"null",function(e){return null===e.value});break;case"number":case"integer":s.parsers=[function(e){return c(e)?""===e?null:e:Number(e)}],u.hasOwnProperty("minimum")&&(s.templateOptions.min=u.minimum),u.hasOwnProperty("maximum")&&(s.templateOptions.max=u.maximum),u.hasOwnProperty("exclusiveMinimum")&&(s.templateOptions.exclusiveMinimum=u.exclusiveMinimum,this.addValidator(s,"exclusiveMinimum",function(e){var r=e.value;return c(r)||r>u.exclusiveMinimum})),u.hasOwnProperty("exclusiveMaximum")&&(s.templateOptions.exclusiveMaximum=u.exclusiveMaximum,this.addValidator(s,"exclusiveMaximum",function(e){var r=e.value;return c(r)||r<u.exclusiveMaximum})),u.hasOwnProperty("multipleOf")&&(s.templateOptions.step=u.multipleOf,this.addValidator(s,"multipleOf",function(e){var r=e.value;if(c(r)||"number"!=typeof r||0===r||u.multipleOf<=0)return!0;var t=Math.pow(10,function n(e){if(!isFinite(e))return 0;for(var r=1,t=0;Math.round(e*r)/r!==e;)r*=10,t++;return t}(u.multipleOf));return Math.round(r*t)%Math.round(u.multipleOf*t)==0}));break;case"string":var t=u.type;Array.isArray(t)&&-1!==t.indexOf("null")&&(s.parsers=[function(e){return c(e)?null:e}]),["minLength","maxLength","pattern"].forEach(function(e){u.hasOwnProperty(e)&&(s.templateOptions[e]=u[e])});break;case"object":s.fieldGroup=[];var n=d(this.resolveDependencies(u),2),f=n[0],i=n[1];Object.keys(u.properties||{}).forEach(function(a){var e=o._toFieldConfig(u.properties[a],m({},l,{key:a}));if(s.fieldGroup.push(e),(Array.isArray(u.required)&&-1!==u.required.indexOf(a)||f[a])&&(e.expressionProperties=m({},e.expressionProperties||{},{"templateOptions.required":function(r,e,t){for(var n=t.parent,i=t.fieldGroup&&null!=t.key?n.model:t.model;null==n.key&&n.parent;)n=n.parent;var o=!(!n||!n.templateOptions)&&n.templateOptions.required;return!(!i&&!o)&&(!(!Array.isArray(u.required)||-1===u.required.indexOf(a))||f[a]&&r&&f[a].some(function(e){return!c(r[e])}))}})),i[a]){var r=i[a].oneOf;r&&r.every(function(e){return e.properties&&e.properties[a]&&y(e.properties[a])})?r.forEach(function(e){var r=e.properties,t=a,n=r[t],i=p(r,["symbol"==typeof t?t:t+""]);s.fieldGroup.push(m({},o._toFieldConfig(m({},e,{properties:i}),m({},l,{resetOnHide:!0})),{hideExpression:function(e){return!e||((r=n).hasOwnProperty("const")?r["const"]:r["enum"][0])!==e[a];var r}}))}):s.fieldGroup.push(m({},o._toFieldConfig(i[a],l),{hideExpression:function(e){return!e||c(e[a])}}))}}),u.oneOf&&s.fieldGroup.push(this.resolveMultiSchema("oneOf",u.oneOf,m({},l,{shareFormControl:!1}))),u.anyOf&&s.fieldGroup.push(this.resolveMultiSchema("anyOf",u.anyOf,l));break;case"array":if(u.hasOwnProperty("minItems")&&(s.templateOptions.minItems=u.minItems,this.addValidator(s,"minItems",function(e){var r=e.value;return c(r)||r.length>=u.minItems})),u.hasOwnProperty("maxItems")&&(s.templateOptions.maxItems=u.maxItems,this.addValidator(s,"maxItems",function(e){var r=e.value;return c(r)||r.length<=u.maxItems})),u.hasOwnProperty("uniqueItems")&&(s.templateOptions.uniqueItems=u.uniqueItems,this.addValidator(s,"uniqueItems",function(e){var r=e.value;return!(!c(r)&&u.uniqueItems)||Array.from(new Set(r.map(function(e){return JSON.stringify(e)}))).length===r.length})),u.items&&!Array.isArray(u.items)&&(u.items=this.resolveSchema(u.items,l)),!this.isEnum(u)){var a=this;Object.defineProperty(s,"fieldArray",{get:function(){if(u.items&&!Array.isArray(u.items))return a._toFieldConfig(u.items,l);var e=this.fieldGroup?this.fieldGroup.length:0;if(u.items&&u.items[e]){var r=a._toFieldConfig(u.items[e],m({},l));return r.templateOptions.removable=!1,r}return u.additionalItems?a._toFieldConfig(u.additionalItems,l):{}},enumerable:!0,configurable:!0})}}return u.hasOwnProperty("const")&&(s.templateOptions["const"]=u["const"],this.addValidator(s,"const",function(e){return e.value===u["const"]}),s.type||(s.defaultValue=u["const"])),this.isEnum(u)&&(s.templateOptions.multiple="array"===s.type,s.type="enum",s.templateOptions.options=this.toEnumOptions(u)),u.widget&&u.widget.formlyConfig&&(s=this.mergeFields(s,u.widget.formlyConfig)),l.map?l.map(s,u):s},e.prototype.resolveSchema=function(e,r){return e&&e.$ref&&(e=this.resolveDefinition(e,r)),e&&e.allOf&&(e=this.resolveAllOf(e,r)),e},e.prototype.resolveAllOf=function(e,i){var o=this,r=e.allOf,t=p(e,["allOf"]);if(!r.length)throw Error("allOf array can not be empty "+r+".");return r.reduce(function(r,t){return t=o.resolveSchema(t,i),r.required&&t.required&&(r.required=function n(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(d(arguments[r]));return e}(r.required,t.required)),t.uniqueItems&&(r.uniqueItems=t.uniqueItems),["maxLength","maximum","exclusiveMaximum","maxItems","maxProperties"].forEach(function(e){c(r[e])||c(t[e])||(r[e]=r[e]<t[e]?r[e]:t[e])}),["minLength","minimum","exclusiveMinimum","minItems","minProperties"].forEach(function(e){c(r[e])||c(t[e])||(r[e]=r[e]>t[e]?r[e]:t[e])}),a.ɵreverseDeepMerge(r,t)},t)},e.prototype.resolveMultiSchema=function(l,s,f){var p=this;return{type:"multischema",fieldGroup:[{type:"enum",defaultValue:-1,templateOptions:{multiple:"anyOf"===l,options:s.map(function(e,r){return{label:e.title,value:r,disabled:e.readOnly}})},hooks:{onInit:function(e){return e.formControl.valueChanges.pipe(t.tap(function(){return e.options._checkField(e.parent)}))}}},{fieldGroup:s.map(function(e,u){return m({},p._toFieldConfig(e,m({},f,{resetOnHide:!0})),{hideExpression:function(e,r,t,n){var i=t.parent.parent.fieldGroup[0].formControl;if(-1===i.value||n){var o=t.parent.fieldGroup.map(function(e,r){return[e,r]}).filter(function(e){var r=d(e,2),t=r[0],n=r[1];return p.isFieldValid(t,s[n],f)}).sort(function(e,r){var t=d(e,1)[0],n=d(r,1)[0],i=h(t),o=h(n);return i===o?t.templateOptions.disabled===n.templateOptions.disabled?0:t.templateOptions.disabled?1:-1:i<o?1:-1}).map(function(e){return d(e,2)[1]});if("anyOf"===l){var a=o.filter(function(e){return h(t.parent.fieldGroup[e])});o=0<a.length?a:[o[0]||0]}o=0<o.length?o:[0],i.setValue("anyOf"===l?o:o[0])}return Array.isArray(i.value)?-1===i.value.indexOf(u):i.value!==u}})})}]}},e.prototype.resolveDefinition=function(t,e){var r=d(t.$ref.split("#/"),2),n=r[0],i=r[1];if(n)throw Error("Remote schemas for "+t.$ref+" not supported yet.");var o=i?i.split("/").reduce(function(e,r){return e&&e.hasOwnProperty(r)?e[r]:null},e.schema):null;if(!o)throw Error("Cannot find a definition for "+t.$ref+".");return o.$ref?this.resolveDefinition(o,e):m({},o,["title","description","default","widget"].reduce(function(e,r){return t.hasOwnProperty(r)&&(e[r]=t[r]),e},{}))},e.prototype.resolveDependencies=function(t){var n={},i={};return Object.keys(t.dependencies||{}).forEach(function(r){var e=t.dependencies[r];Array.isArray(e)?e.forEach(function(e){n[e]?n[e].push(r):n[e]=[r]}):i[r]=e}),[n,i]},e.prototype.guessType=function(e){var r=e?e.type:null;if(!r&&e&&e.properties)return"object";if(Array.isArray(r)){if(1===r.length)return r[0];if(2===r.length&&-1!==r.indexOf("null"))return r["null"===r[0]?1:0]}return r},e.prototype.addValidator=function(e,r,t){e.validators=e.validators||{},e.validators[r]=t},e.prototype.isEnum=function(e){return e["enum"]||e.anyOf&&e.anyOf.every(y)||e.oneOf&&e.oneOf.every(y)||e.uniqueItems&&e.items&&!Array.isArray(e.items)&&this.isEnum(e.items)},e.prototype.toEnumOptions=function(e){if(e["enum"])return e["enum"].map(function(e){return{value:e,label:e}});var r=function(e){var r=e.hasOwnProperty("const")?e["const"]:e["enum"][0],t={value:r,label:e.title||r};return e.readOnly&&(t.disabled=!0),t};return e.anyOf?e.anyOf.map(r):e.oneOf?e.oneOf.map(r):this.toEnumOptions(e.items)},e.prototype.isFieldValid=function(e,r,t){return e.options._buildField({form:new n.FormGroup({}),fieldGroup:[this._toFieldConfig(r,m({},t,{resetOnHide:!0,ignoreDefault:!0,map:null}))],model:e.model?a.ɵclone(e.model):e.fieldArray?[]:{}}).form.valid},e.prototype.mergeFields=function(e,r){for(var t in r)i(e[t])&&i(r[t])?e[t]=this.mergeFields(e[t],r[t]):null!=r[t]&&(e[t]=r[t]);return e},e.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=r.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();e.FormlyJsonschema=o,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("@angular/forms"),require("@ngx-formly/core"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@ngx-formly/core/json-schema",["exports","@angular/core","@angular/forms","@ngx-formly/core","rxjs/operators"],r):r((e["ngx-formly"]=e["ngx-formly"]||{},e["ngx-formly"].core=e["ngx-formly"].core||{},e["ngx-formly"].core["json-schema"]={}),e.ng.core,e.ng.forms,e["ngx-formly"].core,e.rxjs.operators)}(this,function(e,r,i,p,t){"use strict";var m=function(){return(m=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)};function d(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]])}return t}function c(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,i,o=t.call(e),a=[];try{for(;(void 0===r||0<r--)&&!(n=o.next()).done;)a.push(n.value)}catch(u){i={error:u}}finally{try{n&&!n.done&&(t=o["return"])&&t.call(o)}finally{if(i)throw i.error}}return a}function y(e){return""===e||e===undefined||null===e}function h(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function v(e){return e.hasOwnProperty("const")||e["enum"]&&1===e["enum"].length}function O(e){if(!e.fieldGroup)return e.key&&p.ɵgetFieldValue(e)!==undefined?1:0;var r=e.fieldGroup.reduce(function(e,r){return O(r)+e},0);if(0===r&&e.key){var t=p.ɵgetFieldValue(e);if(null===t||t!==undefined&&(e.fieldArray&&Array.isArray(t)||!e.fieldArray&&h(t)))return 1}return r}var n=function(){function e(){}return e.prototype.toFieldConfig=function(e,r){return this._toFieldConfig(e,m({schema:e},r||{}))},e.prototype._toFieldConfig=function(u,e){var o=this,r=e.key,l=d(e,["key"]);u=this.resolveSchema(u,l);var s={type:this.guessType(u),defaultValue:u["default"],templateOptions:{label:u.title,readonly:u.readOnly,description:u.description}};switch(null!=r&&(s.key=r),l.ignoreDefault||!u.readOnly&&!l.readOnly||(s.templateOptions.disabled=!0,l=m({},l,{readOnly:!0})),l.resetOnHide&&(s.resetOnHide=!0),r&&l.strict&&this.addValidator(s,"type",function(e,r){var t=p.ɵgetFieldValue(r);if(null!=t)switch(s.type){case"string":return"string"==typeof t;case"integer":return function n(e){return Number.isInteger?Number.isInteger(e):"number"==typeof e&&Math.floor(e)===e}(t);case"number":return"number"==typeof t;case"object":return h(t);case"array":return Array.isArray(t)}return!0}),!1===l.shareFormControl&&(s.shareFormControl=!1),l.ignoreDefault&&delete s.defaultValue,s.type){case"null":this.addValidator(s,"null",function(e){return null===e.value});break;case"number":case"integer":s.parsers=[function(e){return y(e)?""===e?null:e:Number(e)}],u.hasOwnProperty("minimum")&&(s.templateOptions.min=u.minimum),u.hasOwnProperty("maximum")&&(s.templateOptions.max=u.maximum),u.hasOwnProperty("exclusiveMinimum")&&(s.templateOptions.exclusiveMinimum=u.exclusiveMinimum,this.addValidator(s,"exclusiveMinimum",function(e){var r=e.value;return y(r)||r>u.exclusiveMinimum})),u.hasOwnProperty("exclusiveMaximum")&&(s.templateOptions.exclusiveMaximum=u.exclusiveMaximum,this.addValidator(s,"exclusiveMaximum",function(e){var r=e.value;return y(r)||r<u.exclusiveMaximum})),u.hasOwnProperty("multipleOf")&&(s.templateOptions.step=u.multipleOf,this.addValidator(s,"multipleOf",function(e){var r=e.value;if(y(r)||"number"!=typeof r||0===r||u.multipleOf<=0)return!0;var t=Math.pow(10,function n(e){if(!isFinite(e))return 0;for(var r=1,t=0;Math.round(e*r)/r!==e;)r*=10,t++;return t}(u.multipleOf));return Math.round(r*t)%Math.round(u.multipleOf*t)==0}));break;case"string":var t=u.type;Array.isArray(t)&&-1!==t.indexOf("null")&&(s.parsers=[function(e){return y(e)?null:e}]),["minLength","maxLength","pattern"].forEach(function(e){u.hasOwnProperty(e)&&(s.templateOptions[e]=u[e])});break;case"object":s.fieldGroup||(s.fieldGroup=[]);var n=c(this.resolveDependencies(u),2),f=n[0],i=n[1];Object.keys(u.properties||{}).forEach(function(a){var e=o._toFieldConfig(u.properties[a],m({},l,{key:a}));if(s.fieldGroup.push(e),(Array.isArray(u.required)&&-1!==u.required.indexOf(a)||f[a])&&(e.expressionProperties=m({},e.expressionProperties||{},{"templateOptions.required":function(r,e,t){for(var n=t.parent,i=t.fieldGroup&&null!=t.key?n.model:t.model;null==n.key&&n.parent;)n=n.parent;var o=!(!n||!n.templateOptions)&&n.templateOptions.required;return!(!i&&!o)&&(!(!Array.isArray(u.required)||-1===u.required.indexOf(a))||f[a]&&r&&f[a].some(function(e){return!y(r[e])}))}})),i[a]){var r=i[a].oneOf;r&&r.every(function(e){return e.properties&&e.properties[a]&&v(e.properties[a])})?r.forEach(function(e){var r=e.properties,t=a,n=r[t],i=d(r,["symbol"==typeof t?t:t+""]);s.fieldGroup.push(m({},o._toFieldConfig(m({},e,{properties:i}),m({},l,{resetOnHide:!0})),{hideExpression:function(e){return!e||((r=n).hasOwnProperty("const")?r["const"]:r["enum"][0])!==e[a];var r}}))}):s.fieldGroup.push(m({},o._toFieldConfig(i[a],l),{hideExpression:function(e){return!e||y(e[a])}}))}}),u.oneOf&&s.fieldGroup.push(this.resolveMultiSchema("oneOf",u.oneOf,m({},l,{shareFormControl:!1}))),u.anyOf&&s.fieldGroup.push(this.resolveMultiSchema("anyOf",u.anyOf,l));break;case"array":if(u.hasOwnProperty("minItems")&&(s.templateOptions.minItems=u.minItems,this.addValidator(s,"minItems",function(e){var r=e.value;return y(r)||r.length>=u.minItems})),u.hasOwnProperty("maxItems")&&(s.templateOptions.maxItems=u.maxItems,this.addValidator(s,"maxItems",function(e){var r=e.value;return y(r)||r.length<=u.maxItems})),u.hasOwnProperty("uniqueItems")&&(s.templateOptions.uniqueItems=u.uniqueItems,this.addValidator(s,"uniqueItems",function(e){var r=e.value;return!(!y(r)&&u.uniqueItems)||Array.from(new Set(r.map(function(e){return JSON.stringify(e)}))).length===r.length})),u.items&&!Array.isArray(u.items)&&(u.items=this.resolveSchema(u.items,l)),!this.isEnum(u)){var a=this;Object.defineProperty(s,"fieldArray",{get:function(){if(u.items&&!Array.isArray(u.items))return a._toFieldConfig(u.items,l);var e=this.fieldGroup?this.fieldGroup.length:0;if(u.items&&u.items[e]){var r=a._toFieldConfig(u.items[e],m({},l));return r.templateOptions.removable=!1,r}return u.additionalItems?a._toFieldConfig(u.additionalItems,l):{}},enumerable:!0,configurable:!0})}}return u.hasOwnProperty("const")&&(s.templateOptions["const"]=u["const"],this.addValidator(s,"const",function(e){return e.value===u["const"]}),s.type||(s.defaultValue=u["const"])),this.isEnum(u)&&(s.templateOptions.multiple="array"===s.type,s.type="enum",s.templateOptions.options=this.toEnumOptions(u)),u.oneOf&&!s.type&&(delete s.key,s.fieldGroup=[this.resolveMultiSchema("oneOf",u.oneOf,m({},l,{key:r,shareFormControl:!1}))]),u.widget&&u.widget.formlyConfig&&(s=this.mergeFields(s,u.widget.formlyConfig)),l.map?l.map(s,u):s},e.prototype.resolveSchema=function(e,r){return e&&e.$ref&&(e=this.resolveDefinition(e,r)),e&&e.allOf&&(e=this.resolveAllOf(e,r)),e},e.prototype.resolveAllOf=function(e,i){var o=this,r=e.allOf,t=d(e,["allOf"]);if(!r.length)throw Error("allOf array can not be empty "+r+".");return r.reduce(function(r,t){return t=o.resolveSchema(t,i),r.required&&t.required&&(r.required=function n(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(c(arguments[r]));return e}(r.required,t.required)),t.uniqueItems&&(r.uniqueItems=t.uniqueItems),["maxLength","maximum","exclusiveMaximum","maxItems","maxProperties"].forEach(function(e){y(r[e])||y(t[e])||(r[e]=r[e]<t[e]?r[e]:t[e])}),["minLength","minimum","exclusiveMinimum","minItems","minProperties"].forEach(function(e){y(r[e])||y(t[e])||(r[e]=r[e]>t[e]?r[e]:t[e])}),p.ɵreverseDeepMerge(r,t)},t)},e.prototype.resolveMultiSchema=function(l,s,f){var p=this;return{type:"multischema",fieldGroup:[{type:"enum",defaultValue:-1,templateOptions:{multiple:"anyOf"===l,options:s.map(function(e,r){return{label:e.title,value:r,disabled:e.readOnly}})},hooks:{onInit:function(e){return e.formControl.valueChanges.pipe(t.tap(function(){return e.options._checkField(e.parent)}))}}},{fieldGroup:s.map(function(e,u){return m({},p._toFieldConfig(e,m({},f,{resetOnHide:!0})),{hideExpression:function(e,r,t,n){var i=t.parent.parent.fieldGroup[0].formControl;if(-1===i.value||n){var o=t.parent.fieldGroup.map(function(e,r){return[e,r,p.isFieldValid(e,s[r],f)]}).sort(function(e,r){var t=c(e,3),n=t[0],i=(t[1],t[2]),o=c(r,3),a=o[0],u=(o[1],o[2]);if(i!==u)return u?1:-1;var l=O(n),s=O(a);return l===s?n.templateOptions.disabled===a.templateOptions.disabled?0:n.templateOptions.disabled?1:-1:l<s?1:-1}).map(function(e){return c(e,2)[1]});if("anyOf"===l){var a=o.filter(function(e){return O(t.parent.fieldGroup[e])});o=0<a.length?a:[o[0]||0]}o=0<o.length?o:[0],i.setValue("anyOf"===l?o:o[0])}return Array.isArray(i.value)?-1===i.value.indexOf(u):i.value!==u}})})}]}},e.prototype.resolveDefinition=function(t,e){var r=c(t.$ref.split("#/"),2),n=r[0],i=r[1];if(n)throw Error("Remote schemas for "+t.$ref+" not supported yet.");var o=i?i.split("/").reduce(function(e,r){return e&&e.hasOwnProperty(r)?e[r]:null},e.schema):null;if(!o)throw Error("Cannot find a definition for "+t.$ref+".");return o.$ref?this.resolveDefinition(o,e):m({},o,["title","description","default","widget"].reduce(function(e,r){return t.hasOwnProperty(r)&&(e[r]=t[r]),e},{}))},e.prototype.resolveDependencies=function(t){var n={},i={};return Object.keys(t.dependencies||{}).forEach(function(r){var e=t.dependencies[r];Array.isArray(e)?e.forEach(function(e){n[e]?n[e].push(r):n[e]=[r]}):i[r]=e}),[n,i]},e.prototype.guessType=function(e){var r=e?e.type:null;if(!r&&e&&e.properties)return"object";if(Array.isArray(r)){if(1===r.length)return r[0];if(2===r.length&&-1!==r.indexOf("null"))return r["null"===r[0]?1:0]}return r},e.prototype.addValidator=function(e,r,t){e.validators=e.validators||{},e.validators[r]=t},e.prototype.isEnum=function(e){return e["enum"]||e.anyOf&&e.anyOf.every(v)||e.oneOf&&e.oneOf.every(v)||e.uniqueItems&&e.items&&!Array.isArray(e.items)&&this.isEnum(e.items)},e.prototype.toEnumOptions=function(e){if(e["enum"])return e["enum"].map(function(e){return{value:e,label:e}});var r=function(e){var r=e.hasOwnProperty("const")?e["const"]:e["enum"][0],t={value:r,label:e.title||r};return e.readOnly&&(t.disabled=!0),t};return e.anyOf?e.anyOf.map(r):e.oneOf?e.oneOf.map(r):this.toEnumOptions(e.items)},e.prototype.isFieldValid=function(e,r,t){var n=e.model?p.ɵclone(e.model):e.fieldArray?[]:{};return e.options._buildField({form:Array.isArray(n)?new i.FormArray([]):new i.FormGroup({}),fieldGroup:[this._toFieldConfig(r,m({},t,{resetOnHide:!0,ignoreDefault:!0,map:null,strict:!0}))],model:n}).form.valid},e.prototype.mergeFields=function(e,r){for(var t in r)h(e[t])&&h(r[t])?e[t]=this.mergeFields(e[t],r[t]):null!=r[t]&&(e[t]=r[t]);return e},e.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],e.ngInjectableDef=r.defineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();e.FormlyJsonschema=n,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=ngx-formly-core-json-schema.umd.min.js.map