@universal-material/data-grid 0.1.0 → 0.2.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.
Files changed (37) hide show
  1. package/README.md +37 -20
  2. package/custom-elements.json +35 -7
  3. package/dist/export/types.d.ts +1 -1
  4. package/dist/export/types.js.map +1 -1
  5. package/dist/features/column-chooser.js +3 -2
  6. package/dist/features/column-chooser.js.map +1 -1
  7. package/dist/features/filter-row.js +4 -3
  8. package/dist/features/filter-row.js.map +1 -1
  9. package/dist/features/header-filter.d.ts +5 -1
  10. package/dist/features/header-filter.js +15 -6
  11. package/dist/features/header-filter.js.map +1 -1
  12. package/dist/features/scroll-port.d.ts +51 -0
  13. package/dist/features/scroll-port.js +329 -0
  14. package/dist/features/scroll-port.js.map +1 -0
  15. package/dist/grid-column-def.d.ts +16 -4
  16. package/dist/grid-column-def.js.map +1 -1
  17. package/dist/grid-column.d.ts +8 -2
  18. package/dist/grid-column.js +8 -2
  19. package/dist/grid-column.js.map +1 -1
  20. package/dist/grid.d.ts +30 -4
  21. package/dist/grid.js +505 -112
  22. package/dist/grid.js.map +1 -1
  23. package/dist/grid.min.js +592 -484
  24. package/dist/grid.styles.js +111 -9
  25. package/dist/grid.styles.js.map +1 -1
  26. package/dist/render/group-row.js +2 -1
  27. package/dist/render/group-row.js.map +1 -1
  28. package/dist/render/header.d.ts +17 -1
  29. package/dist/render/header.js +23 -2
  30. package/dist/render/header.js.map +1 -1
  31. package/dist/render/virtualizer.d.ts +49 -1
  32. package/dist/render/virtualizer.js +229 -17
  33. package/dist/render/virtualizer.js.map +1 -1
  34. package/dist/row-model/columns.d.ts +22 -0
  35. package/dist/row-model/columns.js +15 -0
  36. package/dist/row-model/columns.js.map +1 -1
  37. package/package.json +7 -3
package/dist/grid.js CHANGED
@@ -31,6 +31,7 @@ import { HOST_LABEL_ATTRIBUTES, HostLabel } from './features/host-label.js';
31
31
  import { HEADER_ROW, navigationKeyOf, nextCell, nextHeaderCell, rangeBetween, } from './features/keyboard.js';
32
32
  import { isContextMenuKey, MenuController, renderMenu } from './features/menu.js';
33
33
  import { clampWidth, ColumnResizeController, DEFAULT_MIN_COLUMN_WIDTH, measureContentWidth, } from './features/resize.js';
34
+ import { ScrollPortController } from './features/scroll-port.js';
34
35
  import { Debouncer, renderHighlighted, renderSearchPanel, SearchController } from './features/search.js';
35
36
  import { countSelected, normalizeSelectionMode, SelectionModel, } from './features/selection.js';
36
37
  import { formatMessage, initialSorting, nextSorting, sameSorting, sortGestureOf, sortingAfterGesture, toggleOrder, } from './features/sorting.js';
@@ -46,12 +47,12 @@ import { rendererContent } from './render/content.js';
46
47
  import { renderBuiltInEditor } from './render/editors.js';
47
48
  import { renderIndentCells, renderSummaryCells, renderTotalFooter } from './render/footer.js';
48
49
  import { groupRowLabel, renderGroupRowCells } from './render/group-row.js';
49
- import { isActivationKey, renderBandHeaderCell, renderHeaderCell, renderSortIndicator } from './render/header.js';
50
+ import { isActivationKey, labelledByHeader, renderBandHeaderCell, renderHeaderCell, renderSortIndicator } from './render/header.js';
50
51
  import { keyedRows } from './render/keyed-rows.js';
51
52
  import { RowVirtualizer } from './render/virtualizer.js';
52
53
  import { RowsWithAdded } from './row-model/added-rows.js';
53
54
  import { cellRangeEdges, countCells, isSingleCell, parseTsv, pasteSize, rectOf, rowBands, sameCorners, unescapePasted, } from './row-model/cell-range.js';
54
- import { ancestorsOf, buildColumnTree, buildHeaderRows, headerCellAt, moveAmongSiblings, normalizeLeafOrder, orderedSiblings, rootOf, } from './row-model/columns.js';
55
+ import { ancestorsOf, buildColumnTree, buildHeaderRows, columnText, headerText, headerCellAt, moveAmongSiblings, normalizeLeafOrder, orderedSiblings, rootOf, } from './row-model/columns.js';
55
56
  import { createComparer } from './row-model/compare.js';
56
57
  import { distinctValues } from './row-model/distinct.js';
57
58
  import { allValuesConvert, applyMask, combineFilters, compileFilter, filterItems, hasColumnCondition, replaceColumnCondition, searchExpression, } from './row-model/filter.js';
@@ -538,9 +539,9 @@ const isRenderResult = (value) => value === null || value === undefined || value
538
539
  * @cssprop --u-grid-header-cell-padding - Header cell padding.
539
540
  * @cssprop --u-grid-header-cell-font-size - Header cell font size. Default `0.8125rem`.
540
541
  * @cssprop --u-grid-header-cell-font-weight - Header cell font weight.
541
- * @cssprop --u-grid-cell-padding - Data cell padding. Default `13px 16px`.
542
- * @cssprop --u-grid-cell-block-padding - Block padding of data and header cells. Default `13px`.
543
- * @cssprop --u-grid-cell-inline-padding - Inline padding of data and header cells. Default `16px`.
542
+ * @cssprop --u-grid-cell-padding - Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.
543
+ * @cssprop --u-grid-cell-block-padding - Block padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `13px`.
544
+ * @cssprop --u-grid-cell-inline-padding - Inline padding of data and header cells; wins over the old `--u-table-cell-padding` and `--u-grid-data-cell-padding`. Default `16px`.
544
545
  * @cssprop --u-grid-cell-font-size - Data cell font size. Default `0.875rem`.
545
546
  * @cssprop --u-grid-cell-font-weight - Data cell font weight.
546
547
  * @cssprop --u-grid-row-hover-opacity - Intensity of the row and header hover tint (`0%` disables it). Default: state-layer hover token or `8%`.
@@ -914,6 +915,32 @@ let DataGrid = class DataGrid extends LitElement {
914
915
  * the end is reached (remote paging only; with `paging` the pager wins).
915
916
  */
916
917
  this.scrollMode = 'virtual';
918
+ /**
919
+ * Scrolls the grid with an outer container instead of its own scrollbar:
920
+ * the id of an ANCESTOR of the grid (the first ancestor with this id,
921
+ * crossing shadow boundaries, unlike IDREF attributes), or `window` for
922
+ * the page (wins over an element with `id="window"`). The grid grows to
923
+ * its content (do not give it a height), the container scrolls in both
924
+ * directions, and rows and columns are still virtualized by the visible
925
+ * part of the container; toolbar, headers, totals, fixed rows and columns
926
+ * stick to it. The container's `scroll-padding-top`/`-bottom` offsets
927
+ * what the page sticks there (an app bar). `<html>` (or the
928
+ * `document.scrollingElement`) means the window; `<body>` only when it is
929
+ * the scrolling element. Not found, not an ancestor or empty: a console
930
+ * warning and the grid's own scrolling. An element between the grid and
931
+ * the container that clips or scrolls (`overflow` other than
932
+ * `visible`/`clip`) also warns: sticky headers would stick to it. Resolved when
933
+ * the grid connects and when this changes (changing the ancestor's id
934
+ * later does not re-resolve). The attribute alone renders the outer mode
935
+ * on the server.
936
+ */
937
+ this.scrollContainer = null;
938
+ /**
939
+ * The outer scroll container by reference (wins over `scrollContainer`):
940
+ * an ancestor element, or `window`. `document.documentElement` (or the
941
+ * `document.scrollingElement`) means the window. See `scrollContainer`.
942
+ */
943
+ this.scrollContainerElement = null;
917
944
  /** Linhas inteiras (sem a página); `#rows` é a página com `paging`. */
918
945
  this.#allRows = new RowList(rowKeyOf);
919
946
  /** Linhas de dados conhecidas (local: filtradas; remoto: total do servidor; `-1` desconhecido). */
@@ -1025,7 +1052,7 @@ let DataGrid = class DataGrid extends LitElement {
1025
1052
  this.#isGrouped = (column) => this._groupColumns.includes(column);
1026
1053
  // ------------------------------------------------------------ aparência
1027
1054
  // Booleanos: `"false"` desliga (padrão `true` precisa disso — spec 15).
1028
- /** Row height in px (rows with `wrap` columns can grow). */
1055
+ /** Row height in px, padding included (rows with `wrap` columns or taller content grow; the virtualizer measures them). */
1029
1056
  this.rowHeight = 48;
1030
1057
  /** Tints even rows. */
1031
1058
  this.striped = false;
@@ -1287,18 +1314,29 @@ let DataGrid = class DataGrid extends LitElement {
1287
1314
  this._scrollContainerRef = createRef();
1288
1315
  /** @internal */
1289
1316
  this._groupContainerRef = createRef();
1317
+ this.#layoutRef = createRef();
1318
+ /** Rolagem por contêiner externo (spec 27). */
1319
+ this.#scrollPort = new ScrollPortController(this, {
1320
+ scroll: () => this.#onExternalScroll(),
1321
+ moved: () => this.#onExternalMoved(),
1322
+ });
1290
1323
  this.#virtualizer = new RowVirtualizer(this, {
1291
- getScrollElement: () => this._scrollContainerRef.value ?? null,
1324
+ getScrollElement: () => this.#scrollPort.port?.source ?? this._scrollContainerRef.value ?? null,
1325
+ isExternal: () => this.#scrollPort.port !== null,
1292
1326
  rowHeight: () => this.rowHeight,
1293
1327
  overscan: 3,
1294
1328
  getScrollMargin: () => {
1295
1329
  const scroller = this._scrollContainerRef.value;
1296
1330
  const table = scroller?.querySelector('table.grid-table');
1331
+ const port = this.#scrollPort.port;
1332
+ if (!scroller || !table) {
1333
+ return 0;
1334
+ }
1335
+ // Onde a porta começa, em coordenadas da tela, e quanto ela já rolou.
1336
+ const origin = port ? port.rect().top - port.scrollTop : scroller.getBoundingClientRect().top - scroller.scrollTop;
1297
1337
  // O corpo começa depois do cabeçalho e das linhas fixas do topo (no fluxo, sticky ou não).
1298
- return scroller && table
1299
- ? table.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop + (table.tHead?.offsetHeight ?? 0)
1300
- + (table.querySelector(':scope > tbody.fixed-top-rows')?.offsetHeight ?? 0)
1301
- : 0;
1338
+ return table.getBoundingClientRect().top - origin + (table.tHead?.offsetHeight ?? 0)
1339
+ + (table.querySelector(':scope > tbody.fixed-top-rows')?.offsetHeight ?? 0);
1302
1340
  },
1303
1341
  // Barra, cabeçalho e fixas do topo grudam: a área coberta vai até o fim do último.
1304
1342
  getStickyHeight: () => {
@@ -1508,6 +1546,8 @@ let DataGrid = class DataGrid extends LitElement {
1508
1546
  this.#declarativeColumns = columns;
1509
1547
  this.#syncColumns();
1510
1548
  };
1549
+ /** Colunas com `headerRenderer` sem `label` já avisadas, pelo nome em texto (o host pode recriar os objetos a cada render). */
1550
+ this.#warnedUnlabeled = new Set();
1511
1551
  this.#siblingCache = {
1512
1552
  regular: [],
1513
1553
  tree: buildColumnTree([]),
@@ -1516,17 +1556,26 @@ let DataGrid = class DataGrid extends LitElement {
1516
1556
  /** Rolagem horizontal: re-renderiza só quando a janela de colunas muda. */
1517
1557
  this.#onHorizontalScroll = () => {
1518
1558
  const scroller = this._scrollContainerRef.value;
1559
+ const external = this.#externalHorizontal();
1560
+ if (external) {
1561
+ this.#syncVisibleWidth(external.visible);
1562
+ }
1519
1563
  if (!scroller || !this.#freeOffsets) {
1520
1564
  return;
1521
1565
  }
1522
- // Em RTL o scrollLeft vai de 0 a negativo.
1523
- const start = Math.abs(scroller.scrollLeft);
1524
- const viewport = scroller.clientWidth;
1525
- if (start === this.#scrollStart && viewport === this.#viewportWidth) {
1566
+ // Em RTL o scrollLeft vai de 0 a negativo. Porta externa: a parte da tabela antes da borda visível.
1567
+ const start = external ? external.start : Math.abs(scroller.scrollLeft);
1568
+ const viewport = external ? external.visible : scroller.clientWidth;
1569
+ if (start === this.#scrollStart && viewport === this.#columnViewport()) {
1526
1570
  return;
1527
1571
  }
1528
1572
  this.#scrollStart = start;
1529
- this.#viewportWidth = viewport;
1573
+ if (external) {
1574
+ this.#visibleWidth = viewport;
1575
+ }
1576
+ else {
1577
+ this.#viewportWidth = viewport;
1578
+ }
1530
1579
  const next = this.#horizontalWindow();
1531
1580
  if (next.first !== this.#columnWindow.first || next.last !== this.#columnWindow.last) {
1532
1581
  // Cabeçalhos novos no DOM: o arrasto precisa deles.
@@ -1541,12 +1590,16 @@ let DataGrid = class DataGrid extends LitElement {
1541
1590
  if (!scroller || !container) {
1542
1591
  return;
1543
1592
  }
1593
+ const external = this.#externalHorizontal();
1544
1594
  // Em RTL o scrollLeft vai de 0 a negativo.
1545
- const offset = Math.abs(scroller.scrollLeft);
1546
- const overflow = scroller.scrollWidth - scroller.clientWidth;
1595
+ const offset = external ? external.start : Math.abs(scroller.scrollLeft);
1596
+ const after = external ? external.end : scroller.scrollWidth - scroller.clientWidth - offset;
1547
1597
  container.classList.toggle('scroll-start', offset > 0.5);
1548
- container.classList.toggle('scroll-end', overflow - offset > 0.5);
1598
+ container.classList.toggle('scroll-end', after > 0.5);
1549
1599
  };
1600
+ /** Largura visível da porta externa sobre a tabela (0 = rolagem interna). */
1601
+ this.#visibleWidth = 0;
1602
+ this.#syncedVisibleWidth = -1;
1550
1603
  this.#isExpanded = (key, level) => this.#expansion.get(key)?.expanded ?? this.#defaultExpanded(level);
1551
1604
  this.#typesVersion = -1;
1552
1605
  this.#warnedInfinitePaging = false;
@@ -1649,6 +1702,29 @@ let DataGrid = class DataGrid extends LitElement {
1649
1702
  }
1650
1703
  };
1651
1704
  this.#revealAttempts = 0;
1705
+ /** O usuário mexeu na rolagem durante a rolagem suave da API: ela não é refeita (nem o foco roubado). */
1706
+ this.#cancelReveal = (event) => {
1707
+ // Dentro do grid, a tecla/clique já é uma ação do usuário com revelação própria.
1708
+ if (event?.composedPath().includes(this)) {
1709
+ return;
1710
+ }
1711
+ this.#revealInterrupt?.abort();
1712
+ this.#revealInterrupt = undefined;
1713
+ this.#revealPending = false;
1714
+ this.#revealInFlight = false;
1715
+ this.#revealByApi = false;
1716
+ if (this.#deferredFocusFrom !== undefined) {
1717
+ this.#focusPending = false;
1718
+ this.#deferredFocusFrom = undefined;
1719
+ }
1720
+ };
1721
+ /** A última revelação veio de chamada de API (`focusCell`, `editCell`...). */
1722
+ this.#revealByApi = false;
1723
+ /** Rolagem suave da porta externa em curso: a revelação continua no `scrollend`. */
1724
+ this.#revealInFlight = false;
1725
+ /** Margens horizontais do que gruda (colunas fixas, recuos), medidas no render. */
1726
+ this.#revealInline = { start: 0, end: 0 };
1727
+ this.#revealMarginsKey = '';
1652
1728
  /** Foco que entra numa célula (clique, Tab, conteúdo da célula): ela vira a ativa. */
1653
1729
  this.#onGridFocusIn = (event) => {
1654
1730
  const path = event.composedPath();
@@ -1677,7 +1753,8 @@ let DataGrid = class DataGrid extends LitElement {
1677
1753
  this.#setActive(position, 'user');
1678
1754
  }
1679
1755
  else if (path[0] === cell && cell.closest('tr')?.classList.contains('pinned')) {
1680
- // Tab de volta para a célula ativa que está fora da tela: traz a linha.
1756
+ // Tab de volta para a célula ativa que está fora da tela: traz a linha (ação do usuário: na hora).
1757
+ this.#revealByApi = false;
1681
1758
  this.#revealPending = true;
1682
1759
  this.#revealAttempts = 0;
1683
1760
  this.requestUpdate();
@@ -2344,7 +2421,7 @@ let DataGrid = class DataGrid extends LitElement {
2344
2421
  const reference = this.treeColumn;
2345
2422
  const found = reference ? this.#resolveColumn(reference) : undefined;
2346
2423
  if (reference && !found) {
2347
- this.#warnTree('tree-column', `tree-column "${typeof reference === 'string' ? reference : reference.label ?? reference.path ?? ''}" matches no column; the first visible column is used.`);
2424
+ this.#warnTree('tree-column', `tree-column "${typeof reference === 'string' ? reference : columnText(reference)}" matches no column; the first visible column is used.`);
2348
2425
  }
2349
2426
  return found && visible.includes(found) ? found : visible[0];
2350
2427
  }
@@ -3711,7 +3788,7 @@ let DataGrid = class DataGrid extends LitElement {
3711
3788
  const warn = (this.#stateInUse || !!this.#stateStorage) && !(quiet && !name);
3712
3789
  if (!name) {
3713
3790
  if (warn) {
3714
- this.#warnState(`a column without "name" or "path" (${JSON.stringify(column.label ?? '')}) is left out of the state.`);
3791
+ this.#warnState(`a column without "name" or "path" (${JSON.stringify(columnText(column))}) is left out of the state.`);
3715
3792
  }
3716
3793
  }
3717
3794
  else if (named.has(name)) {
@@ -4175,6 +4252,17 @@ let DataGrid = class DataGrid extends LitElement {
4175
4252
  }
4176
4253
  return super.dispatchEvent(event);
4177
4254
  }
4255
+ /**
4256
+ * @internal Contêiner externo que rola o grid (frente 27), quando é um
4257
+ * elemento; `undefined` na rolagem interna ou pela janela (harness de perf).
4258
+ */
4259
+ get _scrollElement() {
4260
+ const port = this.#scrollPort.port;
4261
+ return port && !port.isWindow ? port.element : undefined;
4262
+ }
4263
+ #layoutRef;
4264
+ /** Rolagem por contêiner externo (spec 27). */
4265
+ #scrollPort;
4178
4266
  #virtualizer;
4179
4267
  /** Linhas fixas grudadas (não no modo "rolam com o conteúdo" do zoom alto). */
4180
4268
  #stickyFixed;
@@ -4220,8 +4308,12 @@ let DataGrid = class DataGrid extends LitElement {
4220
4308
  const toolbar = this.#observedToolbar?.isConnected ? this.#observedToolbar.offsetHeight : 0;
4221
4309
  const head = table.tHead?.offsetHeight ?? 0;
4222
4310
  const foot = table.tFoot?.offsetHeight ?? 0;
4223
- const covered = toolbar + head + foot + (top?.offsetHeight ?? 0) + (bottom?.offsetHeight ?? 0);
4224
- const sticky = !(top || bottom) || covered <= scroller.clientHeight * 0.5 || !scroller.clientHeight;
4311
+ const port = this.#scrollPort.port;
4312
+ // Porta externa (spec 27): a conta é contra a altura da porta, somando o que o hospedeiro gruda nela.
4313
+ const inset = port ? this.#scrollPort.padding() : { top: 0, bottom: 0 };
4314
+ const height = port ? port.clientHeight : scroller.clientHeight;
4315
+ const covered = toolbar + head + foot + (top?.offsetHeight ?? 0) + (bottom?.offsetHeight ?? 0) + inset.top + inset.bottom;
4316
+ const sticky = !(top || bottom) || covered <= height * 0.5 || !height;
4225
4317
  container.style.setProperty('--_fixed-top-offset', `${toolbar + head}px`);
4226
4318
  container.style.setProperty('--_fixed-bottom-offset', `${foot}px`);
4227
4319
  if (sticky !== this.#stickyFixed) {
@@ -4291,6 +4383,10 @@ let DataGrid = class DataGrid extends LitElement {
4291
4383
  cachedBlocks: this.#loader.blocksCached,
4292
4384
  loadTimers: (this.#flushTimer === undefined ? 0 : 1) + (this.#loadingTimer === undefined ? 0 : 1),
4293
4385
  rowExpansion: this.#rowExpansion.size,
4386
+ // Rolagem por contêiner externo (frente 27): porta ligada, linhas observadas, esperas de `scrollend`.
4387
+ scrollPortAttached: this.#scrollPort.port ? 1 : 0,
4388
+ scrollPortObservedRows: this.#scrollPort.observedRows,
4389
+ scrollEndWaits: this.#scrollPort.scrollEndWaits,
4294
4390
  // Responsivo (frente 21): o anúncio das ocultas por espaço e o que é guardado por coluna.
4295
4391
  adaptiveTimers: this.#adaptiveTimer === undefined ? 0 : 1,
4296
4392
  adaptiveColumns: this.#adaptiveColumns.length + this.#reportedAdaptive.length,
@@ -4375,6 +4471,8 @@ let DataGrid = class DataGrid extends LitElement {
4375
4471
  this.#rangeSummaryAbort?.abort();
4376
4472
  this.#rangeSummaryAbort = undefined;
4377
4473
  this.#rangeAddMode = false;
4474
+ // Rolagem suave da API em curso (frente 27): sem listeners na porta.
4475
+ this.#cancelReveal();
4378
4476
  // A tabela não segura os rótulos da página enquanto o grid está fora dela (antes do super: precisa do ref).
4379
4477
  this.#hostLabel.disconnect();
4380
4478
  this.#syncTableLabel();
@@ -4420,6 +4518,9 @@ let DataGrid = class DataGrid extends LitElement {
4420
4518
  this.#announcedAdaptive = undefined;
4421
4519
  }
4422
4520
  willUpdate(changed) {
4521
+ if (changed.has('scrollContainer') || changed.has('scrollContainerElement')) {
4522
+ this.#scrollPort.resolve();
4523
+ }
4423
4524
  // No servidor o Lit não chama o `attributeChangedCallback` do elemento: lê o `aria-label` aqui.
4424
4525
  if (isServer) {
4425
4526
  this.#hostLabel.update();
@@ -4558,6 +4659,7 @@ let DataGrid = class DataGrid extends LitElement {
4558
4659
  updated(changed) {
4559
4660
  const virtualizer = this.#virtualizer;
4560
4661
  this.#pruneRowRenders();
4662
+ this.#afterExternalRender();
4561
4663
  this.#observeToolbar();
4562
4664
  this.#observeFixedSections();
4563
4665
  this.#syncTableLabel();
@@ -5839,7 +5941,7 @@ let DataGrid = class DataGrid extends LitElement {
5839
5941
  this.requestUpdate();
5840
5942
  // A resposta chegou com o foco em outra célula: anuncia com contexto.
5841
5943
  if (outcome && !this.#isActiveCell(pending.rowKey, column)) {
5842
- this.#announce(`${column.label ?? ''}: ${outcome.message}`);
5944
+ this.#announce(`${columnText(column)}: ${outcome.message}`);
5843
5945
  }
5844
5946
  return outcome;
5845
5947
  });
@@ -6124,7 +6226,11 @@ let DataGrid = class DataGrid extends LitElement {
6124
6226
  if (!scroller || !rows?.length) {
6125
6227
  return 0;
6126
6228
  }
6127
- const limit = scroller.getBoundingClientRect().top + this.#stickyTop();
6229
+ const port = this.#scrollPort.port;
6230
+ // Porta externa (spec 27): abaixo do que gruda no topo da porta (ou do início do corpo, se ele está mais abaixo).
6231
+ const limit = port
6232
+ ? Math.max(port.rect().top + this.#scrollPort.padding().top + this.#stickyTop(), rows[0].getBoundingClientRect().top)
6233
+ : scroller.getBoundingClientRect().top + this.#stickyTop();
6128
6234
  for (const tr of rows) {
6129
6235
  if (tr.getBoundingClientRect().bottom > limit + 1) {
6130
6236
  return Math.min(Number(tr.getAttribute('data-index')), this.#rows.length);
@@ -6417,11 +6523,11 @@ let DataGrid = class DataGrid extends LitElement {
6417
6523
  }
6418
6524
  const [entry] = pending.errors;
6419
6525
  if (entry) {
6420
- return `${entry[0].label ?? ''}: ${entry[1]}`;
6526
+ return `${columnText(entry[0])}: ${entry[1]}`;
6421
6527
  }
6422
6528
  const [unparsed] = pending.unparsed;
6423
6529
  if (unparsed) {
6424
- return unparsed[0].label ?? '';
6530
+ return columnText(unparsed[0]);
6425
6531
  }
6426
6532
  }
6427
6533
  return '';
@@ -6789,8 +6895,9 @@ let DataGrid = class DataGrid extends LitElement {
6789
6895
  const pending = this.#edits.get(editor.rowKey);
6790
6896
  const column = editor.column;
6791
6897
  const error = pending && column ? pending.errors.get(column) : undefined;
6792
- if (column?.label && !target.hasAttribute('aria-label') && !target.hasAttribute('aria-labelledby')) {
6793
- target.setAttribute('aria-label', column.label);
6898
+ const name = column ? columnText(column) : '';
6899
+ if (name && !target.hasAttribute('aria-label') && !target.hasAttribute('aria-labelledby')) {
6900
+ target.setAttribute('aria-label', name);
6794
6901
  }
6795
6902
  const ids = (target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean);
6796
6903
  const messageId = this.#lightMessage?.id;
@@ -6940,7 +7047,7 @@ let DataGrid = class DataGrid extends LitElement {
6940
7047
  groupLabel: (node, valueText, extra) => {
6941
7048
  const parts = this.showGroupCount ? [countFormat.format(node.items.length), ...extra] : [...extra];
6942
7049
  const info = parts.length ? ` ${formatMessage(translation.groupInfoText, { info: parts.join(listSeparator) })}` : '';
6943
- return `${node.column.label ?? ''}${translation.groupLabelSeparator}${valueText}${info}`;
7050
+ return `${columnText(node.column)}${translation.groupLabelSeparator}${valueText}${info}`;
6944
7051
  },
6945
7052
  };
6946
7053
  }
@@ -7000,7 +7107,7 @@ let DataGrid = class DataGrid extends LitElement {
7000
7107
  return {
7001
7108
  info: {
7002
7109
  column,
7003
- label: column.label ?? '',
7110
+ label: columnText(column),
7004
7111
  dataType,
7005
7112
  alignment: resolveAlignment(column, dataType),
7006
7113
  width: this.#widthOf(column) ?? this.#renderedWidths.get(column),
@@ -7552,7 +7659,7 @@ let DataGrid = class DataGrid extends LitElement {
7552
7659
  if (!scroller || !table || !root) {
7553
7660
  return undefined;
7554
7661
  }
7555
- const box = scroller.getBoundingClientRect();
7662
+ const box = this.#visibleScrollBox(scroller);
7556
7663
  const head = table.tHead?.getBoundingClientRect().bottom ?? box.top;
7557
7664
  const px = Math.min(Math.max(x, box.left + 1), box.right - 2);
7558
7665
  const py = Math.min(Math.max(y, Math.max(head, box.top) + 1), box.bottom - 2);
@@ -7570,6 +7677,25 @@ let DataGrid = class DataGrid extends LitElement {
7570
7677
  }
7571
7678
  return undefined;
7572
7679
  }
7680
+ /**
7681
+ * Área visível da rolagem em coordenadas da tela: o contêiner interno, ou
7682
+ * a parte do grid dentro da porta externa (spec 27).
7683
+ */
7684
+ #visibleScrollBox(scroller) {
7685
+ const box = scroller.getBoundingClientRect();
7686
+ const port = this.#scrollPort.port;
7687
+ if (!port) {
7688
+ return box;
7689
+ }
7690
+ const view = port.rect();
7691
+ const inset = this.#scrollPort.padding();
7692
+ return {
7693
+ top: Math.max(box.top, view.top + inset.top),
7694
+ left: Math.max(box.left, view.left),
7695
+ right: Math.min(box.right, view.right),
7696
+ bottom: Math.min(box.bottom, view.bottom - inset.bottom),
7697
+ };
7698
+ }
7573
7699
  #dragRangeTo() {
7574
7700
  const drag = this.#rangeDrag;
7575
7701
  if (!drag) {
@@ -7610,7 +7736,7 @@ let DataGrid = class DataGrid extends LitElement {
7610
7736
  if (this.#rangeDrag !== drag || !scroller) {
7611
7737
  return;
7612
7738
  }
7613
- const box = scroller.getBoundingClientRect();
7739
+ const box = this.#visibleScrollBox(scroller);
7614
7740
  const head = Math.max(drag.table.tHead?.getBoundingClientRect().bottom ?? box.top, box.top);
7615
7741
  const speed = (distance) => Math.min(Math.ceil(distance / 2) + 2, 48);
7616
7742
  const dy = drag.y < head + AUTO_SCROLL_EDGE
@@ -7622,7 +7748,7 @@ let DataGrid = class DataGrid extends LitElement {
7622
7748
  if (!dx && !dy) {
7623
7749
  return;
7624
7750
  }
7625
- scroller.scrollBy(dx, dy);
7751
+ (this.#scrollPort.port?.source ?? scroller).scrollBy(dx, dy);
7626
7752
  this.#dragRangeTo();
7627
7753
  this.#scheduleRangeAutoScroll();
7628
7754
  });
@@ -7849,7 +7975,7 @@ let DataGrid = class DataGrid extends LitElement {
7849
7975
  /** Coluna sem valor exportável (só `renderer`): célula vazia na cópia. */
7850
7976
  #emptyExportColumn(column) {
7851
7977
  return {
7852
- info: { column, label: column.label ?? '', dataType: this.#dataTypeOf(column), alignment: 'start' },
7978
+ info: { column, label: columnText(column), dataType: this.#dataTypeOf(column), alignment: 'start' },
7853
7979
  read: () => '',
7854
7980
  text: () => '',
7855
7981
  builtIn: true,
@@ -8164,6 +8290,32 @@ let DataGrid = class DataGrid extends LitElement {
8164
8290
  }
8165
8291
  // ------------------------------------------------------------- colunas
8166
8292
  #readDeclarativeColumns;
8293
+ /** Colunas com `headerRenderer` sem `label` já avisadas, pelo nome em texto (o host pode recriar os objetos a cada render). */
8294
+ #warnedUnlabeled;
8295
+ /**
8296
+ * `headerRenderer` sem `label`: o renderer só vale para o cabeçalho; menus,
8297
+ * chip, seletor, anúncios e exportação usam o `path`/`name` cru, e um
8298
+ * renderer só de ícone deixa o cabeçalho sem nome. Avisa uma vez por
8299
+ * coluna e instância (spec 00).
8300
+ */
8301
+ #warnUnlabeledColumns(tree) {
8302
+ for (const column of [...tree.leaves, ...tree.bands]) {
8303
+ if (!column.headerRenderer || column.label) {
8304
+ continue;
8305
+ }
8306
+ const name = columnText(column);
8307
+ const band = tree.childrenOf.has(column);
8308
+ const key = `${band ? 'band' : 'column'}:${name}`;
8309
+ if (this.#warnedUnlabeled.has(key)) {
8310
+ continue;
8311
+ }
8312
+ this.#warnedUnlabeled.add(key);
8313
+ const which = name ? `${band ? 'band' : 'column'} "${name}"` : band ? 'a band' : 'a column';
8314
+ const used = name ? `"${name}" names it` : 'it has no name';
8315
+ console.warn(`<u-grid>: ${which} has a "headerRenderer" but no "label" (with <u-grid-column>, its text content); `
8316
+ + `${used} in menus, the column chooser, announcements and export.`);
8317
+ }
8318
+ }
8167
8319
  /**
8168
8320
  * Concilia as definições com a ordem atual: colunas já conhecidas mantêm a
8169
8321
  * posição e o agrupamento escolhidos pelo usuário; novas entram pelo
@@ -8172,6 +8324,7 @@ let DataGrid = class DataGrid extends LitElement {
8172
8324
  #syncColumns() {
8173
8325
  const tree = buildColumnTree(this.columns);
8174
8326
  this.#columnTree = tree;
8327
+ this.#warnUnlabeledColumns(tree);
8175
8328
  this.#visibleBands = undefined;
8176
8329
  // Só as folhas têm células; as bandas são só cabeçalho.
8177
8330
  const definitions = tree.leaves;
@@ -8486,7 +8639,7 @@ let DataGrid = class DataGrid extends LitElement {
8486
8639
  if (!columns.length) {
8487
8640
  return translation.noAdaptiveColumnsAnnouncement;
8488
8641
  }
8489
- const names = columns.length <= ADAPTIVE_ANNOUNCE_NAMES ? this.#formatList(columns.map(column => column.label ?? '')) : String(columns.length);
8642
+ const names = columns.length <= ADAPTIVE_ANNOUNCE_NAMES ? this.#formatList(columns.map(column => columnText(column))) : String(columns.length);
8490
8643
  return formatMessage(translation.adaptiveColumnsAnnouncement, { columns: names });
8491
8644
  }
8492
8645
  /**
@@ -8504,7 +8657,7 @@ let DataGrid = class DataGrid extends LitElement {
8504
8657
  ...order ? [order === 'asc' ? translation.sortAscending : translation.sortDescending] : [],
8505
8658
  ...hasColumnCondition(filterValue, column) ? [translation.columnFiltered] : [],
8506
8659
  ];
8507
- return parts.length ? [`${column.label ?? ''}${translation.adaptiveLabelSeparator}${parts.join(', ')}`] : [];
8660
+ return parts.length ? [`${columnText(column)}${translation.adaptiveLabelSeparator}${parts.join(', ')}`] : [];
8508
8661
  });
8509
8662
  return [this.#adaptiveAnnouncementText(), ...states].join('. ');
8510
8663
  }
@@ -9027,7 +9180,7 @@ let DataGrid = class DataGrid extends LitElement {
9027
9180
  if (!offsets) {
9028
9181
  return { first: 0, last: -1 };
9029
9182
  }
9030
- const viewport = this.#viewportWidth || DEFAULT_VIEWPORT_WIDTH;
9183
+ const viewport = this.#columnViewport() || DEFAULT_VIEWPORT_WIDTH;
9031
9184
  return columnWindow(offsets, this.#scrollStart, Math.max(viewport - this.#fixedArea, 0), COLUMN_OVERSCAN);
9032
9185
  }
9033
9186
  /** Rolagem horizontal: re-renderiza só quando a janela de colunas muda. */
@@ -9176,15 +9329,24 @@ let DataGrid = class DataGrid extends LitElement {
9176
9329
  return;
9177
9330
  }
9178
9331
  this.#resizeObserver = new ResizeObserver(entries => {
9179
- if (entries.some(entry => entry.target === scroller)) {
9332
+ if (entries.some(entry => entry.target === scroller || entry.target === this)) {
9333
+ // Porta externa (spec 27): o `.scroll-container` tem a largura da tabela; a do grid é a do host.
9334
+ const width = this.#scrollPort.port ? this.clientWidth : scroller.clientWidth;
9180
9335
  this.#layoutDirty = true;
9181
9336
  this.#adaptiveDirty = true;
9182
- this.#viewportWidth = scroller.clientWidth;
9337
+ this.#viewportWidth = width;
9183
9338
  // Zoom só de texto muda o `font-size`: a largura padrão da conta do responsivo acompanha (1.4.4).
9184
9339
  this.#fontScale = this.autoHideColumns ? (parseFloat(getComputedStyle(this).fontSize) || 16) / 16 : 1;
9185
9340
  // Largura visível: o conteúdo do detalhe e da linha inteira não passa dela (WCAG 1.4.10).
9186
9341
  // No contêiner: o \`style\` do \`.scroll-container\` é do template (o render o sobrescreve).
9187
- this._containerRef.value?.style.setProperty('--_viewport-inline-size', `${scroller.clientWidth}px`);
9342
+ this.#layoutRef.value?.style.setProperty('--_fill-inline-size', `${width}px`);
9343
+ // Porta externa (spec 27): a parte visível, medida na rolagem.
9344
+ if (this.#scrollPort.port) {
9345
+ this.#onExternalMoved();
9346
+ }
9347
+ else {
9348
+ this.#layoutRef.value?.style.setProperty('--_viewport-inline-size', `${width}px`);
9349
+ }
9188
9350
  this.requestUpdate();
9189
9351
  }
9190
9352
  this.#syncToolbarOffset();
@@ -9194,6 +9356,8 @@ let DataGrid = class DataGrid extends LitElement {
9194
9356
  }
9195
9357
  });
9196
9358
  this.#resizeObserver.observe(scroller);
9359
+ // Porta externa: a largura do grid é a do host (o `.scroll-container` cresce com a tabela).
9360
+ this.#resizeObserver.observe(this);
9197
9361
  this.#observeToolbar();
9198
9362
  }
9199
9363
  /**
@@ -9224,6 +9388,81 @@ let DataGrid = class DataGrid extends LitElement {
9224
9388
  }
9225
9389
  /** Sombra das fixas: só aparece quando há conteúdo rolado por baixo delas. */
9226
9390
  #updateScrollShadows;
9391
+ /**
9392
+ * Porta externa (spec 27): quanto da tabela fica antes da borda inicial
9393
+ * visível (`start`), depois da final (`end`) e a largura visível — pelos
9394
+ * retângulos, então vale em LTR/RTL e com qualquer `dir` no contêiner.
9395
+ */
9396
+ #externalHorizontal() {
9397
+ const port = this.#scrollPort.port;
9398
+ const table = this.#tableRef.value;
9399
+ if (!port || !table) {
9400
+ return undefined;
9401
+ }
9402
+ const box = table.getBoundingClientRect();
9403
+ const view = port.rect();
9404
+ const left = Math.max(0, view.left - box.left);
9405
+ const right = Math.max(0, box.right - view.right);
9406
+ const visible = Math.max(0, Math.min(view.right, box.right) - Math.max(view.left, box.left));
9407
+ const rtl = this.matches(':dir(rtl)');
9408
+ return { start: rtl ? right : left, end: rtl ? left : right, visible: Math.round(visible) };
9409
+ }
9410
+ /** Largura visível da porta externa sobre a tabela (0 = rolagem interna). */
9411
+ #visibleWidth;
9412
+ #syncedVisibleWidth;
9413
+ /** Largura da área das colunas: a do grid, ou a parte visível na porta externa. */
9414
+ #columnViewport() {
9415
+ return this.#scrollPort.port ? this.#visibleWidth : this.#viewportWidth;
9416
+ }
9417
+ /** `--_viewport-inline-size` = parte visível (barra, detalhe, linha inteira, paginação). */
9418
+ #syncVisibleWidth(width) {
9419
+ if (width !== this.#syncedVisibleWidth && width > 0) {
9420
+ this.#syncedVisibleWidth = width;
9421
+ this.#layoutRef.value?.style.setProperty('--_viewport-inline-size', `${width}px`);
9422
+ }
9423
+ }
9424
+ /** Rolagem da porta externa (spec 27). */
9425
+ #onExternalScroll() {
9426
+ this.#onHorizontalScroll();
9427
+ this.#updateScrollShadows();
9428
+ this.#syncLoadPanel();
9429
+ }
9430
+ /** Depois de cada render com a porta externa: margens, linhas observadas, painel de carga. */
9431
+ #afterExternalRender() {
9432
+ if (!this.#scrollPort.port) {
9433
+ return;
9434
+ }
9435
+ this.#syncRevealMargins();
9436
+ this.#scrollPort.observeRows(this.#tableRef.value?.querySelectorAll(':scope > tbody.body-rows > tr[data-index]:not(.pinned)') ?? []);
9437
+ this.#syncLoadPanel();
9438
+ }
9439
+ /** Painel de carga no centro da parte visível do grid na porta externa. */
9440
+ #syncLoadPanel() {
9441
+ const container = this._containerRef.value;
9442
+ const port = this.#scrollPort.port;
9443
+ if (!port || !container?.querySelector('.lang-scope > .load-panel')) {
9444
+ return;
9445
+ }
9446
+ const box = container.getBoundingClientRect();
9447
+ const view = port.rect();
9448
+ const top = Math.max(box.top, view.top);
9449
+ const bottom = Math.min(box.bottom, view.bottom);
9450
+ const left = Math.max(box.left, view.left);
9451
+ const right = Math.min(box.right, view.right);
9452
+ const block = (top + bottom) / 2 - box.top;
9453
+ const inline = this.matches(':dir(rtl)') ? box.right - (left + right) / 2 : (left + right) / 2 - box.left;
9454
+ container.style.setProperty('--_visible-block-center', `${Math.max(0, block)}px`);
9455
+ container.style.setProperty('--_visible-inline-center', `${Math.max(0, inline)}px`);
9456
+ }
9457
+ /** A porta externa mudou de tamanho, ou o grid se moveu nela sem rolagem (spec 27). */
9458
+ #onExternalMoved() {
9459
+ this.#virtualizer.sync();
9460
+ this.#onHorizontalScroll();
9461
+ this.#updateScrollShadows();
9462
+ this.#syncFixedRows();
9463
+ this.#syncRevealMargins();
9464
+ this.#scrollPort.checkHeight();
9465
+ }
9227
9466
  /**
9228
9467
  * Classe, deslocamento `sticky` e limites de cada coluna visível. Os
9229
9468
  * deslocamentos usam a largura medida (a tabela pode esticar as colunas).
@@ -9328,7 +9567,8 @@ let DataGrid = class DataGrid extends LitElement {
9328
9567
  }
9329
9568
  /** Resolve a coluna de um resumo: `path` (1ª coluna com ele) ou a própria coluna, se definida. */
9330
9569
  #resolveColumn(columnRef) {
9331
- const columns = this.columns;
9570
+ // Folhas, não só o nível de cima: coluna dentro de banda também é referência válida.
9571
+ const columns = this.#columnTree.leaves;
9332
9572
  if (typeof columnRef === 'string') {
9333
9573
  return columns.find(column => column.name === columnRef) ?? columns.find(column => column.path === columnRef);
9334
9574
  }
@@ -10136,7 +10376,7 @@ let DataGrid = class DataGrid extends LitElement {
10136
10376
  #announceSorting(column) {
10137
10377
  const translation = this.#translation;
10138
10378
  const order = this.#orderOf(column);
10139
- const params = { column: column.label ?? '' };
10379
+ const params = { column: columnText(column) };
10140
10380
  const rowSorting = this.#sorting.filter(spec => !this.#isGrouped(spec.column));
10141
10381
  const priority = rowSorting.findIndex(spec => spec.column === column) + 1;
10142
10382
  const orderText = order === 'asc' ? translation.sortAscending : translation.sortDescending;
@@ -10219,7 +10459,7 @@ let DataGrid = class DataGrid extends LitElement {
10219
10459
  const translation = this.#translation;
10220
10460
  const valueText = formatSummaryValue(value, spec, item.format, this.#summaryFormatContext);
10221
10461
  const type = this.#summaryTypeName(item);
10222
- const column = spec.column?.label ?? '';
10462
+ const column = spec.column ? columnText(spec.column) : '';
10223
10463
  const text = type ? formatMessage(translation.summaryText, { type, value: valueText }) : valueText;
10224
10464
  if (!column) {
10225
10465
  return { text, label: text };
@@ -10231,46 +10471,28 @@ let DataGrid = class DataGrid extends LitElement {
10231
10471
  : `${column}${translation.groupLabelSeparator}${valueText}`,
10232
10472
  };
10233
10473
  }
10234
- /** Resumos agrupados pela coluna onde aparecem. */
10474
+ /**
10475
+ * Resumos agrupados pela coluna onde aparecem. Coluna oculta por falta de
10476
+ * espaço (spec 21) não mostra o resumo no rodapé, como as células dela (o
10477
+ * DevExtreme faz o mesmo); o valor segue no `getSummaryValues`.
10478
+ */
10235
10479
  #textsByColumn(summaries, values, include) {
10236
10480
  const texts = new Map();
10237
10481
  const adaptive = this.#adaptiveColumns;
10238
- const lastShown = this._visibleColumns[this._visibleColumns.length - 1];
10239
10482
  summaries.forEach((summary, index) => {
10240
- let { column } = summary.spec;
10241
- if (!column || !include(summary, index)) {
10483
+ const { column } = summary.spec;
10484
+ if (!column || !include(summary, index) || adaptive.includes(column)) {
10242
10485
  return;
10243
10486
  }
10244
- let text = this.#summaryText(summary, values[index]);
10245
- // Coluna oculta por falta de espaço (spec 21): o resumo vai à última exibida, com o texto completo.
10246
- if (adaptive.length && adaptive.includes(column)) {
10247
- if (!lastShown) {
10248
- return;
10249
- }
10250
- column = lastShown;
10251
- text = { text: text.label, label: text.label };
10252
- }
10253
10487
  let list = texts.get(column);
10254
10488
  if (!list) {
10255
10489
  list = [];
10256
10490
  texts.set(column, list);
10257
10491
  }
10258
- list.push(text);
10492
+ list.push(this.#summaryText(summary, values[index]));
10259
10493
  });
10260
10494
  return texts;
10261
10495
  }
10262
- /**
10263
- * Rodapé de totais com colunas ocultas por falta de espaço (spec 21): a
10264
- * última exibida recebe os resumos delas e quebra linha (WCAG 1.4.10). O
10265
- * rodapé de grupo está no virtualizador (altura fixa): lá ela não quebra.
10266
- */
10267
- #summaryLayout(layout) {
10268
- const last = this._visibleColumns[this._visibleColumns.length - 1];
10269
- if (!this.#adaptiveColumns.length || !last) {
10270
- return layout;
10271
- }
10272
- return layout.map(cell => cell.column === last ? { ...cell, className: `${cell.className} adaptive-summaries` } : cell);
10273
- }
10274
10496
  /** Separador de lista do idioma (sem "e"/"and"), calculado uma vez por idioma. */
10275
10497
  get #listSeparatorText() {
10276
10498
  const language = this.language;
@@ -10701,6 +10923,14 @@ let DataGrid = class DataGrid extends LitElement {
10701
10923
  this.#focusPending ||= focus;
10702
10924
  this.#revealPending ||= reveal || focus;
10703
10925
  this.#revealAttempts = 0;
10926
+ // Porta externa (spec 27): chamada de API respeita o `scroll-behavior` do contêiner; teclado/clique, instantâneo.
10927
+ if (reveal || focus) {
10928
+ this.#revealByApi = source === 'api';
10929
+ // Ação do usuário no meio de uma rolagem suave da API: vale a do usuário (instantânea, já).
10930
+ if (source === 'user') {
10931
+ this.#revealInFlight = false;
10932
+ }
10933
+ }
10704
10934
  this.#reportFocus(source);
10705
10935
  this.requestUpdate();
10706
10936
  }
@@ -10871,16 +11101,32 @@ let DataGrid = class DataGrid extends LitElement {
10871
11101
  this.#revealPending = false;
10872
11102
  return;
10873
11103
  }
10874
- if (this.#focusPending) {
11104
+ // Porta externa, API com rolagem suave até uma linha fora da janela
11105
+ // virtual (spec 27): o foco espera a linha chegar (a `.pinned` é
11106
+ // invisível; lupa e realce do leitor iriam para o topo do grid).
11107
+ const pinned = cell.closest('tr')?.classList.contains('pinned') ?? false;
11108
+ const deferFocus = this.#focusPending && pinned && this.#revealPending && this.#scrollPort.port !== null
11109
+ && this.#revealBehavior() !== 'instant';
11110
+ if (deferFocus) {
11111
+ this.#deferredFocusFrom ??= this.#deepActiveElement();
11112
+ }
11113
+ else if (this.#focusPending) {
10875
11114
  this.#focusPending = false;
11115
+ const from = this.#deferredFocusFrom;
11116
+ this.#deferredFocusFrom = undefined;
11117
+ // Foco esperado pela rolagem: só se ninguém o levou para outro lugar enquanto isso.
11118
+ const moved = from !== undefined && this.#deepActiveElement() !== from && !this.matches(':focus-within');
10876
11119
  // Foco perdido num valor da linha adaptativa (linha recriada ao salvar): volta ao mesmo valor (spec 21).
10877
11120
  const adaptive = this.#adaptiveFocus;
10878
11121
  const value = adaptive && cell.classList.contains('detail-cell')
10879
11122
  ? cell.querySelector(`.adaptive-value.focus-target[data-column="${columnIdOf(adaptive.column)}"]`)
10880
11123
  : null;
10881
- (value ?? cell).focus({ preventScroll: true });
11124
+ if (!moved) {
11125
+ (value ?? cell).focus({ preventScroll: true });
11126
+ }
10882
11127
  }
10883
- if (!this.#revealPending) {
11128
+ // Rolagem suave até a linha em curso (porta externa): continua quando ela acabar.
11129
+ if (!this.#revealPending || this.#revealInFlight) {
10884
11130
  return;
10885
11131
  }
10886
11132
  if (cell.closest('tr')?.classList.contains('pinned')) {
@@ -10888,11 +11134,21 @@ let DataGrid = class DataGrid extends LitElement {
10888
11134
  // pela rolagem traz a linha e termina o ajuste (horizontal).
10889
11135
  if (++this.#revealAttempts > 3) {
10890
11136
  this.#revealPending = false;
11137
+ this.#revealByApi = false;
10891
11138
  }
10892
11139
  this.#scrollRowIntoView(this.#activeRowIndex);
10893
11140
  return;
10894
11141
  }
10895
11142
  this.#revealPending = false;
11143
+ if (this.#scrollPort.port) {
11144
+ // Porta externa (spec 27): as margens do `scroll-margin` (CSS) e o `scroll-padding` do contêiner.
11145
+ this.#syncRevealMargins();
11146
+ const behavior = this.#revealBehavior();
11147
+ cell.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior });
11148
+ this.#afterRevealScroll(behavior);
11149
+ this.#revealByApi = false;
11150
+ return;
11151
+ }
10896
11152
  const scroller = this._scrollContainerRef.value;
10897
11153
  if (scroller) {
10898
11154
  // Cabeçalho/barra presos no topo e rodapé de totais preso embaixo: a
@@ -10908,10 +11164,126 @@ let DataGrid = class DataGrid extends LitElement {
10908
11164
  /** Rola até a linha `index` sem depender de ela estar renderizada (abaixo do que é fixo no topo). */
10909
11165
  #scrollRowIntoView(index) {
10910
11166
  // Linhas fixas não rolam na vertical.
10911
- if (this.#isBodyIndex(index)) {
11167
+ if (!this.#isBodyIndex(index)) {
11168
+ return;
11169
+ }
11170
+ if (this.#scrollPort.port) {
11171
+ this.#revealExternalRow(index);
11172
+ }
11173
+ else {
10912
11174
  this.#virtualizer.scrollToIndex(index);
10913
11175
  }
10914
11176
  }
11177
+ /** Foco que esperava a rolagem suave: onde ele estava quando começou a esperar. */
11178
+ #deferredFocusFrom;
11179
+ /** Listeners de interrupção (roda, toque, ponteiro, tecla na porta) durante a rolagem suave. */
11180
+ #revealInterrupt;
11181
+ #deepActiveElement() {
11182
+ let active = document.activeElement;
11183
+ while (active?.shadowRoot?.activeElement) {
11184
+ active = active.shadowRoot.activeElement;
11185
+ }
11186
+ return active;
11187
+ }
11188
+ /** O usuário mexeu na rolagem durante a rolagem suave da API: ela não é refeita (nem o foco roubado). */
11189
+ #cancelReveal;
11190
+ /** A última revelação veio de chamada de API (`focusCell`, `editCell`...). */
11191
+ #revealByApi;
11192
+ /** Rolagem suave da porta externa em curso: a revelação continua no `scrollend`. */
11193
+ #revealInFlight;
11194
+ /** Margens horizontais do que gruda (colunas fixas, recuos), medidas no render. */
11195
+ #revealInline;
11196
+ #revealMarginsKey;
11197
+ #revealProbe;
11198
+ /** `instant` para ação do usuário e com `prefers-reduced-motion`; `auto` (o `scroll-behavior` do contêiner) para API. */
11199
+ #revealBehavior() {
11200
+ const port = this.#scrollPort.port;
11201
+ // `auto` só faz diferença com `scroll-behavior: smooth` no contêiner; sem ele, é instantâneo (e relido já).
11202
+ return this.#revealByApi && port && getComputedStyle(port.element).scrollBehavior === 'smooth'
11203
+ && !window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'instant';
11204
+ }
11205
+ /**
11206
+ * Margens de rolagem (spec 27) das células e dos focáveis delas (CSS) e
11207
+ * deslocamentos do que o hospedeiro gruda no contêiner (`scroll-padding`
11208
+ * dele), para o `sticky` e para a regra dos 50%.
11209
+ */
11210
+ #syncRevealMargins() {
11211
+ const layout = this.#layoutRef.value;
11212
+ if (!layout || !this.#scrollPort.port) {
11213
+ return;
11214
+ }
11215
+ const inset = this.#scrollPort.padding();
11216
+ // A barra de erro (56px) cobre o pé da parte visível.
11217
+ const error = this.#dataSource && this.#loader.error ? 56 : 0;
11218
+ const values = [this.#stickyTop(), this.#stickyBottom() + error, this.#revealInline.start, this.#revealInline.end, inset.top, inset.bottom];
11219
+ const key = values.join();
11220
+ if (key === this.#revealMarginsKey) {
11221
+ return;
11222
+ }
11223
+ this.#revealMarginsKey = key;
11224
+ const names = ['--_reveal-top', '--_reveal-bottom', '--_reveal-start', '--_reveal-end', '--_port-inset-top', '--_port-inset-bottom'];
11225
+ names.forEach((name, i) => layout.style.setProperty(name, `${values[i]}px`));
11226
+ }
11227
+ /**
11228
+ * Linha fora da janela virtual com a porta externa: um alvo invisível onde
11229
+ * a linha estaria recebe o `scrollIntoView` (rola também os ancestrais do
11230
+ * contêiner). Na horizontal fica na borda visível — o ajuste horizontal
11231
+ * vem com a célula, quando a linha entrar no render.
11232
+ */
11233
+ #revealExternalRow(index) {
11234
+ const port = this.#scrollPort.port;
11235
+ const container = this._containerRef.value;
11236
+ const body = this.#tableRef.value?.querySelector(':scope > tbody.body-rows');
11237
+ if (!port || !container || !body) {
11238
+ return;
11239
+ }
11240
+ this.#syncRevealMargins();
11241
+ const inset = this.#scrollPort.padding();
11242
+ const top = this.#stickyTop();
11243
+ const bottom = this.#stickyBottom() + (this.#dataSource && this.#loader.error ? 56 : 0);
11244
+ const offset = this.#virtualizer.revealOffset(index, top + inset.top, bottom + inset.bottom);
11245
+ const box = container.getBoundingClientRect();
11246
+ const view = port.rect();
11247
+ const probe = this.#revealProbe ??= Object.assign(document.createElement('div'), { className: 'reveal-probe' });
11248
+ probe.setAttribute('aria-hidden', 'true');
11249
+ probe.style.top = `${body.getBoundingClientRect().top - box.top + offset}px`;
11250
+ probe.style.height = `${this.#virtualizer.sizeOf(index)}px`;
11251
+ probe.style.left = `${Math.max(0, Math.min(box.width - 1, Math.max(view.left, box.left) - box.left))}px`;
11252
+ probe.style.scrollMargin = `${top}px 0px ${bottom}px`;
11253
+ container.append(probe);
11254
+ const behavior = this.#revealBehavior();
11255
+ probe.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior });
11256
+ this.#afterRevealScroll(behavior, probe);
11257
+ }
11258
+ /** Depois do `scrollIntoView` na porta externa: instantâneo relê já; suave espera o `scrollend`. */
11259
+ #afterRevealScroll(behavior, probe) {
11260
+ if (behavior === 'instant') {
11261
+ probe?.remove();
11262
+ this.#virtualizer.sync();
11263
+ return;
11264
+ }
11265
+ this.#revealInFlight = true;
11266
+ const port = this.#scrollPort.port;
11267
+ if (port && !this.#revealInterrupt) {
11268
+ this.#revealInterrupt = new AbortController();
11269
+ const options = { passive: true, signal: this.#revealInterrupt.signal };
11270
+ for (const type of ['wheel', 'touchstart', 'pointerdown', 'keydown']) {
11271
+ port.target.addEventListener(type, this.#cancelReveal, options);
11272
+ }
11273
+ }
11274
+ this.#scrollPort.afterScrollEnd(() => {
11275
+ this.#revealInterrupt?.abort();
11276
+ this.#revealInterrupt = undefined;
11277
+ // O alvo fica até a rolagem suave chegar (tirá-lo antes pode interrompê-la).
11278
+ probe?.remove();
11279
+ this.#revealInFlight = false;
11280
+ this.#virtualizer.endGlide();
11281
+ if (this.isConnected) {
11282
+ this.#virtualizer.sync();
11283
+ this.requestUpdate();
11284
+ }
11285
+ });
11286
+ }
10915
11287
  /** Altura do que fica preso no topo da rolagem (cabeçalho das colunas ou barra). */
10916
11288
  #stickyTop() {
10917
11289
  const root = this.renderRoot;
@@ -10931,6 +11303,13 @@ let DataGrid = class DataGrid extends LitElement {
10931
11303
  /** Linhas do corpo que cabem na área visível. */
10932
11304
  #pageSize() {
10933
11305
  const scroller = this._scrollContainerRef.value;
11306
+ const port = this.#scrollPort.port;
11307
+ if (port) {
11308
+ // Porta externa (spec 27): a altura da porta menos o que grudaria nela,
11309
+ // quanto do grid estiver à vista agora.
11310
+ const inset = this.#scrollPort.padding();
11311
+ return Math.max(1, Math.floor((port.clientHeight - inset.top - inset.bottom - this.#stickyTop() - this.#stickyBottom()) / this.rowHeight));
11312
+ }
10934
11313
  if (!scroller) {
10935
11314
  return 1;
10936
11315
  }
@@ -11218,7 +11597,7 @@ let DataGrid = class DataGrid extends LitElement {
11218
11597
  this._userGroupColumn(column, this._groupColumns.length);
11219
11598
  // `groupable: false` recusa: nada a anunciar (spec 17).
11220
11599
  if (this._groupColumns.includes(column)) {
11221
- this.#announce(formatMessage(this.#translation.groupedAnnouncement, { column: column.label ?? '' }));
11600
+ this.#announce(formatMessage(this.#translation.groupedAnnouncement, { column: columnText(column) }));
11222
11601
  }
11223
11602
  this.#focusPending = true;
11224
11603
  return true;
@@ -11491,7 +11870,7 @@ let DataGrid = class DataGrid extends LitElement {
11491
11870
  // Posição entre as irmãs visíveis (o `_regularColumns` já tem a ordem nova).
11492
11871
  const visibleAfter = this.#siblingsOf(column).filter(sibling => this._isColumnVisible(sibling));
11493
11872
  this.#announce(formatMessage(this.#translation.columnMovedAnnouncement, {
11494
- column: column.label ?? '',
11873
+ column: columnText(column),
11495
11874
  position: String(visibleAfter.indexOf(column) + 1),
11496
11875
  count: String(visibleAfter.length),
11497
11876
  }));
@@ -11534,7 +11913,7 @@ let DataGrid = class DataGrid extends LitElement {
11534
11913
  /** Novo nível de uma coluna agrupada (Alt+Shift+←/→ no chip ou menu do painel). */
11535
11914
  #announceGroupLevel(column) {
11536
11915
  this.#announce(formatMessage(this.#translation.groupLevelChangedAnnouncement, {
11537
- column: column.label ?? '',
11916
+ column: columnText(column),
11538
11917
  level: String(this._groupColumns.indexOf(column) + 1),
11539
11918
  count: String(this._groupColumns.length),
11540
11919
  }));
@@ -11542,7 +11921,7 @@ let DataGrid = class DataGrid extends LitElement {
11542
11921
  /** Largura da coluna depois de redimensionar pelo cabeçalho (teclado: com espera; menu: na hora). */
11543
11922
  #announceWidth(column, delay) {
11544
11923
  const announce = () => this.#announce(formatMessage(this.#translation.columnResizedAnnouncement, {
11545
- column: column.label ?? '',
11924
+ column: columnText(column),
11546
11925
  width: String(Math.round(this.#widthOf(column) ?? this._boundsOf(column).width)),
11547
11926
  }));
11548
11927
  if (delay) {
@@ -11556,7 +11935,7 @@ let DataGrid = class DataGrid extends LitElement {
11556
11935
  /** Desagrupa pelo teclado (chip ou linha de grupo): anuncia e leva o foco ao cabeçalho da coluna devolvida. */
11557
11936
  #userUngroup(column) {
11558
11937
  this.#moveColumnTo(false, column, this._regularColumns.length, 'user');
11559
- this.#announce(formatMessage(this.#translation.ungroupedAnnouncement, { column: column.label ?? '' }));
11938
+ this.#announce(formatMessage(this.#translation.ungroupedAnnouncement, { column: columnText(column) }));
11560
11939
  // O foco vai ao cabeçalho da coluna devolvida (fim das comuns); sem cabeçalho, a guarda de foco acha a célula ativa.
11561
11940
  void this.updateComplete.then(() => {
11562
11941
  const col = this.#currentNavColumns().indexOf(column);
@@ -11608,12 +11987,13 @@ let DataGrid = class DataGrid extends LitElement {
11608
11987
  const fixedStart = layout.reduce((sum, { headerClasses, width }) => sum + (headerClasses['fixed-start'] ? width ?? 0 : 0), 0);
11609
11988
  // A barra de erro cobre o pé da área de rolagem: o foco não para debaixo dela.
11610
11989
  // `--_fixed-*`: o rótulo da banda prende entre as áreas fixas (frente 13).
11990
+ this.#revealInline = { start: this.#stickyStart() + fixedStart, end: fixedEnd };
11611
11991
  const scrollPadding = `scroll-padding-inline: ${this.#stickyStart() + fixedStart}px ${fixedEnd}px;`
11612
11992
  + ` --_fixed-start: ${this.#stickyStart() + fixedStart}px; --_fixed-end: ${fixedEnd}px;`
11613
11993
  + (this.#dataSource && this.#loader.error ? ' scroll-padding-block-end: 56px;' : '');
11614
11994
  // Coluna flex: a área do grid e o pager (que pode quebrar linha) dividem a altura.
11615
11995
  return html `
11616
- <div class=${waiting ? 'layout state-loading' : 'layout'}>
11996
+ <div class=${`layout${waiting ? ' state-loading' : ''}${this.#scrollPort.external ? ' external-scroll' : ''}`} ${ref(this.#layoutRef)}>
11617
11997
  <div
11618
11998
  class="container ${classMap(classes)}"
11619
11999
  ${ref(this._containerRef)}>
@@ -11681,7 +12061,8 @@ let DataGrid = class DataGrid extends LitElement {
11681
12061
  }
11682
12062
  /**
11683
12063
  * `fill`: todas as larguras definidas — a última coluna leva a sobra da
11684
- * largura visível (`--_viewport-inline-size`, medida no `ResizeObserver`),
12064
+ * largura do grid (`--_fill-inline-size`, medida no `ResizeObserver`; com a
12065
+ * porta externa, a do grid — não a parte visível, que muda na rolagem),
11685
12066
  * sem ler o DOM no render: as outras colunas entram na conta pelos px e
11686
12067
  * pelas larguras do CSS (recuos, expansão, caixas, comandos).
11687
12068
  */
@@ -11703,7 +12084,7 @@ let DataGrid = class DataGrid extends LitElement {
11703
12084
  ...this.#showCommandColumn ? ['var(--_command-column-width)'] : [],
11704
12085
  ].join(' - ');
11705
12086
  const own = widthOf(last.column) ?? 0;
11706
- fillWidth = `max(${own}px, var(--_viewport-inline-size, 0px) - ${reserved})`;
12087
+ fillWidth = `max(${own}px, var(--_fill-inline-size, 0px) - ${reserved})`;
11707
12088
  }
11708
12089
  return html `
11709
12090
  ${map(this._groupColumns, () => html `
@@ -11950,15 +12331,15 @@ let DataGrid = class DataGrid extends LitElement {
11950
12331
  }
11951
12332
  }
11952
12333
  : undefined,
11953
- trailing: cell.resizable ? this.#renderResizeHandle(cell) : nothing,
12334
+ trailing: cell.resizable ? this.#renderResizeHandle(cell, idSuffix) : nothing,
11954
12335
  filterButton: this.headerFilter && isColumnFilterable(column)
11955
- ? renderHeaderFilterButton(this.#headerFilterPopover, column, filterValue, this.#translation, `header-description-${idSuffix}`)
12336
+ ? renderHeaderFilterButton(this.#headerFilterPopover, column, filterValue, this.#translation, `header-description-${idSuffix}`, idSuffix, this.#textLanguage)
11956
12337
  : nothing,
11957
- menuButton: this.#renderColumnMenuButton(column),
12338
+ menuButton: this.#renderColumnMenuButton(column, idSuffix),
11958
12339
  filtered: hasColumnCondition(filterValue, column),
11959
12340
  description: this.#headerDescription(column, rowSorting[position]?.order, position + 1, showIndex, hasColumnCondition(filterValue, column)),
11960
12341
  keyShortcuts: this.#headerKeyShortcuts(column, cell.resizable),
11961
- label: column.headerRenderer ? this.#renderHeaderContent(column, cell.id) : column.label,
12342
+ label: column.headerRenderer ? this.#renderHeaderContent(column, cell.id) : headerText(column),
11962
12343
  });
11963
12344
  }
11964
12345
  /** Banda: `colspan` = posições renderizadas sob ela; fixa como as filhas. */
@@ -12006,7 +12387,7 @@ let DataGrid = class DataGrid extends LitElement {
12006
12387
  // F2 só leva a algum lugar com conteúdo do \`headerRenderer\` (o botão "⋮" saiu: menu de contexto).
12007
12388
  ...column.headerRenderer ? ['F2'] : [],
12008
12389
  ].join(' '),
12009
- label: column.headerRenderer ? this.#renderHeaderContent(column, id) : column.label,
12390
+ label: column.headerRenderer ? this.#renderHeaderContent(column, id) : headerText(column),
12010
12391
  });
12011
12392
  }
12012
12393
  /**
@@ -12068,7 +12449,7 @@ let DataGrid = class DataGrid extends LitElement {
12068
12449
  * com o rótulo da coluna no idioma do conteúdo. Fora do `.header-text`: o
12069
12450
  * nome do `columnheader` não o inclui.
12070
12451
  */
12071
- #renderColumnMenuButton(column) {
12452
+ #renderColumnMenuButton(column, idSuffix) {
12072
12453
  if (!this.#showsColumnMenuButton(column)) {
12073
12454
  return nothing;
12074
12455
  }
@@ -12076,8 +12457,9 @@ let DataGrid = class DataGrid extends LitElement {
12076
12457
  const at = template.indexOf('{column}');
12077
12458
  const before = at >= 0 ? template.slice(0, at) : template;
12078
12459
  const after = at >= 0 ? template.slice(at + '{column}'.length) : '';
12079
- const columnLabel = column.label ?? '';
12460
+ const columnLabel = columnText(column);
12080
12461
  const open = this.#contextMenuOpenFor('header', column);
12462
+ const named = column.headerRenderer ? labelledByHeader(template, 'header-menu-name', idSuffix) : undefined;
12081
12463
  const openMenu = (button, focusLast) => {
12082
12464
  this.#openHeaderMenu(column, button.closest('th'), { opener: button, focusLast }, null);
12083
12465
  };
@@ -12088,7 +12470,9 @@ let DataGrid = class DataGrid extends LitElement {
12088
12470
  tabindex="-1"
12089
12471
  aria-haspopup="menu"
12090
12472
  aria-expanded=${open ? 'true' : 'false'}
12091
- title=${formatMessage(template, { column: columnLabel })}
12473
+ aria-labelledby=${ifDefined(named?.labelledBy)}
12474
+ lang=${ifDefined(named ? this.#textLanguage : undefined)}
12475
+ title=${ifDefined(named && !column.label ? undefined : formatMessage(template, { column: columnLabel }))}
12092
12476
  @pointerdown=${(event) => {
12093
12477
  // Não ordena nem começa a seleção de intervalo pelo cabeçalho.
12094
12478
  event.stopPropagation();
@@ -12117,17 +12501,20 @@ let DataGrid = class DataGrid extends LitElement {
12117
12501
  openMenu(event.currentTarget, event.key === 'ArrowUp');
12118
12502
  }
12119
12503
  }
12120
- }}><span
12504
+ }}>${named?.parts ?? html `<span
12121
12505
  class="visually-hidden"
12122
- lang=${this.#textLanguage}>${before}<span lang=${this.#contentLanguage}>${columnLabel}</span>${after}</span></button>`;
12506
+ lang=${this.#textLanguage}>${before}<span lang=${this.#contentLanguage}>${columnLabel}</span>${after}</span>`}</button>`;
12123
12507
  }
12124
- #renderResizeHandle({ column, bounds, width }) {
12508
+ #renderResizeHandle({ column, bounds, width }, idSuffix) {
12509
+ const named = column.headerRenderer ? labelledByHeader(this.#translation.resizeHandleLabel, 'resize-handle-name', idSuffix) : undefined;
12125
12510
  // Fora da ordem de Tab (o grid tem um ponto só): F2 no cabeçalho chega aqui, Esc volta.
12126
12511
  return html `<div
12127
12512
  class="resize-handle"
12128
12513
  role="separator"
12129
12514
  aria-orientation="vertical"
12130
- aria-label=${formatMessage(this.#translation.resizeHandleLabel, { column: column.label ?? '' })}
12515
+ aria-label=${ifDefined(named ? undefined : formatMessage(this.#translation.resizeHandleLabel, { column: columnText(column) }))}
12516
+ aria-labelledby=${ifDefined(named?.labelledBy)}
12517
+ lang=${this.#textLanguage}
12131
12518
  aria-valuenow=${ifDefined(width === undefined ? undefined : Math.round(width))}
12132
12519
  aria-valuemin=${bounds.min}
12133
12520
  aria-valuemax=${ifDefined(Number.isFinite(bounds.max) ? bounds.max : undefined)}
@@ -12151,7 +12538,7 @@ let DataGrid = class DataGrid extends LitElement {
12151
12538
  else {
12152
12539
  this.#resize.keyDown(event, column, false);
12153
12540
  }
12154
- }}></div>`;
12541
+ }}>${named?.parts ?? nothing}</div>`;
12155
12542
  }
12156
12543
  #renderBody(window, headerRows, layout) {
12157
12544
  if (!this.#rows.length) {
@@ -12534,7 +12921,7 @@ let DataGrid = class DataGrid extends LitElement {
12534
12921
  const id = columnIdOf(column);
12535
12922
  const labelId = `adaptive-${index}-${id}`;
12536
12923
  const textId = `${labelId}-value`;
12537
- const bands = this._bandChainOf(column).map(band => band.label ?? '')
12924
+ const bands = this._bandChainOf(column).map(band => columnText(band))
12538
12925
  .filter(Boolean);
12539
12926
  const sortPosition = sorting.findIndex(spec => spec.column === column);
12540
12927
  const order = sorting[sortPosition]?.order;
@@ -12570,7 +12957,7 @@ let DataGrid = class DataGrid extends LitElement {
12570
12957
  return html `<div class="adaptive-field" part="adaptive-field"><dt
12571
12958
  class="adaptive-label"
12572
12959
  part="adaptive-label"
12573
- id=${labelId}>${bands.length ? html `<span class="adaptive-band">${bands.join(' ')}</span> ` : nothing}<span class="adaptive-label-text">${column.label ?? ''}</span>${order
12960
+ id=${labelId}>${bands.length ? html `<span class="adaptive-band">${bands.join(' ')}</span> ` : nothing}<span class="adaptive-label-text">${columnText(column)}</span>${order
12574
12961
  ? html `${adaptiveMark(`adaptive-sort ${order}`, SORT_ARROW_PATH)}<span class="visually-hidden"> ${sortText}</span>`
12575
12962
  : nothing}${filtered
12576
12963
  ? html `${adaptiveMark('adaptive-filter', FILTER_MARK_PATH)}<span class="visually-hidden"> ${translation.columnFiltered}</span>`
@@ -12610,7 +12997,7 @@ let DataGrid = class DataGrid extends LitElement {
12610
12997
  }
12611
12998
  const modified = pending.type !== 'add' && adaptive.some(column => pending.modified.has(column));
12612
12999
  const invalid = adaptive.find(column => pending.errors.has(column));
12613
- const error = invalid ? `${invalid.label ?? ''}: ${pending.errors.get(invalid)}` : '';
13000
+ const error = invalid ? `${columnText(invalid)}: ${pending.errors.get(invalid)}` : '';
12614
13001
  return modified || error ? { modified, error } : undefined;
12615
13002
  }
12616
13003
  /** Layout de célula de uma coluna oculta por espaço (render do valor e do editor na linha adaptativa). */
@@ -12750,7 +13137,7 @@ let DataGrid = class DataGrid extends LitElement {
12750
13137
  #renderTotalFooter(layout, ariaRowIndex) {
12751
13138
  const rowIndex = this.#rows.length;
12752
13139
  return renderTotalFooter({
12753
- layout: this.#summaryLayout(layout),
13140
+ layout,
12754
13141
  texts: this.#textsByColumn(this.#totalSpecs, this.#totals, () => true),
12755
13142
  groupColumns: this._groupColumns.length,
12756
13143
  groupColumnWidth: GROUP_COLUMN_WIDTH,
@@ -13017,7 +13404,7 @@ let DataGrid = class DataGrid extends LitElement {
13017
13404
  const parts = pending.rowError ? [pending.rowError] : [];
13018
13405
  for (const [column, message] of pending.errors) {
13019
13406
  if (!this._visibleColumns.includes(column)) {
13020
- parts.push(`${column.label ?? ''}: ${message}`);
13407
+ parts.push(`${columnText(column)}: ${message}`);
13021
13408
  }
13022
13409
  }
13023
13410
  return parts.join(' ');
@@ -13029,7 +13416,7 @@ let DataGrid = class DataGrid extends LitElement {
13029
13416
  const current = editor.drafts.has(column)
13030
13417
  ? editor.drafts.get(column)
13031
13418
  : pending ? this.#pendingValue(pending, column) : getCellValue(row.item, column);
13032
- const label = column.label ?? '';
13419
+ const label = columnText(column);
13033
13420
  const error = pending?.errors.get(column) ?? '';
13034
13421
  const renderer = column.editorRenderer;
13035
13422
  if (renderer) {
@@ -14125,13 +14512,13 @@ let DataGrid = class DataGrid extends LitElement {
14125
14512
  aria-haspopup=${ifDefined(opensMenu ? 'menu' : undefined)}
14126
14513
  aria-expanded=${ifDefined(opensMenu ? this.#contextMenuOpenFor('group-panel', column) ? 'true' : 'false' : undefined)}
14127
14514
  aria-keyshortcuts=${`${menu && sortable ? 'Shift+F10 ' : ''}Alt+Shift+ArrowLeft Alt+Shift+ArrowRight Delete Control+G Meta+G`}
14128
- aria-label=${sortable ? `${column.label ?? ''}, ${order === 'asc' ? translation.sortAscending : translation.sortDescending}` : column.label ?? ''}
14515
+ aria-label=${sortable ? `${columnText(column)}, ${order === 'asc' ? translation.sortAscending : translation.sortDescending}` : columnText(column)}
14129
14516
  @pointerdown=${sortable ? this.#onSortPointerDown : nothing}
14130
14517
  @click=${sortable
14131
14518
  ? (event) => this.#onGroupChipActivate(column, event)
14132
14519
  : opensMenu ? (event) => this.#onMenuChipClick(column, event) : nothing}
14133
14520
  @keydown=${(event) => this.#onChipKeyDown(column, index, event)}>
14134
- <span class="group-label">${column.label}</span>${renderSortIndicator(order)}
14521
+ <span class="group-label">${columnText(column)}</span>${renderSortIndicator(order)}
14135
14522
  </div>`;
14136
14523
  }
14137
14524
  /** Clique no chip que é botão de menu (não ordenável): abre/fecha o menu do painel. */
@@ -14425,7 +14812,7 @@ let DataGrid = class DataGrid extends LitElement {
14425
14812
  return [
14426
14813
  ...index >= 0
14427
14814
  ? [
14428
- { name: 'ungroupColumn', text: translation.ungroupColumn, hiddenSuffix: column.label ?? '' },
14815
+ { name: 'ungroupColumn', text: translation.ungroupColumn, hiddenSuffix: columnText(column) },
14429
14816
  { name: 'moveLeft', text: translation.moveLeft, disabled: !towardLeft },
14430
14817
  { name: 'moveRight', text: translation.moveRight, disabled: !towardRight },
14431
14818
  ]
@@ -14604,7 +14991,7 @@ let DataGrid = class DataGrid extends LitElement {
14604
14991
  row.expanded ? { name: 'collapseGroup', text: translation.collapseGroup } : { name: 'expandGroup', text: translation.expandGroup },
14605
14992
  { name: 'expandAllGroups', text: translation.expandAllGroups },
14606
14993
  { name: 'collapseAllGroups', text: translation.collapseAllGroups },
14607
- { name: 'ungroupColumn', text: translation.ungroupColumn, hiddenSuffix: row.column.label ?? '', separatorBefore: true },
14994
+ { name: 'ungroupColumn', text: translation.ungroupColumn, hiddenSuffix: columnText(row.column), separatorBefore: true },
14608
14995
  ];
14609
14996
  }
14610
14997
  #renderContextMenu() {
@@ -14647,7 +15034,7 @@ let DataGrid = class DataGrid extends LitElement {
14647
15034
  let kind;
14648
15035
  switch (request.target) {
14649
15036
  case 'header':
14650
- label = formatMessage(translation.columnHeaderMenuLabel, { column: request.column?.label ?? '' });
15037
+ label = formatMessage(translation.columnHeaderMenuLabel, { column: request.column ? columnText(request.column) : '' });
14651
15038
  kind = 'column-header-menu';
14652
15039
  break;
14653
15040
  case 'group-panel':
@@ -14834,7 +15221,7 @@ let DataGrid = class DataGrid extends LitElement {
14834
15221
  menu.hide();
14835
15222
  this._userGroupColumn(column, this._groupColumns.length);
14836
15223
  if (this._groupColumns.includes(column)) {
14837
- this.#announce(formatMessage(this.#translation.groupedAnnouncement, { column: column.label ?? '' }));
15224
+ this.#announce(formatMessage(this.#translation.groupedAnnouncement, { column: columnText(column) }));
14838
15225
  }
14839
15226
  this.#focusPending = true;
14840
15227
  break;
@@ -14897,7 +15284,7 @@ let DataGrid = class DataGrid extends LitElement {
14897
15284
  }
14898
15285
  const translation = this.#translation;
14899
15286
  const message = fixed === 'start' ? translation.columnFixedStartAnnouncement : fixed === 'end' ? translation.columnFixedEndAnnouncement : translation.columnUnfixedAnnouncement;
14900
- this.#announce(formatMessage(message, { column: column.label ?? '' }));
15287
+ this.#announce(formatMessage(message, { column: columnText(column) }));
14901
15288
  }
14902
15289
  #runGroupPanelMenuItem(name, column) {
14903
15290
  const menu = this.#contextMenu;
@@ -14924,7 +15311,7 @@ let DataGrid = class DataGrid extends LitElement {
14924
15311
  case 'ungroupColumn':
14925
15312
  if (column && this._groupColumns.includes(column)) {
14926
15313
  this.#moveColumnTo(false, column, this._regularColumns.length, 'user');
14927
- this.#announce(formatMessage(this.#translation.ungroupedAnnouncement, { column: column.label ?? '' }));
15314
+ this.#announce(formatMessage(this.#translation.ungroupedAnnouncement, { column: columnText(column) }));
14928
15315
  }
14929
15316
  break;
14930
15317
  case 'ungroupAll':
@@ -15279,7 +15666,7 @@ let DataGrid = class DataGrid extends LitElement {
15279
15666
  if (!this._canDropColumn(column, target)) {
15280
15667
  // Recusado (fixa × livre, outra banda): pelo teclado, diz por que nada mudou (WCAG 4.1.3).
15281
15668
  if (keyboard) {
15282
- this.#announce(formatMessage(this.#translation.columnMoveRefusedAnnouncement, { column: column.label ?? '', target: target.label ?? '' }));
15669
+ this.#announce(formatMessage(this.#translation.columnMoveRefusedAnnouncement, { column: columnText(column), target: columnText(target) }));
15283
15670
  }
15284
15671
  return false;
15285
15672
  }
@@ -15292,7 +15679,7 @@ let DataGrid = class DataGrid extends LitElement {
15292
15679
  const listed = orderedSiblings(this._regularColumns, this.#columnTree, this._parentBandOf(column) ?? null)
15293
15680
  .filter(sibling => sibling.showInChooser !== false);
15294
15681
  this.#announce(formatMessage(this.#translation.columnMovedAnnouncement, {
15295
- column: column.label ?? '',
15682
+ column: columnText(column),
15296
15683
  position: String(listed.indexOf(column) + 1),
15297
15684
  count: String(listed.length),
15298
15685
  }));
@@ -15416,6 +15803,12 @@ __decorate([
15416
15803
  __decorate([
15417
15804
  property({ attribute: 'scroll-mode' })
15418
15805
  ], DataGrid.prototype, "scrollMode", void 0);
15806
+ __decorate([
15807
+ property({ attribute: 'scroll-container' })
15808
+ ], DataGrid.prototype, "scrollContainer", void 0);
15809
+ __decorate([
15810
+ property({ attribute: false })
15811
+ ], DataGrid.prototype, "scrollContainerElement", void 0);
15419
15812
  __decorate([
15420
15813
  property({ attribute: false })
15421
15814
  ], DataGrid.prototype, "items", null);