chrv-components 1.10.18 → 1.10.19
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/chrv-components-1.10.19.tgz +0 -0
- package/fesm2022/chrv-components.mjs +28 -15
- package/fesm2022/chrv-components.mjs.map +1 -1
- package/lib/chr-tag-select/chr-tag-select.component.d.ts +7 -5
- package/lib/models/controls.d.ts +4 -3
- package/package.json +1 -1
- package/chrv-components-1.10.18.tgz +0 -0
|
Binary file
|
|
@@ -15,7 +15,7 @@ import * as i1$3 from '@angular/forms';
|
|
|
15
15
|
import { NG_VALIDATORS, Validators, FormControl, ReactiveFormsModule, FormsModule, FormGroup } from '@angular/forms';
|
|
16
16
|
import * as i2$1 from '@angular/material/autocomplete';
|
|
17
17
|
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
18
|
-
import { Observable, map, BehaviorSubject, skip, debounceTime, distinctUntilChanged, startWith, from, mergeMap, toArray,
|
|
18
|
+
import { Observable, map, BehaviorSubject, skip, debounceTime, distinctUntilChanged, startWith, Subject, from, mergeMap, toArray, timer, catchError, forkJoin, take, skipWhile, tap, finalize as finalize$1 } from 'rxjs';
|
|
19
19
|
import * as i3$1 from '@angular/material/core';
|
|
20
20
|
import { MatOption } from '@angular/material/core';
|
|
21
21
|
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
@@ -1218,12 +1218,16 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1218
1218
|
* If this callback returns a different value (by reference (ex: different object)) the entry will be replaced by the new value.
|
|
1219
1219
|
*/
|
|
1220
1220
|
this.editCallback = null;
|
|
1221
|
+
//Subject used in callback methods to update the value when received.
|
|
1222
|
+
this.editSubject = new Subject();
|
|
1221
1223
|
/**
|
|
1222
1224
|
* Callback that will be called BEFORE the value is added with the selected value passed as parameter.
|
|
1223
1225
|
* If this callback returns null, the entry will NOT be added.
|
|
1224
1226
|
* This lets you update the value before it's added.
|
|
1225
1227
|
*/
|
|
1226
1228
|
this.addCallback = null;
|
|
1229
|
+
//Subject used in callback methods to update the value when received.
|
|
1230
|
+
this.addSubject = new Subject();
|
|
1227
1231
|
/**
|
|
1228
1232
|
* Callback that will be called during the removal of the value. This will be called with the deleted value passed as parameter.
|
|
1229
1233
|
*/
|
|
@@ -1249,19 +1253,19 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1249
1253
|
this.addFromText = (event) => {
|
|
1250
1254
|
if (this.acceptText && this.textInputValue.trim()) {
|
|
1251
1255
|
const value = this.addCallback
|
|
1252
|
-
? this.addCallback(this.textInputValue)
|
|
1256
|
+
? this.addCallback(this.textInputValue, this.addSubject)
|
|
1253
1257
|
: this.textInputValue;
|
|
1254
1258
|
if (this.addCallback && (value === null || value === undefined)) {
|
|
1255
1259
|
this.textInputValue = '';
|
|
1256
1260
|
return;
|
|
1257
1261
|
}
|
|
1258
|
-
this.
|
|
1259
|
-
this.textInputValue = '';
|
|
1260
|
-
this.onValueChange(this.value);
|
|
1262
|
+
this.addSubject.next(value);
|
|
1261
1263
|
}
|
|
1262
1264
|
};
|
|
1263
1265
|
this.add = (event) => {
|
|
1264
|
-
const value = this.addCallback
|
|
1266
|
+
const value = this.addCallback
|
|
1267
|
+
? this.addCallback(event, this.addSubject)
|
|
1268
|
+
: event;
|
|
1265
1269
|
if (this.addCallback && (value === null || value === undefined)) {
|
|
1266
1270
|
this.textInputValue = '';
|
|
1267
1271
|
return;
|
|
@@ -1270,14 +1274,14 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1270
1274
|
this.value = [...(this.value ?? []), value];
|
|
1271
1275
|
}
|
|
1272
1276
|
this.textInputValue = '';
|
|
1273
|
-
this.
|
|
1277
|
+
this.addSubject.next(value);
|
|
1274
1278
|
};
|
|
1275
1279
|
this.edit = (entry) => {
|
|
1276
1280
|
//If no callback, return;
|
|
1277
1281
|
if (this.editCallback === undefined || this.editCallback === null)
|
|
1278
1282
|
return;
|
|
1279
1283
|
//Call the callback and retrive it's return value
|
|
1280
|
-
const res = this.editCallback(entry);
|
|
1284
|
+
const res = this.editCallback(entry, this.editSubject);
|
|
1281
1285
|
//If the callback returns null, we remove the value.
|
|
1282
1286
|
if (res === null && this.value !== null) {
|
|
1283
1287
|
this.value = this.value?.filter((v) => v != entry);
|
|
@@ -1285,13 +1289,11 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1285
1289
|
return this.onValueChange(this.value);
|
|
1286
1290
|
}
|
|
1287
1291
|
//If the callback returns a different value (different by reference (ex: different object)), we replace the edited entry by the returned entry.
|
|
1288
|
-
if (entry != res) {
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
this.value[this.value.indexOf(entry)] = entry;
|
|
1294
|
-
return this.onValueChange(this.value);
|
|
1292
|
+
// if (entry != res) {
|
|
1293
|
+
return this.editSubject.next(res);
|
|
1294
|
+
// }
|
|
1295
|
+
// this.value![this.value!.indexOf(entry)] = entry;
|
|
1296
|
+
// return this.onValueChange(this.value);
|
|
1295
1297
|
};
|
|
1296
1298
|
this.registerFilters = () => {
|
|
1297
1299
|
this.filteredModelOptions = this.values.pipe(startWith(''), map((value) => this._filterModel(this.textInputValue || -1)), map((values) => {
|
|
@@ -1355,6 +1357,17 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1355
1357
|
this.registerFilters();
|
|
1356
1358
|
if (this.acceptText === null)
|
|
1357
1359
|
this.acceptText = this.display === null && this.data === null;
|
|
1360
|
+
//Register subject listeners
|
|
1361
|
+
this.addSubject.subscribe((entry) => {
|
|
1362
|
+
this.value = [...(this.value ?? []), entry];
|
|
1363
|
+
this.onValueChange(this.value);
|
|
1364
|
+
});
|
|
1365
|
+
this.editSubject.subscribe((entry) => {
|
|
1366
|
+
const index = this.value?.indexOf(entry);
|
|
1367
|
+
this.value[index] = entry;
|
|
1368
|
+
this.value = [...(this.value ?? [])];
|
|
1369
|
+
return this.onValueChange(this.value);
|
|
1370
|
+
});
|
|
1358
1371
|
}
|
|
1359
1372
|
writeValue(obj) {
|
|
1360
1373
|
super.writeValue(obj);
|