@gravitee/ui-particles-angular 5.13.0 → 5.14.0-improve-json-schema-preview-0f3c2db
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';
|
|
@@ -12,8 +12,8 @@ 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, toLower, dropRight, isNil, isArray, remove, isObject, cloneDeep, set } from 'lodash';
|
|
16
|
-
import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap } from 'rxjs/operators';
|
|
15
|
+
import { isEmpty, toLower, dropRight, isNil, isArray, remove, isObject, cloneDeep, set, uniqueId } from 'lodash';
|
|
16
|
+
import { startWith, map, distinctUntilChanged, tap, debounce, takeUntil, delay, filter, switchMap, debounceTime } from 'rxjs/operators';
|
|
17
17
|
import * as i7 from '@angular/forms';
|
|
18
18
|
import { FormsModule, FormArray, FormGroup, FormControl, NG_VALUE_ACCESSOR, ReactiveFormsModule, NgControl } from '@angular/forms';
|
|
19
19
|
import * as i2$2 from '@angular/cdk/a11y';
|
|
@@ -49,6 +49,7 @@ import { FieldType, FieldArrayType, FieldWrapper, FormlyModule } from '@ngx-form
|
|
|
49
49
|
import { FormlyMaterialModule } from '@ngx-formly/material';
|
|
50
50
|
import * as i3$2 from '@angular/material/slide-toggle';
|
|
51
51
|
import { MatSlideToggle, MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
52
|
+
import { TestBed } from '@angular/core/testing';
|
|
52
53
|
|
|
53
54
|
/*
|
|
54
55
|
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
@@ -2858,6 +2859,7 @@ class GioFormJsonSchemaComponent {
|
|
|
2858
2859
|
this.options = {};
|
|
2859
2860
|
this.model = {};
|
|
2860
2861
|
this.fields = [];
|
|
2862
|
+
this.loading = true;
|
|
2861
2863
|
this._onChange = () => ({});
|
|
2862
2864
|
this._onTouched = () => ({});
|
|
2863
2865
|
this.touched = false;
|
|
@@ -2896,7 +2898,9 @@ class GioFormJsonSchemaComponent {
|
|
|
2896
2898
|
// To simulate the behavior of classic form controls, emit value only when the form is touched
|
|
2897
2899
|
// Allow to keep the formControl pristine until the user interact with it
|
|
2898
2900
|
this.formGroup.valueChanges
|
|
2899
|
-
.pipe(takeUntil(this.unsubscribe$),
|
|
2901
|
+
.pipe(takeUntil(this.unsubscribe$),
|
|
2902
|
+
// Group all valueChanges events emit by formly in a single one
|
|
2903
|
+
debounceTime(50), filter(() => this.touched))
|
|
2900
2904
|
.subscribe(value => {
|
|
2901
2905
|
this._onChange(value);
|
|
2902
2906
|
});
|
|
@@ -3140,7 +3144,7 @@ GioFjsObjectTypeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.
|
|
|
3140
3144
|
<formly-field *ngFor="let f of field.fieldGroup" class="wrapper__fields__field" [field]="f"></formly-field>
|
|
3141
3145
|
</div>
|
|
3142
3146
|
</div>
|
|
3143
|
-
`, 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"] }] });
|
|
3147
|
+
`, 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"] }] });
|
|
3144
3148
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioFjsObjectTypeComponent, decorators: [{
|
|
3145
3149
|
type: Component,
|
|
3146
3150
|
args: [{ selector: 'gio-fjs-object-type', template: `
|
|
@@ -3154,7 +3158,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3154
3158
|
<formly-field *ngFor="let f of field.fieldGroup" class="wrapper__fields__field" [field]="f"></formly-field>
|
|
3155
3159
|
</div>
|
|
3156
3160
|
</div>
|
|
3157
|
-
`, 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"] }]
|
|
3161
|
+
`, 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"] }]
|
|
3158
3162
|
}] });
|
|
3159
3163
|
|
|
3160
3164
|
/*
|
|
@@ -3747,6 +3751,475 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3747
3751
|
}]
|
|
3748
3752
|
}] });
|
|
3749
3753
|
|
|
3754
|
+
/*
|
|
3755
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3756
|
+
*
|
|
3757
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3758
|
+
* you may not use this file except in compliance with the License.
|
|
3759
|
+
* You may obtain a copy of the License at
|
|
3760
|
+
*
|
|
3761
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3762
|
+
*
|
|
3763
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3764
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3765
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3766
|
+
* See the License for the specific language governing permissions and
|
|
3767
|
+
* limitations under the License.
|
|
3768
|
+
*/
|
|
3769
|
+
const GIO_MONACO_EDITOR_CONFIG = new InjectionToken('gio-monaco-editor-config');
|
|
3770
|
+
|
|
3771
|
+
/*
|
|
3772
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3773
|
+
*
|
|
3774
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3775
|
+
* you may not use this file except in compliance with the License.
|
|
3776
|
+
* You may obtain a copy of the License at
|
|
3777
|
+
*
|
|
3778
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3779
|
+
*
|
|
3780
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3781
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3782
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3783
|
+
* See the License for the specific language governing permissions and
|
|
3784
|
+
* limitations under the License.
|
|
3785
|
+
*/
|
|
3786
|
+
class GioMonacoEditorService {
|
|
3787
|
+
constructor() {
|
|
3788
|
+
this.loaded$ = new ReplaySubject(1);
|
|
3789
|
+
this.loaded = false;
|
|
3790
|
+
}
|
|
3791
|
+
loadEditor() {
|
|
3792
|
+
if (this.loaded) {
|
|
3793
|
+
// Already loaded, do nothing.
|
|
3794
|
+
return Promise.resolve();
|
|
3795
|
+
}
|
|
3796
|
+
this.loaded = true;
|
|
3797
|
+
return new Promise(resolve => {
|
|
3798
|
+
// Monaco is already loaded
|
|
3799
|
+
if (typeof window.monaco === 'object') {
|
|
3800
|
+
resolve();
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3803
|
+
const onGotAmdLoader = () => {
|
|
3804
|
+
// Load Monaco
|
|
3805
|
+
window.require.config({ paths: { vs: 'assets/monaco-editor/min/vs' } });
|
|
3806
|
+
window.require(['vs/editor/editor.main'], () => {
|
|
3807
|
+
resolve();
|
|
3808
|
+
});
|
|
3809
|
+
};
|
|
3810
|
+
// Load AMD loader if necessary
|
|
3811
|
+
if (!window.require) {
|
|
3812
|
+
const loaderScript = document.createElement('script');
|
|
3813
|
+
loaderScript.type = 'text/javascript';
|
|
3814
|
+
loaderScript.src = 'assets/monaco-editor/min/vs/loader.js';
|
|
3815
|
+
loaderScript.addEventListener('load', onGotAmdLoader);
|
|
3816
|
+
document.body.appendChild(loaderScript);
|
|
3817
|
+
}
|
|
3818
|
+
else {
|
|
3819
|
+
onGotAmdLoader();
|
|
3820
|
+
}
|
|
3821
|
+
}).then(() => {
|
|
3822
|
+
this.loaded$.next({ monaco: window.monaco });
|
|
3823
|
+
});
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
GioMonacoEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3827
|
+
GioMonacoEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorService, providedIn: 'root' });
|
|
3828
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorService, decorators: [{
|
|
3829
|
+
type: Injectable,
|
|
3830
|
+
args: [{
|
|
3831
|
+
providedIn: 'root',
|
|
3832
|
+
}]
|
|
3833
|
+
}] });
|
|
3834
|
+
|
|
3835
|
+
/*
|
|
3836
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3837
|
+
*
|
|
3838
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3839
|
+
* you may not use this file except in compliance with the License.
|
|
3840
|
+
* You may obtain a copy of the License at
|
|
3841
|
+
*
|
|
3842
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3843
|
+
*
|
|
3844
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3845
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3846
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3847
|
+
* See the License for the specific language governing permissions and
|
|
3848
|
+
* limitations under the License.
|
|
3849
|
+
*/
|
|
3850
|
+
class GioLanguageJsonService {
|
|
3851
|
+
constructor(codeEditorService) {
|
|
3852
|
+
this.unsubscribe$ = new Subject();
|
|
3853
|
+
codeEditorService.loaded$.pipe(takeUntil(this.unsubscribe$)).subscribe(event => {
|
|
3854
|
+
this.setup(event.monaco);
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
ngOnDestroy() {
|
|
3858
|
+
this.unsubscribe$.next();
|
|
3859
|
+
this.unsubscribe$.complete();
|
|
3860
|
+
}
|
|
3861
|
+
setup(monaco) {
|
|
3862
|
+
if (!monaco) {
|
|
3863
|
+
throw new Error('Monaco is not loaded');
|
|
3864
|
+
}
|
|
3865
|
+
this.monaco = monaco;
|
|
3866
|
+
const defaults = monaco.languages.json.jsonDefaults;
|
|
3867
|
+
defaults.setDiagnosticsOptions({
|
|
3868
|
+
validate: true,
|
|
3869
|
+
allowComments: true,
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
addSchemas(id, definitions = []) {
|
|
3873
|
+
if (!this.monaco) {
|
|
3874
|
+
throw new Error('Monaco is not loaded');
|
|
3875
|
+
}
|
|
3876
|
+
const defaults = this.monaco.languages.json.jsonDefaults;
|
|
3877
|
+
const options = defaults.diagnosticsOptions;
|
|
3878
|
+
let schemas = definitions.map(({ uri, schema }) => ({
|
|
3879
|
+
uri,
|
|
3880
|
+
schema,
|
|
3881
|
+
fileMatch: [id || '*.json'],
|
|
3882
|
+
}));
|
|
3883
|
+
if (options && options.schemas && options.schemas.length > 0) {
|
|
3884
|
+
schemas = [...options.schemas, ...schemas];
|
|
3885
|
+
}
|
|
3886
|
+
defaults.setDiagnosticsOptions({
|
|
3887
|
+
...options,
|
|
3888
|
+
schemas: schemas,
|
|
3889
|
+
});
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
GioLanguageJsonService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioLanguageJsonService, deps: [{ token: GioMonacoEditorService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3893
|
+
GioLanguageJsonService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioLanguageJsonService, providedIn: 'root' });
|
|
3894
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioLanguageJsonService, decorators: [{
|
|
3895
|
+
type: Injectable,
|
|
3896
|
+
args: [{
|
|
3897
|
+
providedIn: 'root',
|
|
3898
|
+
}]
|
|
3899
|
+
}], ctorParameters: function () { return [{ type: GioMonacoEditorService }]; } });
|
|
3900
|
+
|
|
3901
|
+
/*
|
|
3902
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
3903
|
+
*
|
|
3904
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3905
|
+
* you may not use this file except in compliance with the License.
|
|
3906
|
+
* You may obtain a copy of the License at
|
|
3907
|
+
*
|
|
3908
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3909
|
+
*
|
|
3910
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3911
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3912
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3913
|
+
* See the License for the specific language governing permissions and
|
|
3914
|
+
* limitations under the License.
|
|
3915
|
+
*/
|
|
3916
|
+
class GioMonacoEditorComponent {
|
|
3917
|
+
constructor(config, monacoEditorService, languageJsonService, hostElement, changeDetectorRef, ngZone) {
|
|
3918
|
+
this.config = config;
|
|
3919
|
+
this.monacoEditorService = monacoEditorService;
|
|
3920
|
+
this.languageJsonService = languageJsonService;
|
|
3921
|
+
this.hostElement = hostElement;
|
|
3922
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
3923
|
+
this.ngZone = ngZone;
|
|
3924
|
+
this.options = {};
|
|
3925
|
+
this.id = uniqueId('gio-monaco-editor-');
|
|
3926
|
+
this.loading = true;
|
|
3927
|
+
this.defaultOptions = {
|
|
3928
|
+
contextmenu: false,
|
|
3929
|
+
minimap: {
|
|
3930
|
+
enabled: true,
|
|
3931
|
+
},
|
|
3932
|
+
automaticLayout: true,
|
|
3933
|
+
scrollBeyondLastLine: false,
|
|
3934
|
+
};
|
|
3935
|
+
this.value = '';
|
|
3936
|
+
this.readOnly = false;
|
|
3937
|
+
this._onChange = () => ({});
|
|
3938
|
+
this._onTouched = () => ({});
|
|
3939
|
+
this.unsubscribe$ = new Subject();
|
|
3940
|
+
this.monacoEditorService.loadEditor();
|
|
3941
|
+
}
|
|
3942
|
+
ngAfterViewInit() {
|
|
3943
|
+
// Wait until monaco editor is available
|
|
3944
|
+
this.monacoEditorService.loaded$.pipe(takeUntil(this.unsubscribe$)).subscribe(({ monaco }) => {
|
|
3945
|
+
this.setupEditor(monaco);
|
|
3946
|
+
this.loading = false;
|
|
3947
|
+
this.changeDetectorRef.detectChanges();
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3950
|
+
ngOnDestroy() {
|
|
3951
|
+
if (this.standaloneCodeEditor) {
|
|
3952
|
+
this.standaloneCodeEditor.dispose();
|
|
3953
|
+
this.standaloneCodeEditor = undefined;
|
|
3954
|
+
}
|
|
3955
|
+
if (this.textModel) {
|
|
3956
|
+
this.textModel.dispose();
|
|
3957
|
+
this.textModel = undefined;
|
|
3958
|
+
}
|
|
3959
|
+
this.unsubscribe$.next();
|
|
3960
|
+
this.unsubscribe$.complete();
|
|
3961
|
+
}
|
|
3962
|
+
// From ControlValueAccessor interface
|
|
3963
|
+
writeValue(_value) {
|
|
3964
|
+
if (_value) {
|
|
3965
|
+
this.value = _value;
|
|
3966
|
+
}
|
|
3967
|
+
if (this.textModel) {
|
|
3968
|
+
this.textModel.setValue(this.value);
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
// From ControlValueAccessor interface
|
|
3972
|
+
registerOnChange(fn) {
|
|
3973
|
+
this._onChange = fn;
|
|
3974
|
+
}
|
|
3975
|
+
// From ControlValueAccessor interface
|
|
3976
|
+
registerOnTouched(fn) {
|
|
3977
|
+
this._onTouched = fn;
|
|
3978
|
+
}
|
|
3979
|
+
// From ControlValueAccessor interface
|
|
3980
|
+
setDisabledState(isDisabled) {
|
|
3981
|
+
this.readOnly = isDisabled;
|
|
3982
|
+
}
|
|
3983
|
+
setupEditor(monaco) {
|
|
3984
|
+
if (!this.hostElement) {
|
|
3985
|
+
throw new Error('No editor ref found.');
|
|
3986
|
+
}
|
|
3987
|
+
const domElement = this.hostElement.nativeElement;
|
|
3988
|
+
const settings = {
|
|
3989
|
+
value: this.value,
|
|
3990
|
+
language: this.languageConfig?.language ?? 'text',
|
|
3991
|
+
uri: `code-${uniqueId()}`,
|
|
3992
|
+
};
|
|
3993
|
+
this.ngZone.runOutsideAngular(() => {
|
|
3994
|
+
this.textModel = monaco.editor.createModel(settings.value, settings.language, monaco.Uri.parse(settings.uri));
|
|
3995
|
+
});
|
|
3996
|
+
const options = Object.assign({}, this.defaultOptions, this.options, {
|
|
3997
|
+
readOnly: this.readOnly,
|
|
3998
|
+
theme: this.config.theme ?? 'vs',
|
|
3999
|
+
model: this.textModel,
|
|
4000
|
+
});
|
|
4001
|
+
this.standaloneCodeEditor = monaco.editor.create(domElement, {
|
|
4002
|
+
...options,
|
|
4003
|
+
});
|
|
4004
|
+
this.textModel?.onDidChangeContent(() => {
|
|
4005
|
+
const newValue = this.textModel?.getValue();
|
|
4006
|
+
this.ngZone.run(() => {
|
|
4007
|
+
newValue && this._onChange(newValue);
|
|
4008
|
+
this._onTouched();
|
|
4009
|
+
});
|
|
4010
|
+
});
|
|
4011
|
+
this.standaloneCodeEditor?.onDidBlurEditorWidget(() => {
|
|
4012
|
+
this.ngZone.run(() => {
|
|
4013
|
+
this._onTouched();
|
|
4014
|
+
});
|
|
4015
|
+
});
|
|
4016
|
+
this.setupLanguage(settings.uri, this.languageConfig);
|
|
4017
|
+
}
|
|
4018
|
+
setupLanguage(uri, languageConfig) {
|
|
4019
|
+
if (!languageConfig) {
|
|
4020
|
+
return;
|
|
4021
|
+
}
|
|
4022
|
+
const { language } = languageConfig;
|
|
4023
|
+
if (language) {
|
|
4024
|
+
const lang = language.toLowerCase();
|
|
4025
|
+
switch (lang) {
|
|
4026
|
+
case 'json':
|
|
4027
|
+
if (languageConfig.schemas) {
|
|
4028
|
+
this.languageJsonService.addSchemas(uri, languageConfig.schemas);
|
|
4029
|
+
}
|
|
4030
|
+
break;
|
|
4031
|
+
default:
|
|
4032
|
+
break;
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
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 });
|
|
4038
|
+
GioMonacoEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioMonacoEditorComponent, selector: "gio-monaco-editor", inputs: { languageConfig: "languageConfig", options: "options" }, providers: [
|
|
4039
|
+
{
|
|
4040
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4041
|
+
useExisting: forwardRef(() => GioMonacoEditorComponent),
|
|
4042
|
+
multi: true,
|
|
4043
|
+
},
|
|
4044
|
+
], 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"] }] });
|
|
4045
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorComponent, decorators: [{
|
|
4046
|
+
type: Component,
|
|
4047
|
+
args: [{ selector: 'gio-monaco-editor', template: ` <div *ngIf="loading">Loading...</div>`, providers: [
|
|
4048
|
+
{
|
|
4049
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4050
|
+
useExisting: forwardRef(() => GioMonacoEditorComponent),
|
|
4051
|
+
multi: true,
|
|
4052
|
+
},
|
|
4053
|
+
], styles: [":host{display:block;height:100%;min-height:150px}\n"] }]
|
|
4054
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
4055
|
+
type: Inject,
|
|
4056
|
+
args: [GIO_MONACO_EDITOR_CONFIG]
|
|
4057
|
+
}] }, { type: GioMonacoEditorService }, { type: GioLanguageJsonService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }]; }, propDecorators: { languageConfig: [{
|
|
4058
|
+
type: Input
|
|
4059
|
+
}], options: [{
|
|
4060
|
+
type: Input
|
|
4061
|
+
}] } });
|
|
4062
|
+
|
|
4063
|
+
/*
|
|
4064
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
4065
|
+
*
|
|
4066
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4067
|
+
* you may not use this file except in compliance with the License.
|
|
4068
|
+
* You may obtain a copy of the License at
|
|
4069
|
+
*
|
|
4070
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4071
|
+
*
|
|
4072
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4073
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4074
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4075
|
+
* See the License for the specific language governing permissions and
|
|
4076
|
+
* limitations under the License.
|
|
4077
|
+
*/
|
|
4078
|
+
class GioMonacoEditorModule {
|
|
4079
|
+
static forRoot(config) {
|
|
4080
|
+
return {
|
|
4081
|
+
ngModule: GioMonacoEditorModule,
|
|
4082
|
+
providers: [
|
|
4083
|
+
{
|
|
4084
|
+
provide: GIO_MONACO_EDITOR_CONFIG,
|
|
4085
|
+
useValue: config,
|
|
4086
|
+
},
|
|
4087
|
+
],
|
|
4088
|
+
};
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
GioMonacoEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4092
|
+
GioMonacoEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, declarations: [GioMonacoEditorComponent], imports: [CommonModule, HttpClientModule, ReactiveFormsModule], exports: [GioMonacoEditorComponent] });
|
|
4093
|
+
GioMonacoEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, providers: [
|
|
4094
|
+
{
|
|
4095
|
+
provide: GIO_MONACO_EDITOR_CONFIG,
|
|
4096
|
+
useValue: {},
|
|
4097
|
+
},
|
|
4098
|
+
], imports: [[CommonModule, HttpClientModule, ReactiveFormsModule]] });
|
|
4099
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorModule, decorators: [{
|
|
4100
|
+
type: NgModule,
|
|
4101
|
+
args: [{
|
|
4102
|
+
imports: [CommonModule, HttpClientModule, ReactiveFormsModule],
|
|
4103
|
+
declarations: [GioMonacoEditorComponent],
|
|
4104
|
+
exports: [GioMonacoEditorComponent],
|
|
4105
|
+
providers: [
|
|
4106
|
+
{
|
|
4107
|
+
provide: GIO_MONACO_EDITOR_CONFIG,
|
|
4108
|
+
useValue: {},
|
|
4109
|
+
},
|
|
4110
|
+
],
|
|
4111
|
+
}]
|
|
4112
|
+
}] });
|
|
4113
|
+
|
|
4114
|
+
/*
|
|
4115
|
+
* Copyright (C) 2023 The Gravitee team (http://gravitee.io)
|
|
4116
|
+
*
|
|
4117
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4118
|
+
* you may not use this file except in compliance with the License.
|
|
4119
|
+
* You may obtain a copy of the License at
|
|
4120
|
+
*
|
|
4121
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4122
|
+
*
|
|
4123
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4124
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4125
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4126
|
+
* See the License for the specific language governing permissions and
|
|
4127
|
+
* limitations under the License.
|
|
4128
|
+
*/
|
|
4129
|
+
/**
|
|
4130
|
+
* This component is used to test the GioMonacoEditorComponent.
|
|
4131
|
+
* This component simulates monaco editor with a simple input.
|
|
4132
|
+
*/
|
|
4133
|
+
class GioMonacoEditorTestingComponent extends GioMonacoEditorComponent {
|
|
4134
|
+
get getValue() {
|
|
4135
|
+
return this.value;
|
|
4136
|
+
}
|
|
4137
|
+
changeValue(value) {
|
|
4138
|
+
this._onTouched();
|
|
4139
|
+
this._onChange(value);
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
GioMonacoEditorTestingComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorTestingComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
4143
|
+
GioMonacoEditorTestingComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: GioMonacoEditorTestingComponent, selector: "gio-monaco-editor", providers: [
|
|
4144
|
+
{
|
|
4145
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4146
|
+
useExisting: forwardRef(() => GioMonacoEditorTestingComponent),
|
|
4147
|
+
multi: true,
|
|
4148
|
+
},
|
|
4149
|
+
], usesInheritance: true, ngImport: i0, template: '<input type="text" [value]="getValue" (input)="changeValue($any($event).target?.value)" />', isInline: true });
|
|
4150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: GioMonacoEditorTestingComponent, decorators: [{
|
|
4151
|
+
type: Component,
|
|
4152
|
+
args: [{
|
|
4153
|
+
selector: 'gio-monaco-editor',
|
|
4154
|
+
template: '<input type="text" [value]="getValue" (input)="changeValue($any($event).target?.value)" />',
|
|
4155
|
+
providers: [
|
|
4156
|
+
{
|
|
4157
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4158
|
+
useExisting: forwardRef(() => GioMonacoEditorTestingComponent),
|
|
4159
|
+
multi: true,
|
|
4160
|
+
},
|
|
4161
|
+
],
|
|
4162
|
+
}]
|
|
4163
|
+
}] });
|
|
4164
|
+
|
|
4165
|
+
/*
|
|
4166
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
4167
|
+
*
|
|
4168
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4169
|
+
* you may not use this file except in compliance with the License.
|
|
4170
|
+
* You may obtain a copy of the License at
|
|
4171
|
+
*
|
|
4172
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4173
|
+
*
|
|
4174
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4175
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4176
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4177
|
+
* See the License for the specific language governing permissions and
|
|
4178
|
+
* limitations under the License.
|
|
4179
|
+
*/
|
|
4180
|
+
// Hack to replace the default gio-monaco-editor component with fake one for testing purpose.
|
|
4181
|
+
try {
|
|
4182
|
+
TestBed.overrideModule(GioMonacoEditorModule, {
|
|
4183
|
+
remove: {
|
|
4184
|
+
declarations: [GioMonacoEditorComponent],
|
|
4185
|
+
exports: [GioMonacoEditorComponent],
|
|
4186
|
+
},
|
|
4187
|
+
add: {
|
|
4188
|
+
declarations: [GioMonacoEditorTestingComponent],
|
|
4189
|
+
exports: [GioMonacoEditorTestingComponent],
|
|
4190
|
+
},
|
|
4191
|
+
});
|
|
4192
|
+
}
|
|
4193
|
+
catch (e) {
|
|
4194
|
+
// Do nothing
|
|
4195
|
+
}
|
|
4196
|
+
class GioMonacoEditorHarness extends ComponentHarness {
|
|
4197
|
+
constructor() {
|
|
4198
|
+
super(...arguments);
|
|
4199
|
+
this.getInputEl = this.locatorFor('input');
|
|
4200
|
+
}
|
|
4201
|
+
/**
|
|
4202
|
+
* Gets a `HarnessPredicate` that can be used to search for a `GioMonacoEditorHarness` that meets
|
|
4203
|
+
* certain criteria.
|
|
4204
|
+
*
|
|
4205
|
+
* @param options Options for filtering which input instances are considered a match.
|
|
4206
|
+
* @return a `HarnessPredicate` configured with the given options.
|
|
4207
|
+
*/
|
|
4208
|
+
static with(options = {}) {
|
|
4209
|
+
return new HarnessPredicate(GioMonacoEditorHarness, options);
|
|
4210
|
+
}
|
|
4211
|
+
async setValue(value) {
|
|
4212
|
+
const inputEl = await this.getInputEl();
|
|
4213
|
+
await inputEl.clear();
|
|
4214
|
+
await inputEl.sendKeys(value);
|
|
4215
|
+
}
|
|
4216
|
+
async getValue() {
|
|
4217
|
+
const inputEl = await this.getInputEl();
|
|
4218
|
+
return inputEl.getProperty('value');
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
GioMonacoEditorHarness.hostSelector = 'gio-monaco-editor';
|
|
4222
|
+
|
|
3750
4223
|
/*
|
|
3751
4224
|
* Copyright (C) 2021 The Gravitee team (http://gravitee.io)
|
|
3752
4225
|
*
|
|
@@ -3783,5 +4256,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
3783
4256
|
* Generated bundle index. Do not edit.
|
|
3784
4257
|
*/
|
|
3785
4258
|
|
|
3786
|
-
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 };
|
|
4259
|
+
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 };
|
|
3787
4260
|
//# sourceMappingURL=gravitee-ui-particles-angular.mjs.map
|