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

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.
@@ -12,7 +12,7 @@ import { ComponentHarness, HarnessPredicate, parallel, TestKey } from '@angular/
12
12
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
13
13
  import * as i3$1 from '@angular/material/form-field';
14
14
  import { MatFormFieldControl, MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
15
- import { isEmpty as isEmpty$1, toLower, dropRight, isNil, isArray, remove, cloneDeep, isObject as isObject$1, set } from 'lodash';
15
+ import { isEmpty, toLower, dropRight, isNil, isArray, remove, isObject, cloneDeep, set } from 'lodash';
16
16
  import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap } from 'rxjs/operators';
17
17
  import * as i7 from '@angular/forms';
18
18
  import { FormsModule, FormArray, FormGroup, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
@@ -43,8 +43,9 @@ import * as i6$2 from 'ngx-file-helpers';
43
43
  import { ReadMode, NgxFileHelpersModule } from 'ngx-file-helpers';
44
44
  import { MatSelectHarness } from '@angular/material/select/testing';
45
45
  import { toSvg } from 'jdenticon';
46
- import * as i1$3 from '@ngx-formly/core';
47
- import { ɵhasKey, ɵgetFieldValue, ɵreverseDeepMerge, ɵclone, FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
46
+ import * as i1$3 from '@ngx-formly/core/json-schema';
47
+ import * as i1$4 from '@ngx-formly/core';
48
+ import { FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
48
49
  import { FormlyMaterialModule } from '@ngx-formly/material';
49
50
 
50
51
  /*
@@ -323,7 +324,7 @@ class GioFormTagsInputComponent {
323
324
  }
324
325
  // From ControlValueAccessor interface
325
326
  get empty() {
326
- return isEmpty$1(this.value) && isEmpty$1(this._tagInput?.nativeElement?.value);
327
+ return isEmpty(this.value) && isEmpty(this._tagInput?.nativeElement?.value);
327
328
  }
328
329
  // From ControlValueAccessor interface
329
330
  get shouldLabelFloat() {
@@ -385,7 +386,7 @@ class GioFormTagsInputComponent {
385
386
  addChipToFormControl(event) {
386
387
  const input = this._tagInput?.nativeElement;
387
388
  const tagToAdd = (event.value ?? '').trim();
388
- if (isEmpty$1(tagToAdd)) {
389
+ if (isEmpty(tagToAdd)) {
389
390
  return;
390
391
  }
391
392
  // Add the tag only if shouldAddTag in validationCb return true
@@ -1169,7 +1170,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
1169
1170
  }] } });
1170
1171
  const removeLastEmptyHeader = (headers) => {
1171
1172
  const lastHeader = headers[headers.length - 1];
1172
- if (lastHeader && isEmpty$1(lastHeader.key) && isEmpty$1(lastHeader.value)) {
1173
+ if (lastHeader && isEmpty(lastHeader.key) && isEmpty(lastHeader.value)) {
1173
1174
  return dropRight(headers);
1174
1175
  }
1175
1176
  return headers;
@@ -2762,590 +2763,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
2762
2763
  * limitations under the License.
2763
2764
  */
2764
2765
 
2765
- /*
2766
- * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
2767
- *
2768
- * Licensed under the Apache License, Version 2.0 (the "License");
2769
- * you may not use this file except in compliance with the License.
2770
- * You may obtain a copy of the License at
2771
- *
2772
- * http://www.apache.org/licenses/LICENSE-2.0
2773
- *
2774
- * Unless required by applicable law or agreed to in writing, software
2775
- * distributed under the License is distributed on an "AS IS" BASIS,
2776
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2777
- * See the License for the specific language governing permissions and
2778
- * limitations under the License.
2779
- */
2780
- // https://stackoverflow.com/a/27865285
2781
- function decimalPlaces(a) {
2782
- if (!isFinite(a)) {
2783
- return 0;
2784
- }
2785
- let e = 1, p = 0;
2786
- while (Math.round(a * e) / e !== a) {
2787
- e *= 10;
2788
- p++;
2789
- }
2790
- return p;
2791
- }
2792
- function isEmpty(v) {
2793
- return v === '' || v == null;
2794
- }
2795
- function isObject(v) {
2796
- return v != null && typeof v === 'object' && !Array.isArray(v);
2797
- }
2798
- function isInteger(value) {
2799
- return Number.isInteger ? Number.isInteger(value) : typeof value === 'number' && Math.floor(value) === value;
2800
- }
2801
- function isConst(schema) {
2802
- return typeof schema === 'object' && (schema.hasOwnProperty('const') || (schema.enum && schema.enum.length === 1));
2803
- }
2804
- function totalMatchedFields(field) {
2805
- if (!field.fieldGroup) {
2806
- return ɵhasKey(field) && ɵgetFieldValue(field) !== undefined ? 1 : 0;
2807
- }
2808
- const total = field.fieldGroup.reduce((s, f) => totalMatchedFields(f) + s, 0);
2809
- if (total === 0 && ɵhasKey(field)) {
2810
- const value = ɵgetFieldValue(field);
2811
- if (value === null || (value !== undefined && ((field.fieldArray && Array.isArray(value)) || (!field.fieldArray && isObject(value))))) {
2812
- return 1;
2813
- }
2814
- }
2815
- return total;
2816
- }
2817
- class GioJsonschema {
2818
- toFieldConfig(schema, options) {
2819
- return this._toFieldConfig(schema, { schema, ...(options || {}) });
2820
- }
2821
- _toFieldConfig(schema, { key, ...options }) {
2822
- schema = this.resolveSchema(schema, options);
2823
- const types = this.guessSchemaType(schema);
2824
- let field = {
2825
- type: types[0],
2826
- defaultValue: schema.default,
2827
- props: {
2828
- label: schema.title,
2829
- readonly: schema.readOnly,
2830
- description: schema.description,
2831
- },
2832
- };
2833
- if (key != null) {
2834
- field.key = key;
2835
- }
2836
- if (!options.ignoreDefault && (schema.readOnly || options.readOnly)) {
2837
- field.props.disabled = true;
2838
- options = { ...options, readOnly: true };
2839
- }
2840
- if (options.resetOnHide) {
2841
- field.resetOnHide = true;
2842
- }
2843
- if (key && options.strict) {
2844
- this.addValidator(field, 'type', (c, f) => {
2845
- const value = ɵgetFieldValue(f);
2846
- if (value != null) {
2847
- switch (field.type) {
2848
- case 'string': {
2849
- return typeof value === 'string';
2850
- }
2851
- case 'integer': {
2852
- return isInteger(value);
2853
- }
2854
- case 'number': {
2855
- return typeof value === 'number';
2856
- }
2857
- case 'object': {
2858
- return isObject(value);
2859
- }
2860
- case 'array': {
2861
- return Array.isArray(value);
2862
- }
2863
- }
2864
- }
2865
- return true;
2866
- });
2867
- }
2868
- if (options.shareFormControl === false) {
2869
- field.shareFormControl = false;
2870
- }
2871
- if (options.ignoreDefault) {
2872
- delete field.defaultValue;
2873
- }
2874
- this.addValidator(field, 'type', {
2875
- schemaType: types,
2876
- expression: ({ value }) => {
2877
- if (value === undefined) {
2878
- return true;
2879
- }
2880
- if (value === null && types.indexOf('null') !== -1) {
2881
- return true;
2882
- }
2883
- switch (types[0]) {
2884
- case 'null': {
2885
- return typeof value === null;
2886
- }
2887
- case 'string': {
2888
- return typeof value === 'string';
2889
- }
2890
- case 'integer': {
2891
- return isInteger(value);
2892
- }
2893
- case 'number': {
2894
- return typeof value === 'number';
2895
- }
2896
- case 'object': {
2897
- return isObject(value);
2898
- }
2899
- case 'array': {
2900
- return Array.isArray(value);
2901
- }
2902
- }
2903
- return true;
2904
- },
2905
- });
2906
- switch (field.type) {
2907
- case 'number':
2908
- case 'integer': {
2909
- field.parsers = [(v) => (isEmpty(v) ? undefined : Number(v))];
2910
- if (schema.hasOwnProperty('minimum')) {
2911
- field.props.min = schema.minimum;
2912
- }
2913
- if (schema.hasOwnProperty('maximum')) {
2914
- field.props.max = schema.maximum;
2915
- }
2916
- if (schema.hasOwnProperty('exclusiveMinimum')) {
2917
- field.props.exclusiveMinimum = schema.exclusiveMinimum;
2918
- this.addValidator(field, 'exclusiveMinimum', ({ value }) => isEmpty(value) || value > schema.exclusiveMinimum);
2919
- }
2920
- if (schema.hasOwnProperty('exclusiveMaximum')) {
2921
- field.props.exclusiveMaximum = schema.exclusiveMaximum;
2922
- this.addValidator(field, 'exclusiveMaximum', ({ value }) => isEmpty(value) || value < schema.exclusiveMaximum);
2923
- }
2924
- if (schema.hasOwnProperty('multipleOf')) {
2925
- field.props.step = schema.multipleOf;
2926
- this.addValidator(field, 'multipleOf', ({ value }) => {
2927
- if (isEmpty(value) || typeof value !== 'number' || value === 0 || schema.multipleOf <= 0) {
2928
- return true;
2929
- }
2930
- // https://github.com/ajv-validator/ajv/issues/652#issue-283610859
2931
- const multiplier = Math.pow(10, decimalPlaces(schema.multipleOf));
2932
- return Math.round(value * multiplier) % Math.round(schema.multipleOf * multiplier) === 0;
2933
- });
2934
- }
2935
- break;
2936
- }
2937
- case 'string': {
2938
- field.parsers = [
2939
- v => {
2940
- if (types.indexOf('null') !== -1) {
2941
- v = isEmpty(v) ? null : v;
2942
- }
2943
- else if (!field.props.required) {
2944
- v = v === '' ? undefined : v;
2945
- }
2946
- return v;
2947
- },
2948
- ];
2949
- ['minLength', 'maxLength', 'pattern'].forEach(prop => {
2950
- if (schema.hasOwnProperty(prop)) {
2951
- field.props[prop] = schema[prop];
2952
- }
2953
- });
2954
- break;
2955
- }
2956
- case 'object': {
2957
- if (!field.fieldGroup) {
2958
- field.fieldGroup = [];
2959
- }
2960
- const { propDeps, schemaDeps } = this.resolveDependencies(schema);
2961
- Object.keys(schema.properties || {}).forEach(property => {
2962
- const isRequired = Array.isArray(schema.required) && schema.required.indexOf(property) !== -1;
2963
- const f = this._toFieldConfig(schema.properties[property], {
2964
- ...options,
2965
- key: property,
2966
- isOptional: options.isOptional || !isRequired,
2967
- });
2968
- field.fieldGroup.push(f);
2969
- if (isRequired || propDeps[property]) {
2970
- f.expressions = {
2971
- ...(f.expressions || {}),
2972
- 'props.required': f => {
2973
- let parent = f.parent;
2974
- const model = f.fieldGroup && f.key != null ? parent.model : f.model;
2975
- while (parent.key == null && parent.parent) {
2976
- parent = parent.parent;
2977
- }
2978
- const required = parent && parent.props ? parent.props.required : false;
2979
- if (!model && !required) {
2980
- return false;
2981
- }
2982
- if (Array.isArray(schema.required) && schema.required.indexOf(property) !== -1) {
2983
- return true;
2984
- }
2985
- return propDeps[property] && f.model && propDeps[property].some(k => !isEmpty(f.model[k]));
2986
- },
2987
- };
2988
- }
2989
- if (schemaDeps[property]) {
2990
- const getConstValue = (s) => {
2991
- return s.hasOwnProperty('const') ? s.const : s.enum[0];
2992
- };
2993
- const oneOfSchema = schemaDeps[property].oneOf;
2994
- if (oneOfSchema && oneOfSchema.every(o => o.properties && o.properties[property] && isConst(o.properties[property]))) {
2995
- oneOfSchema.forEach(oneOfSchemaItem => {
2996
- const { [property]: constSchema, ...properties } = oneOfSchemaItem.properties;
2997
- field.fieldGroup.push({
2998
- ...this._toFieldConfig({ ...oneOfSchemaItem, properties }, { ...options, resetOnHide: true }),
2999
- expressions: {
3000
- hide: f => !f.model || getConstValue(constSchema) !== f.model[property],
3001
- },
3002
- });
3003
- });
3004
- }
3005
- else {
3006
- field.fieldGroup.push({
3007
- ...this._toFieldConfig(schemaDeps[property], options),
3008
- expressions: {
3009
- hide: f => !f.model || isEmpty(f.model[property]),
3010
- },
3011
- });
3012
- }
3013
- }
3014
- });
3015
- console.log('schema', cloneDeep(schema));
3016
- if (schema.oneOf) {
3017
- console.log(cloneDeep(field.fieldGroup));
3018
- field.fieldGroup.push(this.resolveMultiSchema('oneOf', schema.oneOf, { ...options, shareFormControl: false }));
3019
- }
3020
- if (schema.anyOf) {
3021
- field.fieldGroup.push(this.resolveMultiSchema('anyOf', schema.anyOf, options));
3022
- }
3023
- break;
3024
- }
3025
- case 'array': {
3026
- if (schema.hasOwnProperty('minItems')) {
3027
- field.props.minItems = schema.minItems;
3028
- this.addValidator(field, 'minItems', (c, f) => {
3029
- const value = ɵgetFieldValue(f);
3030
- return isEmpty(value) || value.length >= schema.minItems;
3031
- });
3032
- if (!options.isOptional && schema.minItems > 0 && field.defaultValue === undefined) {
3033
- field.defaultValue = Array.from(new Array(schema.minItems));
3034
- }
3035
- }
3036
- if (schema.hasOwnProperty('maxItems')) {
3037
- field.props.maxItems = schema.maxItems;
3038
- this.addValidator(field, 'maxItems', (c, f) => {
3039
- const value = ɵgetFieldValue(f);
3040
- return isEmpty(value) || value.length <= schema.maxItems;
3041
- });
3042
- }
3043
- if (schema.hasOwnProperty('uniqueItems')) {
3044
- field.props.uniqueItems = schema.uniqueItems;
3045
- this.addValidator(field, 'uniqueItems', (c, f) => {
3046
- const value = ɵgetFieldValue(f);
3047
- if (isEmpty(value) || !schema.uniqueItems) {
3048
- return true;
3049
- }
3050
- const uniqueItems = Array.from(new Set(value.map((v) => JSON.stringify(v))));
3051
- return uniqueItems.length === value.length;
3052
- });
3053
- }
3054
- // resolve items schema needed for isEnum check
3055
- if (schema.items && !Array.isArray(schema.items)) {
3056
- schema.items = this.resolveSchema(schema.items, options);
3057
- }
3058
- // TODO: remove isEnum check once adding an option to skip extension
3059
- if (!this.isEnum(schema)) {
3060
- field.fieldArray = (root) => {
3061
- if (!Array.isArray(schema.items)) {
3062
- // When items is a single schema, the additionalItems keyword is meaningless, and it should not be used.
3063
- const f = schema.items ? this._toFieldConfig(schema.items, options) : {};
3064
- if (f.props) {
3065
- f.props.required = true;
3066
- }
3067
- return f;
3068
- }
3069
- const length = root.fieldGroup ? root.fieldGroup.length : 0;
3070
- const itemSchema = schema.items[length] ? schema.items[length] : schema.additionalItems;
3071
- const f = itemSchema ? this._toFieldConfig(itemSchema, options) : {};
3072
- if (f.props) {
3073
- f.props.required = true;
3074
- }
3075
- if (schema.items[length]) {
3076
- f.props.removable = false;
3077
- }
3078
- return f;
3079
- };
3080
- }
3081
- break;
3082
- }
3083
- }
3084
- if (schema.hasOwnProperty('const')) {
3085
- field.props.const = schema.const;
3086
- this.addValidator(field, 'const', ({ value }) => value === schema.const);
3087
- if (!field.type) {
3088
- field.defaultValue = schema.const;
3089
- }
3090
- }
3091
- if (this.isEnum(schema)) {
3092
- field.props.multiple = field.type === 'array';
3093
- field.type = 'enum';
3094
- field.props.options = this.toEnumOptions(schema);
3095
- }
3096
- if (schema.oneOf && !field.type) {
3097
- delete field.key;
3098
- field.fieldGroup = [this.resolveMultiSchema('oneOf', schema.oneOf, { ...options, key, shareFormControl: false })];
3099
- }
3100
- // map in possible formlyConfig options from the widget property
3101
- if (schema.widget?.formlyConfig) {
3102
- field = this.mergeFields(field, schema.widget.formlyConfig);
3103
- }
3104
- field.templateOptions = field.props;
3105
- // if there is a map function passed in, use it to allow the user to
3106
- // further customize how fields are being mapped
3107
- return options.map ? options.map(field, schema) : field;
3108
- }
3109
- resolveSchema(schema, options) {
3110
- if (schema && schema.$ref) {
3111
- console.log('resolveSchema', { schema });
3112
- schema = this.resolveDefinition(schema, options);
3113
- console.log('resolved', { schema });
3114
- }
3115
- if (schema && schema.allOf) {
3116
- console.log('noopo');
3117
- schema = this.resolveAllOf(schema, options);
3118
- }
3119
- return schema;
3120
- }
3121
- resolveAllOf({ allOf, ...baseSchema }, options) {
3122
- console.log('resolveAllOf', { allOf });
3123
- if (!allOf.length) {
3124
- throw Error(`allOf array can not be empty ${allOf}.`);
3125
- }
3126
- return allOf.reduce((base, schema) => {
3127
- schema = this.resolveSchema(schema, options);
3128
- console.log('resolveAllOf > resolveSchema', { schema });
3129
- if (base.required && schema.required) {
3130
- base.required = [...base.required, ...schema.required];
3131
- }
3132
- if (schema.uniqueItems) {
3133
- base.uniqueItems = schema.uniqueItems;
3134
- }
3135
- // resolve to min value
3136
- ['maxLength', 'maximum', 'exclusiveMaximum', 'maxItems', 'maxProperties'].forEach(prop => {
3137
- if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {
3138
- base[prop] = base[prop] < schema[prop] ? base[prop] : schema[prop];
3139
- }
3140
- });
3141
- // resolve to max value
3142
- ['minLength', 'minimum', 'exclusiveMinimum', 'minItems', 'minProperties'].forEach(prop => {
3143
- if (!isEmpty(base[prop]) && !isEmpty(schema[prop])) {
3144
- base[prop] = base[prop] > schema[prop] ? base[prop] : schema[prop];
3145
- }
3146
- });
3147
- return ɵreverseDeepMerge(base, schema);
3148
- }, baseSchema);
3149
- }
3150
- resolveMultiSchema(mode, schemas, options) {
3151
- console.log('resolveMultiSchema', { mode, schemas, options });
3152
- return {
3153
- type: 'multischema',
3154
- fieldGroup: [
3155
- {
3156
- type: 'enum',
3157
- defaultValue: -1,
3158
- props: {
3159
- multiple: mode === 'anyOf',
3160
- options: schemas.map((s, i) => ({ label: s.title, value: i, disabled: s.readOnly })),
3161
- },
3162
- hooks: {
3163
- onInit: f => f.formControl.valueChanges.pipe(tap(() => f.options.detectChanges(f.parent))),
3164
- },
3165
- },
3166
- {
3167
- fieldGroup: schemas.map((s, i) => ({
3168
- ...this._toFieldConfig(s, { ...options, resetOnHide: true }),
3169
- expressions: {
3170
- hide: (f, forceUpdate) => {
3171
- const control = f.parent.parent.fieldGroup[0].formControl;
3172
- if (control.value === -1 || forceUpdate) {
3173
- let value = f.parent.fieldGroup
3174
- .map((f, i) => [f, i, this.isFieldValid(f, i, schemas, options)])
3175
- .sort(([f1, , f1Valid], [f2, , f2Valid]) => {
3176
- if (f1Valid !== f2Valid) {
3177
- return f2Valid ? 1 : -1;
3178
- }
3179
- const matchedFields1 = totalMatchedFields(f1);
3180
- const matchedFields2 = totalMatchedFields(f2);
3181
- if (matchedFields1 === matchedFields2) {
3182
- if (f1.props.disabled === f2.props.disabled) {
3183
- return 0;
3184
- }
3185
- return matchedFields2 > matchedFields1 ? 1 : -1;
3186
- }
3187
- return matchedFields2 > matchedFields1 ? 1 : -1;
3188
- })
3189
- .map(([, i]) => i);
3190
- if (mode === 'anyOf') {
3191
- const definedValue = value.filter(i => totalMatchedFields(f.parent.fieldGroup[i]));
3192
- value = definedValue.length > 0 ? definedValue : [value[0] || 0];
3193
- }
3194
- value = value.length > 0 ? value : [0];
3195
- control.setValue(mode === 'anyOf' ? value : value[0]);
3196
- }
3197
- return Array.isArray(control.value) ? control.value.indexOf(i) === -1 : control.value !== i;
3198
- },
3199
- },
3200
- })),
3201
- },
3202
- ],
3203
- };
3204
- }
3205
- resolveDefinition(schema, options) {
3206
- const [uri, pointer] = schema.$ref.split('#/');
3207
- if (uri) {
3208
- throw Error(`Remote schemas for ${schema.$ref} not supported yet.`);
3209
- }
3210
- const definition = !pointer
3211
- ? null
3212
- : pointer.split('/').reduce((def, path) => (def?.hasOwnProperty(path) ? def[path] : null), options.schema);
3213
- if (!definition) {
3214
- throw Error(`Cannot find a definition for ${schema.$ref}.`);
3215
- }
3216
- if (definition.$ref) {
3217
- return this.resolveDefinition(definition, options);
3218
- }
3219
- console.log({ definition, schema });
3220
- return {
3221
- ...definition,
3222
- ...(schema.properties ? { properties: { ...schema.properties, ...definition.properties } } : {}),
3223
- ...['title', 'description', 'default', 'widget'].reduce((annotation, p) => {
3224
- if (schema.hasOwnProperty(p)) {
3225
- annotation[p] = schema[p];
3226
- }
3227
- return annotation;
3228
- }, {}),
3229
- };
3230
- }
3231
- resolveDependencies(schema) {
3232
- const propDeps = {};
3233
- const schemaDeps = {};
3234
- Object.keys(schema.dependencies || {}).forEach(prop => {
3235
- const dependency = schema.dependencies[prop];
3236
- if (Array.isArray(dependency)) {
3237
- // Property dependencies
3238
- dependency.forEach(dep => {
3239
- if (!propDeps[dep]) {
3240
- propDeps[dep] = [prop];
3241
- }
3242
- else {
3243
- propDeps[dep].push(prop);
3244
- }
3245
- });
3246
- }
3247
- else {
3248
- // schema dependencies
3249
- schemaDeps[prop] = dependency;
3250
- }
3251
- });
3252
- return { propDeps, schemaDeps };
3253
- }
3254
- guessSchemaType(schema) {
3255
- const type = schema?.type;
3256
- if (!type && schema?.properties) {
3257
- return ['object'];
3258
- }
3259
- if (Array.isArray(type)) {
3260
- if (type.length === 1) {
3261
- return type;
3262
- }
3263
- if (type.length === 2 && type.indexOf('null') !== -1) {
3264
- return type.sort(t1 => (t1 == 'null' ? 1 : -1));
3265
- }
3266
- return type;
3267
- }
3268
- return type ? [type] : [];
3269
- }
3270
- addValidator(field, name, validator) {
3271
- field.validators = field.validators || {};
3272
- field.validators[name] = validator;
3273
- }
3274
- isEnum(schema) {
3275
- return (!!schema.enum ||
3276
- (schema.anyOf && schema.anyOf.every(isConst)) ||
3277
- (schema.oneOf && schema.oneOf.every(isConst)) ||
3278
- (schema.uniqueItems && schema.items && !Array.isArray(schema.items) && this.isEnum(schema.items)));
3279
- }
3280
- toEnumOptions(schema) {
3281
- if (schema.enum) {
3282
- return schema.enum.map(value => ({ value, label: value }));
3283
- }
3284
- const toEnum = (s) => {
3285
- const value = s.hasOwnProperty('const') ? s.const : s.enum[0];
3286
- const option = { value, label: s.title || value };
3287
- if (s.readOnly) {
3288
- option.disabled = true;
3289
- }
3290
- return option;
3291
- };
3292
- if (schema.anyOf) {
3293
- return schema.anyOf.map(toEnum);
3294
- }
3295
- if (schema.oneOf) {
3296
- return schema.oneOf.map(toEnum);
3297
- }
3298
- return this.toEnumOptions(schema.items);
3299
- }
3300
- isFieldValid(root, i, schemas, options) {
3301
- if (!root._schemasFields) {
3302
- Object.defineProperty(root, '_schemasFields', { enumerable: false, writable: true, configurable: true });
3303
- root._schemasFields = {};
3304
- }
3305
- let field = root._schemasFields[i];
3306
- const model = root.model ? ɵclone(root.model) : root.fieldArray ? [] : {};
3307
- if (!field) {
3308
- field = root._schemasFields[i] = root.options.build({
3309
- form: Array.isArray(model) ? new FormArray([]) : new FormGroup({}),
3310
- fieldGroup: [
3311
- this._toFieldConfig(schemas[i], {
3312
- ...options,
3313
- resetOnHide: true,
3314
- ignoreDefault: true,
3315
- map: null,
3316
- strict: true,
3317
- }),
3318
- ],
3319
- model,
3320
- options: {},
3321
- });
3322
- }
3323
- else {
3324
- field.model = model;
3325
- root.options.build(field);
3326
- }
3327
- return field.form.valid;
3328
- }
3329
- mergeFields(f1, f2) {
3330
- for (let prop in f2) {
3331
- const f1Prop = prop === 'templateOptions' ? 'props' : prop;
3332
- if (isObject(f1[f1Prop]) && isObject(f2[prop])) {
3333
- f1[f1Prop] = this.mergeFields(f1[f1Prop], f2[prop]);
3334
- }
3335
- else if (f2[prop] != null) {
3336
- f1[f1Prop] = f2[prop];
3337
- }
3338
- }
3339
- return f1;
3340
- }
3341
- }
3342
- GioJsonschema.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioJsonschema, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3343
- GioJsonschema.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioJsonschema, providedIn: 'root' });
3344
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioJsonschema, decorators: [{
3345
- type: Injectable,
3346
- args: [{ providedIn: 'root' }]
3347
- }] });
3348
-
3349
2766
  /*
3350
2767
  * Copyright (C) 2023 The Gravitee team (http://gravitee.io)
3351
2768
  *
@@ -3370,7 +2787,7 @@ class GioFormJsonSchemaComponent {
3370
2787
  this.fields = [];
3371
2788
  }
3372
2789
  set jsonSchema(jsonSchema) {
3373
- if (isObject$1(jsonSchema)) {
2790
+ if (isObject(jsonSchema)) {
3374
2791
  this.fields = [this.toFormlyFieldConfig(jsonSchema)];
3375
2792
  }
3376
2793
  }
@@ -3399,15 +2816,15 @@ class GioFormJsonSchemaComponent {
3399
2816
  };
3400
2817
  }
3401
2818
  }
3402
- GioFormJsonSchemaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, deps: [{ token: GioJsonschema }], target: i0.ɵɵFactoryTarget.Component });
3403
- 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"] }] });
2819
+ 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 });
2820
+ 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"] }] });
3404
2821
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, decorators: [{
3405
2822
  type: Component,
3406
2823
  args: [{
3407
2824
  selector: 'gio-form-json-schema',
3408
2825
  template: `<formly-form [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`,
3409
2826
  }]
3410
- }], ctorParameters: function () { return [{ type: GioJsonschema }]; }, propDecorators: { jsonSchema: [{
2827
+ }], ctorParameters: function () { return [{ type: i1$3.FormlyJsonschema }]; }, propDecorators: { jsonSchema: [{
3411
2828
  type: Input
3412
2829
  }], formGroup: [{
3413
2830
  type: Input
@@ -3477,7 +2894,7 @@ GioFjsObjectTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.
3477
2894
  </div>
3478
2895
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3479
2896
  </div>
3480
- `, 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"] }] });
2897
+ `, 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"] }] });
3481
2898
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsObjectTypeComponent, decorators: [{
3482
2899
  type: Component,
3483
2900
  args: [{ selector: 'gio-fjs-object-type', template: `
@@ -3489,7 +2906,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3489
2906
  </div>
3490
2907
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3491
2908
  </div>
3492
- `, 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"] }]
2909
+ `, 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"] }]
3493
2910
  }] });
3494
2911
 
3495
2912
  /*
@@ -3530,7 +2947,7 @@ GioFjsArrayTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
3530
2947
  <button class="btn btn-primary" type="button" (click)="add()">+</button>
3531
2948
  </div>
3532
2949
  </div>
3533
- `, 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"] }] });
2950
+ `, 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"] }] });
3534
2951
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsArrayTypeComponent, decorators: [{
3535
2952
  type: Component,
3536
2953
  args: [{ selector: 'gio-fjs-array-type', template: `
@@ -3553,7 +2970,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3553
2970
  <button class="btn btn-primary" type="button" (click)="add()">+</button>
3554
2971
  </div>
3555
2972
  </div>
3556
- `, 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"] }]
2973
+ `, 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"] }]
3557
2974
  }] });
3558
2975
 
3559
2976
  function minItemsValidationMessage(error, field) {
@@ -3654,7 +3071,7 @@ GioFjsMultiSchemaTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
3654
3071
  </div>
3655
3072
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3656
3073
  </div>
3657
- `, 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"] }] });
3074
+ `, 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"] }] });
3658
3075
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsMultiSchemaTypeComponent, decorators: [{
3659
3076
  type: Component,
3660
3077
  args: [{ selector: 'gio-fjs-multi-schema-type', template: `
@@ -3666,7 +3083,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
3666
3083
  </div>
3667
3084
  <formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
3668
3085
  </div>
3669
- `, 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"] }]
3086
+ `, 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"] }]
3670
3087
  }] });
3671
3088
 
3672
3089
  /*
@@ -3693,7 +3110,7 @@ GioFormJsonSchemaModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
3693
3110
  GioFjsMultiSchemaTypeComponent,
3694
3111
  GioFjsArrayTypeComponent,
3695
3112
  GioFormFieldWrapperComponent], imports: [CommonModule,
3696
- ReactiveFormsModule, i1$3.FormlyModule, FormlyMaterialModule,
3113
+ ReactiveFormsModule, i1$4.FormlyModule, FormlyMaterialModule,
3697
3114
  GioIconsModule], exports: [GioFormJsonSchemaComponent, FormlyModule] });
3698
3115
  GioFormJsonSchemaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaModule, imports: [[
3699
3116
  CommonModule,