vgapp 1.5.4 → 1.5.5

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Описание: разметка Fixed Header с отдельными слоями заголовка и тела VGTable.
3
- * Возможности: перенос настоящего thead без клона, автоматическая синхронизация ширин колонок и горизонтальной прокрутки.
3
+ * Возможности: перенос настоящего thead без клона, intrinsic-минимумы и синхронизация ширин колонок и горизонтальной прокрутки.
4
4
  */
5
5
 
6
6
  const MODE_CLASSES = ['vg-table-wrapper--sticky-container', 'vg-table-wrapper--sticky-page'];
@@ -68,9 +68,19 @@ class _stickyHeader {
68
68
  return this._headerTable || this._element;
69
69
  }
70
70
 
71
- getBody() {
72
- return this._body;
73
- }
71
+ getBody() {
72
+ return this._body;
73
+ }
74
+
75
+ refreshIntrinsicMinimums() {
76
+ const widths = this._measureIntrinsicColumnMinimums();
77
+ this._getHeaders().forEach((header, index) => {
78
+ const key = this._columnKey(header, index);
79
+ if (this._hasDeclaredWidth(header) || this._hardColumnWidths.has(key) || !(widths[index] > 0)) return;
80
+ this._columnMinimumWidths.set(key, Math.max(this._columnMinimumWidths.get(key) || 0, widths[index]));
81
+ });
82
+ return this.refresh();
83
+ }
74
84
 
75
85
  syncScroll() {
76
86
  this._syncScroll();
@@ -215,6 +225,36 @@ class _stickyHeader {
215
225
  });
216
226
  }
217
227
 
228
+ _measureIntrinsicColumnMinimums() {
229
+ if (!this._wrapper || !this._head) return [];
230
+
231
+ const probe = this._element.cloneNode(true);
232
+ probe.removeAttribute('data-vg-table');
233
+ probe.removeAttribute('data-vg-table-sticky-header');
234
+ probe.setAttribute('aria-hidden', 'true');
235
+ probe.querySelector(':scope > colgroup[data-vg-table-sticky-colgroup]')?.remove();
236
+ probe.insertBefore(this._head.cloneNode(true), probe.tBodies[0] || null);
237
+ probe.querySelectorAll('thead th').forEach((header) => header.style.setProperty('white-space', 'nowrap', 'important'));
238
+ [
239
+ ['position', 'absolute'],
240
+ ['inset', '0 auto auto 0'],
241
+ ['visibility', 'hidden'],
242
+ ['pointer-events', 'none'],
243
+ ['width', 'min-content'],
244
+ ['min-width', '0'],
245
+ ['max-width', 'none'],
246
+ ['table-layout', 'auto'],
247
+ ].forEach(([property, value]) => probe.style.setProperty(property, value, 'important'));
248
+
249
+ this._wrapper.append(probe);
250
+ try {
251
+ const rows = Array.from(probe.tHead?.rows || []);
252
+ return this._measureRow(rows.at(-1));
253
+ } finally {
254
+ probe.remove();
255
+ }
256
+ }
257
+
218
258
  _rememberColumnGeometry(widths) {
219
259
  const headers = this._getHeaders();
220
260
  const sourceCols = Array.from(this._element.querySelector(':scope > colgroup:not([data-vg-table-sticky-colgroup])')?.children || []);
@@ -150,8 +150,8 @@ class VGTable extends BaseModule {
150
150
  'sortchange.vg.table',
151
151
  this._isRemote ? this._boundRemoteSortChange : this._boundLocalSortChange
152
152
  );
153
- this._stickyHeader?.refresh?.();
154
153
  }
154
+ this._stickyHeader?.refreshIntrinsicMinimums?.();
155
155
 
156
156
  // Фиксируем настоящие ячейки через native sticky, включая отдельный слой Fixed Header
157
157
  if (!this._complex && !this._fixedColumns && this._params.fixedColumns.enabled === true) {
@@ -1137,7 +1137,7 @@ class VGTable extends BaseModule {
1137
1137
 
1138
1138
  _refreshColumnsLayout(structure = false) {
1139
1139
  this._sorting?.refresh?.(structure);
1140
- this._stickyHeader?.refresh?.();
1140
+ this._stickyHeader?.refreshIntrinsicMinimums?.();
1141
1141
  this._fixedColumns?.refresh?.();
1142
1142
  }
1143
1143
 
@@ -1426,11 +1426,11 @@ class VGTable extends BaseModule {
1426
1426
  _afterRemoteRender(detail = {}) {
1427
1427
  if (detail.renderedCount > 0) this._states?.clear();
1428
1428
  this._columns?.refresh?.();
1429
- this._sorting?.refresh?.();
1430
- this._expandable?.refresh?.();
1431
- this._rowReorder?.refresh?.();
1432
- this._stickyHeader?.refresh?.();
1433
- this._fixedColumns?.refresh?.();
1429
+ this._sorting?.refresh?.();
1430
+ this._expandable?.refresh?.();
1431
+ this._rowReorder?.refresh?.();
1432
+ this._stickyHeader?.refreshIntrinsicMinimums?.();
1433
+ this._fixedColumns?.refresh?.();
1434
1434
  }
1435
1435
 
1436
1436
  /**