@gravitee/ui-particles-angular 5.7.3-json-schema-77b8f57 → 5.7.3-json-schema-ff60d4e

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.
@@ -8,12 +8,12 @@ import * as i2 from '@angular/material/button';
8
8
  import { MatButtonModule } from '@angular/material/button';
9
9
  import * as i2$1 from '@angular/common';
10
10
  import { CommonModule } from '@angular/common';
11
- import { __awaiter, __rest } from 'tslib';
11
+ import { __awaiter } from 'tslib';
12
12
  import { ComponentHarness, HarnessPredicate, parallel, TestKey } from '@angular/cdk/testing';
13
13
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
14
14
  import * as i3$1 from '@angular/material/form-field';
15
15
  import { MatFormFieldControl, MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
16
- import { isEmpty as isEmpty$1, toLower, dropRight, isNil, isArray, remove, cloneDeep, isObject as isObject$1, set } from 'lodash';
16
+ import { isEmpty, toLower, dropRight, isNil, isArray, remove, isObject, cloneDeep, set } from 'lodash';
17
17
  import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap } from 'rxjs/operators';
18
18
  import * as i7 from '@angular/forms';
19
19
  import { FormsModule, FormArray, FormGroup, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
@@ -44,8 +44,9 @@ import * as i6$2 from 'ngx-file-helpers';
44
44
  import { ReadMode, NgxFileHelpersModule } from 'ngx-file-helpers';
45
45
  import { MatSelectHarness } from '@angular/material/select/testing';
46
46
  import { toSvg } from 'jdenticon';
47
- import * as i1$3 from '@ngx-formly/core';
48
- import { ɵhasKey, ɵgetFieldValue, ɵreverseDeepMerge, ɵclone, FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
47
+ import * as i1$3 from '@ngx-formly/core/json-schema';
48
+ import * as i1$4 from '@ngx-formly/core';
49
+ import { FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
49
50
  import { FormlyMaterialModule } from '@ngx-formly/material';
50
51
 
51
52
  /*
@@ -321,7 +322,7 @@ class GioFormTagsInputComponent {
321
322
  // From ControlValueAccessor interface
322
323
  get empty() {
323
324
  var _a, _b;
324
- return isEmpty$1(this.value) && isEmpty$1((_b = (_a = this._tagInput) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.value);
325
+ return isEmpty(this.value) && isEmpty((_b = (_a = this._tagInput) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.value);
325
326
  }
326
327
  // From ControlValueAccessor interface
327
328
  get shouldLabelFloat() {
@@ -384,7 +385,7 @@ class GioFormTagsInputComponent {
384
385
  var _a, _b, _c;
385
386
  const input = (_a = this._tagInput) === null || _a === void 0 ? void 0 : _a.nativeElement;
386
387
  const tagToAdd = ((_b = event.value) !== null && _b !== void 0 ? _b : '').trim();
387
- if (isEmpty$1(tagToAdd)) {
388
+ if (isEmpty(tagToAdd)) {
388
389
  return;
389
390
  }
390
391
  // Add the tag only if shouldAddTag in validationCb return true
@@ -1153,7 +1154,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
1153
1154
  }] } });
1154
1155
  const removeLastEmptyHeader = (headers) => {
1155
1156
  const lastHeader = headers[headers.length - 1];
1156
- if (lastHeader && isEmpty$1(lastHeader.key) && isEmpty$1(lastHeader.value)) {
1157
+ if (lastHeader && isEmpty(lastHeader.key) && isEmpty(lastHeader.value)) {
1157
1158
  return dropRight(headers);
1158
1159
  }
1159
1160
  return headers;
@@ -2727,552 +2728,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
2727
2728
  * limitations under the License.
2728
2729
  */
2729
2730
 
2730
- // https://stackoverflow.com/a/27865285
2731
- function decimalPlaces(a) {
2732
- if (!isFinite(a)) {
2733
- return 0;
2734
- }
2735
- let e = 1, p = 0;
2736
- while (Math.round(a * e) / e !== a) {
2737
- e *= 10;
2738
- p++;
2739
- }
2740
- return p;
2741
- }
2742
- function isEmpty(v) {
2743
- return v === '' || v == null;
2744
- }
2745
- function isObject(v) {
2746
- return v != null && typeof v === 'object' && !Array.isArray(v);
2747
- }
2748
- function isInteger(value) {
2749
- return Number.isInteger ? Number.isInteger(value) : typeof value === 'number' && Math.floor(value) === value;
2750
- }
2751
- function isConst(schema) {
2752
- return typeof schema === 'object' && (schema.hasOwnProperty('const') || (schema.enum && schema.enum.length === 1));
2753
- }
2754
- function totalMatchedFields(field) {
2755
- if (!field.fieldGroup) {
2756
- return ɵhasKey(field) && ɵgetFieldValue(field) !== undefined ? 1 : 0;
2757
- }
2758
- const total = field.fieldGroup.reduce((s, f) => totalMatchedFields(f) + s, 0);
2759
- if (total === 0 && ɵhasKey(field)) {
2760
- const value = ɵgetFieldValue(field);
2761
- if (value === null || (value !== undefined && ((field.fieldArray && Array.isArray(value)) || (!field.fieldArray && isObject(value))))) {
2762
- return 1;
2763
- }
2764
- }
2765
- return total;
2766
- }
2767
- class GioJsonschema {
2768
- toFieldConfig(schema, options) {
2769
- return this._toFieldConfig(schema, Object.assign({ schema }, (options || {})));
2770
- }
2771
- _toFieldConfig(schema, _a) {
2772
- var _b;
2773
- var { key } = _a, options = __rest(_a, ["key"]);
2774
- schema = this.resolveSchema(schema, options);
2775
- const types = this.guessSchemaType(schema);
2776
- let field = {
2777
- type: types[0],
2778
- defaultValue: schema.default,
2779
- props: {
2780
- label: schema.title,
2781
- readonly: schema.readOnly,
2782
- description: schema.description,
2783
- },
2784
- };
2785
- if (key != null) {
2786
- field.key = key;
2787
- }
2788
- if (!options.ignoreDefault && (schema.readOnly || options.readOnly)) {
2789
- field.props.disabled = true;
2790
- options = Object.assign(Object.assign({}, options), { readOnly: true });
2791
- }
2792
- if (options.resetOnHide) {
2793
- field.resetOnHide = true;
2794
- }
2795
- if (key && options.strict) {
2796
- this.addValidator(field, 'type', (c, f) => {
2797
- const value = ɵgetFieldValue(f);
2798
- if (value != null) {
2799
- switch (field.type) {
2800
- case 'string': {
2801
- return typeof value === 'string';
2802
- }
2803
- case 'integer': {
2804
- return isInteger(value);
2805
- }
2806
- case 'number': {
2807
- return typeof value === 'number';
2808
- }
2809
- case 'object': {
2810
- return isObject(value);
2811
- }
2812
- case 'array': {
2813
- return Array.isArray(value);
2814
- }
2815
- }
2816
- }
2817
- return true;
2818
- });
2819
- }
2820
- if (options.shareFormControl === false) {
2821
- field.shareFormControl = false;
2822
- }
2823
- if (options.ignoreDefault) {
2824
- delete field.defaultValue;
2825
- }
2826
- this.addValidator(field, 'type', {
2827
- schemaType: types,
2828
- expression: ({ value }) => {
2829
- if (value === undefined) {
2830
- return true;
2831
- }
2832
- if (value === null && types.indexOf('null') !== -1) {
2833
- return true;
2834
- }
2835
- switch (types[0]) {
2836
- case 'null': {
2837
- return typeof value === null;
2838
- }
2839
- case 'string': {
2840
- return typeof value === 'string';
2841
- }
2842
- case 'integer': {
2843
- return isInteger(value);
2844
- }
2845
- case 'number': {
2846
- return typeof value === 'number';
2847
- }
2848
- case 'object': {
2849
- return isObject(value);
2850
- }
2851
- case 'array': {
2852
- return Array.isArray(value);
2853
- }
2854
- }
2855
- return true;
2856
- },
2857
- });
2858
- switch (field.type) {
2859
- case 'number':
2860
- case 'integer': {
2861
- field.parsers = [(v) => (isEmpty(v) ? undefined : Number(v))];
2862
- if (schema.hasOwnProperty('minimum')) {
2863
- field.props.min = schema.minimum;
2864
- }
2865
- if (schema.hasOwnProperty('maximum')) {
2866
- field.props.max = schema.maximum;
2867
- }
2868
- if (schema.hasOwnProperty('exclusiveMinimum')) {
2869
- field.props.exclusiveMinimum = schema.exclusiveMinimum;
2870
- this.addValidator(field, 'exclusiveMinimum', ({ value }) => isEmpty(value) || value > schema.exclusiveMinimum);
2871
- }
2872
- if (schema.hasOwnProperty('exclusiveMaximum')) {
2873
- field.props.exclusiveMaximum = schema.exclusiveMaximum;
2874
- this.addValidator(field, 'exclusiveMaximum', ({ value }) => isEmpty(value) || value < schema.exclusiveMaximum);
2875
- }
2876
- if (schema.hasOwnProperty('multipleOf')) {
2877
- field.props.step = schema.multipleOf;
2878
- this.addValidator(field, 'multipleOf', ({ value }) => {
2879
- if (isEmpty(value) || typeof value !== 'number' || value === 0 || schema.multipleOf <= 0) {
2880
- return true;
2881
- }
2882
- // https://github.com/ajv-validator/ajv/issues/652#issue-283610859
2883
- const multiplier = Math.pow(10, decimalPlaces(schema.multipleOf));
2884
- return Math.round(value * multiplier) % Math.round(schema.multipleOf * multiplier) === 0;
2885
- });
2886
- }
2887
- break;
2888
- }
2889
- case 'string': {
2890
- field.parsers = [
2891
- v => {
2892
- if (types.indexOf('null') !== -1) {
2893
- v = isEmpty(v) ? null : v;
2894
- }
2895
- else if (!field.props.required) {
2896
- v = v === '' ? undefined : v;
2897
- }
2898
- return v;
2899
- },
2900
- ];
2901
- ['minLength', 'maxLength', 'pattern'].forEach(prop => {
2902
- if (schema.hasOwnProperty(prop)) {
2903
- field.props[prop] = schema[prop];
2904
- }
2905
- });
2906
- break;
2907
- }
2908
- case 'object': {
2909
- if (!field.fieldGroup) {
2910
- field.fieldGroup = [];
2911
- }
2912
- const { propDeps, schemaDeps } = this.resolveDependencies(schema);
2913
- Object.keys(schema.properties || {}).forEach(property => {
2914
- const isRequired = Array.isArray(schema.required) && schema.required.indexOf(property) !== -1;
2915
- const f = this._toFieldConfig(schema.properties[property], Object.assign(Object.assign({}, options), { key: property, isOptional: options.isOptional || !isRequired }));
2916
- field.fieldGroup.push(f);
2917
- if (isRequired || propDeps[property]) {
2918
- f.expressions = Object.assign(Object.assign({}, (f.expressions || {})), { 'props.required': f => {
2919
- let parent = f.parent;
2920
- const model = f.fieldGroup && f.key != null ? parent.model : f.model;
2921
- while (parent.key == null && parent.parent) {
2922
- parent = parent.parent;
2923
- }
2924
- const required = parent && parent.props ? parent.props.required : false;
2925
- if (!model && !required) {
2926
- return false;
2927
- }
2928
- if (Array.isArray(schema.required) && schema.required.indexOf(property) !== -1) {
2929
- return true;
2930
- }
2931
- return propDeps[property] && f.model && propDeps[property].some(k => !isEmpty(f.model[k]));
2932
- } });
2933
- }
2934
- if (schemaDeps[property]) {
2935
- const getConstValue = (s) => {
2936
- return s.hasOwnProperty('const') ? s.const : s.enum[0];
2937
- };
2938
- const oneOfSchema = schemaDeps[property].oneOf;
2939
- if (oneOfSchema && oneOfSchema.every(o => o.properties && o.properties[property] && isConst(o.properties[property]))) {
2940
- oneOfSchema.forEach(oneOfSchemaItem => {
2941
- const _a = oneOfSchemaItem.properties, _b = property, constSchema = _a[_b], properties = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
2942
- field.fieldGroup.push(Object.assign(Object.assign({}, this._toFieldConfig(Object.assign(Object.assign({}, oneOfSchemaItem), { properties }), Object.assign(Object.assign({}, options), { resetOnHide: true }))), { expressions: {
2943
- hide: f => !f.model || getConstValue(constSchema) !== f.model[property],
2944
- } }));
2945
- });
2946
- }
2947
- else {
2948
- field.fieldGroup.push(Object.assign(Object.assign({}, this._toFieldConfig(schemaDeps[property], options)), { expressions: {
2949
- hide: f => !f.model || isEmpty(f.model[property]),
2950
- } }));
2951
- }
2952
- }
2953
- });
2954
- console.log('schema', cloneDeep(schema));
2955
- if (schema.oneOf) {
2956
- console.log(cloneDeep(field.fieldGroup));
2957
- field.fieldGroup.push(this.resolveMultiSchema('oneOf', schema.oneOf, Object.assign(Object.assign({}, options), { shareFormControl: false })));
2958
- }
2959
- if (schema.anyOf) {
2960
- field.fieldGroup.push(this.resolveMultiSchema('anyOf', schema.anyOf, options));
2961
- }
2962
- break;
2963
- }
2964
- case 'array': {
2965
- if (schema.hasOwnProperty('minItems')) {
2966
- field.props.minItems = schema.minItems;
2967
- this.addValidator(field, 'minItems', (c, f) => {
2968
- const value = ɵgetFieldValue(f);
2969
- return isEmpty(value) || value.length >= schema.minItems;
2970
- });
2971
- if (!options.isOptional && schema.minItems > 0 && field.defaultValue === undefined) {
2972
- field.defaultValue = Array.from(new Array(schema.minItems));
2973
- }
2974
- }
2975
- if (schema.hasOwnProperty('maxItems')) {
2976
- field.props.maxItems = schema.maxItems;
2977
- this.addValidator(field, 'maxItems', (c, f) => {
2978
- const value = ɵgetFieldValue(f);
2979
- return isEmpty(value) || value.length <= schema.maxItems;
2980
- });
2981
- }
2982
- if (schema.hasOwnProperty('uniqueItems')) {
2983
- field.props.uniqueItems = schema.uniqueItems;
2984
- this.addValidator(field, 'uniqueItems', (c, f) => {
2985
- const value = ɵgetFieldValue(f);
2986
- if (isEmpty(value) || !schema.uniqueItems) {
2987
- return true;
2988
- }
2989
- const uniqueItems = Array.from(new Set(value.map((v) => JSON.stringify(v))));
2990
- return uniqueItems.length === value.length;
2991
- });
2992
- }
2993
- // resolve items schema needed for isEnum check
2994
- if (schema.items && !Array.isArray(schema.items)) {
2995
- schema.items = this.resolveSchema(schema.items, options);
2996
- }
2997
- // TODO: remove isEnum check once adding an option to skip extension
2998
- if (!this.isEnum(schema)) {
2999
- field.fieldArray = (root) => {
3000
- if (!Array.isArray(schema.items)) {
3001
- // When items is a single schema, the additionalItems keyword is meaningless, and it should not be used.
3002
- const f = schema.items ? this._toFieldConfig(schema.items, options) : {};
3003
- if (f.props) {
3004
- f.props.required = true;
3005
- }
3006
- return f;
3007
- }
3008
- const length = root.fieldGroup ? root.fieldGroup.length : 0;
3009
- const itemSchema = schema.items[length] ? schema.items[length] : schema.additionalItems;
3010
- const f = itemSchema ? this._toFieldConfig(itemSchema, options) : {};
3011
- if (f.props) {
3012
- f.props.required = true;
3013
- }
3014
- if (schema.items[length]) {
3015
- f.props.removable = false;
3016
- }
3017
- return f;
3018
- };
3019
- }
3020
- break;
3021
- }
3022
- }
3023
- if (schema.hasOwnProperty('const')) {
3024
- field.props.const = schema.const;
3025
- this.addValidator(field, 'const', ({ value }) => value === schema.const);
3026
- if (!field.type) {
3027
- field.defaultValue = schema.const;
3028
- }
3029
- }
3030
- if (this.isEnum(schema)) {
3031
- field.props.multiple = field.type === 'array';
3032
- field.type = 'enum';
3033
- field.props.options = this.toEnumOptions(schema);
3034
- }
3035
- if (schema.oneOf && !field.type) {
3036
- delete field.key;
3037
- field.fieldGroup = [this.resolveMultiSchema('oneOf', schema.oneOf, Object.assign(Object.assign({}, options), { key, shareFormControl: false }))];
3038
- }
3039
- // map in possible formlyConfig options from the widget property
3040
- if ((_b = schema.widget) === null || _b === void 0 ? void 0 : _b.formlyConfig) {
3041
- field = this.mergeFields(field, schema.widget.formlyConfig);
3042
- }
3043
- field.templateOptions = field.props;
3044
- // if there is a map function passed in, use it to allow the user to
3045
- // further customize how fields are being mapped
3046
- return options.map ? options.map(field, schema) : field;
3047
- }
3048
- resolveSchema(schema, options) {
3049
- if (schema && schema.$ref) {
3050
- console.log('resolveSchema', { schema });
3051
- schema = this.resolveDefinition(schema, options);
3052
- console.log('resolved', { schema });
3053
- }
3054
- if (schema && schema.allOf) {
3055
- console.log('noopo');
3056
- schema = this.resolveAllOf(schema, options);
3057
- }
3058
- return schema;
3059
- }
3060
- resolveAllOf(_a, options) {
3061
- var { allOf } = _a, baseSchema = __rest(_a, ["allOf"]);
3062
- console.log('resolveAllOf', { allOf });
3063
- if (!allOf.length) {
3064
- throw Error(`allOf array can not be empty ${allOf}.`);
3065
- }
3066
- return allOf.reduce((base, schema) => {
3067
- schema = this.resolveSchema(schema, options);
3068
- console.log('resolveAllOf > resolveSchema', { schema });
3069
- if (base.required && schema.required) {
3070
- base.required = [...base.required, ...schema.required];
3071
- }
3072
- if (schema.uniqueItems) {
3073
- base.uniqueItems = schema.uniqueItems;
3074
- }
3075
- // resolve to min value
3076
- ['maxLength', 'maximum', 'exclusiveMaximum', 'maxItems', 'maxProperties'].forEach(prop => {
3077
- if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {
3078
- base[prop] = base[prop] < schema[prop] ? base[prop] : schema[prop];
3079
- }
3080
- });
3081
- // resolve to max value
3082
- ['minLength', 'minimum', 'exclusiveMinimum', 'minItems', 'minProperties'].forEach(prop => {
3083
- if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {
3084
- base[prop] = base[prop] > schema[prop] ? base[prop] : schema[prop];
3085
- }
3086
- });
3087
- return ɵreverseDeepMerge(base, schema);
3088
- }, baseSchema);
3089
- }
3090
- resolveMultiSchema(mode, schemas, options) {
3091
- console.log('resolveMultiSchema', { mode, schemas, options });
3092
- return {
3093
- type: 'multischema',
3094
- fieldGroup: [
3095
- {
3096
- type: 'enum',
3097
- defaultValue: -1,
3098
- props: {
3099
- multiple: mode === 'anyOf',
3100
- options: schemas.map((s, i) => ({ label: s.title, value: i, disabled: s.readOnly })),
3101
- },
3102
- hooks: {
3103
- onInit: f => f.formControl.valueChanges.pipe(tap(() => f.options.detectChanges(f.parent))),
3104
- },
3105
- },
3106
- {
3107
- fieldGroup: schemas.map((s, i) => (Object.assign(Object.assign({}, this._toFieldConfig(s, Object.assign(Object.assign({}, options), { resetOnHide: true }))), { expressions: {
3108
- hide: (f, forceUpdate) => {
3109
- const control = f.parent.parent.fieldGroup[0].formControl;
3110
- if (control.value === -1 || forceUpdate) {
3111
- let value = f.parent.fieldGroup
3112
- .map((f, i) => [f, i, this.isFieldValid(f, i, schemas, options)])
3113
- .sort(([f1, , f1Valid], [f2, , f2Valid]) => {
3114
- if (f1Valid !== f2Valid) {
3115
- return f2Valid ? 1 : -1;
3116
- }
3117
- const matchedFields1 = totalMatchedFields(f1);
3118
- const matchedFields2 = totalMatchedFields(f2);
3119
- if (matchedFields1 === matchedFields2) {
3120
- if (f1.props.disabled === f2.props.disabled) {
3121
- return 0;
3122
- }
3123
- return matchedFields2 > matchedFields1 ? 1 : -1;
3124
- }
3125
- return matchedFields2 > matchedFields1 ? 1 : -1;
3126
- })
3127
- .map(([, i]) => i);
3128
- if (mode === 'anyOf') {
3129
- const definedValue = value.filter(i => totalMatchedFields(f.parent.fieldGroup[i]));
3130
- value = definedValue.length > 0 ? definedValue : [value[0] || 0];
3131
- }
3132
- value = value.length > 0 ? value : [0];
3133
- control.setValue(mode === 'anyOf' ? value : value[0]);
3134
- }
3135
- return Array.isArray(control.value) ? control.value.indexOf(i) === -1 : control.value !== i;
3136
- },
3137
- } }))),
3138
- },
3139
- ],
3140
- };
3141
- }
3142
- resolveDefinition(schema, options) {
3143
- const [uri, pointer] = schema.$ref.split('#/');
3144
- if (uri) {
3145
- throw Error(`Remote schemas for ${schema.$ref} not supported yet.`);
3146
- }
3147
- const definition = !pointer
3148
- ? null
3149
- : pointer.split('/').reduce((def, path) => ((def === null || def === void 0 ? void 0 : def.hasOwnProperty(path)) ? def[path] : null), options.schema);
3150
- if (!definition) {
3151
- throw Error(`Cannot find a definition for ${schema.$ref}.`);
3152
- }
3153
- if (definition.$ref) {
3154
- return this.resolveDefinition(definition, options);
3155
- }
3156
- console.log({ definition, schema });
3157
- return Object.assign(Object.assign(Object.assign({}, definition), (schema.properties ? { properties: Object.assign(Object.assign({}, schema.properties), definition.properties) } : {})), ['title', 'description', 'default', 'widget'].reduce((annotation, p) => {
3158
- if (schema.hasOwnProperty(p)) {
3159
- annotation[p] = schema[p];
3160
- }
3161
- return annotation;
3162
- }, {}));
3163
- }
3164
- resolveDependencies(schema) {
3165
- const propDeps = {};
3166
- const schemaDeps = {};
3167
- Object.keys(schema.dependencies || {}).forEach(prop => {
3168
- const dependency = schema.dependencies[prop];
3169
- if (Array.isArray(dependency)) {
3170
- // Property dependencies
3171
- dependency.forEach(dep => {
3172
- if (!propDeps[dep]) {
3173
- propDeps[dep] = [prop];
3174
- }
3175
- else {
3176
- propDeps[dep].push(prop);
3177
- }
3178
- });
3179
- }
3180
- else {
3181
- // schema dependencies
3182
- schemaDeps[prop] = dependency;
3183
- }
3184
- });
3185
- return { propDeps, schemaDeps };
3186
- }
3187
- guessSchemaType(schema) {
3188
- const type = schema === null || schema === void 0 ? void 0 : schema.type;
3189
- if (!type && (schema === null || schema === void 0 ? void 0 : schema.properties)) {
3190
- return ['object'];
3191
- }
3192
- if (Array.isArray(type)) {
3193
- if (type.length === 1) {
3194
- return type;
3195
- }
3196
- if (type.length === 2 && type.indexOf('null') !== -1) {
3197
- return type.sort(t1 => (t1 == 'null' ? 1 : -1));
3198
- }
3199
- return type;
3200
- }
3201
- return type ? [type] : [];
3202
- }
3203
- addValidator(field, name, validator) {
3204
- field.validators = field.validators || {};
3205
- field.validators[name] = validator;
3206
- }
3207
- isEnum(schema) {
3208
- return (!!schema.enum ||
3209
- (schema.anyOf && schema.anyOf.every(isConst)) ||
3210
- (schema.oneOf && schema.oneOf.every(isConst)) ||
3211
- (schema.uniqueItems && schema.items && !Array.isArray(schema.items) && this.isEnum(schema.items)));
3212
- }
3213
- toEnumOptions(schema) {
3214
- if (schema.enum) {
3215
- return schema.enum.map(value => ({ value, label: value }));
3216
- }
3217
- const toEnum = (s) => {
3218
- const value = s.hasOwnProperty('const') ? s.const : s.enum[0];
3219
- const option = { value, label: s.title || value };
3220
- if (s.readOnly) {
3221
- option.disabled = true;
3222
- }
3223
- return option;
3224
- };
3225
- if (schema.anyOf) {
3226
- return schema.anyOf.map(toEnum);
3227
- }
3228
- if (schema.oneOf) {
3229
- return schema.oneOf.map(toEnum);
3230
- }
3231
- return this.toEnumOptions(schema.items);
3232
- }
3233
- isFieldValid(root, i, schemas, options) {
3234
- if (!root._schemasFields) {
3235
- Object.defineProperty(root, '_schemasFields', { enumerable: false, writable: true, configurable: true });
3236
- root._schemasFields = {};
3237
- }
3238
- let field = root._schemasFields[i];
3239
- const model = root.model ? ɵclone(root.model) : root.fieldArray ? [] : {};
3240
- if (!field) {
3241
- field = root._schemasFields[i] = root.options.build({
3242
- form: Array.isArray(model) ? new FormArray([]) : new FormGroup({}),
3243
- fieldGroup: [
3244
- this._toFieldConfig(schemas[i], Object.assign(Object.assign({}, options), { resetOnHide: true, ignoreDefault: true, map: null, strict: true })),
3245
- ],
3246
- model,
3247
- options: {},
3248
- });
3249
- }
3250
- else {
3251
- field.model = model;
3252
- root.options.build(field);
3253
- }
3254
- return field.form.valid;
3255
- }
3256
- mergeFields(f1, f2) {
3257
- for (let prop in f2) {
3258
- const f1Prop = prop === 'templateOptions' ? 'props' : prop;
3259
- if (isObject(f1[f1Prop]) && isObject(f2[prop])) {
3260
- f1[f1Prop] = this.mergeFields(f1[f1Prop], f2[prop]);
3261
- }
3262
- else if (f2[prop] != null) {
3263
- f1[f1Prop] = f2[prop];
3264
- }
3265
- }
3266
- return f1;
3267
- }
3268
- }
3269
- GioJsonschema.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioJsonschema, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3270
- GioJsonschema.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioJsonschema, providedIn: 'root' });
3271
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioJsonschema, decorators: [{
3272
- type: Injectable,
3273
- args: [{ providedIn: 'root' }]
3274
- }] });
3275
-
3276
2731
  /*
3277
2732
  * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
3278
2733
  *
@@ -3297,7 +2752,7 @@ class GioFormJsonSchemaComponent {
3297
2752
  this.fields = [];
3298
2753
  }
3299
2754
  set jsonSchema(jsonSchema) {
3300
- if (isObject$1(jsonSchema)) {
2755
+ if (isObject(jsonSchema)) {
3301
2756
  this.fields = [this.toFormlyFieldConfig(jsonSchema)];
3302
2757
  }
3303
2758
  }
@@ -3324,15 +2779,15 @@ class GioFormJsonSchemaComponent {
3324
2779
  };
3325
2780
  }
3326
2781
  }
3327
- GioFormJsonSchemaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, deps: [{ token: GioJsonschema }], target: i0.ɵɵFactoryTarget.Component });
3328
- GioFormJsonSchemaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormJsonSchemaComponent, selector: "gio-form-json-schema", inputs: { jsonSchema: "jsonSchema", formGroup: "formGroup", options: "options", initialValue: "initialValue" }, ngImport: i0, template: `<formly-form [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`, isInline: true, components: [{ type: i1$3.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }] });
2782
+ GioFormJsonSchemaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, deps: [{ token: i1$3.FormlyJsonschema }], target: i0.ɵɵFactoryTarget.Component });
2783
+ GioFormJsonSchemaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormJsonSchemaComponent, selector: "gio-form-json-schema", inputs: { jsonSchema: "jsonSchema", formGroup: "formGroup", options: "options", initialValue: "initialValue" }, ngImport: i0, template: `<formly-form [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`, isInline: true, components: [{ type: i1$4.FormlyForm, selector: "formly-form", inputs: ["form", "model", "fields", "options"], outputs: ["modelChange"] }] });
3329
2784
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, decorators: [{
3330
2785
  type: Component,
3331
2786
  args: [{
3332
2787
  selector: 'gio-form-json-schema',
3333
2788
  template: `<formly-form [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`,
3334
2789
  }]
3335
- }], ctorParameters: function () { return [{ type: GioJsonschema }]; }, propDecorators: { jsonSchema: [{
2790
+ }], ctorParameters: function () { return [{ type: i1$3.FormlyJsonschema }]; }, propDecorators: { jsonSchema: [{
3336
2791
  type: Input
3337
2792
  }], formGroup: [{
3338
2793
  type: Input
@@ -3402,7 +2857,7 @@ GioFjsObjectTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.
3402
2857
  </div>
3403
2858
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3404
2859
  </div>
3405
- `, isInline: true, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px;display:flex;flex-direction:column}.wrapper:empty{display:none}.wrapper formly-field+formly-field{margin-top:8px}\n"], components: [{ type: i1$3.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$3.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2860
+ `, isInline: true, styles: [".wrapper{display:flex;flex-direction:column;padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}.wrapper formly-field+formly-field{margin-top:8px}\n"], components: [{ type: i1$4.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$4.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3406
2861
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsObjectTypeComponent, decorators: [{
3407
2862
  type: Component,
3408
2863
  args: [{ selector: 'gio-fjs-object-type', template: `
@@ -3414,7 +2869,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3414
2869
  </div>
3415
2870
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3416
2871
  </div>
3417
- `, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px;display:flex;flex-direction:column}.wrapper:empty{display:none}.wrapper formly-field+formly-field{margin-top:8px}\n"] }]
2872
+ `, styles: [".wrapper{display:flex;flex-direction:column;padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}.wrapper formly-field+formly-field{margin-top:8px}\n"] }]
3418
2873
  }] });
3419
2874
 
3420
2875
  /*
@@ -3455,7 +2910,7 @@ GioFjsArrayTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
3455
2910
  <button class="btn btn-primary" type="button" (click)="add()">+</button>
3456
2911
  </div>
3457
2912
  </div>
3458
- `, isInline: true, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}.wrapper formly-field+formly-field{margin-top:8px;display:block}\n"], components: [{ type: i1$3.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$3.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2913
+ `, isInline: true, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}.wrapper formly-field+formly-field{display:block;margin-top:8px}\n"], components: [{ type: i1$4.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$4.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3459
2914
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsArrayTypeComponent, decorators: [{
3460
2915
  type: Component,
3461
2916
  args: [{ selector: 'gio-fjs-array-type', template: `
@@ -3478,7 +2933,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3478
2933
  <button class="btn btn-primary" type="button" (click)="add()">+</button>
3479
2934
  </div>
3480
2935
  </div>
3481
- `, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}.wrapper formly-field+formly-field{margin-top:8px;display:block}\n"] }]
2936
+ `, styles: [".wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}.wrapper formly-field+formly-field{display:block;margin-top:8px}\n"] }]
3482
2937
  }] });
3483
2938
 
3484
2939
  function minItemsValidationMessage(error, field) {
@@ -3589,7 +3044,7 @@ GioFjsMultiSchemaTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
3589
3044
  </div>
3590
3045
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3591
3046
  </div>
3592
- `, isInline: true, styles: ["::ng-deep gio-fjs-multi-schema-type .wrapper formly-field:first-child mat-form-field{padding-bottom:0}.wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}\n"], components: [{ type: i1$3.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$3.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3047
+ `, isInline: true, styles: ["::ng-deep gio-fjs-multi-schema-type div.wrapper formly-field:first-child mat-form-field{padding-bottom:0}.wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}\n"], components: [{ type: i1$4.ɵFormlyValidationMessage, selector: "formly-validation-message", inputs: ["field"] }, { type: i1$4.FormlyField, selector: "formly-field", inputs: ["field"] }], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
3593
3048
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsMultiSchemaTypeComponent, decorators: [{
3594
3049
  type: Component,
3595
3050
  args: [{ selector: 'gio-fjs-multi-schema-type', template: `
@@ -3601,7 +3056,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3601
3056
  </div>
3602
3057
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3603
3058
  </div>
3604
- `, styles: ["::ng-deep gio-fjs-multi-schema-type .wrapper formly-field:first-child mat-form-field{padding-bottom:0}.wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}\n"] }]
3059
+ `, styles: ["::ng-deep gio-fjs-multi-schema-type div.wrapper formly-field:first-child mat-form-field{padding-bottom:0}.wrapper{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper:empty{display:none}\n"] }]
3605
3060
  }] });
3606
3061
 
3607
3062
  /*
@@ -3628,7 +3083,7 @@ GioFormJsonSchemaModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
3628
3083
  GioFjsMultiSchemaTypeComponent,
3629
3084
  GioFjsArrayTypeComponent,
3630
3085
  GioFormFieldWrapperComponent], imports: [CommonModule,
3631
- ReactiveFormsModule, i1$3.FormlyModule, FormlyMaterialModule,
3086
+ ReactiveFormsModule, i1$4.FormlyModule, FormlyMaterialModule,
3632
3087
  GioIconsModule], exports: [GioFormJsonSchemaComponent, FormlyModule] });
3633
3088
  GioFormJsonSchemaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaModule, imports: [[
3634
3089
  CommonModule,