@acorex/components 22.4.33 → 22.4.34
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.
|
@@ -3410,7 +3410,7 @@ class AXDataTableComponent extends AXBaseDataTable {
|
|
|
3410
3410
|
}
|
|
3411
3411
|
/**
|
|
3412
3412
|
* Measures a column's content width without writing it back.
|
|
3413
|
-
* Tree-expander columns use
|
|
3413
|
+
* Tree-expander columns use {@link measureTreeColumnContentWidth} so icon, gap, and indent stay in the result.
|
|
3414
3414
|
*/
|
|
3415
3415
|
measureColumnContentWidth(columnIndex, options = {}) {
|
|
3416
3416
|
if (!isPlatformBrowser(this.platformID)) {
|
|
@@ -3475,12 +3475,8 @@ class AXDataTableComponent extends AXBaseDataTable {
|
|
|
3475
3475
|
const bodyRows = mainTable.querySelectorAll('tbody tr:not(.empty-row)');
|
|
3476
3476
|
const helperTbody = this.document.createElement('tbody');
|
|
3477
3477
|
helperTable.appendChild(helperTbody);
|
|
3478
|
-
const rootRowsOnly = options.rootRowsOnly === true;
|
|
3479
3478
|
const sampleSize = Math.min(20, bodyRows.length);
|
|
3480
3479
|
for (let i = 0; i < sampleSize; i++) {
|
|
3481
|
-
if (rootRowsOnly && this.isNestedTreeRow(bodyRows[i], bodyCellIndex)) {
|
|
3482
|
-
continue;
|
|
3483
|
-
}
|
|
3484
3480
|
const cells = bodyRows[i].querySelectorAll('td');
|
|
3485
3481
|
if (cells.length <= bodyCellIndex) {
|
|
3486
3482
|
continue;
|
|
@@ -3606,7 +3602,7 @@ class AXDataTableComponent extends AXBaseDataTable {
|
|
|
3606
3602
|
this.enforceTreeFillColumnWidths();
|
|
3607
3603
|
this.updateColumnLayoutWidths();
|
|
3608
3604
|
}
|
|
3609
|
-
/**
|
|
3605
|
+
/** Expanded rows paint after `onItemExpanded`; remeasure once icon, gap, and indent are in the DOM. */
|
|
3610
3606
|
scheduleTreeFillAfterExpand() {
|
|
3611
3607
|
if (!isPlatformBrowser(this.platformID) || !this.columnsList().some((column) => this.isTreeFillColumn(column))) {
|
|
3612
3608
|
return;
|
|
@@ -3617,57 +3613,112 @@ class AXDataTableComponent extends AXBaseDataTable {
|
|
|
3617
3613
|
this.treeFillAfterExpandTimer = setTimeout(() => {
|
|
3618
3614
|
this.treeFillAfterExpandTimer = null;
|
|
3619
3615
|
this.refreshTreeFillLayout(false);
|
|
3620
|
-
},
|
|
3616
|
+
}, 100);
|
|
3621
3617
|
}
|
|
3622
3618
|
/**
|
|
3623
|
-
* Stores the content width of tree-expander columns from
|
|
3624
|
-
*
|
|
3619
|
+
* Stores the content width of tree-expander columns from the rows currently on screen.
|
|
3620
|
+
* Collapsed trees measure parent rows. After expand, nested indent is included.
|
|
3625
3621
|
*/
|
|
3626
3622
|
measureTreeFillColumns(headerOnly) {
|
|
3627
3623
|
this.columnsList().forEach((column, index) => {
|
|
3628
3624
|
if (!this.isTreeFillColumn(column) || this.userResizedColumns.has(column)) {
|
|
3629
3625
|
return;
|
|
3630
3626
|
}
|
|
3631
|
-
|
|
3632
|
-
return;
|
|
3633
|
-
}
|
|
3634
|
-
const measured = this.measureColumnContentWidth(index, {
|
|
3635
|
-
maxWidth: 500,
|
|
3636
|
-
headerOnly,
|
|
3637
|
-
rootRowsOnly: !headerOnly,
|
|
3638
|
-
});
|
|
3627
|
+
const measured = this.measureTreeColumnContentWidth(index, headerOnly);
|
|
3639
3628
|
if (measured != null) {
|
|
3640
3629
|
this.treeFillContentWidths.set(column, measured);
|
|
3641
3630
|
}
|
|
3642
3631
|
});
|
|
3643
3632
|
}
|
|
3644
|
-
/**
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3633
|
+
/**
|
|
3634
|
+
* Widest visible tree cell. Padding, border, level indent, expand icon, and flex gap
|
|
3635
|
+
* are read from the live cell. Text is measured alone: a cloned cell stays at the
|
|
3636
|
+
* current column width because of `min-w-0`, `w-full`, and `truncate`.
|
|
3637
|
+
*/
|
|
3638
|
+
measureTreeColumnContentWidth(columnIndex, headerOnly) {
|
|
3639
|
+
if (!isPlatformBrowser(this.platformID)) {
|
|
3640
|
+
return null;
|
|
3650
3641
|
}
|
|
3651
|
-
const parsed = Number(level);
|
|
3652
|
-
return Number.isFinite(parsed) && parsed > 0;
|
|
3653
|
-
}
|
|
3654
|
-
columnHasVisibleRootRow(columnIndex) {
|
|
3655
3642
|
const column = this.columnsList()[columnIndex];
|
|
3656
|
-
const
|
|
3657
|
-
|
|
3658
|
-
|
|
3643
|
+
const hostElement = this.getHostElement();
|
|
3644
|
+
const mainTable = hostElement?.querySelector('table');
|
|
3645
|
+
if (!column || !hostElement || !mainTable) {
|
|
3646
|
+
return null;
|
|
3659
3647
|
}
|
|
3660
3648
|
const bodyCellIndex = this.getColumnColIndex(column);
|
|
3661
|
-
if (bodyCellIndex
|
|
3662
|
-
return
|
|
3649
|
+
if (bodyCellIndex === -1) {
|
|
3650
|
+
return null;
|
|
3663
3651
|
}
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3652
|
+
let maxWidth = 0;
|
|
3653
|
+
const headerCell = mainTable.querySelector(`thead th[data-column-name="${column.name}"]`);
|
|
3654
|
+
if (headerCell) {
|
|
3655
|
+
maxWidth = Math.max(maxWidth, this.readTreeCellContentWidth(headerCell));
|
|
3656
|
+
}
|
|
3657
|
+
if (!headerOnly) {
|
|
3658
|
+
const bodyRows = mainTable.querySelectorAll('tbody tr:not(.empty-row)');
|
|
3659
|
+
for (let i = 0; i < bodyRows.length; i++) {
|
|
3660
|
+
const cell = bodyRows[i].querySelectorAll('td')[bodyCellIndex];
|
|
3661
|
+
if (!cell) {
|
|
3662
|
+
continue;
|
|
3663
|
+
}
|
|
3664
|
+
maxWidth = Math.max(maxWidth, this.readTreeCellContentWidth(cell));
|
|
3668
3665
|
}
|
|
3669
3666
|
}
|
|
3670
|
-
|
|
3667
|
+
if (maxWidth <= 0) {
|
|
3668
|
+
return null;
|
|
3669
|
+
}
|
|
3670
|
+
return Math.min(Math.max(Math.ceil(maxWidth), column.minAutoWidth), 500);
|
|
3671
|
+
}
|
|
3672
|
+
readTreeCellContentWidth(cell) {
|
|
3673
|
+
const view = this.document.defaultView;
|
|
3674
|
+
if (!view) {
|
|
3675
|
+
return 0;
|
|
3676
|
+
}
|
|
3677
|
+
const px = (value) => {
|
|
3678
|
+
const parsed = Number.parseFloat(value);
|
|
3679
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
3680
|
+
};
|
|
3681
|
+
const cellStyle = view.getComputedStyle(cell);
|
|
3682
|
+
const chrome = px(cellStyle.paddingInlineStart) +
|
|
3683
|
+
px(cellStyle.paddingInlineEnd) +
|
|
3684
|
+
px(cellStyle.borderInlineStartWidth) +
|
|
3685
|
+
px(cellStyle.borderInlineEndWidth);
|
|
3686
|
+
const indent = cell.querySelector('.ax-data-table-nested-indent');
|
|
3687
|
+
const indentStyle = indent ? view.getComputedStyle(indent) : null;
|
|
3688
|
+
const indentPadding = indentStyle ? px(indentStyle.paddingInlineStart) + px(indentStyle.paddingInlineEnd) : 0;
|
|
3689
|
+
const handler = cell.querySelector('.ax-expand-handler');
|
|
3690
|
+
const handlerWidth = handler?.getBoundingClientRect().width ?? 0;
|
|
3691
|
+
const gap = handler && indentStyle ? px(indentStyle.columnGap) || px(indentStyle.gap) : 0;
|
|
3692
|
+
const textHost = (indent ? cell.querySelector('.ax-data-table-cell-text') : cell.querySelector('.ax-caption'));
|
|
3693
|
+
return chrome + indentPadding + handlerWidth + gap + (textHost ? this.readIntrinsicTextWidth(textHost) : 0);
|
|
3694
|
+
}
|
|
3695
|
+
/** Text width outside the table, so truncation and flex shrinking do not cap it. */
|
|
3696
|
+
readIntrinsicTextWidth(source) {
|
|
3697
|
+
const probe = this.document.createElement('div');
|
|
3698
|
+
const clone = source.cloneNode(true);
|
|
3699
|
+
const loosen = (el) => {
|
|
3700
|
+
el.style.width = 'max-content';
|
|
3701
|
+
el.style.minWidth = 'max-content';
|
|
3702
|
+
el.style.maxWidth = 'none';
|
|
3703
|
+
el.style.whiteSpace = 'nowrap';
|
|
3704
|
+
el.style.overflow = 'visible';
|
|
3705
|
+
el.style.textOverflow = 'clip';
|
|
3706
|
+
el.style.flex = '0 0 auto';
|
|
3707
|
+
el.style.display = 'inline-block';
|
|
3708
|
+
};
|
|
3709
|
+
loosen(clone);
|
|
3710
|
+
clone.querySelectorAll('*').forEach((node) => loosen(node));
|
|
3711
|
+
probe.style.position = 'fixed';
|
|
3712
|
+
probe.style.left = '0';
|
|
3713
|
+
probe.style.top = '0';
|
|
3714
|
+
probe.style.visibility = 'hidden';
|
|
3715
|
+
probe.style.pointerEvents = 'none';
|
|
3716
|
+
probe.style.width = 'max-content';
|
|
3717
|
+
probe.appendChild(clone);
|
|
3718
|
+
this.document.body.appendChild(probe);
|
|
3719
|
+
const width = probe.getBoundingClientRect().width;
|
|
3720
|
+
probe.remove();
|
|
3721
|
+
return width;
|
|
3671
3722
|
}
|
|
3672
3723
|
readPixelWidth(width) {
|
|
3673
3724
|
if (typeof width === 'number' && Number.isFinite(width)) {
|
|
@@ -3684,7 +3735,8 @@ class AXDataTableComponent extends AXBaseDataTable {
|
|
|
3684
3735
|
/**
|
|
3685
3736
|
* Sizes the table to the sum of column widths so columns keep their content width
|
|
3686
3737
|
* and the wrapper scrolls horizontally when that sum exceeds the container.
|
|
3687
|
-
* A tree-expander column stays at the widest
|
|
3738
|
+
* A tree-expander column stays at the widest visible row, including icon, gap, padding, and indent.
|
|
3739
|
+
* Leftover space stays in the spacer.
|
|
3688
3740
|
*/
|
|
3689
3741
|
updateColumnLayoutWidths() {
|
|
3690
3742
|
const columns = this.columnsList();
|