@arsedizioni/ars-utils 19.0.18 → 19.0.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.
|
@@ -2354,30 +2354,36 @@ class ChipsSelectorComponent {
|
|
|
2354
2354
|
}, 100);
|
|
2355
2355
|
}
|
|
2356
2356
|
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Get current selection
|
|
2359
|
+
* @returns current selection
|
|
2360
|
+
*/
|
|
2361
|
+
getSelection() {
|
|
2362
|
+
const value = !this.multiple() || this.collapsed() || this.collapsedDisplayMode() === "button"
|
|
2363
|
+
? this.singleSelection
|
|
2364
|
+
: this.selection ?? [];
|
|
2365
|
+
const isArray = Array.isArray(value);
|
|
2366
|
+
if (isArray) {
|
|
2367
|
+
return value ?? [];
|
|
2368
|
+
}
|
|
2369
|
+
else {
|
|
2370
|
+
return value ? [value] : [];
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2357
2373
|
/**
|
|
2358
2374
|
* Update current value with a little delay
|
|
2359
2375
|
*/
|
|
2360
2376
|
updateValue() {
|
|
2361
2377
|
setTimeout(() => {
|
|
2362
|
-
|
|
2363
|
-
? this.singleSelection
|
|
2364
|
-
: this.selection ?? [];
|
|
2365
|
-
const isArray = Array.isArray(value);
|
|
2366
|
-
if (isArray) {
|
|
2367
|
-
this.writeValue(value);
|
|
2368
|
-
}
|
|
2369
|
-
else {
|
|
2370
|
-
this.writeValue([value]);
|
|
2371
|
-
}
|
|
2378
|
+
this.writeValue(this.getSelection());
|
|
2372
2379
|
}, 250);
|
|
2373
2380
|
}
|
|
2374
2381
|
/**
|
|
2375
2382
|
* Check if a item is selectable
|
|
2383
|
+
* @param item: the item to check
|
|
2376
2384
|
*/
|
|
2377
2385
|
isSelectable(item) {
|
|
2378
|
-
return
|
|
2379
|
-
? this.singleSelection?.value === item.value
|
|
2380
|
-
: this.selection?.findIndex(x => x.value === item.value) !== -1);
|
|
2386
|
+
return this.getSelection().findIndex(x => x.value === item.value) !== -1;
|
|
2381
2387
|
}
|
|
2382
2388
|
writeValue(value) {
|
|
2383
2389
|
if (this.value !== value) {
|