@gravitee/ui-particles-angular 5.7.3-improve-form-json-compo-db890aa → 5.7.3-json-schema-77b8f57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/gio-form-json-schema/gio-form-json-schema.component.mjs +17 -75
- package/esm2020/lib/gio-form-json-schema/gio-form-json-schema.module.mjs +1 -11
- package/esm2020/lib/gio-form-json-schema/service/json-schema.service.mjs +592 -0
- package/esm2020/lib/gio-form-json-schema/type-component/array-type.component.mjs +8 -11
- package/esm2020/lib/gio-form-json-schema/type-component/multischema-type.component.mjs +20 -23
- package/esm2020/lib/gio-form-json-schema/type-component/object-type.component.mjs +8 -11
- package/fesm2015/gravitee-ui-particles-angular.mjs +601 -132
- package/fesm2015/gravitee-ui-particles-angular.mjs.map +1 -1
- package/fesm2020/gravitee-ui-particles-angular.mjs +636 -125
- package/fesm2020/gravitee-ui-particles-angular.mjs.map +1 -1
- package/lib/gio-form-json-schema/gio-form-json-schema.component.d.ts +8 -22
- package/lib/gio-form-json-schema/gio-form-json-schema.module.d.ts +5 -6
- package/lib/gio-form-json-schema/service/json-schema.service.d.ts +28 -0
- package/lib/gio-form-json-schema/type-component/multischema-type.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { trigger, transition, style, animate } from '@angular/animations';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { EventEmitter, Component, HostBinding, Input, Output, HostListener, NgModule, Optional, Self, ViewChild, Directive, Inject, forwardRef, ChangeDetectionStrategy, Injectable, ViewEncapsulation, ContentChildren
|
|
3
|
+
import { EventEmitter, Component, HostBinding, Input, Output, HostListener, NgModule, Optional, Self, ViewChild, Directive, Inject, forwardRef, ChangeDetectionStrategy, Injectable, ViewEncapsulation, ContentChildren } from '@angular/core';
|
|
4
4
|
import { timer, Subject, fromEvent, of, BehaviorSubject } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/material/card';
|
|
6
6
|
import { MatCardModule } from '@angular/material/card';
|
|
@@ -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 } from 'tslib';
|
|
11
|
+
import { __awaiter, __rest } 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, toLower, dropRight, isNil, isArray, remove, isObject,
|
|
16
|
+
import { isEmpty as isEmpty$1, toLower, dropRight, isNil, isArray, remove, cloneDeep, isObject as isObject$1, 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,9 +44,8 @@ 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
|
|
49
|
-
import { FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
|
|
47
|
+
import * as i1$3 from '@ngx-formly/core';
|
|
48
|
+
import { ɵhasKey, ɵgetFieldValue, ɵreverseDeepMerge, ɵclone, FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-formly/core';
|
|
50
49
|
import { FormlyMaterialModule } from '@ngx-formly/material';
|
|
51
50
|
|
|
52
51
|
/*
|
|
@@ -322,7 +321,7 @@ class GioFormTagsInputComponent {
|
|
|
322
321
|
// From ControlValueAccessor interface
|
|
323
322
|
get empty() {
|
|
324
323
|
var _a, _b;
|
|
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);
|
|
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);
|
|
326
325
|
}
|
|
327
326
|
// From ControlValueAccessor interface
|
|
328
327
|
get shouldLabelFloat() {
|
|
@@ -385,7 +384,7 @@ class GioFormTagsInputComponent {
|
|
|
385
384
|
var _a, _b, _c;
|
|
386
385
|
const input = (_a = this._tagInput) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
387
386
|
const tagToAdd = ((_b = event.value) !== null && _b !== void 0 ? _b : '').trim();
|
|
388
|
-
if (isEmpty(tagToAdd)) {
|
|
387
|
+
if (isEmpty$1(tagToAdd)) {
|
|
389
388
|
return;
|
|
390
389
|
}
|
|
391
390
|
// Add the tag only if shouldAddTag in validationCb return true
|
|
@@ -1154,7 +1153,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1154
1153
|
}] } });
|
|
1155
1154
|
const removeLastEmptyHeader = (headers) => {
|
|
1156
1155
|
const lastHeader = headers[headers.length - 1];
|
|
1157
|
-
if (lastHeader && isEmpty(lastHeader.key) && isEmpty(lastHeader.value)) {
|
|
1156
|
+
if (lastHeader && isEmpty$1(lastHeader.key) && isEmpty$1(lastHeader.value)) {
|
|
1158
1157
|
return dropRight(headers);
|
|
1159
1158
|
}
|
|
1160
1159
|
return headers;
|
|
@@ -2728,6 +2727,552 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
2728
2727
|
* limitations under the License.
|
|
2729
2728
|
*/
|
|
2730
2729
|
|
|
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
|
+
|
|
2731
3276
|
/*
|
|
2732
3277
|
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
2733
3278
|
*
|
|
@@ -2744,76 +3289,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
2744
3289
|
* limitations under the License.
|
|
2745
3290
|
*/
|
|
2746
3291
|
class GioFormJsonSchemaComponent {
|
|
2747
|
-
constructor(formlyJsonschema
|
|
3292
|
+
constructor(formlyJsonschema) {
|
|
2748
3293
|
this.formlyJsonschema = formlyJsonschema;
|
|
2749
|
-
this.elRef = elRef;
|
|
2750
|
-
this.fm = fm;
|
|
2751
|
-
this.ngControl = ngControl;
|
|
2752
|
-
this.unsubscribe$ = new Subject();
|
|
2753
3294
|
this.formGroup = new FormGroup({});
|
|
2754
3295
|
this.options = {};
|
|
2755
3296
|
this.model = {};
|
|
2756
3297
|
this.fields = [];
|
|
2757
|
-
this._onChange = () => ({});
|
|
2758
|
-
this._onTouched = () => ({});
|
|
2759
|
-
this.touched = false;
|
|
2760
|
-
if (ngControl) {
|
|
2761
|
-
// Setting the value accessor directly (instead of using
|
|
2762
|
-
// the providers `NG_VALUE_ACCESSOR`) to avoid running into a circular import.
|
|
2763
|
-
ngControl.valueAccessor = this;
|
|
2764
|
-
}
|
|
2765
|
-
// When the user interact with the form, mark it as touched
|
|
2766
|
-
fm.monitor(elRef.nativeElement, true)
|
|
2767
|
-
.pipe(takeUntil(this.unsubscribe$))
|
|
2768
|
-
.subscribe(() => {
|
|
2769
|
-
this._onTouched();
|
|
2770
|
-
this.touched = true;
|
|
2771
|
-
});
|
|
2772
3298
|
}
|
|
2773
3299
|
set jsonSchema(jsonSchema) {
|
|
2774
|
-
if (isObject(jsonSchema)) {
|
|
3300
|
+
if (isObject$1(jsonSchema)) {
|
|
2775
3301
|
this.fields = [this.toFormlyFieldConfig(jsonSchema)];
|
|
2776
3302
|
}
|
|
2777
3303
|
}
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
(_b = (_a = this.ngControl) === null || _a === void 0 ? void 0 : _a.control) === null || _b === void 0 ? void 0 : _b.setErrors(null);
|
|
2783
|
-
}
|
|
2784
|
-
if (status === 'INVALID') {
|
|
2785
|
-
(_d = (_c = this.ngControl) === null || _c === void 0 ? void 0 : _c.control) === null || _d === void 0 ? void 0 : _d.setErrors({ invalid: true });
|
|
2786
|
-
}
|
|
2787
|
-
});
|
|
2788
|
-
// To simulate the behavior of classic form controls, emit value only when the form is touched
|
|
2789
|
-
// Allow to keep the formControl pristine until the user interact with it
|
|
2790
|
-
this.formGroup.valueChanges
|
|
2791
|
-
.pipe(takeUntil(this.unsubscribe$), filter(() => this.touched))
|
|
2792
|
-
.subscribe(value => {
|
|
2793
|
-
this._onChange(value);
|
|
2794
|
-
});
|
|
2795
|
-
}
|
|
2796
|
-
ngOnDestroy() {
|
|
2797
|
-
this.unsubscribe$.next();
|
|
2798
|
-
this.unsubscribe$.unsubscribe();
|
|
2799
|
-
this.fm.stopMonitoring(this.elRef.nativeElement);
|
|
2800
|
-
}
|
|
2801
|
-
// From ControlValueAccessor
|
|
2802
|
-
writeValue(value) {
|
|
2803
|
-
var _a;
|
|
2804
|
-
this.model = (_a = cloneDeep(value)) !== null && _a !== void 0 ? _a : {};
|
|
2805
|
-
}
|
|
2806
|
-
// From ControlValueAccessor
|
|
2807
|
-
registerOnChange(fn) {
|
|
2808
|
-
this._onChange = fn;
|
|
2809
|
-
}
|
|
2810
|
-
// From ControlValueAccessor
|
|
2811
|
-
registerOnTouched(fn) {
|
|
2812
|
-
this._onTouched = fn;
|
|
2813
|
-
}
|
|
2814
|
-
// From ControlValueAccessor
|
|
2815
|
-
setDisabledState(_isDisabled) {
|
|
2816
|
-
throw new Error('Method not implemented.');
|
|
3304
|
+
set initialValue(initialValue) {
|
|
3305
|
+
if (initialValue) {
|
|
3306
|
+
this.model = cloneDeep(initialValue);
|
|
3307
|
+
}
|
|
2817
3308
|
}
|
|
2818
3309
|
toFormlyFieldConfig(jsonSchema) {
|
|
2819
3310
|
return this.formlyJsonschema.toFieldConfig(jsonSchema, {
|
|
@@ -2833,25 +3324,22 @@ class GioFormJsonSchemaComponent {
|
|
|
2833
3324
|
};
|
|
2834
3325
|
}
|
|
2835
3326
|
}
|
|
2836
|
-
GioFormJsonSchemaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, deps: [{ token:
|
|
2837
|
-
GioFormJsonSchemaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFormJsonSchemaComponent, selector: "gio-form-json-schema", inputs: { jsonSchema: "jsonSchema", options: "options" }, ngImport: i0, template: `<formly-form
|
|
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"] }] });
|
|
2838
3329
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaComponent, decorators: [{
|
|
2839
3330
|
type: Component,
|
|
2840
3331
|
args: [{
|
|
2841
3332
|
selector: 'gio-form-json-schema',
|
|
2842
|
-
template: `<formly-form
|
|
2843
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3333
|
+
template: `<formly-form [fields]="fields" [options]="options" [form]="formGroup" [model]="model"></formly-form>`,
|
|
2844
3334
|
}]
|
|
2845
|
-
}], ctorParameters: function () {
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
}, {
|
|
2849
|
-
type: Optional
|
|
2850
|
-
}] }];
|
|
2851
|
-
}, propDecorators: { jsonSchema: [{
|
|
3335
|
+
}], ctorParameters: function () { return [{ type: GioJsonschema }]; }, propDecorators: { jsonSchema: [{
|
|
3336
|
+
type: Input
|
|
3337
|
+
}], formGroup: [{
|
|
2852
3338
|
type: Input
|
|
2853
3339
|
}], options: [{
|
|
2854
3340
|
type: Input
|
|
3341
|
+
}], initialValue: [{
|
|
3342
|
+
type: Input
|
|
2855
3343
|
}] } });
|
|
2856
3344
|
|
|
2857
3345
|
/*
|
|
@@ -2906,30 +3394,27 @@ class GioFjsObjectTypeComponent extends FieldType {
|
|
|
2906
3394
|
}
|
|
2907
3395
|
GioFjsObjectTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsObjectTypeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2908
3396
|
GioFjsObjectTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFjsObjectTypeComponent, selector: "gio-fjs-object-type", usesInheritance: true, ngImport: i0, template: `
|
|
2909
|
-
<div>
|
|
2910
|
-
<
|
|
3397
|
+
<div class="wrapper">
|
|
3398
|
+
<h4 *ngIf="to.label">{{ to.label }}</h4>
|
|
2911
3399
|
<p *ngIf="to.description">{{ to.description }}</p>
|
|
2912
3400
|
<div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
|
|
2913
3401
|
<formly-validation-message [field]="field"></formly-validation-message>
|
|
2914
3402
|
</div>
|
|
2915
3403
|
<formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
|
|
2916
3404
|
</div>
|
|
2917
|
-
`, isInline: true, components: [{ type: i1$
|
|
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"] }] });
|
|
2918
3406
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsObjectTypeComponent, decorators: [{
|
|
2919
3407
|
type: Component,
|
|
2920
|
-
args: [{
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
<div>
|
|
2924
|
-
<legend *ngIf="to.label">{{ to.label }}</legend>
|
|
3408
|
+
args: [{ selector: 'gio-fjs-object-type', template: `
|
|
3409
|
+
<div class="wrapper">
|
|
3410
|
+
<h4 *ngIf="to.label">{{ to.label }}</h4>
|
|
2925
3411
|
<p *ngIf="to.description">{{ to.description }}</p>
|
|
2926
3412
|
<div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
|
|
2927
3413
|
<formly-validation-message [field]="field"></formly-validation-message>
|
|
2928
3414
|
</div>
|
|
2929
3415
|
<formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
|
|
2930
3416
|
</div>
|
|
2931
|
-
`,
|
|
2932
|
-
}]
|
|
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"] }]
|
|
2933
3418
|
}] });
|
|
2934
3419
|
|
|
2935
3420
|
/*
|
|
@@ -2951,8 +3436,8 @@ class GioFjsArrayTypeComponent extends FieldArrayType {
|
|
|
2951
3436
|
}
|
|
2952
3437
|
GioFjsArrayTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsArrayTypeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2953
3438
|
GioFjsArrayTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFjsArrayTypeComponent, selector: "gio-fjs-array-type", usesInheritance: true, ngImport: i0, template: `
|
|
2954
|
-
<div>
|
|
2955
|
-
<
|
|
3439
|
+
<div class="wrapper">
|
|
3440
|
+
<h4 *ngIf="to.label">{{ to.label }}</h4>
|
|
2956
3441
|
<p *ngIf="to.description">{{ to.description }}</p>
|
|
2957
3442
|
|
|
2958
3443
|
<div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
|
|
@@ -2970,14 +3455,12 @@ GioFjsArrayTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
|
|
|
2970
3455
|
<button class="btn btn-primary" type="button" (click)="add()">+</button>
|
|
2971
3456
|
</div>
|
|
2972
3457
|
</div>
|
|
2973
|
-
`, isInline: true, components: [{ type: i1$
|
|
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"] }] });
|
|
2974
3459
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsArrayTypeComponent, decorators: [{
|
|
2975
3460
|
type: Component,
|
|
2976
|
-
args: [{
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
<div>
|
|
2980
|
-
<legend *ngIf="to.label">{{ to.label }}</legend>
|
|
3461
|
+
args: [{ selector: 'gio-fjs-array-type', template: `
|
|
3462
|
+
<div class="wrapper">
|
|
3463
|
+
<h4 *ngIf="to.label">{{ to.label }}</h4>
|
|
2981
3464
|
<p *ngIf="to.description">{{ to.description }}</p>
|
|
2982
3465
|
|
|
2983
3466
|
<div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
|
|
@@ -2995,8 +3478,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
2995
3478
|
<button class="btn btn-primary" type="button" (click)="add()">+</button>
|
|
2996
3479
|
</div>
|
|
2997
3480
|
</div>
|
|
2998
|
-
`,
|
|
2999
|
-
}]
|
|
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"] }]
|
|
3000
3482
|
}] });
|
|
3001
3483
|
|
|
3002
3484
|
function minItemsValidationMessage(error, field) {
|
|
@@ -3093,37 +3575,33 @@ function bannerExtension(field) {
|
|
|
3093
3575
|
* limitations under the License.
|
|
3094
3576
|
*/
|
|
3095
3577
|
class GioFjsMultiSchemaTypeComponent extends FieldType {
|
|
3578
|
+
ngOnInit() {
|
|
3579
|
+
set(this.field, 'fieldGroup[0].props.appearance', 'fill');
|
|
3580
|
+
}
|
|
3096
3581
|
}
|
|
3097
3582
|
GioFjsMultiSchemaTypeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsMultiSchemaTypeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
3098
3583
|
GioFjsMultiSchemaTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioFjsMultiSchemaTypeComponent, selector: "gio-fjs-multi-schema-type", usesInheritance: true, ngImport: i0, template: `
|
|
3099
|
-
<div class="
|
|
3100
|
-
<
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
<
|
|
3104
|
-
<formly-validation-message [field]="field"></formly-validation-message>
|
|
3105
|
-
</div>
|
|
3106
|
-
<formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
|
|
3584
|
+
<div class="wrapper">
|
|
3585
|
+
<h5 *ngIf="props.label">{{ props.label }}</h5>
|
|
3586
|
+
<p *ngIf="props.description">{{ props.description }}</p>
|
|
3587
|
+
<div role="alert" *ngIf="showError && formControl.errors">
|
|
3588
|
+
<formly-validation-message [field]="field"></formly-validation-message>
|
|
3107
3589
|
</div>
|
|
3590
|
+
<formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
|
|
3108
3591
|
</div>
|
|
3109
|
-
`, isInline: true, components: [{ type: i1$
|
|
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"] }] });
|
|
3110
3593
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsMultiSchemaTypeComponent, decorators: [{
|
|
3111
3594
|
type: Component,
|
|
3112
|
-
args: [{
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
<div
|
|
3117
|
-
<
|
|
3118
|
-
<p *ngIf="props.description">{{ props.description }}</p>
|
|
3119
|
-
<div class="alert alert-danger" role="alert" *ngIf="showError && formControl.errors">
|
|
3120
|
-
<formly-validation-message [field]="field"></formly-validation-message>
|
|
3121
|
-
</div>
|
|
3122
|
-
<formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
|
|
3595
|
+
args: [{ selector: 'gio-fjs-multi-schema-type', template: `
|
|
3596
|
+
<div class="wrapper">
|
|
3597
|
+
<h5 *ngIf="props.label">{{ props.label }}</h5>
|
|
3598
|
+
<p *ngIf="props.description">{{ props.description }}</p>
|
|
3599
|
+
<div role="alert" *ngIf="showError && formControl.errors">
|
|
3600
|
+
<formly-validation-message [field]="field"></formly-validation-message>
|
|
3123
3601
|
</div>
|
|
3602
|
+
<formly-field *ngFor="let f of field.fieldGroup" [field]="f"></formly-field>
|
|
3124
3603
|
</div>
|
|
3125
|
-
`,
|
|
3126
|
-
}]
|
|
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"] }]
|
|
3127
3605
|
}] });
|
|
3128
3606
|
|
|
3129
3607
|
/*
|
|
@@ -3150,12 +3628,10 @@ GioFormJsonSchemaModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0",
|
|
|
3150
3628
|
GioFjsMultiSchemaTypeComponent,
|
|
3151
3629
|
GioFjsArrayTypeComponent,
|
|
3152
3630
|
GioFormFieldWrapperComponent], imports: [CommonModule,
|
|
3153
|
-
|
|
3154
|
-
ReactiveFormsModule, i1$4.FormlyModule, FormlyMaterialModule,
|
|
3631
|
+
ReactiveFormsModule, i1$3.FormlyModule, FormlyMaterialModule,
|
|
3155
3632
|
GioIconsModule], exports: [GioFormJsonSchemaComponent, FormlyModule] });
|
|
3156
3633
|
GioFormJsonSchemaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFormJsonSchemaModule, imports: [[
|
|
3157
3634
|
CommonModule,
|
|
3158
|
-
A11yModule,
|
|
3159
3635
|
ReactiveFormsModule,
|
|
3160
3636
|
FormlyModule.forRoot({
|
|
3161
3637
|
validationMessages: [
|
|
@@ -3181,9 +3657,6 @@ GioFormJsonSchemaModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
3181
3657
|
{ name: 'multischema', component: GioFjsMultiSchemaTypeComponent },
|
|
3182
3658
|
],
|
|
3183
3659
|
extensions: [{ name: 'banner', extension: { onPopulate: bannerExtension } }],
|
|
3184
|
-
extras: {
|
|
3185
|
-
checkExpressionOn: 'changeDetectionCheck',
|
|
3186
|
-
},
|
|
3187
3660
|
}),
|
|
3188
3661
|
FormlyMaterialModule,
|
|
3189
3662
|
GioIconsModule,
|
|
@@ -3201,7 +3674,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3201
3674
|
],
|
|
3202
3675
|
imports: [
|
|
3203
3676
|
CommonModule,
|
|
3204
|
-
A11yModule,
|
|
3205
3677
|
ReactiveFormsModule,
|
|
3206
3678
|
FormlyModule.forRoot({
|
|
3207
3679
|
validationMessages: [
|
|
@@ -3227,9 +3699,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3227
3699
|
{ name: 'multischema', component: GioFjsMultiSchemaTypeComponent },
|
|
3228
3700
|
],
|
|
3229
3701
|
extensions: [{ name: 'banner', extension: { onPopulate: bannerExtension } }],
|
|
3230
|
-
extras: {
|
|
3231
|
-
checkExpressionOn: 'changeDetectionCheck',
|
|
3232
|
-
},
|
|
3233
3702
|
}),
|
|
3234
3703
|
FormlyMaterialModule,
|
|
3235
3704
|
GioIconsModule,
|