@anguless/angulux 22.6.5 → 22.6.6
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.
|
@@ -50,8 +50,22 @@ import { SelectButtonModule } from '@anguless/angulux/selectbutton';
|
|
|
50
50
|
import { UniqueComponentId, ObjectUtils, ZIndexUtils } from '@anguless/angulux/utils';
|
|
51
51
|
import { Subject } from 'rxjs';
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* The rule that drew the line above a selected row from the row before it, with a sibling :has().
|
|
55
|
+
* Chrome re-evaluates such a selector for every row inserted beside it, so rendering a long table
|
|
56
|
+
* grew with the square of its rows. It is replaced in place, so the cascade order stays as it was,
|
|
57
|
+
* by a rule on `p-datatable-row-before-selected`, the class Table puts on that row
|
|
58
|
+
* (markRowsBeforeSelected in table.ts). Same property, same colour: the same border is drawn.
|
|
59
|
+
*
|
|
60
|
+
* Done here rather than in @anguless/angulux-styles, so this release works with any version of that
|
|
61
|
+
* package: one without the rule leaves the replace with nothing to do.
|
|
62
|
+
*/
|
|
63
|
+
const SIBLING_HAS_RULE = /\.p-datatable-tbody\s*>\s*tr:has\(\+\s*\.p-datatable-row-selected\)\s*>\s*td\s*\{[^}]*\}/;
|
|
64
|
+
const ROW_BEFORE_SELECTED_RULE = `.p-datatable-tbody > tr.p-datatable-row-before-selected > td {
|
|
65
|
+
border-block-end-color: dt('datatable.body.cell.selected.border.color');
|
|
66
|
+
}`;
|
|
53
67
|
const style = /*css*/ `
|
|
54
|
-
${style$1}
|
|
68
|
+
${String(style$1).replace(SIBLING_HAS_RULE, ROW_BEFORE_SELECTED_RULE)}
|
|
55
69
|
|
|
56
70
|
/* For AnguluxConfig */
|
|
57
71
|
.p-datatable-scrollable-table > .p-datatable-thead {
|
|
@@ -564,6 +578,70 @@ class TableService {
|
|
|
564
578
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.2", ngImport: i0, type: TableService, decorators: [{
|
|
565
579
|
type: Injectable
|
|
566
580
|
}] });
|
|
581
|
+
const ROW_SELECTED = 'p-datatable-row-selected';
|
|
582
|
+
const ROW_BEFORE_SELECTED = 'p-datatable-row-before-selected';
|
|
583
|
+
const rowsBeforeSelected = new WeakMap();
|
|
584
|
+
/**
|
|
585
|
+
* Mark the row right before each selected row of a table with `p-datatable-row-before-selected`,
|
|
586
|
+
* which the stylesheet gives the selected border colour: the line above a selected row.
|
|
587
|
+
*
|
|
588
|
+
* The stylesheet used to find that row itself, with `tr:has(+ .p-datatable-row-selected)`. Chrome
|
|
589
|
+
* re-evaluates a sibling :has() for every row inserted beside it, so rendering a long table grew
|
|
590
|
+
* with the square of its rows: 16,000 rows took 1,176 ms, 190 ms with the class (upstream 22.1.3,
|
|
591
|
+
* measured 2026-11-18). The class draws the same border, so nothing on screen changes.
|
|
592
|
+
*
|
|
593
|
+
* Called after the table and after its body are checked: in a zoneless app a change to the rows can
|
|
594
|
+
* refresh the body alone. When the same rows are selected, each after the same element, and the
|
|
595
|
+
* marks are all there, it changes nothing and returns. Module-level, so Table's API is unchanged.
|
|
596
|
+
*/
|
|
597
|
+
function markRowsBeforeSelected(host) {
|
|
598
|
+
const last = rowsBeforeSelected.get(host);
|
|
599
|
+
// Live collections: the browser keeps their contents until the DOM under the host changes.
|
|
600
|
+
const selected = host.getElementsByClassName(ROW_SELECTED);
|
|
601
|
+
if (!selected.length && !last)
|
|
602
|
+
return;
|
|
603
|
+
if (last && last.selected.length === selected.length && host.getElementsByClassName(ROW_BEFORE_SELECTED).length === last.marks.size) {
|
|
604
|
+
let i = 0;
|
|
605
|
+
for (; i < selected.length; i++) {
|
|
606
|
+
const row = selected[i];
|
|
607
|
+
if (row !== last.selected[i] || row.previousElementSibling !== last.previous[i])
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
if (i === selected.length)
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const rows = [];
|
|
614
|
+
const previous = [];
|
|
615
|
+
const marks = new Set();
|
|
616
|
+
// A row of a table nested in this one belongs to that table. Rows come in document order, so the
|
|
617
|
+
// rows of one tbody are consecutive: ask once per tbody, not once per row.
|
|
618
|
+
let parent = null;
|
|
619
|
+
let own = false;
|
|
620
|
+
for (let i = 0; i < selected.length; i++) {
|
|
621
|
+
const row = selected[i];
|
|
622
|
+
const before = row.previousElementSibling;
|
|
623
|
+
rows.push(row);
|
|
624
|
+
previous.push(before);
|
|
625
|
+
if (row.parentElement !== parent) {
|
|
626
|
+
parent = row.parentElement;
|
|
627
|
+
own = parent?.closest(host.localName) === host;
|
|
628
|
+
}
|
|
629
|
+
if (own && before?.tagName === 'TR')
|
|
630
|
+
marks.add(before);
|
|
631
|
+
}
|
|
632
|
+
if (last)
|
|
633
|
+
for (const row of last.marks)
|
|
634
|
+
if (!marks.has(row))
|
|
635
|
+
row.classList.remove(ROW_BEFORE_SELECTED);
|
|
636
|
+
// Checked one by one, not taken from the last set: a [className] binding can drop a class it does not know.
|
|
637
|
+
for (const row of marks)
|
|
638
|
+
if (!row.classList.contains(ROW_BEFORE_SELECTED))
|
|
639
|
+
row.classList.add(ROW_BEFORE_SELECTED);
|
|
640
|
+
if (rows.length)
|
|
641
|
+
rowsBeforeSelected.set(host, { selected: rows, previous, marks });
|
|
642
|
+
else
|
|
643
|
+
rowsBeforeSelected.delete(host);
|
|
644
|
+
}
|
|
567
645
|
/**
|
|
568
646
|
* Table displays data in tabular format.
|
|
569
647
|
* @group Components
|
|
@@ -1283,6 +1361,7 @@ class Table extends BaseComponent {
|
|
|
1283
1361
|
bindDirectiveInstance = inject(Bind, { self: true });
|
|
1284
1362
|
onAfterViewChecked() {
|
|
1285
1363
|
this.bindDirectiveInstance.setAttrs(this.ptms(['host', 'root']));
|
|
1364
|
+
isPlatformBrowser(this.platformId) && markRowsBeforeSelected(this.el.nativeElement);
|
|
1286
1365
|
}
|
|
1287
1366
|
onInit() {
|
|
1288
1367
|
if (this.lazy && this.lazyLoadOnInit) {
|
|
@@ -3760,6 +3839,10 @@ class TableBody extends BaseComponent {
|
|
|
3760
3839
|
this.updateFrozenRowGroupHeaderStickyPosition();
|
|
3761
3840
|
}
|
|
3762
3841
|
}
|
|
3842
|
+
onAfterViewChecked() {
|
|
3843
|
+
// The rows are this view's: a change to them can refresh it without its table.
|
|
3844
|
+
isPlatformBrowser(this.platformId) && markRowsBeforeSelected(this.dataTable.el.nativeElement);
|
|
3845
|
+
}
|
|
3763
3846
|
constructor(dataTable, tableService) {
|
|
3764
3847
|
super();
|
|
3765
3848
|
this.dataTable = dataTable;
|