@arsedizioni/ars-utils 19.0.17 → 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.
@@ -2218,11 +2218,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImpor
2218
2218
  class ChipsSelectorComponent {
2219
2219
  set value(value) {
2220
2220
  this._value = value;
2221
- this.propagateChange(this._value);
2222
- this.stateChanges.next();
2223
- if (this.changesEnabled) {
2224
- this.changed.emit(this._value);
2225
- }
2226
2221
  this.selection = [];
2227
2222
  this.singleSelection = null;
2228
2223
  if (this._value) {
@@ -2235,6 +2230,11 @@ class ChipsSelectorComponent {
2235
2230
  this.singleSelection = this.selection[0];
2236
2231
  }
2237
2232
  }
2233
+ this.propagateChange(this._value);
2234
+ this.stateChanges.next();
2235
+ if (this.changesEnabled) {
2236
+ this.changed.emit(this._value);
2237
+ }
2238
2238
  }
2239
2239
  get value() {
2240
2240
  return this._value;
@@ -2354,29 +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
- 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
- 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 (this.selection?.findIndex(x => x.value === item.value) !== -1 || this.singleSelection?.value === item.value)
2379
- && this.mustSelect();
2386
+ return this.getSelection().findIndex(x => x.value === item.value) !== -1;
2380
2387
  }
2381
2388
  writeValue(value) {
2382
2389
  if (this.value !== value) {