@universal-material/data-grid 0.2.0 → 0.3.1

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 (45) hide show
  1. package/README.md +1 -1
  2. package/custom-elements.json +118 -15
  3. package/dist/data/data-source.d.ts +6 -2
  4. package/dist/data/data-source.js.map +1 -1
  5. package/dist/export-xlsx/index.d.ts +2 -1
  6. package/dist/export-xlsx/index.js +4 -2
  7. package/dist/export-xlsx/index.js.map +1 -1
  8. package/dist/features/column-chooser.js +1 -1
  9. package/dist/features/column-chooser.js.map +1 -1
  10. package/dist/features/filter-row.d.ts +1 -0
  11. package/dist/features/filter-row.js +13 -8
  12. package/dist/features/filter-row.js.map +1 -1
  13. package/dist/features/header-filter.d.ts +4 -1
  14. package/dist/features/header-filter.js +7 -5
  15. package/dist/features/header-filter.js.map +1 -1
  16. package/dist/features/scroll-port.d.ts +7 -0
  17. package/dist/features/scroll-port.js +22 -0
  18. package/dist/features/scroll-port.js.map +1 -1
  19. package/dist/grid-column-def.d.ts +45 -11
  20. package/dist/grid-column-def.js +6 -2
  21. package/dist/grid-column-def.js.map +1 -1
  22. package/dist/grid-column.d.ts +23 -5
  23. package/dist/grid-column.js +32 -5
  24. package/dist/grid-column.js.map +1 -1
  25. package/dist/grid-i18n.js +14 -14
  26. package/dist/grid-i18n.js.map +1 -1
  27. package/dist/grid.d.ts +36 -10
  28. package/dist/grid.js +298 -56
  29. package/dist/grid.js.map +1 -1
  30. package/dist/grid.min.js +445 -387
  31. package/dist/grid.styles.js +60 -5
  32. package/dist/grid.styles.js.map +1 -1
  33. package/dist/render/cell.js +5 -2
  34. package/dist/render/cell.js.map +1 -1
  35. package/dist/row-model/columns.d.ts +21 -3
  36. package/dist/row-model/columns.js +14 -4
  37. package/dist/row-model/columns.js.map +1 -1
  38. package/dist/row-model/filter.d.ts +19 -4
  39. package/dist/row-model/filter.js +29 -9
  40. package/dist/row-model/filter.js.map +1 -1
  41. package/dist/row-model/format.js +1 -1
  42. package/dist/row-model/format.js.map +1 -1
  43. package/dist/state/grid-state.d.ts +2 -2
  44. package/dist/state/grid-state.js.map +1 -1
  45. package/package.json +1 -1
package/dist/grid.js CHANGED
@@ -52,7 +52,7 @@ import { keyedRows } from './render/keyed-rows.js';
52
52
  import { RowVirtualizer } from './render/virtualizer.js';
53
53
  import { RowsWithAdded } from './row-model/added-rows.js';
54
54
  import { cellRangeEdges, countCells, isSingleCell, parseTsv, pasteSize, rectOf, rowBands, sameCorners, unescapePasted, } from './row-model/cell-range.js';
55
- import { ancestorsOf, buildColumnTree, buildHeaderRows, columnText, headerText, headerCellAt, moveAmongSiblings, normalizeLeafOrder, orderedSiblings, rootOf, } from './row-model/columns.js';
55
+ import { ancestorsOf, buildColumnTree, booleanTexts, buildHeaderRows, columnText, headerText, headerCellAt, moveAmongSiblings, normalizeLeafOrder, orderedSiblings, rootOf, } from './row-model/columns.js';
56
56
  import { createComparer } from './row-model/compare.js';
57
57
  import { distinctValues } from './row-model/distinct.js';
58
58
  import { allValuesConvert, applyMask, combineFilters, compileFilter, filterItems, hasColumnCondition, replaceColumnCondition, searchExpression, } from './row-model/filter.js';
@@ -461,6 +461,8 @@ const detailOrMaster = (rows, key, keyOf) => {
461
461
  };
462
462
  /** Linha de detalhe (master-detail). */
463
463
  const isDetailRow = (row) => !!row && !!row.isDetail;
464
+ /** Linhas de esqueleto do `loading` antes de medir a altura (servidor e 1º render). */
465
+ const LOADING_PLACEHOLDER_ROWS = 10;
464
466
  /** `rowRenderer` que já lançou ou devolveu valor inválido (um `console.error` por função). */
465
467
  const reportedRowRenderers = new WeakSet();
466
468
  const isRenderResult = (value) => value === null || value === undefined || value === nothing || typeof value === 'string'
@@ -535,10 +537,12 @@ const isRenderResult = (value) => value === null || value === undefined || value
535
537
  * @cssprop --u-grid-toolbar-padding - Padding of the bar. Default `8px 16px`.
536
538
  * @cssprop --u-grid-toolbar-block-padding - Block padding of the bar. Default `8px`.
537
539
  * @cssprop --u-grid-toolbar-inline-padding - Inline padding of the bar. Default: the cell inline padding.
538
- * @cssprop --u-grid-header-cell-height - Height of the column header cells. Default `46px`.
540
+ * @cssprop --u-grid-toolbar-gap - Space between the bar items and between its lines (a `gap` value). Default `8px`. A change at runtime applies at the next toolbar layout (resize or item change).
541
+ * @cssprop --u-grid-header-cell-height - Minimum height of the column header cells (rows with `header-wrap` grow). Default `46px`.
539
542
  * @cssprop --u-grid-header-cell-padding - Header cell padding.
540
543
  * @cssprop --u-grid-header-cell-font-size - Header cell font size. Default `0.8125rem`.
541
544
  * @cssprop --u-grid-header-cell-font-weight - Header cell font weight.
545
+ * @cssprop --u-grid-header-cell-max-lines - With `header-wrap`, max lines of the default header label (ellipsis on the last). Integer or `none` (default).
542
546
  * @cssprop --u-grid-cell-padding - Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.
543
547
  * @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
548
  * @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`.
@@ -570,8 +574,8 @@ const isRenderResult = (value) => value === null || value === undefined || value
570
574
  * @cssprop --u-grid-sort-indicator-size - Size of the sort arrow. Default `1.125em`.
571
575
  * @cssprop --u-grid-drop-indicator-color - Drag-and-drop drop indicator color.
572
576
  * @cssprop --u-grid-drop-indicator-width - Drop indicator thickness. Default `3px`.
573
- * @cssprop --u-grid-resize-handle-width - Invisible resize hit area at the end of each header cell (over the end padding, capped to it; the cursor changes on hover). Default `8px`.
574
- * @cssprop --u-grid-column-header-menu-button-size - Size of the "⋮" column header menu button and of the header filter button. Default `24px` (WCAG 2.5.8).
577
+ * @cssprop --u-grid-resize-handle-width - Invisible resize area at the end of each header cell, over its end padding (the header buttons reach up to it). Default `8px`.
578
+ * @cssprop --u-grid-column-header-menu-button-size - Size of the header "⋮" and filter buttons, side by side. Default `24px` (WCAG 2.5.8; below it, add spacing).
575
579
  * @cssprop --u-grid-resize-handle-color - Color of the separator shown at the column edge while dragging to resize. Default: `--u-grid-drop-indicator-color`.
576
580
  * @cssprop --u-grid-fixed-shadow-color - Shadow at the edge of fixed columns while scrolling.
577
581
  * @cssprop --u-grid-column-chooser-background-color - Column chooser background.
@@ -587,7 +591,7 @@ const isRenderResult = (value) => value === null || value === undefined || value
587
591
  * @cssprop --u-grid-header-filter-background-color - Header filter popover background.
588
592
  * @cssprop --u-grid-header-filter-shape - Header filter popover corner radius. Default `12px`.
589
593
  * @cssprop --u-grid-load-panel-background-color - Background of the load panel.
590
- * @cssprop --u-grid-skeleton-row-color - Color of the placeholders in rows still loading.
594
+ * @cssprop --u-grid-skeleton-row-color - Color of the placeholders in rows still loading (remote rows, or `loading` with no rows).
591
595
  * @cssprop --u-grid-pager-height - Minimum height of the pager. Default `56px`.
592
596
  * @cssprop --u-grid-modified-cell-background-color - Background of edited, unsaved cells (`editMode="batch"`). Default: primary color at 10%.
593
597
  * @cssprop --u-grid-modified-cell-indicator-color - Corner mark of edited, unsaved cells (not shown by color alone). Default: primary color.
@@ -610,7 +614,7 @@ const isRenderResult = (value) => value === null || value === undefined || value
610
614
  * @csspart cell - Data cells (`<td>`).
611
615
  * @csspart selection-cell - Cells and header of the selection checkbox column.
612
616
  * @csspart selection-checkbox - The selection checkboxes (rows and "select all").
613
- * @csspart no-data - The cell rendered in the empty state.
617
+ * @csspart no-data - The cell rendered in the empty state, or the "Loading…" cell while `loading` has no rows.
614
618
  * @csspart header-cell - Column header cells (`<th>`), bands included.
615
619
  * @csspart band-header-cell - Band header cells (multi-level headers); they also match `header-cell`.
616
620
  * @csspart sort-indicator - The sort arrow (and priority number) in headers and group chips.
@@ -666,8 +670,8 @@ const isRenderResult = (value) => value === null || value === undefined || value
666
670
  * @csspart pager-button - Pager buttons (first, previous, page numbers, next, last).
667
671
  * @csspart page-size-select - The page size `<select>` of the pager.
668
672
  * @csspart page-info - The "Page x of y (n items)" text of the pager.
669
- * @csspart load-panel - The load panel shown while a data source loads.
670
- * @csspart skeleton-row - Rows of a remote source not loaded yet (with `row`).
673
+ * @csspart load-panel - The load panel shown while a data source loads or `loading` is set (with rows).
674
+ * @csspart skeleton-row - Rows of a remote source not loaded yet (with `row`), or placeholder rows while `loading` has no rows.
671
675
  * @csspart error-row - The bar shown when the data source failed.
672
676
  * @csspart retry-button - The "Retry" button of the error bar.
673
677
  * @csspart search-highlight - Search matches (`<mark>`) in native cells (not in `renderer` cells).
@@ -703,6 +707,30 @@ let DataGrid = class DataGrid extends LitElement {
703
707
  * the translated "No data" text.
704
708
  */
705
709
  this.noDataRenderer = null;
710
+ /**
711
+ * Shows the grid as loading, for `items` you are still fetching. With rows
712
+ * on screen, the load panel (`::part(load-panel)`) covers them; with no rows
713
+ * yet, a "Loading…" row and placeholder rows (`::part(skeleton-row)`) take
714
+ * the place of the empty state (`noDataRenderer` is not called). Placeholder
715
+ * rows are never data: not exported, selected, counted or focusable by API.
716
+ * Does not fire `u-grid-loading`/`u-grid-load`; with `dataSource`, it adds
717
+ * to the source's own loading state (the getter returns only what you set).
718
+ */
719
+ this.loading = false;
720
+ /**
721
+ * Wraps the column header labels in several lines instead of an ellipsis
722
+ * (the header row grows; `--u-grid-header-cell-height` is its minimum). It
723
+ * breaks only between words (hyphenation follows the `lang`); a word longer
724
+ * than the column ends in an ellipsis, and `--u-grid-header-cell-max-lines`
725
+ * limits the lines. A cut default label shows its full text as a tooltip on
726
+ * hover; from the keyboard, widen the column (Alt+→) or auto-size it from
727
+ * the header menu. A column's `headerWrap` wins. Auto-size measures the
728
+ * label in one line. If the toolbar and the headers take more than half of
729
+ * the visible height, the headers stop sticking (WCAG 2.4.11).
730
+ */
731
+ this.headerWrap = false;
732
+ /** Linhas de esqueleto do `loading` sem linhas: fixo no servidor e no 1º render (hidratação); depois, o que cabe. */
733
+ this.#placeholderRows = LOADING_PLACEHOLDER_ROWS;
706
734
  /**
707
735
  * Builds the detail of a row (master-detail; property only). With it, a
708
736
  * toggle column appears at the start and each expanded row is followed by
@@ -800,6 +828,8 @@ let DataGrid = class DataGrid extends LitElement {
800
828
  this.#refreshCount = 0;
801
829
  this.#remoteVersion = -1;
802
830
  this.#loadingAnnounced = false;
831
+ /** O "Carregando…" anunciado veio do \`loading\` (o fim é anunciado; a espera do estado não). */
832
+ this.#loadingByProperty = false;
803
833
  this.#warnedColumns = new Set();
804
834
  // ------------------------------------------------------- árvore (frente 25)
805
835
  /**
@@ -1368,6 +1398,19 @@ let DataGrid = class DataGrid extends LitElement {
1368
1398
  /** Barra (painel de grupos, busca, seletor) observada para a altura que prende o cabeçalho. */
1369
1399
  this.#observedToolbar = null;
1370
1400
  this.#toolbarRef = createRef();
1401
+ /**
1402
+ * Fontes carregadas depois da medida (relato de uso: "Obrigatório" medido
1403
+ * com a fonte de reserva e cortado 1px quando a Lato chegou): as larguras
1404
+ * automáticas são medidas de novo; as do usuário e as definidas ficam.
1405
+ */
1406
+ this.#onFontsLoaded = () => {
1407
+ if (!this.columnAutoWidth) {
1408
+ return;
1409
+ }
1410
+ this.#autoWidthDirty = true;
1411
+ this.#layoutDirty = true;
1412
+ this.requestUpdate();
1413
+ };
1371
1414
  /**
1372
1415
  * Linhas de detalhe de um bloco de itens: posições dos itens cuja expansão
1373
1416
  * difere do padrão. Poucas chaves sem `keyExpr`: `indexOf` por chave
@@ -1605,6 +1648,27 @@ let DataGrid = class DataGrid extends LitElement {
1605
1648
  this.#warnedInfinitePaging = false;
1606
1649
  /** 1ª linha da última janela renderizada (o 1º pedido de uma consulta nova já traz o bloco dela). */
1607
1650
  this.#lastWindowFirst = 0;
1651
+ /** Coluna do campo de uma condição: `path`, depois `name` de coluna sem `path` (o mesmo do avaliador). */
1652
+ this.#resolveFilterField = field => {
1653
+ if (!this.#filterFields) {
1654
+ const index = new Map();
1655
+ const leaves = this.#columnTree.leaves;
1656
+ for (const column of leaves) {
1657
+ if (column.path && !index.has(column.path)) {
1658
+ index.set(column.path, column);
1659
+ }
1660
+ }
1661
+ for (const column of leaves) {
1662
+ if (!column.path && column.name && !index.has(column.name)) {
1663
+ index.set(column.name, column);
1664
+ }
1665
+ }
1666
+ this.#filterFields = index;
1667
+ }
1668
+ return this.#filterFields.get(field);
1669
+ };
1670
+ /** Colunas já avisadas por `filterable: true` sem efeito (uma vez por coluna). */
1671
+ this.#warnedFilterable = new WeakSet();
1608
1672
  this.#canSortByUser = (column) => this.#sortingMode !== 'none' && isColumnSortable(column);
1609
1673
  this.#onSortPointerDown = () => {
1610
1674
  this.#dragged = false;
@@ -1634,7 +1698,21 @@ let DataGrid = class DataGrid extends LitElement {
1634
1698
  * ao passar o mouse — medir todas as células a cada render custaria caro.
1635
1699
  */
1636
1700
  this.#updateCellHint = (event) => {
1637
- const cell = event.target?.closest?.('td.truncate');
1701
+ const target = event.target;
1702
+ // Rótulo do cabeçalho cortado (reticências, palavra longa ou limite de linhas): a dica tem o texto
1703
+ // inteiro — só no rótulo padrão (\`headerRenderer\` cuida do próprio conteúdo). Conforto de mouse:
1704
+ // pelo teclado, o rótulo inteiro se lê alargando a coluna ou pelo autoajuste (spec 17).
1705
+ const label = target?.closest?.('th .header-text');
1706
+ if (label instanceof HTMLElement && !label.firstElementChild) {
1707
+ if (label.scrollWidth > label.clientWidth || label.scrollHeight > label.clientHeight) {
1708
+ label.title = label.textContent.trim();
1709
+ }
1710
+ else {
1711
+ label.removeAttribute('title');
1712
+ }
1713
+ return;
1714
+ }
1715
+ const cell = target?.closest?.('td.truncate');
1638
1716
  if (!(cell instanceof HTMLElement)) {
1639
1717
  return;
1640
1718
  }
@@ -2107,6 +2185,8 @@ let DataGrid = class DataGrid extends LitElement {
2107
2185
  this.#summaryDirty = true;
2108
2186
  }
2109
2187
  #summary;
2188
+ /** Linhas de esqueleto do `loading` sem linhas: fixo no servidor e no 1º render (hidratação); depois, o que cabe. */
2189
+ #placeholderRows;
2110
2190
  /**
2111
2191
  * Rows fixed ("pinned") right below the column headers (property only):
2112
2192
  * the host's own items, rendered with the grid columns (formatting, cell
@@ -2333,6 +2413,8 @@ let DataGrid = class DataGrid extends LitElement {
2333
2413
  #flushTimer;
2334
2414
  #loadingTimer;
2335
2415
  #loadingAnnounced;
2416
+ /** O "Carregando…" anunciado veio do \`loading\` (o fim é anunciado; a espera do estado não). */
2417
+ #loadingByProperty;
2336
2418
  #warnedColumns;
2337
2419
  /** Fonte remota com linhas sob demanda (paginação ou agrupamento no servidor). */
2338
2420
  get #lazy() {
@@ -3367,8 +3449,9 @@ let DataGrid = class DataGrid extends LitElement {
3367
3449
  * Column filter (property only): a serializable expression such as
3368
3450
  * `[['age', '>', 30], 'and', ['name', 'contains', 'an']]`. The filter row
3369
3451
  * and the header filter read and write it, so it always holds the current
3370
- * filter. The grid keeps a frozen copy (never the host array). Setting it
3371
- * does not fire `u-grid-filter-change`.
3452
+ * filter. A condition refers to its column by `path` or, for a computed
3453
+ * column (`valueGetter` without `path`), by `name`. The grid keeps a frozen
3454
+ * copy (never the host array). Setting it does not fire `u-grid-filter-change`.
3372
3455
  */
3373
3456
  get filterValue() {
3374
3457
  return this.#filtering.filterValue;
@@ -4272,7 +4355,8 @@ let DataGrid = class DataGrid extends LitElement {
4272
4355
  const table = this.#tableRef.value;
4273
4356
  const observer = this.#resizeObserver;
4274
4357
  const wanted = new Set();
4275
- if (table && observer && (this.#fixedTopItems.length || this.#fixedBottomItems.length)) {
4358
+ if (table && observer && (this.#fixedTopItems.length || this.#fixedBottomItems.length || this.#anyHeaderWrap)) {
4359
+ // Rótulos que quebram linha: a altura do cabeçalho muda sem o host mudar (zoom de texto, largura).
4276
4360
  for (const element of [table.tHead, table.tFoot, ...table.querySelectorAll(':scope > tbody.fixed-rows')]) {
4277
4361
  if (element) {
4278
4362
  wanted.add(element);
@@ -4314,7 +4398,10 @@ let DataGrid = class DataGrid extends LitElement {
4314
4398
  const height = port ? port.clientHeight : scroller.clientHeight;
4315
4399
  const covered = toolbar + head + foot + (top?.offsetHeight ?? 0) + (bottom?.offsetHeight ?? 0) + inset.top + inset.bottom;
4316
4400
  const sticky = !(top || bottom) || covered <= height * 0.5 || !height;
4317
- container.style.setProperty('--_fixed-top-offset', `${toolbar + head}px`);
4401
+ // Rótulos quebrados: barra + cabeçalho acima da metade da altura visível deixam de grudar (WCAG 2.4.11).
4402
+ const headerSticky = !this.#anyHeaderWrap || toolbar + head + inset.top <= height * 0.5 || !height;
4403
+ container.classList.toggle('header-rows-scroll', !headerSticky);
4404
+ container.style.setProperty('--_fixed-top-offset', `${headerSticky ? toolbar + head : toolbar}px`);
4318
4405
  container.style.setProperty('--_fixed-bottom-offset', `${foot}px`);
4319
4406
  if (sticky !== this.#stickyFixed) {
4320
4407
  this.#stickyFixed = sticky;
@@ -4439,12 +4526,20 @@ let DataGrid = class DataGrid extends LitElement {
4439
4526
  }
4440
4527
  return result;
4441
4528
  }
4529
+ /**
4530
+ * Fontes carregadas depois da medida (relato de uso: "Obrigatório" medido
4531
+ * com a fonte de reserva e cortado 1px quando a Lato chegou): as larguras
4532
+ * automáticas são medidas de novo; as do usuário e as definidas ficam.
4533
+ */
4534
+ #onFontsLoaded;
4442
4535
  connectedCallback() {
4443
4536
  // Shadow root declarativo antes do 1º update: hidratação do SSR.
4444
4537
  const hydrating = !this.hasUpdated && !!this.shadowRoot;
4445
4538
  super.connectedCallback();
4446
4539
  this.#readDeclarativeColumns();
4447
4540
  this.#unobserveDocumentLanguage = observeDocumentLanguage(() => this.requestUpdate());
4541
+ // Fonte da página que chega depois da 1ª medida (web font): \`column-auto-width\` mede de novo.
4542
+ document.fonts?.addEventListener('loadingdone', this.#onFontsLoaded);
4448
4543
  this.#hostLabel.update();
4449
4544
  this.#dragAndDropDirty = true;
4450
4545
  this.#layoutDirty = true;
@@ -4479,6 +4574,7 @@ let DataGrid = class DataGrid extends LitElement {
4479
4574
  super.disconnectedCallback();
4480
4575
  this.#unobserveDocumentLanguage?.();
4481
4576
  this.#unobserveDocumentLanguage = undefined;
4577
+ document.fonts?.removeEventListener('loadingdone', this.#onFontsLoaded);
4482
4578
  this.#columnDragAndDrop.detach();
4483
4579
  this.#groupDragAndDrop.detach();
4484
4580
  releaseInteractions(this);
@@ -5107,7 +5203,7 @@ let DataGrid = class DataGrid extends LitElement {
5107
5203
  : [];
5108
5204
  }
5109
5205
  #summaryValue({ item, spec }, value) {
5110
- return { item, value: value ?? null, text: formatSummaryValue(value, spec, item.format, this.#summaryFormatContext) };
5206
+ return { item, value: value ?? null, text: formatSummaryValue(value, spec, item.format, this.#summaryFormatContext(spec.column)) };
5111
5207
  }
5112
5208
  #findGroup(groupPath) {
5113
5209
  if (!Array.isArray(groupPath)) {
@@ -5468,7 +5564,8 @@ let DataGrid = class DataGrid extends LitElement {
5468
5564
  }
5469
5565
  /**
5470
5566
  * The effective filter: `filterValue` `and` the search, as an expression
5471
- * (copy). The search becomes `[path, 'contains', text]` joined by `or`
5567
+ * (copy). The search becomes `[field, 'contains', text]` (`field`: the
5568
+ * `path`, or the `name` of a computed column) joined by `or`
5472
5569
  * over the visible filterable columns (number and date columns included:
5473
5570
  * `contains` matches their displayed text). `null` without filter.
5474
5571
  */
@@ -8114,9 +8211,18 @@ let DataGrid = class DataGrid extends LitElement {
8114
8211
  if (kind === 'boolean') {
8115
8212
  const value = text.trim().toLowerCase();
8116
8213
  const translation = this.#translation;
8214
+ const own = booleanTexts(column, translation);
8117
8215
  if (!value) {
8118
8216
  return null;
8119
8217
  }
8218
+ // Aceita o texto da coluna e o do idioma (a cópia gera o da coluna); os da coluna primeiro:
8219
+ // um `falseText: 'Sim'` não pode virar `true` pelo `trueText` do idioma.
8220
+ if (value === own.trueText.toLowerCase()) {
8221
+ return true;
8222
+ }
8223
+ if (value === own.falseText.toLowerCase()) {
8224
+ return false;
8225
+ }
8120
8226
  if (['true', '1', 'yes', '✓', translation.trueText.toLowerCase()].includes(value)) {
8121
8227
  return true;
8122
8228
  }
@@ -8240,6 +8346,12 @@ let DataGrid = class DataGrid extends LitElement {
8240
8346
  * @internal
8241
8347
  */
8242
8348
  _columnChanged(column, change) {
8349
+ // `path`/`name` podem ter mudado no mesmo objeto (spec 28). Renomear
8350
+ // uma calculada chega como `display`: o campo das condições mudou.
8351
+ this.#filterFields = undefined;
8352
+ if (change === 'display' && !column.path && column.valueGetter) {
8353
+ this.#filtering.invalidate();
8354
+ }
8243
8355
  if (change === 'columns') {
8244
8356
  // Colunas aninhadas entraram/saíram de uma banda declarativa.
8245
8357
  if (!this.#columnsProperty) {
@@ -8299,6 +8411,18 @@ let DataGrid = class DataGrid extends LitElement {
8299
8411
  * coluna e instância (spec 00).
8300
8412
  */
8301
8413
  #warnUnlabeledColumns(tree) {
8414
+ for (const column of tree.leaves) {
8415
+ // Calculada sem `label` (spec 28): o cabeçalho mostra o `name`, que costuma ser id.
8416
+ if (!column.label && !column.headerRenderer && !column.path && column.valueGetter && column.name
8417
+ && (this.#isFilterable(column) || isColumnSortable(column))) {
8418
+ const key = `computed:${column.name}`;
8419
+ if (!this.#warnedUnlabeled.has(key)) {
8420
+ this.#warnedUnlabeled.add(key);
8421
+ console.warn(`<u-grid>: column "${column.name}" has a "valueGetter" but no "label"; its header, menus and `
8422
+ + `announcements show the name "${column.name}".`);
8423
+ }
8424
+ }
8425
+ }
8302
8426
  for (const column of [...tree.leaves, ...tree.bands]) {
8303
8427
  if (!column.headerRenderer || column.label) {
8304
8428
  continue;
@@ -8324,6 +8448,7 @@ let DataGrid = class DataGrid extends LitElement {
8324
8448
  #syncColumns() {
8325
8449
  const tree = buildColumnTree(this.columns);
8326
8450
  this.#columnTree = tree;
8451
+ this.#filterFields = undefined;
8327
8452
  this.#warnUnlabeledColumns(tree);
8328
8453
  this.#visibleBands = undefined;
8329
8454
  // Só as folhas têm células; as bandas são só cabeçalho.
@@ -8655,7 +8780,7 @@ let DataGrid = class DataGrid extends LitElement {
8655
8780
  const order = sorting.find(spec => spec.column === column)?.order;
8656
8781
  const parts = [
8657
8782
  ...order ? [order === 'asc' ? translation.sortAscending : translation.sortDescending] : [],
8658
- ...hasColumnCondition(filterValue, column) ? [translation.columnFiltered] : [],
8783
+ ...hasColumnCondition(filterValue, column, this.#resolveFilterField) ? [translation.columnFiltered] : [],
8659
8784
  ];
8660
8785
  return parts.length ? [`${columnText(column)}${translation.adaptiveLabelSeparator}${parts.join(', ')}`] : [];
8661
8786
  });
@@ -9323,6 +9448,17 @@ let DataGrid = class DataGrid extends LitElement {
9323
9448
  });
9324
9449
  return changed;
9325
9450
  }
9451
+ /** Linhas de esqueleto que cabem abaixo do cabeçalho (uma a menos: a linha "Carregando…"). */
9452
+ #measurePlaceholderRows(scroller) {
9453
+ const body = scroller.querySelector('tbody.body-rows');
9454
+ if (!body || this.#scrollPort.port) {
9455
+ return;
9456
+ }
9457
+ const top = body.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
9458
+ const footer = scroller.querySelector('tfoot')?.offsetHeight ?? 0;
9459
+ const fits = Math.floor((scroller.clientHeight - top - footer) / this.rowHeight) - 1;
9460
+ this.#placeholderRows = Math.min(20, Math.max(1, fits));
9461
+ }
9326
9462
  #observeScrollContainer() {
9327
9463
  const scroller = this._scrollContainerRef.value;
9328
9464
  if (!scroller || this.#resizeObserver || typeof ResizeObserver === 'undefined') {
@@ -9340,6 +9476,7 @@ let DataGrid = class DataGrid extends LitElement {
9340
9476
  // Largura visível: o conteúdo do detalhe e da linha inteira não passa dela (WCAG 1.4.10).
9341
9477
  // No contêiner: o \`style\` do \`.scroll-container\` é do template (o render o sobrescreve).
9342
9478
  this.#layoutRef.value?.style.setProperty('--_fill-inline-size', `${width}px`);
9479
+ this.#measurePlaceholderRows(scroller);
9343
9480
  // Porta externa (spec 27): a parte visível, medida na rolagem.
9344
9481
  if (this.#scrollPort.port) {
9345
9482
  this.#onExternalMoved();
@@ -9353,6 +9490,8 @@ let DataGrid = class DataGrid extends LitElement {
9353
9490
  this.#measureToolbar();
9354
9491
  if (this.#observedFixedSections.size) {
9355
9492
  this.#syncFixedRows();
9493
+ // Cabeçalho mais alto (rótulos quebrados): a margem de revelar o foco acompanha (WCAG 2.4.11).
9494
+ this.#syncRevealMargins();
9356
9495
  }
9357
9496
  });
9358
9497
  this.#resizeObserver.observe(scroller);
@@ -9462,6 +9601,7 @@ let DataGrid = class DataGrid extends LitElement {
9462
9601
  this.#syncFixedRows();
9463
9602
  this.#syncRevealMargins();
9464
9603
  this.#scrollPort.checkHeight();
9604
+ this.#scrollPort.checkHorizontalClip(this.#tableRef.value?.offsetWidth ?? 0);
9465
9605
  }
9466
9606
  /**
9467
9607
  * Classe, deslocamento `sticky` e limites de cada coluna visível. Os
@@ -9526,7 +9666,7 @@ let DataGrid = class DataGrid extends LitElement {
9526
9666
  insetInlineStart: side === 'start' ? `${offsets[index]}px` : undefined,
9527
9667
  insetInlineEnd: side === 'end' ? `${offsets[index]}px` : undefined,
9528
9668
  };
9529
- const truncate = !column.wrap && !column.renderer && column.booleanDisplay !== 'icon';
9669
+ const truncate = !column.wrap && !column.renderer && column.booleanDisplay !== 'icon' && column.booleanDisplay !== 'check';
9530
9670
  const bounds = this._boundsOf(column);
9531
9671
  const resizable = this.#isResizable(column) && (!nextColumnMode || !!this._resizeNeighbor(column));
9532
9672
  return [
@@ -9824,7 +9964,7 @@ let DataGrid = class DataGrid extends LitElement {
9824
9964
  const id = `${operation}:${columnIdOf(column)}`;
9825
9965
  if (!this.#warnedColumns.has(id)) {
9826
9966
  this.#warnedColumns.add(id);
9827
- console.warn(`<u-grid>: column "${column.label ?? column.path ?? ''}" needs a plain "path" for remote ${operation}; ignored on the server.`);
9967
+ console.warn(`<u-grid>: column "${columnText(column)}" needs a plain "path" for remote ${operation}; ignored on the server.`);
9828
9968
  }
9829
9969
  return undefined;
9830
9970
  }
@@ -10016,20 +10156,35 @@ let DataGrid = class DataGrid extends LitElement {
10016
10156
  }
10017
10157
  this.#loadingAnnounced = false;
10018
10158
  }
10019
- /** Esperando o estado sem fonte de dados: "Carregando…" aos 300 ms, uma vez (com fonte, `#afterRenderLoad` cuida). */
10159
+ /**
10160
+ * Esperando o estado ou com `loading`, sem fonte de dados: "Carregando…"
10161
+ * aos 300 ms, uma vez (com fonte, `#afterRenderLoad` cuida). Ao terminar
10162
+ * uma carga anunciada, diz quantas linhas vieram (ou "sem dados"): quem
10163
+ * ouviu o começo fica sabendo do fim (WCAG 4.1.3).
10164
+ */
10020
10165
  #announceStateLoading() {
10021
10166
  if (this.#dataSource) {
10022
10167
  return;
10023
10168
  }
10024
- if (!this.#stateWaiting) {
10169
+ const waiting = this.#stateWaiting || this.loading;
10170
+ if (!waiting) {
10025
10171
  clearTimeout(this.#loadingTimer);
10026
10172
  this.#loadingTimer = undefined;
10173
+ // Só o \`loading\` anuncia o fim (a espera do estado salvo segue como antes: limpa e pronto).
10174
+ const announced = this.#loadingAnnounced && this.#loadingByProperty;
10175
+ this.#loadingByProperty = false;
10027
10176
  this.#clearLoadingAnnouncement();
10177
+ if (announced) {
10178
+ this.#announce(this.#rows.length
10179
+ ? formatMessage(this.#translation.filteredAnnouncement, { count: String(this.#totalCount) })
10180
+ : this.#translation.noData);
10181
+ }
10028
10182
  }
10029
10183
  else if (!this.#loadingTimer && !this.#loadingAnnounced && this.isConnected) {
10030
10184
  this.#loadingTimer = setTimeout(() => {
10031
10185
  this.#loadingTimer = undefined;
10032
- if (this.#stateWaiting) {
10186
+ if (this.#stateWaiting || this.loading) {
10187
+ this.#loadingByProperty = this.loading;
10033
10188
  this.#loadingAnnounced = true;
10034
10189
  this.#announce(this.#translation.loading);
10035
10190
  }
@@ -10243,7 +10398,7 @@ let DataGrid = class DataGrid extends LitElement {
10243
10398
  const columns = [...this._regularColumns, ...this._groupColumns];
10244
10399
  const known = new Set(columns);
10245
10400
  const contexts = new Map();
10246
- const { trueText, falseText } = this.#translation;
10401
+ const translation = this.#translation;
10247
10402
  const language = this.language;
10248
10403
  const dataTypeOf = (column) => known.has(column)
10249
10404
  ? this.#dataTypeOf(column)
@@ -10251,7 +10406,7 @@ let DataGrid = class DataGrid extends LitElement {
10251
10406
  const contextOf = (column) => {
10252
10407
  let context = contexts.get(column);
10253
10408
  if (!context) {
10254
- context = { language, dataType: dataTypeOf(column), trueText, falseText };
10409
+ context = { language, dataType: dataTypeOf(column), ...booleanTexts(column, translation) };
10255
10410
  contexts.set(column, context);
10256
10411
  }
10257
10412
  return context;
@@ -10259,6 +10414,7 @@ let DataGrid = class DataGrid extends LitElement {
10259
10414
  return {
10260
10415
  language,
10261
10416
  columns,
10417
+ resolve: this.#resolveFilterField,
10262
10418
  dataTypeOf,
10263
10419
  textOf: (item, column) => formatCell(item, column, contextOf(column)),
10264
10420
  alphabetOf: column => displayAlphabet(column, contextOf(column), foldText),
@@ -10279,7 +10435,7 @@ let DataGrid = class DataGrid extends LitElement {
10279
10435
  * @internal
10280
10436
  */
10281
10437
  _searchColumns() {
10282
- return [...this._groupColumns, ...this._shownColumns].filter(isColumnFilterable);
10438
+ return [...this._groupColumns, ...this._shownColumns].filter(column => this.#isFilterable(column));
10283
10439
  }
10284
10440
  /** @internal */
10285
10441
  _columnDataType(column) {
@@ -10287,7 +10443,51 @@ let DataGrid = class DataGrid extends LitElement {
10287
10443
  }
10288
10444
  /** @internal */
10289
10445
  _isFilterable(column) {
10290
- return isColumnFilterable(column);
10446
+ return this.#isFilterable(column);
10447
+ }
10448
+ /** @internal */
10449
+ _resolveFilterField(field) {
10450
+ return this.#resolveFilterField(field);
10451
+ }
10452
+ /** Campo de condição → coluna (spec 28); índice refeito quando as colunas mudam. */
10453
+ #filterFields;
10454
+ /** Coluna do campo de uma condição: `path`, depois `name` de coluna sem `path` (o mesmo do avaliador). */
10455
+ #resolveFilterField;
10456
+ /** Colunas já avisadas por `filterable: true` sem efeito (uma vez por coluna). */
10457
+ #warnedFilterable;
10458
+ /**
10459
+ * O usuário pode filtrar pela coluna (linha de filtro, funil, busca)? Além
10460
+ * de {@link isColumnFilterable}: a coluna sem `path` precisa ser a dona do
10461
+ * próprio `name` (sem colisão com um `path` ou com outra calculada) e, com
10462
+ * filtro remoto, só com `filterable: true` (o servidor não conhece o getter).
10463
+ */
10464
+ #isFilterable(column) {
10465
+ if (!isColumnFilterable(column)) {
10466
+ if (column.filterable === true) {
10467
+ this.#warnFilterable(column, 'needs a "path", or a "valueGetter" and a "name", to be filterable; ignored.');
10468
+ }
10469
+ return false;
10470
+ }
10471
+ if (column.path) {
10472
+ return true;
10473
+ }
10474
+ if (this.#resolveFilterField(column.name) !== column) {
10475
+ if (column.filterable === true) {
10476
+ this.#warnFilterable(column, `has the name "${column.name}" of another column's path or name; not filterable.`);
10477
+ }
10478
+ return false;
10479
+ }
10480
+ return !this.#remote.filtering || column.filterable === true;
10481
+ }
10482
+ /** Funil do filtro do cabeçalho: sem ele na coluna calculada remota (a lista viria só das linhas carregadas). */
10483
+ #hasFunnel(column) {
10484
+ return this.headerFilter && this.#isFilterable(column) && (!!column.path || !this.#remote.filtering);
10485
+ }
10486
+ #warnFilterable(column, problem) {
10487
+ if (!this.#warnedFilterable.has(column)) {
10488
+ this.#warnedFilterable.add(column);
10489
+ console.warn(`<u-grid>: column "${columnText(column)}" ${problem}`);
10490
+ }
10291
10491
  }
10292
10492
  /**
10293
10493
  * Gesto na linha de filtro ou no filtro do cabeçalho: troca (ou tira, com
@@ -10295,7 +10495,7 @@ let DataGrid = class DataGrid extends LitElement {
10295
10495
  * @internal
10296
10496
  */
10297
10497
  _userFilterColumn(column, kind, condition) {
10298
- this.#changeFilter(replaceColumnCondition(this.#filtering.filterValue, column, kind, condition), this.#filtering.searchText, 'user');
10498
+ this.#changeFilter(replaceColumnCondition(this.#filtering.filterValue, column, kind, condition, this.#resolveFilterField), this.#filtering.searchText, 'user');
10299
10499
  }
10300
10500
  /** @internal */
10301
10501
  _userSearch(text) {
@@ -10308,7 +10508,7 @@ let DataGrid = class DataGrid extends LitElement {
10308
10508
  * @internal
10309
10509
  */
10310
10510
  _distinctValues(column) {
10311
- const others = combineFilters(replaceColumnCondition(this.#filtering.filterValue, column, 'header', null), searchExpression(this.#filtering.searchText, this._searchColumns()));
10511
+ const others = combineFilters(replaceColumnCondition(this.#filtering.filterValue, column, 'header', null, this.#resolveFilterField), searchExpression(this.#filtering.searchText, this._searchColumns()));
10312
10512
  let items = this.#items;
10313
10513
  try {
10314
10514
  items = filterItems(items, compileFilter(others, this._filterContext()));
@@ -10408,8 +10608,7 @@ let DataGrid = class DataGrid extends LitElement {
10408
10608
  return this.#dataTypes.get(column);
10409
10609
  }
10410
10610
  #formatContext(column) {
10411
- const { trueText, falseText } = this.#translation;
10412
- return { language: this.language, dataType: this.#dataTypeOf(column), trueText, falseText };
10611
+ return { language: this.language, dataType: this.#dataTypeOf(column), ...booleanTexts(column, this.#translation) };
10413
10612
  }
10414
10613
  #groupValueText(row) {
10415
10614
  const { column } = row;
@@ -10430,9 +10629,9 @@ let DataGrid = class DataGrid extends LitElement {
10430
10629
  return formatCellValue(row.value, row.firstItem, column, this.#formatContext(column));
10431
10630
  }
10432
10631
  // ---------------------------------------------------------------- resumos
10433
- get #summaryFormatContext() {
10434
- const { trueText, falseText } = this.#translation;
10435
- return { language: this.language, trueText, falseText };
10632
+ /** Contexto dos resumos; os textos de `true`/`false` são os da coluna do resumo. */
10633
+ #summaryFormatContext(column) {
10634
+ return { language: this.language, ...booleanTexts(column, this.#translation) };
10436
10635
  }
10437
10636
  #summaryTypeName(item) {
10438
10637
  if (item.label) {
@@ -10457,7 +10656,7 @@ let DataGrid = class DataGrid extends LitElement {
10457
10656
  /** Texto da célula (`"Sum: 1,234"`) e rótulo completo (`"Sum of Population: 1,234"`). */
10458
10657
  #summaryText({ item, spec }, value) {
10459
10658
  const translation = this.#translation;
10460
- const valueText = formatSummaryValue(value, spec, item.format, this.#summaryFormatContext);
10659
+ const valueText = formatSummaryValue(value, spec, item.format, this.#summaryFormatContext(spec.column));
10461
10660
  const type = this.#summaryTypeName(item);
10462
10661
  const column = spec.column ? columnText(spec.column) : '';
10463
10662
  const text = type ? formatMessage(translation.summaryText, { type, value: valueText }) : valueText;
@@ -11290,7 +11489,9 @@ let DataGrid = class DataGrid extends LitElement {
11290
11489
  const thead = root.querySelector('thead');
11291
11490
  const toolbar = root.querySelector('.header');
11292
11491
  // Com a barra, o cabeçalho prende logo abaixo dela (\`.header + table thead\`); as fixas do topo, abaixo dele.
11293
- return (thead?.offsetHeight ?? 0) + (toolbar?.offsetHeight ?? 0) + this.#fixedHeight('top');
11492
+ // Cabeçalho alto demais (\`headerWrap\`, regra dos 50%): ele rola com o conteúdo e não cobre nada.
11493
+ const head = this._containerRef.value?.classList.contains('header-rows-scroll') ? 0 : thead?.offsetHeight ?? 0;
11494
+ return head + (toolbar?.offsetHeight ?? 0) + this.#fixedHeight('top');
11294
11495
  }
11295
11496
  /** Altura do rodapé de totais e das fixas do fundo (presos no fim da rolagem). */
11296
11497
  #stickyBottom() {
@@ -12003,10 +12204,10 @@ let DataGrid = class DataGrid extends LitElement {
12003
12204
  class=${`grid-table${fit ? ' fit' : ''}${this.#cellSelectionMode !== 'none' ? ' cell-range-mode' : ''}`}
12004
12205
  role=${this._groupColumns.length || this.#treeOn ? 'treegrid' : 'grid'}
12005
12206
  aria-label=${ifDefined(this.#hostLabel.name || undefined)}
12006
- aria-rowcount="${waiting || this.#unknownRowCount ? -1 : this.#bodyRowCount + headerRows + footerRows + fixedTop.length + fixedBottom.length}"
12207
+ aria-rowcount="${waiting || this.#unknownRowCount || this.#loadingPlaceholders ? -1 : this.#bodyRowCount + headerRows + footerRows + fixedTop.length + fixedBottom.length}"
12007
12208
  aria-colcount="${navColumns.length}"
12008
12209
  aria-multiselectable=${ifDefined(selectionMode === 'multiple' || this.#cellSelectionMode !== 'none' ? 'true' : undefined)}
12009
- aria-busy=${ifDefined(waiting || (this.#isLoading && !this.#reshapeLoading) || this.#filtering.pending ? 'true' : undefined)}
12210
+ aria-busy=${ifDefined(waiting || (this.#isLoading && !this.#reshapeLoading) || this.#filtering.pending || this.#loadingPlaceholders ? 'true' : undefined)}
12010
12211
  ${ref(this.#tableRef)}
12011
12212
  @pointerover=${this.#updateCellHint}
12012
12213
  @keydown=${this.#onGridKeyDown}
@@ -12180,7 +12381,7 @@ let DataGrid = class DataGrid extends LitElement {
12180
12381
  controller: this.#filterRow,
12181
12382
  column: cell.column,
12182
12383
  dataType: this.#dataTypeOf(cell.column),
12183
- filterable: isColumnFilterable(cell.column),
12384
+ filterable: this.#isFilterable(cell.column),
12184
12385
  translation,
12185
12386
  className: cell.className,
12186
12387
  style: cell.style,
@@ -12308,8 +12509,12 @@ let DataGrid = class DataGrid extends LitElement {
12308
12509
  const idSuffix = `${header.level}-${cell.col + 1}`;
12309
12510
  return renderHeaderCell({
12310
12511
  column,
12311
- // Cabeçalho multinível: a folha que fecha a última posição não leva a linha do fim (é a borda do grid).
12312
- classes: header.start + header.span === cells.length ? { ...cell.headerClasses, 'last-column': true } : cell.headerClasses,
12512
+ classes: {
12513
+ ...cell.headerClasses,
12514
+ // Cabeçalho multinível: a folha que fecha a última posição não leva a linha do fim (é a borda do grid).
12515
+ 'last-column': header.start + header.span === cells.length,
12516
+ 'header-wrap': this.#wrapsHeader(column),
12517
+ },
12313
12518
  styles: cell.headerStyles,
12314
12519
  colIndex: cell.col + 1,
12315
12520
  tabIndex: active === column ? 0 : -1,
@@ -12332,12 +12537,12 @@ let DataGrid = class DataGrid extends LitElement {
12332
12537
  }
12333
12538
  : undefined,
12334
12539
  trailing: cell.resizable ? this.#renderResizeHandle(cell, idSuffix) : nothing,
12335
- filterButton: this.headerFilter && isColumnFilterable(column)
12336
- ? renderHeaderFilterButton(this.#headerFilterPopover, column, filterValue, this.#translation, `header-description-${idSuffix}`, idSuffix, this.#textLanguage)
12540
+ filterButton: this.#hasFunnel(column)
12541
+ ? renderHeaderFilterButton(this.#headerFilterPopover, column, filterValue, this.#translation, this.#resolveFilterField, `header-description-${idSuffix}`, idSuffix, this.#textLanguage)
12337
12542
  : nothing,
12338
12543
  menuButton: this.#renderColumnMenuButton(column, idSuffix),
12339
- filtered: hasColumnCondition(filterValue, column),
12340
- description: this.#headerDescription(column, rowSorting[position]?.order, position + 1, showIndex, hasColumnCondition(filterValue, column)),
12544
+ filtered: hasColumnCondition(filterValue, column, this.#resolveFilterField),
12545
+ description: this.#headerDescription(column, rowSorting[position]?.order, position + 1, showIndex, hasColumnCondition(filterValue, column, this.#resolveFilterField)),
12341
12546
  keyShortcuts: this.#headerKeyShortcuts(column, cell.resizable),
12342
12547
  label: column.headerRenderer ? this.#renderHeaderContent(column, cell.id) : headerText(column),
12343
12548
  });
@@ -12416,7 +12621,7 @@ let DataGrid = class DataGrid extends LitElement {
12416
12621
  /** \`aria-keyshortcuts\` do cabeçalho: só as teclas que valem para a coluna (nomes do UI Events). */
12417
12622
  #headerKeyShortcuts(column, resizable) {
12418
12623
  const keys = [];
12419
- const funnel = this.headerFilter && isColumnFilterable(column);
12624
+ const funnel = this.#hasFunnel(column);
12420
12625
  if (this.#hasColumnMenu(column)) {
12421
12626
  keys.push('Shift+F10');
12422
12627
  }
@@ -12540,19 +12745,47 @@ let DataGrid = class DataGrid extends LitElement {
12540
12745
  }
12541
12746
  }}>${named?.parts ?? nothing}</div>`;
12542
12747
  }
12748
+ /** Rótulo do cabeçalho quebra linha: o da coluna ou o padrão do grid. */
12749
+ #wrapsHeader(column) {
12750
+ return column.headerWrap ?? this.headerWrap;
12751
+ }
12752
+ /** Alguma coluna visível quebra o rótulo: o cabeçalho tem altura variável (observado). */
12753
+ get #anyHeaderWrap() {
12754
+ return this.headerWrap || this._visibleColumns.some(column => column.headerWrap);
12755
+ }
12756
+ /** `loading` sem linhas: a contagem de linhas fica desconhecida e o esqueleto é só visual. */
12757
+ get #loadingPlaceholders() {
12758
+ return this.loading && !this.#rows.length && !this.#waitingForState;
12759
+ }
12760
+ /**
12761
+ * Linha do estado vazio: "sem dados" ou, com `loading`, "Carregando…" e
12762
+ * linhas de esqueleto só visuais (`aria-hidden`, sem papel nem foco; spec
12763
+ * 17), no lugar do que caberia na tela. Um template só: ao terminar a carga
12764
+ * o mesmo `<td>` fica e só o conteúdo muda.
12765
+ */
12766
+ #renderEmptyRow(layout) {
12767
+ const columns = Math.max(this.#totalColumns(layout), 1);
12768
+ const loading = this.loading;
12769
+ return html `
12770
+ <tr role="row" class=${loading ? 'no-data-row loading-row' : 'no-data-row'}>
12771
+ <td role="gridcell" part="no-data" lang=${ifDefined(this.noDataRenderer && !loading ? undefined : this.#textLanguage)} colspan="${columns}">${loading
12772
+ ? this.#translation.loading
12773
+ : this.noDataRenderer ? this.#renderNoDataContent(this.noDataRenderer) : this.#translation.noData}</td>
12774
+ </tr>
12775
+ ${loading
12776
+ ? map(Array.from({ length: this.#placeholderRows }), () => html `
12777
+ <tr class="skeleton-row loading-placeholder" part="row skeleton-row" aria-hidden="true">
12778
+ ${map(Array.from({ length: columns }), () => html `<td><span class="skeleton"></span></td>`)}
12779
+ </tr>`)
12780
+ : nothing}`;
12781
+ }
12543
12782
  #renderBody(window, headerRows, layout) {
12544
12783
  if (!this.#rows.length) {
12545
12784
  // Carregando pela 1ª vez (ou esperando o estado): o painel fala; "sem dados" só depois da resposta.
12546
12785
  if (this.#waitingForState || (this.#dataSource && !this.#loader.current)) {
12547
12786
  return nothing;
12548
12787
  }
12549
- return html `
12550
- <tr role="row" class="no-data-row">
12551
- <td role="gridcell" part="no-data" lang=${ifDefined(this.noDataRenderer ? undefined : this.#textLanguage)} colspan="${Math.max(this.#totalColumns(layout), 1)}">${this.noDataRenderer
12552
- ? this.#renderNoDataContent(this.noDataRenderer)
12553
- : this.#translation.noData}</td>
12554
- </tr>
12555
- `;
12788
+ return this.#renderEmptyRow(layout);
12556
12789
  }
12557
12790
  // As linhas ficam no fluxo da tabela, uma após a outra, depois de uma
12558
12791
  // linha espaçadora com a altura até a 1ª linha da janela (vale também
@@ -12622,13 +12855,15 @@ let DataGrid = class DataGrid extends LitElement {
12622
12855
  /** Painel de carregamento (consulta inteira) e barra de erro com "tentar de novo". */
12623
12856
  #renderLoadState() {
12624
12857
  const waiting = this.#waitingForState;
12625
- if (!this.#dataSource && !waiting) {
12858
+ // `loading` com linhas na tela: o painel por cima, sem `aria-busy` (as células seguem legíveis).
12859
+ const localLoading = this.loading && this.#rows.length > 0;
12860
+ if (!this.#dataSource && !waiting && !localLoading) {
12626
12861
  return nothing;
12627
12862
  }
12628
12863
  const translation = this.#translation;
12629
12864
  const failure = this.#dataSource ? this.#loader.error : undefined;
12630
12865
  return html `
12631
- ${waiting || this.#isLoading
12866
+ ${waiting || this.#isLoading || localLoading
12632
12867
  ? html `<div class="load-panel" part="load-panel" aria-hidden=${ifDefined(waiting ? undefined : 'true')}>
12633
12868
  <span class="load-spinner" aria-hidden="true"></span><span>${translation.loading}</span>
12634
12869
  </div>`
@@ -12930,7 +13165,7 @@ let DataGrid = class DataGrid extends LitElement {
12930
13165
  const sortText = order && sorting.length > 1 && sortPosition > 0
12931
13166
  ? formatMessage(translation.columnSortPriority, { order: orderText, priority: String(sortPosition + 1) })
12932
13167
  : orderText;
12933
- const filtered = hasColumnCondition(filterValue, column);
13168
+ const filtered = hasColumnCondition(filterValue, column, this.#resolveFilterField);
12934
13169
  const cell = this.#adaptiveCellLayout(column, id);
12935
13170
  const removed = pending?.type === 'remove';
12936
13171
  const added = pending?.type === 'add';
@@ -13614,7 +13849,7 @@ let DataGrid = class DataGrid extends LitElement {
13614
13849
  return rendererContent({
13615
13850
  host: this,
13616
13851
  slotName: `u-grid-internal:group:${row.key}`,
13617
- deps: [row.groupKey, column, renderer, this.#renderEpoch(), row.value, row.expanded, row.itemCount, row.summaries, defaultText],
13852
+ deps: [row.groupKey, column, renderer, this.#renderEpoch(), row.value, row.expanded, row.itemCount, row.summaries, defaultText, row.firstItem],
13618
13853
  renderer,
13619
13854
  invoke: signal => renderer.call(column, {
13620
13855
  column,
@@ -13624,6 +13859,7 @@ let DataGrid = class DataGrid extends LitElement {
13624
13859
  groupIndex: row.level,
13625
13860
  itemCount: row.itemCount,
13626
13861
  expanded: row.expanded,
13862
+ firstItem: row.firstItem,
13627
13863
  get summaries() {
13628
13864
  return summaries();
13629
13865
  },
@@ -13684,7 +13920,7 @@ let DataGrid = class DataGrid extends LitElement {
13684
13920
  return html `<span class="node-summary">${this.#summaryTexts(summary)}</span>`;
13685
13921
  }
13686
13922
  const content = renderDataCell(this, row, cell.column, cell.id, cell.format, this.#renderEpoch(), adaptive);
13687
- return matcher && typeof content === 'string' && isColumnFilterable(cell.column)
13923
+ return matcher && typeof content === 'string' && this.#isFilterable(cell.column)
13688
13924
  ? renderHighlighted(content, matcher)
13689
13925
  : content;
13690
13926
  }
@@ -15731,6 +15967,12 @@ __decorate([
15731
15967
  __decorate([
15732
15968
  property({ attribute: false })
15733
15969
  ], DataGrid.prototype, "noDataRenderer", void 0);
15970
+ __decorate([
15971
+ property({ type: Boolean, converter: booleanAttribute(false) })
15972
+ ], DataGrid.prototype, "loading", void 0);
15973
+ __decorate([
15974
+ property({ type: Boolean, converter: booleanAttribute(false), attribute: 'header-wrap' })
15975
+ ], DataGrid.prototype, "headerWrap", void 0);
15734
15976
  __decorate([
15735
15977
  property({ attribute: false })
15736
15978
  ], DataGrid.prototype, "detailRenderer", void 0);