chrv-components 1.10.18 → 1.10.20
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.20.tgz +0 -0
- package/fesm2022/chrv-components.mjs +30 -18
- 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,35 +1253,32 @@ 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;
|
|
1268
1272
|
}
|
|
1269
|
-
if (!this.value?.find((v) => v == value)) {
|
|
1270
|
-
this.value = [...(this.value ?? []), value];
|
|
1271
|
-
}
|
|
1272
1273
|
this.textInputValue = '';
|
|
1273
|
-
this.
|
|
1274
|
+
this.addSubject.next(value);
|
|
1274
1275
|
};
|
|
1275
1276
|
this.edit = (entry) => {
|
|
1276
1277
|
//If no callback, return;
|
|
1277
1278
|
if (this.editCallback === undefined || this.editCallback === null)
|
|
1278
1279
|
return;
|
|
1279
1280
|
//Call the callback and retrive it's return value
|
|
1280
|
-
const res = this.editCallback(entry);
|
|
1281
|
+
const res = this.editCallback(entry, this.editSubject);
|
|
1281
1282
|
//If the callback returns null, we remove the value.
|
|
1282
1283
|
if (res === null && this.value !== null) {
|
|
1283
1284
|
this.value = this.value?.filter((v) => v != entry);
|
|
@@ -1285,13 +1286,11 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1285
1286
|
return this.onValueChange(this.value);
|
|
1286
1287
|
}
|
|
1287
1288
|
//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);
|
|
1289
|
+
// if (entry != res) {
|
|
1290
|
+
return this.editSubject.next(res);
|
|
1291
|
+
// }
|
|
1292
|
+
// this.value![this.value!.indexOf(entry)] = entry;
|
|
1293
|
+
// return this.onValueChange(this.value);
|
|
1295
1294
|
};
|
|
1296
1295
|
this.registerFilters = () => {
|
|
1297
1296
|
this.filteredModelOptions = this.values.pipe(startWith(''), map((value) => this._filterModel(this.textInputValue || -1)), map((values) => {
|
|
@@ -1355,6 +1354,19 @@ class ChrTagSelectComponent extends ChrBaseInputComponent {
|
|
|
1355
1354
|
this.registerFilters();
|
|
1356
1355
|
if (this.acceptText === null)
|
|
1357
1356
|
this.acceptText = this.display === null && this.data === null;
|
|
1357
|
+
//Register subject listeners
|
|
1358
|
+
this.addSubject.subscribe((entry) => {
|
|
1359
|
+
if (!this.value?.find((v) => v == entry)) {
|
|
1360
|
+
this.value = [...(this.value ?? []), entry];
|
|
1361
|
+
this.onValueChange(this.value);
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
this.editSubject.subscribe((entry) => {
|
|
1365
|
+
const index = this.value?.indexOf(entry);
|
|
1366
|
+
this.value[index] = entry;
|
|
1367
|
+
this.value = [...(this.value ?? [])];
|
|
1368
|
+
return this.onValueChange(this.value);
|
|
1369
|
+
});
|
|
1358
1370
|
}
|
|
1359
1371
|
writeValue(obj) {
|
|
1360
1372
|
super.writeValue(obj);
|