@akcelik/strct 3.0.0 → 3.1.0
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.
|
@@ -10830,7 +10830,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
|
|
|
10830
10830
|
args: [{ selector: '[strctDatagridActionBar]' }]
|
|
10831
10831
|
}] });
|
|
10832
10832
|
/**
|
|
10833
|
-
* Interactive data table: sortable columns, row selection
|
|
10833
|
+
* Interactive data table: sortable columns, row selection (Shift-click a row
|
|
10834
|
+
* checkbox to carry its new state across a whole block), expandable detail
|
|
10834
10835
|
* rows, a batch action bar and built-in paging.
|
|
10835
10836
|
* <strct-datagrid [columns]="cols" [rows]="data" selectable expandable [pageSize]="10">
|
|
10836
10837
|
* <button strct-button strctDatagridActions size="sm">Migrate</button>
|
|
@@ -11904,15 +11905,49 @@ class StrctDatagrid {
|
|
|
11904
11905
|
}
|
|
11905
11906
|
this.expandedRows.set(next);
|
|
11906
11907
|
}
|
|
11908
|
+
/** The row a Shift-click measures its range from: the last one toggled on
|
|
11909
|
+
* its own. A range leaves it where it is, so successive Shift-clicks
|
|
11910
|
+
* re-project from the same origin instead of walking the anchor along. */
|
|
11911
|
+
rangeAnchor = null;
|
|
11912
|
+
/** Set by the row checkbox's click, consumed by the `toggleRow` that the
|
|
11913
|
+
* same interaction fires immediately after. */
|
|
11914
|
+
rangeIntent = false;
|
|
11915
|
+
noteRangeIntent(event) {
|
|
11916
|
+
this.rangeIntent = event.shiftKey;
|
|
11917
|
+
}
|
|
11918
|
+
/**
|
|
11919
|
+
* Toggle one row. Shift-clicking a row checkbox instead applies the clicked
|
|
11920
|
+
* box's new state across every row between the anchor and this one — so a
|
|
11921
|
+
* Shift-click selects a block, and Shift-clicking a checked box clears one.
|
|
11922
|
+
*/
|
|
11907
11923
|
toggleRow(row) {
|
|
11908
11924
|
const id = this.idOf(row);
|
|
11925
|
+
const select = !this.selected().has(id);
|
|
11909
11926
|
const next = new Set(this.selected());
|
|
11910
|
-
|
|
11911
|
-
|
|
11927
|
+
const ranged = this.rangeIntent;
|
|
11928
|
+
this.rangeIntent = false;
|
|
11929
|
+
if (ranged && this.rangeAnchor !== null) {
|
|
11930
|
+
const rows = this.selectionRows();
|
|
11931
|
+
const from = rows.findIndex((r) => this.idOf(r) === this.rangeAnchor);
|
|
11932
|
+
const to = rows.findIndex((r) => this.idOf(r) === id);
|
|
11933
|
+
// A vanished anchor (paged away, filtered out) degrades to a plain toggle.
|
|
11934
|
+
if (from !== -1 && to !== -1) {
|
|
11935
|
+
for (let i = Math.min(from, to); i <= Math.max(from, to); i++) {
|
|
11936
|
+
const rid = this.idOf(rows[i]);
|
|
11937
|
+
if (select)
|
|
11938
|
+
next.add(rid);
|
|
11939
|
+
else
|
|
11940
|
+
next.delete(rid);
|
|
11941
|
+
}
|
|
11942
|
+
this.commitSelection(next);
|
|
11943
|
+
return;
|
|
11944
|
+
}
|
|
11912
11945
|
}
|
|
11913
|
-
|
|
11946
|
+
if (select)
|
|
11914
11947
|
next.add(id);
|
|
11915
|
-
|
|
11948
|
+
else
|
|
11949
|
+
next.delete(id);
|
|
11950
|
+
this.rangeAnchor = id;
|
|
11916
11951
|
this.commitSelection(next);
|
|
11917
11952
|
}
|
|
11918
11953
|
toggleAll() {
|
|
@@ -11924,9 +11959,11 @@ class StrctDatagrid {
|
|
|
11924
11959
|
else {
|
|
11925
11960
|
rows.forEach((r) => next.add(this.idOf(r)));
|
|
11926
11961
|
}
|
|
11962
|
+
this.rangeAnchor = null;
|
|
11927
11963
|
this.commitSelection(next);
|
|
11928
11964
|
}
|
|
11929
11965
|
clearSelection() {
|
|
11966
|
+
this.rangeAnchor = null;
|
|
11930
11967
|
this.commitSelection(new Set());
|
|
11931
11968
|
}
|
|
11932
11969
|
/** Last known row object per selected id — selections made on one page stay
|
|
@@ -12238,9 +12275,12 @@ class StrctDatagrid {
|
|
|
12238
12275
|
[class.strct-dg__cell--sticky]="stickyActive()"
|
|
12239
12276
|
[style.insetInlineStart.px]="utilLeft('sel')"
|
|
12240
12277
|
>
|
|
12278
|
+
<!-- click fires (and bubbles) before the input's change,
|
|
12279
|
+
so the modifier is recorded by the time toggleRow runs. -->
|
|
12241
12280
|
<strct-checkbox
|
|
12242
12281
|
[ariaLabel]="selectRowLabel(row)"
|
|
12243
12282
|
[checked]="isSelected(row)"
|
|
12283
|
+
(click)="noteRangeIntent($event)"
|
|
12244
12284
|
(checkedChange)="toggleRow(row)"
|
|
12245
12285
|
/>
|
|
12246
12286
|
</td>
|
|
@@ -12724,9 +12764,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImpor
|
|
|
12724
12764
|
[class.strct-dg__cell--sticky]="stickyActive()"
|
|
12725
12765
|
[style.insetInlineStart.px]="utilLeft('sel')"
|
|
12726
12766
|
>
|
|
12767
|
+
<!-- click fires (and bubbles) before the input's change,
|
|
12768
|
+
so the modifier is recorded by the time toggleRow runs. -->
|
|
12727
12769
|
<strct-checkbox
|
|
12728
12770
|
[ariaLabel]="selectRowLabel(row)"
|
|
12729
12771
|
[checked]="isSelected(row)"
|
|
12772
|
+
(click)="noteRangeIntent($event)"
|
|
12730
12773
|
(checkedChange)="toggleRow(row)"
|
|
12731
12774
|
/>
|
|
12732
12775
|
</td>
|