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