@clr/angular 17.11.8 → 17.11.10
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/clarity.api.md +14 -3
- package/data/datagrid/datagrid-single-selection.directive.d.ts +8 -3
- package/data/datagrid/datagrid.d.ts +3 -2
- package/data/datagrid/providers/selection.d.ts +11 -3
- package/esm2020/data/datagrid/datagrid-row.mjs +2 -1
- package/esm2020/data/datagrid/datagrid-single-selection.directive.mjs +19 -7
- package/esm2020/data/datagrid/datagrid.mjs +6 -1
- package/esm2020/data/datagrid/providers/selection.mjs +28 -28
- package/fesm2015/clr-angular.mjs +52 -34
- package/fesm2015/clr-angular.mjs.map +1 -1
- package/fesm2020/clr-angular.mjs +51 -33
- package/fesm2020/clr-angular.mjs.map +1 -1
- package/package.json +2 -2
package/fesm2015/clr-angular.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { Subject, BehaviorSubject, Observable, fromEvent, isObservable, of, shar
|
|
|
9
9
|
import * as i2 from '@angular/animations';
|
|
10
10
|
import { animation, style, animate, trigger, transition, state, useAnimation, keyframes } from '@angular/animations';
|
|
11
11
|
import * as i1 from '@angular/forms';
|
|
12
|
-
import { FormControl, FormGroup, FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, SelectMultipleControlValueAccessor
|
|
12
|
+
import { FormControl, FormGroup, FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, SelectMultipleControlValueAccessor } from '@angular/forms';
|
|
13
13
|
import * as i1$1 from '@angular/router';
|
|
14
14
|
import { RouterModule } from '@angular/router';
|
|
15
15
|
import * as i1$2 from '@angular/cdk/a11y';
|
|
@@ -21157,8 +21157,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
21157
21157
|
*/
|
|
21158
21158
|
let nbSelection = 0;
|
|
21159
21159
|
class Selection {
|
|
21160
|
-
constructor(_items, filters) {
|
|
21160
|
+
constructor(_items, filters, differs) {
|
|
21161
21161
|
this._items = _items;
|
|
21162
|
+
this.differs = differs;
|
|
21162
21163
|
this.preserveSelection = false;
|
|
21163
21164
|
/**
|
|
21164
21165
|
* Shift key state, for use in range selection.
|
|
@@ -21166,8 +21167,8 @@ class Selection {
|
|
|
21166
21167
|
this.shiftPressed = false;
|
|
21167
21168
|
/** @deprecated since 2.0, remove in 3.0 */
|
|
21168
21169
|
this.rowSelectionMode = false;
|
|
21169
|
-
this.prevSelectionRefs = []; // Refs of selected items
|
|
21170
21170
|
this.lockedRefs = []; // Ref of locked items
|
|
21171
|
+
this._currentSelectionRefs = [];
|
|
21171
21172
|
this.valueCollector = new Subject();
|
|
21172
21173
|
this._selectionType = SelectionType.None;
|
|
21173
21174
|
/**
|
|
@@ -21179,6 +21180,8 @@ class Selection {
|
|
|
21179
21180
|
*/
|
|
21180
21181
|
this.subscriptions = [];
|
|
21181
21182
|
this.id = 'clr-dg-selection' + nbSelection++;
|
|
21183
|
+
this.trackBy = _items.trackBy;
|
|
21184
|
+
this._differ = differs.find(this._current || []).create(this.trackBy);
|
|
21182
21185
|
this.subscriptions.push(filters.change.subscribe(() => {
|
|
21183
21186
|
if (!this._selectable || this.preserveSelection) {
|
|
21184
21187
|
return;
|
|
@@ -21195,14 +21198,10 @@ class Selection {
|
|
|
21195
21198
|
case SelectionType.Single: {
|
|
21196
21199
|
let newSingle;
|
|
21197
21200
|
let selectionUpdated = false;
|
|
21198
|
-
// if the currentSingle has been set before data was loaded, we look up and save the ref from current data set
|
|
21199
|
-
if (this.currentSingle && !this.prevSingleSelectionRef) {
|
|
21200
|
-
this.prevSingleSelectionRef = _items.trackBy(this.currentSingle);
|
|
21201
|
-
}
|
|
21202
21201
|
updatedItems.forEach(item => {
|
|
21203
21202
|
const ref = _items.trackBy(item);
|
|
21204
21203
|
// If one of the updated items is the previously selectedSingle, set it as the new one
|
|
21205
|
-
if (this.
|
|
21204
|
+
if (this.currentSingleSelectionRef === ref) {
|
|
21206
21205
|
newSingle = item;
|
|
21207
21206
|
selectionUpdated = true;
|
|
21208
21207
|
}
|
|
@@ -21225,13 +21224,6 @@ class Selection {
|
|
|
21225
21224
|
case SelectionType.Multi: {
|
|
21226
21225
|
let leftOver = this.current.slice();
|
|
21227
21226
|
let selectionUpdated = false;
|
|
21228
|
-
// if the current has been set before data was loaded, we look up and save the ref from current data set
|
|
21229
|
-
if (this.current.length > 0 && this.prevSelectionRefs.length !== this.current.length) {
|
|
21230
|
-
this.prevSelectionRefs = [];
|
|
21231
|
-
this.current.forEach(item => {
|
|
21232
|
-
this.prevSelectionRefs.push(_items.trackBy(item));
|
|
21233
|
-
});
|
|
21234
|
-
}
|
|
21235
21227
|
// Duplicate loop, when the issue is issue#2342 is revisited keep in mind that
|
|
21236
21228
|
// we need to go over every updated item and check to see if there are valid to be
|
|
21237
21229
|
// locked or not and update it. When only add items that are found in the lockedRefs back.
|
|
@@ -21250,7 +21242,7 @@ class Selection {
|
|
|
21250
21242
|
updatedItems.forEach(item => {
|
|
21251
21243
|
const ref = _items.trackBy(item);
|
|
21252
21244
|
// Look in current selected refs array if item is selected, and update actual value
|
|
21253
|
-
const selectedIndex = this.
|
|
21245
|
+
const selectedIndex = this.currentSelectionRefs.indexOf(ref);
|
|
21254
21246
|
if (selectedIndex > -1) {
|
|
21255
21247
|
leftOver[selectedIndex] = item;
|
|
21256
21248
|
selectionUpdated = true;
|
|
@@ -21299,6 +21291,7 @@ class Selection {
|
|
|
21299
21291
|
}
|
|
21300
21292
|
set current(value) {
|
|
21301
21293
|
this.updateCurrent(value, true);
|
|
21294
|
+
this.updateCurrentSelectionRefs();
|
|
21302
21295
|
}
|
|
21303
21296
|
get currentSingle() {
|
|
21304
21297
|
return this._currentSingle;
|
|
@@ -21308,9 +21301,6 @@ class Selection {
|
|
|
21308
21301
|
return;
|
|
21309
21302
|
}
|
|
21310
21303
|
this._currentSingle = value;
|
|
21311
|
-
if (value) {
|
|
21312
|
-
this.prevSingleSelectionRef = this._items.trackBy(value);
|
|
21313
|
-
}
|
|
21314
21304
|
this.emitChange();
|
|
21315
21305
|
}
|
|
21316
21306
|
// We do not want to expose the Subject itself, but the Observable which is read-only
|
|
@@ -21322,17 +21312,25 @@ class Selection {
|
|
|
21322
21312
|
}
|
|
21323
21313
|
// Refs of currently selected items
|
|
21324
21314
|
get currentSelectionRefs() {
|
|
21325
|
-
|
|
21326
|
-
return ((_a = this._current) === null || _a === void 0 ? void 0 : _a.map(item => this._items.trackBy(item))) || [];
|
|
21315
|
+
return this._currentSelectionRefs;
|
|
21327
21316
|
}
|
|
21328
21317
|
// Ref of currently selected item
|
|
21329
21318
|
get currentSingleSelectionRef() {
|
|
21330
21319
|
return this._currentSingle && this._items.trackBy(this._currentSingle);
|
|
21331
21320
|
}
|
|
21321
|
+
checkForChanges() {
|
|
21322
|
+
const changes = this._differ.diff(this._current);
|
|
21323
|
+
// @TODO move the trackBy from items to selection as it's used only here and is not needed in items
|
|
21324
|
+
if (this.trackBy !== this._items.trackBy) {
|
|
21325
|
+
this.trackBy = this._items.trackBy;
|
|
21326
|
+
}
|
|
21327
|
+
if (changes) {
|
|
21328
|
+
this.updateCurrentSelectionRefs();
|
|
21329
|
+
}
|
|
21330
|
+
}
|
|
21332
21331
|
clearSelection() {
|
|
21333
21332
|
this._current = [];
|
|
21334
|
-
this.
|
|
21335
|
-
this.prevSingleSelectionRef = null;
|
|
21333
|
+
this._currentSelectionRefs = [];
|
|
21336
21334
|
this._currentSingle = null;
|
|
21337
21335
|
this.emitChange();
|
|
21338
21336
|
}
|
|
@@ -21472,17 +21470,15 @@ class Selection {
|
|
|
21472
21470
|
*/
|
|
21473
21471
|
selectItem(item) {
|
|
21474
21472
|
this.current = this.current.concat(item);
|
|
21475
|
-
// Push selected ref onto array
|
|
21476
|
-
this.prevSelectionRefs.push(this._items.trackBy(item));
|
|
21477
21473
|
}
|
|
21478
21474
|
/**
|
|
21479
21475
|
* Deselects an item
|
|
21480
21476
|
*/
|
|
21481
21477
|
deselectItem(indexOfItem) {
|
|
21482
21478
|
this.current = this.current.slice(0, indexOfItem).concat(this.current.slice(indexOfItem + 1));
|
|
21483
|
-
if (indexOfItem < this.
|
|
21479
|
+
if (indexOfItem < this.currentSelectionRefs.length) {
|
|
21484
21480
|
// Keep selected refs array in sync
|
|
21485
|
-
const removedItems = this.
|
|
21481
|
+
const removedItems = this.currentSelectionRefs[indexOfItem];
|
|
21486
21482
|
// locked reference is no longer needed (if any)
|
|
21487
21483
|
this.lockedRefs = this.lockedRefs.filter(locked => locked !== removedItems[0]);
|
|
21488
21484
|
}
|
|
@@ -21501,12 +21497,16 @@ class Selection {
|
|
|
21501
21497
|
this._change.next(this.current);
|
|
21502
21498
|
}
|
|
21503
21499
|
}
|
|
21500
|
+
updateCurrentSelectionRefs() {
|
|
21501
|
+
var _a;
|
|
21502
|
+
this._currentSelectionRefs = ((_a = this._current) === null || _a === void 0 ? void 0 : _a.map(item => this._items.trackBy(item))) || [];
|
|
21503
|
+
}
|
|
21504
21504
|
}
|
|
21505
|
-
Selection.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: Selection, deps: [{ token: Items }, { token: FiltersProvider }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
21505
|
+
Selection.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: Selection, deps: [{ token: Items }, { token: FiltersProvider }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
21506
21506
|
Selection.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: Selection });
|
|
21507
21507
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: Selection, decorators: [{
|
|
21508
21508
|
type: Injectable
|
|
21509
|
-
}], ctorParameters: function () { return [{ type: Items }, { type: FiltersProvider }]; } });
|
|
21509
|
+
}], ctorParameters: function () { return [{ type: Items }, { type: FiltersProvider }, { type: i0.IterableDiffers }]; } });
|
|
21510
21510
|
|
|
21511
21511
|
/*
|
|
21512
21512
|
* Copyright (c) 2016-2025 Broadcom. All Rights Reserved.
|
|
@@ -21579,14 +21579,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
21579
21579
|
* This software is released under MIT license.
|
|
21580
21580
|
* The full license information can be found in LICENSE in the root directory of this project.
|
|
21581
21581
|
*/
|
|
21582
|
-
class ClrDatagridSingleSelectionValueAccessor
|
|
21582
|
+
class ClrDatagridSingleSelectionValueAccessor {
|
|
21583
21583
|
constructor(renderer, elementRef) {
|
|
21584
|
-
super(renderer, elementRef, null);
|
|
21585
21584
|
this.renderer = renderer;
|
|
21586
21585
|
this.elementRef = elementRef;
|
|
21586
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
21587
|
+
this.onChange = () => { };
|
|
21588
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
21589
|
+
this.onTouched = () => { };
|
|
21590
|
+
}
|
|
21591
|
+
registerOnChange(fn) {
|
|
21592
|
+
this.onChange = fn;
|
|
21593
|
+
}
|
|
21594
|
+
registerOnTouched(fn) {
|
|
21595
|
+
this.onTouched = fn;
|
|
21596
|
+
}
|
|
21597
|
+
setDisabledState(isDisabled) {
|
|
21598
|
+
this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', isDisabled);
|
|
21587
21599
|
}
|
|
21588
21600
|
writeValue(value) {
|
|
21589
|
-
this.
|
|
21601
|
+
this.state = value;
|
|
21590
21602
|
this.updateChecked();
|
|
21591
21603
|
}
|
|
21592
21604
|
keyOf(value) {
|
|
@@ -21596,7 +21608,7 @@ class ClrDatagridSingleSelectionValueAccessor extends DefaultValueAccessor {
|
|
|
21596
21608
|
return value;
|
|
21597
21609
|
}
|
|
21598
21610
|
updateChecked() {
|
|
21599
|
-
const model = this.keyOf(this.
|
|
21611
|
+
const model = this.keyOf(this.state);
|
|
21600
21612
|
const value = this.keyOf(this.value);
|
|
21601
21613
|
this.renderer.setProperty(this.elementRef.nativeElement, 'checked', model === value);
|
|
21602
21614
|
}
|
|
@@ -21608,7 +21620,7 @@ ClrDatagridSingleSelectionValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minV
|
|
|
21608
21620
|
useExisting: forwardRef(() => ClrDatagridSingleSelectionValueAccessor),
|
|
21609
21621
|
multi: true,
|
|
21610
21622
|
},
|
|
21611
|
-
],
|
|
21623
|
+
], ngImport: i0 });
|
|
21612
21624
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: ClrDatagridSingleSelectionValueAccessor, decorators: [{
|
|
21613
21625
|
type: Directive,
|
|
21614
21626
|
args: [{
|
|
@@ -21887,6 +21899,7 @@ class ClrDatagridRow {
|
|
|
21887
21899
|
const newSelection = new Set(this.selection.current.concat(items.slice(Math.min(startIx, endIx), Math.max(startIx, endIx) + 1)));
|
|
21888
21900
|
this.selection.clearSelection();
|
|
21889
21901
|
this.selection.current.push(...newSelection);
|
|
21902
|
+
this.selection.checkForChanges();
|
|
21890
21903
|
}
|
|
21891
21904
|
else {
|
|
21892
21905
|
// page number has changed or
|
|
@@ -22819,6 +22832,11 @@ class ClrDatagrid {
|
|
|
22819
22832
|
}));
|
|
22820
22833
|
});
|
|
22821
22834
|
}
|
|
22835
|
+
ngDoCheck() {
|
|
22836
|
+
// we track for changes on selection.current because it can happen with pushing items
|
|
22837
|
+
// instead of overriding the variable
|
|
22838
|
+
this.selection.checkForChanges();
|
|
22839
|
+
}
|
|
22822
22840
|
ngOnDestroy() {
|
|
22823
22841
|
this._subscriptions.forEach((sub) => sub.unsubscribe());
|
|
22824
22842
|
this._virtualScrollSubscriptions.forEach((sub) => sub.unsubscribe());
|