@apipass/inputs 1.0.149 → 1.0.150

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.
@@ -33,6 +33,8 @@ import { NgSelectModule } from '@ng-select/ng-select';
33
33
  import * as i1$1 from '@angular/cdk/overlay';
34
34
  import { OverlayModule } from '@angular/cdk/overlay';
35
35
  import { RouterModule } from '@angular/router';
36
+ import 'brace';
37
+ import 'brace/theme/monokai';
36
38
  import * as i3$3 from '@apipass/buttons';
37
39
  import { ButtonsModule } from '@apipass/buttons';
38
40
  import moment from 'moment-timezone';
@@ -1046,6 +1048,378 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
1046
1048
  type: Output
1047
1049
  }] } });
1048
1050
 
1051
+ class AceEditorComponent {
1052
+ zone;
1053
+ textChanged = new EventEmitter();
1054
+ textChange = new EventEmitter();
1055
+ style = {};
1056
+ _options = {};
1057
+ _readOnly = false;
1058
+ _theme = 'monokai';
1059
+ _mode = 'html';
1060
+ _autoUpdateContent = true;
1061
+ _editor;
1062
+ _durationBeforeCallback = 0;
1063
+ _text = '';
1064
+ oldText;
1065
+ timeoutSaving;
1066
+ constructor(elementRef, zone) {
1067
+ this.zone = zone;
1068
+ const el = elementRef.nativeElement;
1069
+ this.zone.runOutsideAngular(() => {
1070
+ this._editor = ace.edit(el);
1071
+ });
1072
+ this._editor.$blockScrolling = Infinity;
1073
+ }
1074
+ ngOnInit() {
1075
+ this.init();
1076
+ this.initEvents();
1077
+ }
1078
+ ngOnDestroy() {
1079
+ this._editor.destroy();
1080
+ }
1081
+ init() {
1082
+ this._editor.setKeyboardHandler('ace/keyboard/vscode');
1083
+ this.setOptions({
1084
+ enableBasicAutocompletion: true,
1085
+ autoScrollEditorIntoView: true,
1086
+ enableLiveAutocompletion: true
1087
+ });
1088
+ this.setTheme(this._theme);
1089
+ this.setMode(this._mode);
1090
+ this.setReadOnly(this._readOnly);
1091
+ const completerIndex = this._editor.completers.findIndex((completer) => completer.id === 'apipass-completions');
1092
+ if (completerIndex > -1) { // only splice array when item is found
1093
+ this._editor.completers.splice(completerIndex, 1); // 2nd parameter means remove one item only
1094
+ }
1095
+ }
1096
+ setCustomCompletions(customCompletions) {
1097
+ const completer = this._editor.completers.find((completer) => completer.id === 'apipass-completions');
1098
+ if (!completer) {
1099
+ this.setOptions({
1100
+ enableBasicAutocompletion: true,
1101
+ autoScrollEditorIntoView: true,
1102
+ enableLiveAutocompletion: true
1103
+ });
1104
+ this._editor.completers.push({
1105
+ id: 'apipass-completions',
1106
+ getCompletions: function (editor, session, pos, prefix, callback) {
1107
+ callback(null, customCompletions);
1108
+ }
1109
+ });
1110
+ }
1111
+ else {
1112
+ completer.getCompletions = (editor, session, pos, prefix, callback) => {
1113
+ callback(null, customCompletions);
1114
+ };
1115
+ }
1116
+ }
1117
+ initEvents() {
1118
+ this._editor.on('change', () => {
1119
+ this.updateText();
1120
+ });
1121
+ this._editor.on('paste', () => {
1122
+ this.updateText();
1123
+ });
1124
+ }
1125
+ updateText() {
1126
+ const newVal = this._editor.getValue();
1127
+ if (newVal === this.oldText) {
1128
+ return;
1129
+ }
1130
+ if (!this._durationBeforeCallback) {
1131
+ this._text = newVal;
1132
+ this.zone.run(() => {
1133
+ this.textChange.emit(newVal);
1134
+ this.textChanged.emit(newVal);
1135
+ });
1136
+ this._onChange(newVal);
1137
+ }
1138
+ else {
1139
+ if (this.timeoutSaving) {
1140
+ clearTimeout(this.timeoutSaving);
1141
+ }
1142
+ this.timeoutSaving = setTimeout(() => {
1143
+ this._text = newVal;
1144
+ this.zone.run(() => {
1145
+ this.textChange.emit(newVal);
1146
+ this.textChanged.emit(newVal);
1147
+ });
1148
+ this.timeoutSaving = null;
1149
+ }, this._durationBeforeCallback);
1150
+ }
1151
+ this.oldText = newVal;
1152
+ }
1153
+ set options(options) {
1154
+ this.setOptions(options);
1155
+ }
1156
+ setOptions(options) {
1157
+ this._options = options;
1158
+ this._editor.setOptions(options || {});
1159
+ }
1160
+ set readOnly(readOnly) {
1161
+ this.setReadOnly(readOnly);
1162
+ }
1163
+ setReadOnly(readOnly) {
1164
+ this._readOnly = readOnly;
1165
+ this._editor.setReadOnly(readOnly);
1166
+ }
1167
+ set theme(theme) {
1168
+ this.setTheme(theme);
1169
+ }
1170
+ setTheme(theme) {
1171
+ this._theme = theme;
1172
+ this._editor.setTheme(`ace/theme/${theme}`);
1173
+ }
1174
+ set mode(mode) {
1175
+ this.setMode(mode);
1176
+ }
1177
+ setMode(mode) {
1178
+ this._mode = mode;
1179
+ if (typeof this._mode === 'object') {
1180
+ this._editor.getSession().setMode(this._mode);
1181
+ }
1182
+ else {
1183
+ this._editor.getSession().setMode(`ace/mode/${this._mode}`);
1184
+ }
1185
+ }
1186
+ get value() {
1187
+ return this.text;
1188
+ }
1189
+ set value(value) {
1190
+ this.setText(value);
1191
+ }
1192
+ writeValue(value) {
1193
+ this.setText(value);
1194
+ }
1195
+ _onChange = (_) => {
1196
+ };
1197
+ registerOnChange(fn) {
1198
+ this._onChange = fn;
1199
+ }
1200
+ _onTouched = () => {
1201
+ };
1202
+ registerOnTouched(fn) {
1203
+ this._onTouched = fn;
1204
+ }
1205
+ get text() {
1206
+ return this._text;
1207
+ }
1208
+ set text(text) {
1209
+ this.setText(text);
1210
+ }
1211
+ setText(text) {
1212
+ if (text === null || text === undefined) {
1213
+ text = '';
1214
+ }
1215
+ if (this._text !== text && this._autoUpdateContent) {
1216
+ this._text = text;
1217
+ this._editor.setValue(text);
1218
+ this._onChange(text);
1219
+ this._editor.clearSelection();
1220
+ }
1221
+ }
1222
+ set autoUpdateContent(status) {
1223
+ this.setAutoUpdateContent(status);
1224
+ }
1225
+ setAutoUpdateContent(status) {
1226
+ this._autoUpdateContent = status;
1227
+ }
1228
+ set durationBeforeCallback(num) {
1229
+ this.setDurationBeforeCallback(num);
1230
+ }
1231
+ setDurationBeforeCallback(num) {
1232
+ this._durationBeforeCallback = num;
1233
+ }
1234
+ getEditor() {
1235
+ return this._editor;
1236
+ }
1237
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: AceEditorComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
1238
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.2", type: AceEditorComponent, selector: "ace-editor", inputs: { style: "style", options: "options", readOnly: "readOnly", theme: "theme", mode: "mode", value: "value", text: "text", autoUpdateContent: "autoUpdateContent", durationBeforeCallback: "durationBeforeCallback" }, outputs: { textChanged: "textChanged", textChange: "textChange" }, providers: [{
1239
+ provide: NG_VALUE_ACCESSOR,
1240
+ useExisting: forwardRef(() => AceEditorComponent),
1241
+ multi: true
1242
+ }], ngImport: i0, template: '', isInline: true, styles: [":host{display:block;width:100%}\n"] });
1243
+ }
1244
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: AceEditorComponent, decorators: [{
1245
+ type: Component,
1246
+ args: [{ selector: 'ace-editor', template: '', providers: [{
1247
+ provide: NG_VALUE_ACCESSOR,
1248
+ useExisting: forwardRef(() => AceEditorComponent),
1249
+ multi: true
1250
+ }], styles: [":host{display:block;width:100%}\n"] }]
1251
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { textChanged: [{
1252
+ type: Output
1253
+ }], textChange: [{
1254
+ type: Output
1255
+ }], style: [{
1256
+ type: Input
1257
+ }], options: [{
1258
+ type: Input
1259
+ }], readOnly: [{
1260
+ type: Input
1261
+ }], theme: [{
1262
+ type: Input
1263
+ }], mode: [{
1264
+ type: Input
1265
+ }], value: [{
1266
+ type: Input
1267
+ }], text: [{
1268
+ type: Input
1269
+ }], autoUpdateContent: [{
1270
+ type: Input
1271
+ }], durationBeforeCallback: [{
1272
+ type: Input
1273
+ }] } });
1274
+
1275
+ class AceEditorDirective {
1276
+ zone;
1277
+ textChanged = new EventEmitter();
1278
+ textChange = new EventEmitter();
1279
+ _options = {};
1280
+ _readOnly = false;
1281
+ _theme = 'monokai';
1282
+ _mode = 'html';
1283
+ _autoUpdateContent = true;
1284
+ _durationBeforeCallback = 0;
1285
+ _text = '';
1286
+ editor;
1287
+ oldText;
1288
+ timeoutSaving;
1289
+ constructor(elementRef, zone) {
1290
+ this.zone = zone;
1291
+ const el = elementRef.nativeElement;
1292
+ this.zone.runOutsideAngular(() => {
1293
+ this.editor = ace.edit(el);
1294
+ });
1295
+ this.editor.$blockScrolling = Infinity;
1296
+ }
1297
+ ngOnInit() {
1298
+ this.init();
1299
+ this.initEvents();
1300
+ }
1301
+ ngOnDestroy() {
1302
+ this.editor.destroy();
1303
+ }
1304
+ init() {
1305
+ this.editor.setOptions(this._options || {});
1306
+ this.editor.setTheme(`ace/theme/${this._theme}`);
1307
+ this.setMode(this._mode);
1308
+ this.editor.setReadOnly(this._readOnly);
1309
+ }
1310
+ initEvents() {
1311
+ this.editor.on('change', () => { this.updateText(); });
1312
+ this.editor.on('paste', () => { this.updateText(); });
1313
+ }
1314
+ updateText() {
1315
+ const newVal = this.editor.getValue();
1316
+ if (newVal === this.oldText) {
1317
+ return;
1318
+ }
1319
+ if (!this._durationBeforeCallback) {
1320
+ this._text = newVal;
1321
+ this.zone.run(() => {
1322
+ this.textChange.emit(newVal);
1323
+ this.textChanged.emit(newVal);
1324
+ });
1325
+ }
1326
+ else {
1327
+ if (this.timeoutSaving != null) {
1328
+ clearTimeout(this.timeoutSaving);
1329
+ }
1330
+ this.timeoutSaving = setTimeout(() => {
1331
+ this._text = newVal;
1332
+ this.zone.run(() => {
1333
+ this.textChange.emit(newVal);
1334
+ this.textChanged.emit(newVal);
1335
+ });
1336
+ this.timeoutSaving = null;
1337
+ }, this._durationBeforeCallback);
1338
+ }
1339
+ this.oldText = newVal;
1340
+ }
1341
+ set options(options) {
1342
+ this._options = options;
1343
+ this.editor.setOptions(options || {});
1344
+ }
1345
+ set readOnly(readOnly) {
1346
+ this._readOnly = readOnly;
1347
+ this.editor.setReadOnly(readOnly);
1348
+ }
1349
+ set theme(theme) {
1350
+ this._theme = theme;
1351
+ this.editor.setTheme(`ace/theme/${theme}`);
1352
+ }
1353
+ set mode(mode) {
1354
+ this.setMode(mode);
1355
+ }
1356
+ setMode(mode) {
1357
+ this._mode = mode;
1358
+ if (typeof this._mode === 'object') {
1359
+ this.editor.getSession().setMode(this._mode);
1360
+ }
1361
+ else {
1362
+ this.editor.getSession().setMode(`ace/mode/${this._mode}`);
1363
+ }
1364
+ }
1365
+ get text() {
1366
+ return this._text;
1367
+ }
1368
+ set text(text) {
1369
+ this.setText(text);
1370
+ }
1371
+ setText(text) {
1372
+ if (this._text !== text) {
1373
+ if (text === null || text === undefined) {
1374
+ text = '';
1375
+ }
1376
+ if (this._autoUpdateContent) {
1377
+ this._text = text;
1378
+ this.editor.setValue(text);
1379
+ this.editor.clearSelection();
1380
+ }
1381
+ }
1382
+ }
1383
+ set autoUpdateContent(status) {
1384
+ this._autoUpdateContent = status;
1385
+ }
1386
+ set durationBeforeCallback(num) {
1387
+ this.setDurationBeforeCallback(num);
1388
+ }
1389
+ setDurationBeforeCallback(num) {
1390
+ this._durationBeforeCallback = num;
1391
+ }
1392
+ get aceEditor() {
1393
+ return this.editor;
1394
+ }
1395
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: AceEditorDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
1396
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.2", type: AceEditorDirective, selector: "[ace-editor]", inputs: { options: "options", readOnly: "readOnly", theme: "theme", mode: "mode", text: "text", autoUpdateContent: "autoUpdateContent", durationBeforeCallback: "durationBeforeCallback" }, outputs: { textChanged: "textChanged", textChange: "textChange" }, ngImport: i0 });
1397
+ }
1398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImport: i0, type: AceEditorDirective, decorators: [{
1399
+ type: Directive,
1400
+ args: [{
1401
+ selector: '[ace-editor]'
1402
+ }]
1403
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { textChanged: [{
1404
+ type: Output
1405
+ }], textChange: [{
1406
+ type: Output
1407
+ }], options: [{
1408
+ type: Input
1409
+ }], readOnly: [{
1410
+ type: Input
1411
+ }], theme: [{
1412
+ type: Input
1413
+ }], mode: [{
1414
+ type: Input
1415
+ }], text: [{
1416
+ type: Input
1417
+ }], autoUpdateContent: [{
1418
+ type: Input
1419
+ }], durationBeforeCallback: [{
1420
+ type: Input
1421
+ }] } });
1422
+
1049
1423
  class InputNumberComponent extends ValueAccessorBase {
1050
1424
  label = '';
1051
1425
  disabled = false;
@@ -1922,6 +2296,8 @@ class InputsModule {
1922
2296
  CustomSelectComponent,
1923
2297
  SelectInterpolationComponent,
1924
2298
  FieldComponent,
2299
+ AceEditorComponent,
2300
+ AceEditorDirective,
1925
2301
  DebouceInputDirective,
1926
2302
  InputDateTimeIntervalComponent,
1927
2303
  KeyValueInputComponent], imports: [RouterModule,
@@ -1955,6 +2331,8 @@ class InputsModule {
1955
2331
  CustomSelectComponent,
1956
2332
  SelectInterpolationComponent,
1957
2333
  FieldComponent,
2334
+ AceEditorComponent,
2335
+ AceEditorDirective,
1958
2336
  DebouceInputDirective,
1959
2337
  InputDateTimeIntervalComponent,
1960
2338
  NgxMaskDirective,
@@ -2032,6 +2410,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
2032
2410
  CustomSelectComponent,
2033
2411
  SelectInterpolationComponent,
2034
2412
  FieldComponent,
2413
+ AceEditorComponent,
2414
+ AceEditorDirective,
2035
2415
  DebouceInputDirective,
2036
2416
  InputDateTimeIntervalComponent,
2037
2417
  KeyValueInputComponent
@@ -2048,6 +2428,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.2", ngImpor
2048
2428
  CustomSelectComponent,
2049
2429
  SelectInterpolationComponent,
2050
2430
  FieldComponent,
2431
+ AceEditorComponent,
2432
+ AceEditorDirective,
2051
2433
  DebouceInputDirective,
2052
2434
  InputDateTimeIntervalComponent,
2053
2435
  NgxMaskDirective,
@@ -2505,5 +2887,5 @@ class TimeIntervalValueBuilder {
2505
2887
  * Generated bundle index. Do not edit.
2506
2888
  */
2507
2889
 
2508
- export { CurrentMonthInterval, CustomSelectComponent, CustomSelectItem, DebouceInputDirective, DefaultIntervalsBuilder, FieldComponent, InputAvatarComponent, InputBooleanComponent, InputDateTimeIntervalComponent, InputFileComponent, InputImageComponent, InputNumberComponent, InputTextComponent, InputsModule, KeyValueInputComponent, LastFiveMinutesInterval, LastHourInterval, LastMinuteInterval, LastMonthInterval, LastOneWeekInterval, LastQuarterInterval, LastTenMinutesInterval, LastThirtyMinutesInterval, LastThreeHoursInterval, LastTwoHoursInterval, LastYearInterval, SelectBoxComponent, SelectEnumComponent, SelectInterpolationComponent, ThisQuarterInterval, ThisWeekInterval, ThisYearInterval, TimeIntervalValue, TimeIntervalValueBuilder, TimeIntervalsBuilder, TodayInterval, ValueAccessorBase, YesterdayInterval };
2890
+ export { AceEditorComponent, AceEditorDirective, CurrentMonthInterval, CustomSelectComponent, CustomSelectItem, DebouceInputDirective, DefaultIntervalsBuilder, FieldComponent, InputAvatarComponent, InputBooleanComponent, InputDateTimeIntervalComponent, InputFileComponent, InputImageComponent, InputNumberComponent, InputTextComponent, InputsModule, KeyValueInputComponent, LastFiveMinutesInterval, LastHourInterval, LastMinuteInterval, LastMonthInterval, LastOneWeekInterval, LastQuarterInterval, LastTenMinutesInterval, LastThirtyMinutesInterval, LastThreeHoursInterval, LastTwoHoursInterval, LastYearInterval, SelectBoxComponent, SelectEnumComponent, SelectInterpolationComponent, ThisQuarterInterval, ThisWeekInterval, ThisYearInterval, TimeIntervalValue, TimeIntervalValueBuilder, TimeIntervalsBuilder, TodayInterval, ValueAccessorBase, YesterdayInterval };
2509
2891
  //# sourceMappingURL=apipass-inputs.mjs.map