@gravitee/ui-particles-angular 5.13.0 → 5.14.0-improve-json-schema-preview-7fe3956
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 +6 -3
- package/esm2020/lib/gio-form-json-schema/model/GioJsonSchema.mjs +1 -1
- package/esm2020/lib/gio-form-json-schema/type-component/object-type.component.mjs +2 -2
- package/esm2020/lib/gio-monaco-editor/gio-monaco-editor.component.mjs +172 -0
- package/esm2020/lib/gio-monaco-editor/gio-monaco-editor.harness.mjs +63 -0
- package/esm2020/lib/gio-monaco-editor/gio-monaco-editor.module.mjs +58 -0
- package/esm2020/lib/gio-monaco-editor/gio-monaco-editor.testing.component.mjs +55 -0
- package/esm2020/lib/gio-monaco-editor/models/GioMonacoEditorConfig.mjs +18 -0
- package/esm2020/lib/gio-monaco-editor/models/MonacoEditorTheme.mjs +2 -0
- package/esm2020/lib/gio-monaco-editor/services/gio-language-json.service.mjs +71 -0
- package/esm2020/lib/gio-monaco-editor/services/gio-monaco-editor.service.mjs +67 -0
- package/esm2020/lib/public-api.mjs +4 -1
- package/fesm2015/gravitee-ui-particles-angular.mjs +469 -8
- package/fesm2015/gravitee-ui-particles-angular.mjs.map +1 -1
- package/fesm2020/gravitee-ui-particles-angular.mjs +481 -8
- package/fesm2020/gravitee-ui-particles-angular.mjs.map +1 -1
- package/lib/gio-form-json-schema/gio-form-json-schema.component.d.ts +1 -0
- package/lib/gio-form-json-schema/model/GioJsonSchema.d.ts +17 -11
- package/lib/gio-monaco-editor/gio-monaco-editor.component.d.ts +45 -0
- package/lib/gio-monaco-editor/gio-monaco-editor.harness.d.ts +16 -0
- package/lib/gio-monaco-editor/gio-monaco-editor.module.d.ts +18 -0
- package/lib/gio-monaco-editor/gio-monaco-editor.testing.component.d.ts +12 -0
- package/lib/gio-monaco-editor/models/GioMonacoEditorConfig.d.ts +6 -0
- package/lib/gio-monaco-editor/models/MonacoEditorTheme.d.ts +1 -0
- package/lib/gio-monaco-editor/services/gio-language-json.service.d.ts +17 -0
- package/lib/gio-monaco-editor/services/gio-monaco-editor.service.d.ts +18 -0
- package/lib/public-api.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
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, Host, ContentChild } from '@angular/core';
|
|
4
|
-
import { timer, Subject, fromEvent, of, BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { EventEmitter, Component, HostBinding, Input, Output, HostListener, NgModule, Optional, Self, ViewChild, Directive, Inject, forwardRef, ChangeDetectionStrategy, Injectable, ViewEncapsulation, ContentChildren, Host, ContentChild, InjectionToken } from '@angular/core';
|
|
4
|
+
import { timer, Subject, fromEvent, of, BehaviorSubject, ReplaySubject } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/material/card';
|
|
6
6
|
import { MatCardModule } from '@angular/material/card';
|
|
7
7
|
import * as i2 from '@angular/material/button';
|
|
@@ -13,8 +13,8 @@ import { ComponentHarness, HarnessPredicate, parallel, TestKey } from '@angular/
|
|
|
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, cloneDeep, set } from 'lodash';
|
|
17
|
-
import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap } from 'rxjs/operators';
|
|
16
|
+
import { isEmpty, toLower, dropRight, isNil, isArray, remove, isObject, cloneDeep, set, uniqueId } from 'lodash';
|
|
17
|
+
import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap, debounceTime } from 'rxjs/operators';
|
|
18
18
|
import * as i7 from '@angular/forms';
|
|
19
19
|
import { FormsModule, FormArray, FormGroup, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule, NgControl } from '@angular/forms';
|
|
20
20
|
import * as i2$2 from '@angular/cdk/a11y';
|
|
@@ -50,6 +50,7 @@ import { FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-form
|
|
|
50
50
|
import { FormlyMaterialModule } from '@ngx-formly/material';
|
|
51
51
|
import * as i3$2 from '@angular/material/slide-toggle';
|
|
52
52
|
import { MatSlideToggle, MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
53
|
+
import { TestBed } from '@angular/core/testing';
|
|
53
54
|
|
|
54
55
|
/*
|
|
55
56
|
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
@@ -2822,6 +2823,7 @@ class GioFormJsonSchemaComponent {
|
|
|
2822
2823
|
this.options = {};
|
|
2823
2824
|
this.model = {};
|
|
2824
2825
|
this.fields = [];
|
|
2826
|
+
this.loading = true;
|
|
2825
2827
|
this._onChange = () => ({});
|
|
2826
2828
|
this._onTouched = () => ({});
|
|
2827
2829
|
this.touched = false;
|
|
@@ -2860,7 +2862,9 @@ class GioFormJsonSchemaComponent {
|
|
|
2860
2862
|
// To simulate the behavior of classic form controls, emit value only when the form is touched
|
|
2861
2863
|
// Allow to keep the formControl pristine until the user interact with it
|
|
2862
2864
|
this.formGroup.valueChanges
|
|
2863
|
-
.pipe(takeUntil(this.unsubscribe$),
|
|
2865
|
+
.pipe(takeUntil(this.unsubscribe$),
|
|
2866
|
+
// Group all valueChanges events emit by formly in a single one
|
|
2867
|
+
debounceTime(50), filter(() => this.touched))
|
|
2864
2868
|
.subscribe(value => {
|
|
2865
2869
|
this._onChange(value);
|
|
2866
2870
|
});
|
|
@@ -3108,7 +3112,7 @@ GioFjsObjectTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.
|
|
|
3108
3112
|
<formly-field *ngFor="let f of field.fieldGroup" class="wrapper__fields__field" [field]="f"></formly-field>
|
|
3109
3113
|
</div>
|
|
3110
3114
|
</div>
|
|
3111
|
-
`, isInline: true, styles: [".wrapper{display:flex;flex-direction:column}.wrapper__title{font:600 18px/24px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:16px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}.wrapper__fields{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__fields:has(> .wrapper__fields__field:only-child):has(> .wrapper__fields__field:empty){display:none}.wrapper__fields__field:empty{display:none}.wrapper__fields__field+.wrapper__fields__field:not(:empty){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"] }] });
|
|
3115
|
+
`, isInline: true, styles: [".wrapper{display:flex;flex-direction:column}.wrapper__title{font:600 18px/24px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:16px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}.wrapper__fields{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__fields:empty{display:none}.wrapper__fields:has(> .wrapper__fields__field:only-child):has(> .wrapper__fields__field:empty){display:none}.wrapper__fields__field:empty{display:none}.wrapper__fields__field+.wrapper__fields__field:not(:empty){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"] }] });
|
|
3112
3116
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsObjectTypeComponent, decorators: [{
|
|
3113
3117
|
type: Component,
|
|
3114
3118
|
args: [{ selector: 'gio-fjs-object-type', template: `
|
|
@@ -3122,7 +3126,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3122
3126
|
<formly-field *ngFor="let f of field.fieldGroup" class="wrapper__fields__field" [field]="f"></formly-field>
|
|
3123
3127
|
</div>
|
|
3124
3128
|
</div>
|
|
3125
|
-
`, styles: [".wrapper{display:flex;flex-direction:column}.wrapper__title{font:600 18px/24px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:16px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}.wrapper__fields{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__fields:has(> .wrapper__fields__field:only-child):has(> .wrapper__fields__field:empty){display:none}.wrapper__fields__field:empty{display:none}.wrapper__fields__field+.wrapper__fields__field:not(:empty){display:block;margin-top:8px}\n"] }]
|
|
3129
|
+
`, styles: [".wrapper{display:flex;flex-direction:column}.wrapper__title{font:600 18px/24px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:.4px;margin-bottom:16px}.wrapper:empty{display:none}.wrapper__error{font:400 12px/16px Golos UI,Roboto,Helvetica Neue,sans-serif;letter-spacing:normal;color:#ec4899}.wrapper__fields{padding:8px;border:1px solid #d3d5dc;border-radius:8px}.wrapper__fields:empty{display:none}.wrapper__fields:has(> .wrapper__fields__field:only-child):has(> .wrapper__fields__field:empty){display:none}.wrapper__fields__field:empty{display:none}.wrapper__fields__field+.wrapper__fields__field:not(:empty){display:block;margin-top:8px}\n"] }]
|
|
3126
3130
|
}] });
|
|
3127
3131
|
|
|
3128
3132
|
/*
|
|
@@ -3711,6 +3715,463 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3711
3715
|
}]
|
|
3712
3716
|
}] });
|
|
3713
3717
|
|
|
3718
|
+
/*
|
|
3719
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3720
|
+
*
|
|
3721
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3722
|
+
* you may not use this file except in compliance with the License.
|
|
3723
|
+
* You may obtain a copy of the License at
|
|
3724
|
+
*
|
|
3725
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3726
|
+
*
|
|
3727
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3728
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3729
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3730
|
+
* See the License for the specific language governing permissions and
|
|
3731
|
+
* limitations under the License.
|
|
3732
|
+
*/
|
|
3733
|
+
const GIO_MONACO_EDITOR_CONFIG = new InjectionToken('gio-monaco-editor-config');
|
|
3734
|
+
|
|
3735
|
+
/*
|
|
3736
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3737
|
+
*
|
|
3738
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3739
|
+
* you may not use this file except in compliance with the License.
|
|
3740
|
+
* You may obtain a copy of the License at
|
|
3741
|
+
*
|
|
3742
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3743
|
+
*
|
|
3744
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3745
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3746
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3747
|
+
* See the License for the specific language governing permissions and
|
|
3748
|
+
* limitations under the License.
|
|
3749
|
+
*/
|
|
3750
|
+
class GioMonacoEditorService {
|
|
3751
|
+
constructor() {
|
|
3752
|
+
this.loaded$ = new ReplaySubject(1);
|
|
3753
|
+
this.loaded = false;
|
|
3754
|
+
}
|
|
3755
|
+
loadEditor() {
|
|
3756
|
+
if (this.loaded) {
|
|
3757
|
+
// Already loaded, do nothing.
|
|
3758
|
+
return Promise.resolve();
|
|
3759
|
+
}
|
|
3760
|
+
this.loaded = true;
|
|
3761
|
+
return new Promise(resolve => {
|
|
3762
|
+
// Monaco is already loaded
|
|
3763
|
+
if (typeof window.monaco === 'object') {
|
|
3764
|
+
resolve();
|
|
3765
|
+
return;
|
|
3766
|
+
}
|
|
3767
|
+
const onGotAmdLoader = () => {
|
|
3768
|
+
// Load Monaco
|
|
3769
|
+
window.require.config({ paths: { vs: 'assets/monaco-editor/min/vs' } });
|
|
3770
|
+
window.require(['vs/editor/editor.main'], () => {
|
|
3771
|
+
resolve();
|
|
3772
|
+
});
|
|
3773
|
+
};
|
|
3774
|
+
// Load AMD loader if necessary
|
|
3775
|
+
if (!window.require) {
|
|
3776
|
+
const loaderScript = document.createElement('script');
|
|
3777
|
+
loaderScript.type = 'text/javascript';
|
|
3778
|
+
loaderScript.src = 'assets/monaco-editor/min/vs/loader.js';
|
|
3779
|
+
loaderScript.addEventListener('load', onGotAmdLoader);
|
|
3780
|
+
document.body.appendChild(loaderScript);
|
|
3781
|
+
}
|
|
3782
|
+
else {
|
|
3783
|
+
onGotAmdLoader();
|
|
3784
|
+
}
|
|
3785
|
+
}).then(() => {
|
|
3786
|
+
this.loaded$.next({ monaco: window.monaco });
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
GioMonacoEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3791
|
+
GioMonacoEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorService, providedIn: 'root' });
|
|
3792
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorService, decorators: [{
|
|
3793
|
+
type: Injectable,
|
|
3794
|
+
args: [{
|
|
3795
|
+
providedIn: 'root',
|
|
3796
|
+
}]
|
|
3797
|
+
}] });
|
|
3798
|
+
|
|
3799
|
+
/*
|
|
3800
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3801
|
+
*
|
|
3802
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3803
|
+
* you may not use this file except in compliance with the License.
|
|
3804
|
+
* You may obtain a copy of the License at
|
|
3805
|
+
*
|
|
3806
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3807
|
+
*
|
|
3808
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3809
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3810
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3811
|
+
* See the License for the specific language governing permissions and
|
|
3812
|
+
* limitations under the License.
|
|
3813
|
+
*/
|
|
3814
|
+
class GioLanguageJsonService {
|
|
3815
|
+
constructor(codeEditorService) {
|
|
3816
|
+
this.unsubscribe$ = new Subject();
|
|
3817
|
+
codeEditorService.loaded$.pipe(takeUntil(this.unsubscribe$)).subscribe(event => {
|
|
3818
|
+
this.setup(event.monaco);
|
|
3819
|
+
});
|
|
3820
|
+
}
|
|
3821
|
+
ngOnDestroy() {
|
|
3822
|
+
this.unsubscribe$.next();
|
|
3823
|
+
this.unsubscribe$.complete();
|
|
3824
|
+
}
|
|
3825
|
+
setup(monaco) {
|
|
3826
|
+
if (!monaco) {
|
|
3827
|
+
throw new Error('Monaco is not loaded');
|
|
3828
|
+
}
|
|
3829
|
+
this.monaco = monaco;
|
|
3830
|
+
const defaults = monaco.languages.json.jsonDefaults;
|
|
3831
|
+
defaults.setDiagnosticsOptions({
|
|
3832
|
+
validate: true,
|
|
3833
|
+
allowComments: true,
|
|
3834
|
+
});
|
|
3835
|
+
}
|
|
3836
|
+
addSchemas(id, definitions = []) {
|
|
3837
|
+
if (!this.monaco) {
|
|
3838
|
+
throw new Error('Monaco is not loaded');
|
|
3839
|
+
}
|
|
3840
|
+
const defaults = this.monaco.languages.json.jsonDefaults;
|
|
3841
|
+
const options = defaults.diagnosticsOptions;
|
|
3842
|
+
let schemas = definitions.map(({ uri, schema }) => ({
|
|
3843
|
+
uri,
|
|
3844
|
+
schema,
|
|
3845
|
+
fileMatch: [id || '*.json'],
|
|
3846
|
+
}));
|
|
3847
|
+
if (options && options.schemas && options.schemas.length > 0) {
|
|
3848
|
+
schemas = [...options.schemas, ...schemas];
|
|
3849
|
+
}
|
|
3850
|
+
defaults.setDiagnosticsOptions(Object.assign(Object.assign({}, options), { schemas: schemas }));
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
GioLanguageJsonService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioLanguageJsonService, deps: [{ token: GioMonacoEditorService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3854
|
+
GioLanguageJsonService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioLanguageJsonService, providedIn: 'root' });
|
|
3855
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioLanguageJsonService, decorators: [{
|
|
3856
|
+
type: Injectable,
|
|
3857
|
+
args: [{
|
|
3858
|
+
providedIn: 'root',
|
|
3859
|
+
}]
|
|
3860
|
+
}], ctorParameters: function () { return [{ type: GioMonacoEditorService }]; } });
|
|
3861
|
+
|
|
3862
|
+
/*
|
|
3863
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3864
|
+
*
|
|
3865
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3866
|
+
* you may not use this file except in compliance with the License.
|
|
3867
|
+
* You may obtain a copy of the License at
|
|
3868
|
+
*
|
|
3869
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3870
|
+
*
|
|
3871
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3872
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3873
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3874
|
+
* See the License for the specific language governing permissions and
|
|
3875
|
+
* limitations under the License.
|
|
3876
|
+
*/
|
|
3877
|
+
class GioMonacoEditorComponent {
|
|
3878
|
+
constructor(config, monacoEditorService, languageJsonService, hostElement, changeDetectorRef, ngZone) {
|
|
3879
|
+
this.config = config;
|
|
3880
|
+
this.monacoEditorService = monacoEditorService;
|
|
3881
|
+
this.languageJsonService = languageJsonService;
|
|
3882
|
+
this.hostElement = hostElement;
|
|
3883
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
3884
|
+
this.ngZone = ngZone;
|
|
3885
|
+
this.options = {};
|
|
3886
|
+
this.id = uniqueId('gio-monaco-editor-');
|
|
3887
|
+
this.loading = true;
|
|
3888
|
+
this.defaultOptions = {
|
|
3889
|
+
contextmenu: false,
|
|
3890
|
+
minimap: {
|
|
3891
|
+
enabled: true,
|
|
3892
|
+
},
|
|
3893
|
+
automaticLayout: true,
|
|
3894
|
+
scrollBeyondLastLine: false,
|
|
3895
|
+
};
|
|
3896
|
+
this.value = '';
|
|
3897
|
+
this.readOnly = false;
|
|
3898
|
+
this._onChange = () => ({});
|
|
3899
|
+
this._onTouched = () => ({});
|
|
3900
|
+
this.unsubscribe$ = new Subject();
|
|
3901
|
+
this.monacoEditorService.loadEditor();
|
|
3902
|
+
}
|
|
3903
|
+
ngAfterViewInit() {
|
|
3904
|
+
// Wait until monaco editor is available
|
|
3905
|
+
this.monacoEditorService.loaded$.pipe(takeUntil(this.unsubscribe$)).subscribe(({ monaco }) => {
|
|
3906
|
+
this.setupEditor(monaco);
|
|
3907
|
+
this.loading = false;
|
|
3908
|
+
this.changeDetectorRef.detectChanges();
|
|
3909
|
+
});
|
|
3910
|
+
}
|
|
3911
|
+
ngOnDestroy() {
|
|
3912
|
+
if (this.standaloneCodeEditor) {
|
|
3913
|
+
this.standaloneCodeEditor.dispose();
|
|
3914
|
+
this.standaloneCodeEditor = undefined;
|
|
3915
|
+
}
|
|
3916
|
+
if (this.textModel) {
|
|
3917
|
+
this.textModel.dispose();
|
|
3918
|
+
this.textModel = undefined;
|
|
3919
|
+
}
|
|
3920
|
+
this.unsubscribe$.next();
|
|
3921
|
+
this.unsubscribe$.complete();
|
|
3922
|
+
}
|
|
3923
|
+
// From ControlValueAccessor interface
|
|
3924
|
+
writeValue(_value) {
|
|
3925
|
+
if (_value) {
|
|
3926
|
+
this.value = _value;
|
|
3927
|
+
}
|
|
3928
|
+
if (this.textModel) {
|
|
3929
|
+
this.textModel.setValue(this.value);
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
// From ControlValueAccessor interface
|
|
3933
|
+
registerOnChange(fn) {
|
|
3934
|
+
this._onChange = fn;
|
|
3935
|
+
}
|
|
3936
|
+
// From ControlValueAccessor interface
|
|
3937
|
+
registerOnTouched(fn) {
|
|
3938
|
+
this._onTouched = fn;
|
|
3939
|
+
}
|
|
3940
|
+
// From ControlValueAccessor interface
|
|
3941
|
+
setDisabledState(isDisabled) {
|
|
3942
|
+
this.readOnly = isDisabled;
|
|
3943
|
+
}
|
|
3944
|
+
setupEditor(monaco) {
|
|
3945
|
+
var _a, _b, _c, _d, _e;
|
|
3946
|
+
if (!this.hostElement) {
|
|
3947
|
+
throw new Error('No editor ref found.');
|
|
3948
|
+
}
|
|
3949
|
+
const domElement = this.hostElement.nativeElement;
|
|
3950
|
+
const settings = {
|
|
3951
|
+
value: this.value,
|
|
3952
|
+
language: (_b = (_a = this.languageConfig) === null || _a === void 0 ? void 0 : _a.language) !== null && _b !== void 0 ? _b : 'text',
|
|
3953
|
+
uri: `code-${uniqueId()}`,
|
|
3954
|
+
};
|
|
3955
|
+
this.ngZone.runOutsideAngular(() => {
|
|
3956
|
+
this.textModel = monaco.editor.createModel(settings.value, settings.language, monaco.Uri.parse(settings.uri));
|
|
3957
|
+
});
|
|
3958
|
+
const options = Object.assign({}, this.defaultOptions, this.options, {
|
|
3959
|
+
readOnly: this.readOnly,
|
|
3960
|
+
theme: (_c = this.config.theme) !== null && _c !== void 0 ? _c : 'vs',
|
|
3961
|
+
model: this.textModel,
|
|
3962
|
+
});
|
|
3963
|
+
this.standaloneCodeEditor = monaco.editor.create(domElement, Object.assign({}, options));
|
|
3964
|
+
(_d = this.textModel) === null || _d === void 0 ? void 0 : _d.onDidChangeContent(() => {
|
|
3965
|
+
var _a;
|
|
3966
|
+
const newValue = (_a = this.textModel) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
3967
|
+
this.ngZone.run(() => {
|
|
3968
|
+
newValue && this._onChange(newValue);
|
|
3969
|
+
this._onTouched();
|
|
3970
|
+
});
|
|
3971
|
+
});
|
|
3972
|
+
(_e = this.standaloneCodeEditor) === null || _e === void 0 ? void 0 : _e.onDidBlurEditorWidget(() => {
|
|
3973
|
+
this.ngZone.run(() => {
|
|
3974
|
+
this._onTouched();
|
|
3975
|
+
});
|
|
3976
|
+
});
|
|
3977
|
+
this.setupLanguage(settings.uri, this.languageConfig);
|
|
3978
|
+
}
|
|
3979
|
+
setupLanguage(uri, languageConfig) {
|
|
3980
|
+
if (!languageConfig) {
|
|
3981
|
+
return;
|
|
3982
|
+
}
|
|
3983
|
+
const { language } = languageConfig;
|
|
3984
|
+
if (language) {
|
|
3985
|
+
const lang = language.toLowerCase();
|
|
3986
|
+
switch (lang) {
|
|
3987
|
+
case 'json':
|
|
3988
|
+
if (languageConfig.schemas) {
|
|
3989
|
+
this.languageJsonService.addSchemas(uri, languageConfig.schemas);
|
|
3990
|
+
}
|
|
3991
|
+
break;
|
|
3992
|
+
default:
|
|
3993
|
+
break;
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
}
|
|
3998
|
+
GioMonacoEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorComponent, deps: [{ token: GIO_MONACO_EDITOR_CONFIG }, { token: GioMonacoEditorService }, { token: GioLanguageJsonService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
3999
|
+
GioMonacoEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioMonacoEditorComponent, selector: "gio-monaco-editor", inputs: { languageConfig: "languageConfig", options: "options" }, providers: [
|
|
4000
|
+
{
|
|
4001
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4002
|
+
useExisting: forwardRef(() => GioMonacoEditorComponent),
|
|
4003
|
+
multi: true,
|
|
4004
|
+
},
|
|
4005
|
+
], ngImport: i0, template: ` <div *ngIf="loading">Loading...</div>`, isInline: true, styles: [":host{display:block;height:100%;min-height:150px}\n"], directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
4006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorComponent, decorators: [{
|
|
4007
|
+
type: Component,
|
|
4008
|
+
args: [{ selector: 'gio-monaco-editor', template: ` <div *ngIf="loading">Loading...</div>`, providers: [
|
|
4009
|
+
{
|
|
4010
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4011
|
+
useExisting: forwardRef(() => GioMonacoEditorComponent),
|
|
4012
|
+
multi: true,
|
|
4013
|
+
},
|
|
4014
|
+
], styles: [":host{display:block;height:100%;min-height:150px}\n"] }]
|
|
4015
|
+
}], ctorParameters: function () {
|
|
4016
|
+
return [{ type: undefined, decorators: [{
|
|
4017
|
+
type: Inject,
|
|
4018
|
+
args: [GIO_MONACO_EDITOR_CONFIG]
|
|
4019
|
+
}] }, { type: GioMonacoEditorService }, { type: GioLanguageJsonService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }];
|
|
4020
|
+
}, propDecorators: { languageConfig: [{
|
|
4021
|
+
type: Input
|
|
4022
|
+
}], options: [{
|
|
4023
|
+
type: Input
|
|
4024
|
+
}] } });
|
|
4025
|
+
|
|
4026
|
+
/*
|
|
4027
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
4028
|
+
*
|
|
4029
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4030
|
+
* you may not use this file except in compliance with the License.
|
|
4031
|
+
* You may obtain a copy of the License at
|
|
4032
|
+
*
|
|
4033
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4034
|
+
*
|
|
4035
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4036
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4037
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4038
|
+
* See the License for the specific language governing permissions and
|
|
4039
|
+
* limitations under the License.
|
|
4040
|
+
*/
|
|
4041
|
+
class GioMonacoEditorModule {
|
|
4042
|
+
static forRoot(config) {
|
|
4043
|
+
return {
|
|
4044
|
+
ngModule: GioMonacoEditorModule,
|
|
4045
|
+
providers: [
|
|
4046
|
+
{
|
|
4047
|
+
provide: GIO_MONACO_EDITOR_CONFIG,
|
|
4048
|
+
useValue: config,
|
|
4049
|
+
},
|
|
4050
|
+
],
|
|
4051
|
+
};
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
GioMonacoEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4055
|
+
GioMonacoEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, declarations: [GioMonacoEditorComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule], exports: [GioMonacoEditorComponent] });
|
|
4056
|
+
GioMonacoEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, providers: [
|
|
4057
|
+
{
|
|
4058
|
+
provide: GIO_MONACO_EDITOR_CONFIG,
|
|
4059
|
+
useValue: {},
|
|
4060
|
+
},
|
|
4061
|
+
], imports: [[CommonModule, HttpClientModule, ReactiveFormsModule]] });
|
|
4062
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, decorators: [{
|
|
4063
|
+
type: NgModule,
|
|
4064
|
+
args: [{
|
|
4065
|
+
imports: [CommonModule, HttpClientModule, ReactiveFormsModule],
|
|
4066
|
+
declarations: [GioMonacoEditorComponent],
|
|
4067
|
+
exports: [GioMonacoEditorComponent],
|
|
4068
|
+
providers: [
|
|
4069
|
+
{
|
|
4070
|
+
provide: GIO_MONACO_EDITOR_CONFIG,
|
|
4071
|
+
useValue: {},
|
|
4072
|
+
},
|
|
4073
|
+
],
|
|
4074
|
+
}]
|
|
4075
|
+
}] });
|
|
4076
|
+
|
|
4077
|
+
/*
|
|
4078
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
4079
|
+
*
|
|
4080
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4081
|
+
* you may not use this file except in compliance with the License.
|
|
4082
|
+
* You may obtain a copy of the License at
|
|
4083
|
+
*
|
|
4084
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4085
|
+
*
|
|
4086
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4087
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4088
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4089
|
+
* See the License for the specific language governing permissions and
|
|
4090
|
+
* limitations under the License.
|
|
4091
|
+
*/
|
|
4092
|
+
/**
|
|
4093
|
+
* This component is used to test the GioMonacoEditorComponent.
|
|
4094
|
+
* This component simulates monaco editor with a simple input.
|
|
4095
|
+
*/
|
|
4096
|
+
class GioMonacoEditorTestingComponent extends GioMonacoEditorComponent {
|
|
4097
|
+
get getValue() {
|
|
4098
|
+
return this.value;
|
|
4099
|
+
}
|
|
4100
|
+
changeValue(value) {
|
|
4101
|
+
this._onTouched();
|
|
4102
|
+
this._onChange(value);
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
GioMonacoEditorTestingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorTestingComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
4106
|
+
GioMonacoEditorTestingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioMonacoEditorTestingComponent, selector: "gio-monaco-editor", providers: [
|
|
4107
|
+
{
|
|
4108
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4109
|
+
useExisting: forwardRef(() => GioMonacoEditorTestingComponent),
|
|
4110
|
+
multi: true,
|
|
4111
|
+
},
|
|
4112
|
+
], usesInheritance: true, ngImport: i0, template: '<input type="text" [value]="getValue" (input)="changeValue($any($event).target?.value)" />', isInline: true });
|
|
4113
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorTestingComponent, decorators: [{
|
|
4114
|
+
type: Component,
|
|
4115
|
+
args: [{
|
|
4116
|
+
selector: 'gio-monaco-editor',
|
|
4117
|
+
template: '<input type="text" [value]="getValue" (input)="changeValue($any($event).target?.value)" />',
|
|
4118
|
+
providers: [
|
|
4119
|
+
{
|
|
4120
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4121
|
+
useExisting: forwardRef(() => GioMonacoEditorTestingComponent),
|
|
4122
|
+
multi: true,
|
|
4123
|
+
},
|
|
4124
|
+
],
|
|
4125
|
+
}]
|
|
4126
|
+
}] });
|
|
4127
|
+
|
|
4128
|
+
// Hack to replace the default gio-monaco-editor component with fake one for testing purpose.
|
|
4129
|
+
try {
|
|
4130
|
+
TestBed.overrideModule(GioMonacoEditorModule, {
|
|
4131
|
+
remove: {
|
|
4132
|
+
declarations: [GioMonacoEditorComponent],
|
|
4133
|
+
exports: [GioMonacoEditorComponent],
|
|
4134
|
+
},
|
|
4135
|
+
add: {
|
|
4136
|
+
declarations: [GioMonacoEditorTestingComponent],
|
|
4137
|
+
exports: [GioMonacoEditorTestingComponent],
|
|
4138
|
+
},
|
|
4139
|
+
});
|
|
4140
|
+
}
|
|
4141
|
+
catch (e) {
|
|
4142
|
+
// Do nothing
|
|
4143
|
+
}
|
|
4144
|
+
class GioMonacoEditorHarness extends ComponentHarness {
|
|
4145
|
+
constructor() {
|
|
4146
|
+
super(...arguments);
|
|
4147
|
+
this.getInputEl = this.locatorFor('input');
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* Gets a `HarnessPredicate` that can be used to search for a `GioMonacoEditorHarness` that meets
|
|
4151
|
+
* certain criteria.
|
|
4152
|
+
*
|
|
4153
|
+
* @param options Options for filtering which input instances are considered a match.
|
|
4154
|
+
* @return a `HarnessPredicate` configured with the given options.
|
|
4155
|
+
*/
|
|
4156
|
+
static with(options = {}) {
|
|
4157
|
+
return new HarnessPredicate(GioMonacoEditorHarness, options);
|
|
4158
|
+
}
|
|
4159
|
+
setValue(value) {
|
|
4160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4161
|
+
const inputEl = yield this.getInputEl();
|
|
4162
|
+
yield inputEl.clear();
|
|
4163
|
+
yield inputEl.sendKeys(value);
|
|
4164
|
+
});
|
|
4165
|
+
}
|
|
4166
|
+
getValue() {
|
|
4167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4168
|
+
const inputEl = yield this.getInputEl();
|
|
4169
|
+
return inputEl.getProperty('value');
|
|
4170
|
+
});
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
GioMonacoEditorHarness.hostSelector = 'gio-monaco-editor';
|
|
4174
|
+
|
|
3714
4175
|
/*
|
|
3715
4176
|
* Copyright (C) 2021 The Gravitee team (http://gravitee.io)
|
|
3716
4177
|
*
|
|
@@ -3747,5 +4208,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3747
4208
|
* Generated bundle index. Do not edit.
|
|
3748
4209
|
*/
|
|
3749
4210
|
|
|
3750
|
-
export { GioAvatarComponent, GioAvatarModule, GioBannerActionDirective, GioBannerBodyDirective, GioBannerComponent, GioBannerErrorComponent, GioBannerInfoComponent, GioBannerModule, GioBannerSuccessComponent, GioBannerWarningComponent, GioBreadcrumbComponent, GioBreadcrumbItemDirective, GioBreadcrumbModule, GioConfirmAndValidateDialogComponent, GioConfirmAndValidateDialogHarness, GioConfirmAndValidateDialogModule, GioConfirmDialogComponent, GioConfirmDialogHarness, GioConfirmDialogModule, GioFormFilePickerAddButtonComponent, GioFormFilePickerComponent, GioFormFilePickerEmptyComponent, GioFormFilePickerInputHarness, GioFormFilePickerLabelComponent, GioFormFilePickerModule, GioFormFocusInvalidDirective, GioFormFocusInvalidModule, GioFormHeadersComponent, GioFormHeadersHarness, GioFormHeadersModule, GioFormJsonSchemaComponent, GioFormJsonSchemaModule, GioFormLabelComponent, GioFormPrefixDirective, GioFormSlideToggleComponent, GioFormSlideToggleDirective, GioFormSlideToggleModule, GioFormTagsInputComponent, GioFormTagsInputHarness, GioFormTagsInputModule, GioIconsModule, GioMatConfigModule, GioMenuComponent, GioMenuFooterComponent, GioMenuHeaderComponent, GioMenuItemComponent, GioMenuListComponent, GioMenuModule, GioMenuSelectorComponent, GioMenuSelectorHarness, GioMenuService, GioSaveBarComponent, GioSaveBarHarness, GioSaveBarModule, GioSubmenuComponent, GioSubmenuGroupComponent, GioSubmenuItemComponent, GioSubmenuModule, GioSubmenuTitleDirective, GioTopBarComponent, GioTopBarContentComponent, GioTopBarLinkComponent, GioTopBarLinkModule, GioTopBarMenuComponent, GioTopBarMenuModule, GioTopBarModule, NewFile };
|
|
4211
|
+
export { GioAvatarComponent, GioAvatarModule, GioBannerActionDirective, GioBannerBodyDirective, GioBannerComponent, GioBannerErrorComponent, GioBannerInfoComponent, GioBannerModule, GioBannerSuccessComponent, GioBannerWarningComponent, GioBreadcrumbComponent, GioBreadcrumbItemDirective, GioBreadcrumbModule, GioConfirmAndValidateDialogComponent, GioConfirmAndValidateDialogHarness, GioConfirmAndValidateDialogModule, GioConfirmDialogComponent, GioConfirmDialogHarness, GioConfirmDialogModule, GioFormFilePickerAddButtonComponent, GioFormFilePickerComponent, GioFormFilePickerEmptyComponent, GioFormFilePickerInputHarness, GioFormFilePickerLabelComponent, GioFormFilePickerModule, GioFormFocusInvalidDirective, GioFormFocusInvalidModule, GioFormHeadersComponent, GioFormHeadersHarness, GioFormHeadersModule, GioFormJsonSchemaComponent, GioFormJsonSchemaModule, GioFormLabelComponent, GioFormPrefixDirective, GioFormSlideToggleComponent, GioFormSlideToggleDirective, GioFormSlideToggleModule, GioFormTagsInputComponent, GioFormTagsInputHarness, GioFormTagsInputModule, GioIconsModule, GioMatConfigModule, GioMenuComponent, GioMenuFooterComponent, GioMenuHeaderComponent, GioMenuItemComponent, GioMenuListComponent, GioMenuModule, GioMenuSelectorComponent, GioMenuSelectorHarness, GioMenuService, GioMonacoEditorComponent, GioMonacoEditorHarness, GioMonacoEditorModule, GioSaveBarComponent, GioSaveBarHarness, GioSaveBarModule, GioSubmenuComponent, GioSubmenuGroupComponent, GioSubmenuItemComponent, GioSubmenuModule, GioSubmenuTitleDirective, GioTopBarComponent, GioTopBarContentComponent, GioTopBarLinkComponent, GioTopBarLinkModule, GioTopBarMenuComponent, GioTopBarMenuModule, GioTopBarModule, NewFile };
|
|
3751
4212
|
//# sourceMappingURL=gravitee-ui-particles-angular.mjs.map
|