@universal-material/data-grid 0.2.0 → 0.3.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.
- package/README.md +1 -1
- package/custom-elements.json +114 -15
- package/dist/data/data-source.d.ts +6 -2
- package/dist/data/data-source.js.map +1 -1
- package/dist/export-xlsx/index.d.ts +2 -1
- package/dist/export-xlsx/index.js +4 -2
- package/dist/export-xlsx/index.js.map +1 -1
- package/dist/features/column-chooser.js +1 -1
- package/dist/features/column-chooser.js.map +1 -1
- package/dist/features/filter-row.d.ts +1 -0
- package/dist/features/filter-row.js +13 -8
- package/dist/features/filter-row.js.map +1 -1
- package/dist/features/header-filter.d.ts +4 -1
- package/dist/features/header-filter.js +7 -5
- package/dist/features/header-filter.js.map +1 -1
- package/dist/grid-column-def.d.ts +45 -11
- package/dist/grid-column-def.js +6 -2
- package/dist/grid-column-def.js.map +1 -1
- package/dist/grid-column.d.ts +23 -5
- package/dist/grid-column.js +32 -5
- package/dist/grid-column.js.map +1 -1
- package/dist/grid-i18n.js +14 -14
- package/dist/grid-i18n.js.map +1 -1
- package/dist/grid.d.ts +31 -10
- package/dist/grid.js +255 -55
- package/dist/grid.js.map +1 -1
- package/dist/grid.min.js +457 -418
- package/dist/grid.styles.js +42 -6
- package/dist/grid.styles.js.map +1 -1
- package/dist/render/cell.js +5 -2
- package/dist/render/cell.js.map +1 -1
- package/dist/row-model/columns.d.ts +21 -3
- package/dist/row-model/columns.js +14 -4
- package/dist/row-model/columns.js.map +1 -1
- package/dist/row-model/filter.d.ts +19 -4
- package/dist/row-model/filter.js +29 -9
- package/dist/row-model/filter.js.map +1 -1
- package/dist/row-model/format.js +1 -1
- package/dist/row-model/format.js.map +1 -1
- package/dist/state/grid-state.d.ts +2 -2
- package/dist/state/grid-state.js.map +1 -1
- 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,7 +537,8 @@ 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-
|
|
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.
|
|
@@ -570,8 +573,8 @@ const isRenderResult = (value) => value === null || value === undefined || value
|
|
|
570
573
|
* @cssprop --u-grid-sort-indicator-size - Size of the sort arrow. Default `1.125em`.
|
|
571
574
|
* @cssprop --u-grid-drop-indicator-color - Drag-and-drop drop indicator color.
|
|
572
575
|
* @cssprop --u-grid-drop-indicator-width - Drop indicator thickness. Default `3px`.
|
|
573
|
-
* @cssprop --u-grid-resize-handle-width - Invisible resize
|
|
574
|
-
* @cssprop --u-grid-column-header-menu-button-size - Size of the "⋮"
|
|
576
|
+
* @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`.
|
|
577
|
+
* @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
578
|
* @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
579
|
* @cssprop --u-grid-fixed-shadow-color - Shadow at the edge of fixed columns while scrolling.
|
|
577
580
|
* @cssprop --u-grid-column-chooser-background-color - Column chooser background.
|
|
@@ -587,7 +590,7 @@ const isRenderResult = (value) => value === null || value === undefined || value
|
|
|
587
590
|
* @cssprop --u-grid-header-filter-background-color - Header filter popover background.
|
|
588
591
|
* @cssprop --u-grid-header-filter-shape - Header filter popover corner radius. Default `12px`.
|
|
589
592
|
* @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.
|
|
593
|
+
* @cssprop --u-grid-skeleton-row-color - Color of the placeholders in rows still loading (remote rows, or `loading` with no rows).
|
|
591
594
|
* @cssprop --u-grid-pager-height - Minimum height of the pager. Default `56px`.
|
|
592
595
|
* @cssprop --u-grid-modified-cell-background-color - Background of edited, unsaved cells (`editMode="batch"`). Default: primary color at 10%.
|
|
593
596
|
* @cssprop --u-grid-modified-cell-indicator-color - Corner mark of edited, unsaved cells (not shown by color alone). Default: primary color.
|
|
@@ -610,7 +613,7 @@ const isRenderResult = (value) => value === null || value === undefined || value
|
|
|
610
613
|
* @csspart cell - Data cells (`<td>`).
|
|
611
614
|
* @csspart selection-cell - Cells and header of the selection checkbox column.
|
|
612
615
|
* @csspart selection-checkbox - The selection checkboxes (rows and "select all").
|
|
613
|
-
* @csspart no-data - The cell rendered in the empty state.
|
|
616
|
+
* @csspart no-data - The cell rendered in the empty state, or the "Loading…" cell while `loading` has no rows.
|
|
614
617
|
* @csspart header-cell - Column header cells (`<th>`), bands included.
|
|
615
618
|
* @csspart band-header-cell - Band header cells (multi-level headers); they also match `header-cell`.
|
|
616
619
|
* @csspart sort-indicator - The sort arrow (and priority number) in headers and group chips.
|
|
@@ -666,8 +669,8 @@ const isRenderResult = (value) => value === null || value === undefined || value
|
|
|
666
669
|
* @csspart pager-button - Pager buttons (first, previous, page numbers, next, last).
|
|
667
670
|
* @csspart page-size-select - The page size `<select>` of the pager.
|
|
668
671
|
* @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`).
|
|
672
|
+
* @csspart load-panel - The load panel shown while a data source loads or `loading` is set (with rows).
|
|
673
|
+
* @csspart skeleton-row - Rows of a remote source not loaded yet (with `row`), or placeholder rows while `loading` has no rows.
|
|
671
674
|
* @csspart error-row - The bar shown when the data source failed.
|
|
672
675
|
* @csspart retry-button - The "Retry" button of the error bar.
|
|
673
676
|
* @csspart search-highlight - Search matches (`<mark>`) in native cells (not in `renderer` cells).
|
|
@@ -703,6 +706,26 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
703
706
|
* the translated "No data" text.
|
|
704
707
|
*/
|
|
705
708
|
this.noDataRenderer = null;
|
|
709
|
+
/**
|
|
710
|
+
* Shows the grid as loading, for `items` you are still fetching. With rows
|
|
711
|
+
* on screen, the load panel (`::part(load-panel)`) covers them; with no rows
|
|
712
|
+
* yet, a "Loading…" row and placeholder rows (`::part(skeleton-row)`) take
|
|
713
|
+
* the place of the empty state (`noDataRenderer` is not called). Placeholder
|
|
714
|
+
* rows are never data: not exported, selected, counted or focusable by API.
|
|
715
|
+
* Does not fire `u-grid-loading`/`u-grid-load`; with `dataSource`, it adds
|
|
716
|
+
* to the source's own loading state (the getter returns only what you set).
|
|
717
|
+
*/
|
|
718
|
+
this.loading = false;
|
|
719
|
+
/**
|
|
720
|
+
* Wraps the column header labels in several lines instead of an ellipsis
|
|
721
|
+
* (the header row grows; `--u-grid-header-cell-height` is its minimum). A
|
|
722
|
+
* column's `headerWrap` wins. Auto-size measures the label in one line. If
|
|
723
|
+
* the toolbar and the headers take more than half of the visible height,
|
|
724
|
+
* the headers stop sticking (WCAG 2.4.11).
|
|
725
|
+
*/
|
|
726
|
+
this.headerWrap = false;
|
|
727
|
+
/** Linhas de esqueleto do `loading` sem linhas: fixo no servidor e no 1º render (hidratação); depois, o que cabe. */
|
|
728
|
+
this.#placeholderRows = LOADING_PLACEHOLDER_ROWS;
|
|
706
729
|
/**
|
|
707
730
|
* Builds the detail of a row (master-detail; property only). With it, a
|
|
708
731
|
* toggle column appears at the start and each expanded row is followed by
|
|
@@ -800,6 +823,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
800
823
|
this.#refreshCount = 0;
|
|
801
824
|
this.#remoteVersion = -1;
|
|
802
825
|
this.#loadingAnnounced = false;
|
|
826
|
+
/** O "Carregando…" anunciado veio do \`loading\` (o fim é anunciado; a espera do estado não). */
|
|
827
|
+
this.#loadingByProperty = false;
|
|
803
828
|
this.#warnedColumns = new Set();
|
|
804
829
|
// ------------------------------------------------------- árvore (frente 25)
|
|
805
830
|
/**
|
|
@@ -1605,6 +1630,27 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
1605
1630
|
this.#warnedInfinitePaging = false;
|
|
1606
1631
|
/** 1ª linha da última janela renderizada (o 1º pedido de uma consulta nova já traz o bloco dela). */
|
|
1607
1632
|
this.#lastWindowFirst = 0;
|
|
1633
|
+
/** Coluna do campo de uma condição: `path`, depois `name` de coluna sem `path` (o mesmo do avaliador). */
|
|
1634
|
+
this.#resolveFilterField = field => {
|
|
1635
|
+
if (!this.#filterFields) {
|
|
1636
|
+
const index = new Map();
|
|
1637
|
+
const leaves = this.#columnTree.leaves;
|
|
1638
|
+
for (const column of leaves) {
|
|
1639
|
+
if (column.path && !index.has(column.path)) {
|
|
1640
|
+
index.set(column.path, column);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
for (const column of leaves) {
|
|
1644
|
+
if (!column.path && column.name && !index.has(column.name)) {
|
|
1645
|
+
index.set(column.name, column);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
this.#filterFields = index;
|
|
1649
|
+
}
|
|
1650
|
+
return this.#filterFields.get(field);
|
|
1651
|
+
};
|
|
1652
|
+
/** Colunas já avisadas por `filterable: true` sem efeito (uma vez por coluna). */
|
|
1653
|
+
this.#warnedFilterable = new WeakSet();
|
|
1608
1654
|
this.#canSortByUser = (column) => this.#sortingMode !== 'none' && isColumnSortable(column);
|
|
1609
1655
|
this.#onSortPointerDown = () => {
|
|
1610
1656
|
this.#dragged = false;
|
|
@@ -2107,6 +2153,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
2107
2153
|
this.#summaryDirty = true;
|
|
2108
2154
|
}
|
|
2109
2155
|
#summary;
|
|
2156
|
+
/** Linhas de esqueleto do `loading` sem linhas: fixo no servidor e no 1º render (hidratação); depois, o que cabe. */
|
|
2157
|
+
#placeholderRows;
|
|
2110
2158
|
/**
|
|
2111
2159
|
* Rows fixed ("pinned") right below the column headers (property only):
|
|
2112
2160
|
* the host's own items, rendered with the grid columns (formatting, cell
|
|
@@ -2333,6 +2381,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
2333
2381
|
#flushTimer;
|
|
2334
2382
|
#loadingTimer;
|
|
2335
2383
|
#loadingAnnounced;
|
|
2384
|
+
/** O "Carregando…" anunciado veio do \`loading\` (o fim é anunciado; a espera do estado não). */
|
|
2385
|
+
#loadingByProperty;
|
|
2336
2386
|
#warnedColumns;
|
|
2337
2387
|
/** Fonte remota com linhas sob demanda (paginação ou agrupamento no servidor). */
|
|
2338
2388
|
get #lazy() {
|
|
@@ -3367,8 +3417,9 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
3367
3417
|
* Column filter (property only): a serializable expression such as
|
|
3368
3418
|
* `[['age', '>', 30], 'and', ['name', 'contains', 'an']]`. The filter row
|
|
3369
3419
|
* and the header filter read and write it, so it always holds the current
|
|
3370
|
-
* filter.
|
|
3371
|
-
*
|
|
3420
|
+
* filter. A condition refers to its column by `path` or, for a computed
|
|
3421
|
+
* column (`valueGetter` without `path`), by `name`. The grid keeps a frozen
|
|
3422
|
+
* copy (never the host array). Setting it does not fire `u-grid-filter-change`.
|
|
3372
3423
|
*/
|
|
3373
3424
|
get filterValue() {
|
|
3374
3425
|
return this.#filtering.filterValue;
|
|
@@ -4272,7 +4323,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
4272
4323
|
const table = this.#tableRef.value;
|
|
4273
4324
|
const observer = this.#resizeObserver;
|
|
4274
4325
|
const wanted = new Set();
|
|
4275
|
-
if (table && observer && (this.#fixedTopItems.length || this.#fixedBottomItems.length)) {
|
|
4326
|
+
if (table && observer && (this.#fixedTopItems.length || this.#fixedBottomItems.length || this.#anyHeaderWrap)) {
|
|
4327
|
+
// Rótulos que quebram linha: a altura do cabeçalho muda sem o host mudar (zoom de texto, largura).
|
|
4276
4328
|
for (const element of [table.tHead, table.tFoot, ...table.querySelectorAll(':scope > tbody.fixed-rows')]) {
|
|
4277
4329
|
if (element) {
|
|
4278
4330
|
wanted.add(element);
|
|
@@ -4314,7 +4366,10 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
4314
4366
|
const height = port ? port.clientHeight : scroller.clientHeight;
|
|
4315
4367
|
const covered = toolbar + head + foot + (top?.offsetHeight ?? 0) + (bottom?.offsetHeight ?? 0) + inset.top + inset.bottom;
|
|
4316
4368
|
const sticky = !(top || bottom) || covered <= height * 0.5 || !height;
|
|
4317
|
-
|
|
4369
|
+
// Rótulos quebrados: barra + cabeçalho acima da metade da altura visível deixam de grudar (WCAG 2.4.11).
|
|
4370
|
+
const headerSticky = !this.#anyHeaderWrap || toolbar + head + inset.top <= height * 0.5 || !height;
|
|
4371
|
+
container.classList.toggle('header-rows-scroll', !headerSticky);
|
|
4372
|
+
container.style.setProperty('--_fixed-top-offset', `${headerSticky ? toolbar + head : toolbar}px`);
|
|
4318
4373
|
container.style.setProperty('--_fixed-bottom-offset', `${foot}px`);
|
|
4319
4374
|
if (sticky !== this.#stickyFixed) {
|
|
4320
4375
|
this.#stickyFixed = sticky;
|
|
@@ -5107,7 +5162,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5107
5162
|
: [];
|
|
5108
5163
|
}
|
|
5109
5164
|
#summaryValue({ item, spec }, value) {
|
|
5110
|
-
return { item, value: value ?? null, text: formatSummaryValue(value, spec, item.format, this.#summaryFormatContext) };
|
|
5165
|
+
return { item, value: value ?? null, text: formatSummaryValue(value, spec, item.format, this.#summaryFormatContext(spec.column)) };
|
|
5111
5166
|
}
|
|
5112
5167
|
#findGroup(groupPath) {
|
|
5113
5168
|
if (!Array.isArray(groupPath)) {
|
|
@@ -5468,7 +5523,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5468
5523
|
}
|
|
5469
5524
|
/**
|
|
5470
5525
|
* The effective filter: `filterValue` `and` the search, as an expression
|
|
5471
|
-
* (copy). The search becomes `[
|
|
5526
|
+
* (copy). The search becomes `[field, 'contains', text]` (`field`: the
|
|
5527
|
+
* `path`, or the `name` of a computed column) joined by `or`
|
|
5472
5528
|
* over the visible filterable columns (number and date columns included:
|
|
5473
5529
|
* `contains` matches their displayed text). `null` without filter.
|
|
5474
5530
|
*/
|
|
@@ -8114,9 +8170,18 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
8114
8170
|
if (kind === 'boolean') {
|
|
8115
8171
|
const value = text.trim().toLowerCase();
|
|
8116
8172
|
const translation = this.#translation;
|
|
8173
|
+
const own = booleanTexts(column, translation);
|
|
8117
8174
|
if (!value) {
|
|
8118
8175
|
return null;
|
|
8119
8176
|
}
|
|
8177
|
+
// Aceita o texto da coluna e o do idioma (a cópia gera o da coluna); os da coluna primeiro:
|
|
8178
|
+
// um `falseText: 'Sim'` não pode virar `true` pelo `trueText` do idioma.
|
|
8179
|
+
if (value === own.trueText.toLowerCase()) {
|
|
8180
|
+
return true;
|
|
8181
|
+
}
|
|
8182
|
+
if (value === own.falseText.toLowerCase()) {
|
|
8183
|
+
return false;
|
|
8184
|
+
}
|
|
8120
8185
|
if (['true', '1', 'yes', '✓', translation.trueText.toLowerCase()].includes(value)) {
|
|
8121
8186
|
return true;
|
|
8122
8187
|
}
|
|
@@ -8240,6 +8305,12 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
8240
8305
|
* @internal
|
|
8241
8306
|
*/
|
|
8242
8307
|
_columnChanged(column, change) {
|
|
8308
|
+
// `path`/`name` podem ter mudado no mesmo objeto (spec 28). Renomear
|
|
8309
|
+
// uma calculada chega como `display`: o campo das condições mudou.
|
|
8310
|
+
this.#filterFields = undefined;
|
|
8311
|
+
if (change === 'display' && !column.path && column.valueGetter) {
|
|
8312
|
+
this.#filtering.invalidate();
|
|
8313
|
+
}
|
|
8243
8314
|
if (change === 'columns') {
|
|
8244
8315
|
// Colunas aninhadas entraram/saíram de uma banda declarativa.
|
|
8245
8316
|
if (!this.#columnsProperty) {
|
|
@@ -8299,6 +8370,18 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
8299
8370
|
* coluna e instância (spec 00).
|
|
8300
8371
|
*/
|
|
8301
8372
|
#warnUnlabeledColumns(tree) {
|
|
8373
|
+
for (const column of tree.leaves) {
|
|
8374
|
+
// Calculada sem `label` (spec 28): o cabeçalho mostra o `name`, que costuma ser id.
|
|
8375
|
+
if (!column.label && !column.headerRenderer && !column.path && column.valueGetter && column.name
|
|
8376
|
+
&& (this.#isFilterable(column) || isColumnSortable(column))) {
|
|
8377
|
+
const key = `computed:${column.name}`;
|
|
8378
|
+
if (!this.#warnedUnlabeled.has(key)) {
|
|
8379
|
+
this.#warnedUnlabeled.add(key);
|
|
8380
|
+
console.warn(`<u-grid>: column "${column.name}" has a "valueGetter" but no "label"; its header, menus and `
|
|
8381
|
+
+ `announcements show the name "${column.name}".`);
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
8302
8385
|
for (const column of [...tree.leaves, ...tree.bands]) {
|
|
8303
8386
|
if (!column.headerRenderer || column.label) {
|
|
8304
8387
|
continue;
|
|
@@ -8324,6 +8407,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
8324
8407
|
#syncColumns() {
|
|
8325
8408
|
const tree = buildColumnTree(this.columns);
|
|
8326
8409
|
this.#columnTree = tree;
|
|
8410
|
+
this.#filterFields = undefined;
|
|
8327
8411
|
this.#warnUnlabeledColumns(tree);
|
|
8328
8412
|
this.#visibleBands = undefined;
|
|
8329
8413
|
// Só as folhas têm células; as bandas são só cabeçalho.
|
|
@@ -8655,7 +8739,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
8655
8739
|
const order = sorting.find(spec => spec.column === column)?.order;
|
|
8656
8740
|
const parts = [
|
|
8657
8741
|
...order ? [order === 'asc' ? translation.sortAscending : translation.sortDescending] : [],
|
|
8658
|
-
...hasColumnCondition(filterValue, column) ? [translation.columnFiltered] : [],
|
|
8742
|
+
...hasColumnCondition(filterValue, column, this.#resolveFilterField) ? [translation.columnFiltered] : [],
|
|
8659
8743
|
];
|
|
8660
8744
|
return parts.length ? [`${columnText(column)}${translation.adaptiveLabelSeparator}${parts.join(', ')}`] : [];
|
|
8661
8745
|
});
|
|
@@ -9323,6 +9407,17 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9323
9407
|
});
|
|
9324
9408
|
return changed;
|
|
9325
9409
|
}
|
|
9410
|
+
/** Linhas de esqueleto que cabem abaixo do cabeçalho (uma a menos: a linha "Carregando…"). */
|
|
9411
|
+
#measurePlaceholderRows(scroller) {
|
|
9412
|
+
const body = scroller.querySelector('tbody.body-rows');
|
|
9413
|
+
if (!body || this.#scrollPort.port) {
|
|
9414
|
+
return;
|
|
9415
|
+
}
|
|
9416
|
+
const top = body.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
|
|
9417
|
+
const footer = scroller.querySelector('tfoot')?.offsetHeight ?? 0;
|
|
9418
|
+
const fits = Math.floor((scroller.clientHeight - top - footer) / this.rowHeight) - 1;
|
|
9419
|
+
this.#placeholderRows = Math.min(20, Math.max(1, fits));
|
|
9420
|
+
}
|
|
9326
9421
|
#observeScrollContainer() {
|
|
9327
9422
|
const scroller = this._scrollContainerRef.value;
|
|
9328
9423
|
if (!scroller || this.#resizeObserver || typeof ResizeObserver === 'undefined') {
|
|
@@ -9340,6 +9435,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9340
9435
|
// Largura visível: o conteúdo do detalhe e da linha inteira não passa dela (WCAG 1.4.10).
|
|
9341
9436
|
// No contêiner: o \`style\` do \`.scroll-container\` é do template (o render o sobrescreve).
|
|
9342
9437
|
this.#layoutRef.value?.style.setProperty('--_fill-inline-size', `${width}px`);
|
|
9438
|
+
this.#measurePlaceholderRows(scroller);
|
|
9343
9439
|
// Porta externa (spec 27): a parte visível, medida na rolagem.
|
|
9344
9440
|
if (this.#scrollPort.port) {
|
|
9345
9441
|
this.#onExternalMoved();
|
|
@@ -9353,6 +9449,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9353
9449
|
this.#measureToolbar();
|
|
9354
9450
|
if (this.#observedFixedSections.size) {
|
|
9355
9451
|
this.#syncFixedRows();
|
|
9452
|
+
// Cabeçalho mais alto (rótulos quebrados): a margem de revelar o foco acompanha (WCAG 2.4.11).
|
|
9453
|
+
this.#syncRevealMargins();
|
|
9356
9454
|
}
|
|
9357
9455
|
});
|
|
9358
9456
|
this.#resizeObserver.observe(scroller);
|
|
@@ -9526,7 +9624,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9526
9624
|
insetInlineStart: side === 'start' ? `${offsets[index]}px` : undefined,
|
|
9527
9625
|
insetInlineEnd: side === 'end' ? `${offsets[index]}px` : undefined,
|
|
9528
9626
|
};
|
|
9529
|
-
const truncate = !column.wrap && !column.renderer && column.booleanDisplay !== 'icon';
|
|
9627
|
+
const truncate = !column.wrap && !column.renderer && column.booleanDisplay !== 'icon' && column.booleanDisplay !== 'check';
|
|
9530
9628
|
const bounds = this._boundsOf(column);
|
|
9531
9629
|
const resizable = this.#isResizable(column) && (!nextColumnMode || !!this._resizeNeighbor(column));
|
|
9532
9630
|
return [
|
|
@@ -9824,7 +9922,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9824
9922
|
const id = `${operation}:${columnIdOf(column)}`;
|
|
9825
9923
|
if (!this.#warnedColumns.has(id)) {
|
|
9826
9924
|
this.#warnedColumns.add(id);
|
|
9827
|
-
console.warn(`<u-grid>: column "${column
|
|
9925
|
+
console.warn(`<u-grid>: column "${columnText(column)}" needs a plain "path" for remote ${operation}; ignored on the server.`);
|
|
9828
9926
|
}
|
|
9829
9927
|
return undefined;
|
|
9830
9928
|
}
|
|
@@ -10016,20 +10114,35 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10016
10114
|
}
|
|
10017
10115
|
this.#loadingAnnounced = false;
|
|
10018
10116
|
}
|
|
10019
|
-
/**
|
|
10117
|
+
/**
|
|
10118
|
+
* Esperando o estado ou com `loading`, sem fonte de dados: "Carregando…"
|
|
10119
|
+
* aos 300 ms, uma vez (com fonte, `#afterRenderLoad` cuida). Ao terminar
|
|
10120
|
+
* uma carga anunciada, diz quantas linhas vieram (ou "sem dados"): quem
|
|
10121
|
+
* ouviu o começo fica sabendo do fim (WCAG 4.1.3).
|
|
10122
|
+
*/
|
|
10020
10123
|
#announceStateLoading() {
|
|
10021
10124
|
if (this.#dataSource) {
|
|
10022
10125
|
return;
|
|
10023
10126
|
}
|
|
10024
|
-
|
|
10127
|
+
const waiting = this.#stateWaiting || this.loading;
|
|
10128
|
+
if (!waiting) {
|
|
10025
10129
|
clearTimeout(this.#loadingTimer);
|
|
10026
10130
|
this.#loadingTimer = undefined;
|
|
10131
|
+
// Só o \`loading\` anuncia o fim (a espera do estado salvo segue como antes: limpa e pronto).
|
|
10132
|
+
const announced = this.#loadingAnnounced && this.#loadingByProperty;
|
|
10133
|
+
this.#loadingByProperty = false;
|
|
10027
10134
|
this.#clearLoadingAnnouncement();
|
|
10135
|
+
if (announced) {
|
|
10136
|
+
this.#announce(this.#rows.length
|
|
10137
|
+
? formatMessage(this.#translation.filteredAnnouncement, { count: String(this.#totalCount) })
|
|
10138
|
+
: this.#translation.noData);
|
|
10139
|
+
}
|
|
10028
10140
|
}
|
|
10029
10141
|
else if (!this.#loadingTimer && !this.#loadingAnnounced && this.isConnected) {
|
|
10030
10142
|
this.#loadingTimer = setTimeout(() => {
|
|
10031
10143
|
this.#loadingTimer = undefined;
|
|
10032
|
-
if (this.#stateWaiting) {
|
|
10144
|
+
if (this.#stateWaiting || this.loading) {
|
|
10145
|
+
this.#loadingByProperty = this.loading;
|
|
10033
10146
|
this.#loadingAnnounced = true;
|
|
10034
10147
|
this.#announce(this.#translation.loading);
|
|
10035
10148
|
}
|
|
@@ -10243,7 +10356,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10243
10356
|
const columns = [...this._regularColumns, ...this._groupColumns];
|
|
10244
10357
|
const known = new Set(columns);
|
|
10245
10358
|
const contexts = new Map();
|
|
10246
|
-
const
|
|
10359
|
+
const translation = this.#translation;
|
|
10247
10360
|
const language = this.language;
|
|
10248
10361
|
const dataTypeOf = (column) => known.has(column)
|
|
10249
10362
|
? this.#dataTypeOf(column)
|
|
@@ -10251,7 +10364,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10251
10364
|
const contextOf = (column) => {
|
|
10252
10365
|
let context = contexts.get(column);
|
|
10253
10366
|
if (!context) {
|
|
10254
|
-
context = { language, dataType: dataTypeOf(column),
|
|
10367
|
+
context = { language, dataType: dataTypeOf(column), ...booleanTexts(column, translation) };
|
|
10255
10368
|
contexts.set(column, context);
|
|
10256
10369
|
}
|
|
10257
10370
|
return context;
|
|
@@ -10259,6 +10372,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10259
10372
|
return {
|
|
10260
10373
|
language,
|
|
10261
10374
|
columns,
|
|
10375
|
+
resolve: this.#resolveFilterField,
|
|
10262
10376
|
dataTypeOf,
|
|
10263
10377
|
textOf: (item, column) => formatCell(item, column, contextOf(column)),
|
|
10264
10378
|
alphabetOf: column => displayAlphabet(column, contextOf(column), foldText),
|
|
@@ -10279,7 +10393,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10279
10393
|
* @internal
|
|
10280
10394
|
*/
|
|
10281
10395
|
_searchColumns() {
|
|
10282
|
-
return [...this._groupColumns, ...this._shownColumns].filter(
|
|
10396
|
+
return [...this._groupColumns, ...this._shownColumns].filter(column => this.#isFilterable(column));
|
|
10283
10397
|
}
|
|
10284
10398
|
/** @internal */
|
|
10285
10399
|
_columnDataType(column) {
|
|
@@ -10287,7 +10401,51 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10287
10401
|
}
|
|
10288
10402
|
/** @internal */
|
|
10289
10403
|
_isFilterable(column) {
|
|
10290
|
-
return
|
|
10404
|
+
return this.#isFilterable(column);
|
|
10405
|
+
}
|
|
10406
|
+
/** @internal */
|
|
10407
|
+
_resolveFilterField(field) {
|
|
10408
|
+
return this.#resolveFilterField(field);
|
|
10409
|
+
}
|
|
10410
|
+
/** Campo de condição → coluna (spec 28); índice refeito quando as colunas mudam. */
|
|
10411
|
+
#filterFields;
|
|
10412
|
+
/** Coluna do campo de uma condição: `path`, depois `name` de coluna sem `path` (o mesmo do avaliador). */
|
|
10413
|
+
#resolveFilterField;
|
|
10414
|
+
/** Colunas já avisadas por `filterable: true` sem efeito (uma vez por coluna). */
|
|
10415
|
+
#warnedFilterable;
|
|
10416
|
+
/**
|
|
10417
|
+
* O usuário pode filtrar pela coluna (linha de filtro, funil, busca)? Além
|
|
10418
|
+
* de {@link isColumnFilterable}: a coluna sem `path` precisa ser a dona do
|
|
10419
|
+
* próprio `name` (sem colisão com um `path` ou com outra calculada) e, com
|
|
10420
|
+
* filtro remoto, só com `filterable: true` (o servidor não conhece o getter).
|
|
10421
|
+
*/
|
|
10422
|
+
#isFilterable(column) {
|
|
10423
|
+
if (!isColumnFilterable(column)) {
|
|
10424
|
+
if (column.filterable === true) {
|
|
10425
|
+
this.#warnFilterable(column, 'needs a "path", or a "valueGetter" and a "name", to be filterable; ignored.');
|
|
10426
|
+
}
|
|
10427
|
+
return false;
|
|
10428
|
+
}
|
|
10429
|
+
if (column.path) {
|
|
10430
|
+
return true;
|
|
10431
|
+
}
|
|
10432
|
+
if (this.#resolveFilterField(column.name) !== column) {
|
|
10433
|
+
if (column.filterable === true) {
|
|
10434
|
+
this.#warnFilterable(column, `has the name "${column.name}" of another column's path or name; not filterable.`);
|
|
10435
|
+
}
|
|
10436
|
+
return false;
|
|
10437
|
+
}
|
|
10438
|
+
return !this.#remote.filtering || column.filterable === true;
|
|
10439
|
+
}
|
|
10440
|
+
/** Funil do filtro do cabeçalho: sem ele na coluna calculada remota (a lista viria só das linhas carregadas). */
|
|
10441
|
+
#hasFunnel(column) {
|
|
10442
|
+
return this.headerFilter && this.#isFilterable(column) && (!!column.path || !this.#remote.filtering);
|
|
10443
|
+
}
|
|
10444
|
+
#warnFilterable(column, problem) {
|
|
10445
|
+
if (!this.#warnedFilterable.has(column)) {
|
|
10446
|
+
this.#warnedFilterable.add(column);
|
|
10447
|
+
console.warn(`<u-grid>: column "${columnText(column)}" ${problem}`);
|
|
10448
|
+
}
|
|
10291
10449
|
}
|
|
10292
10450
|
/**
|
|
10293
10451
|
* Gesto na linha de filtro ou no filtro do cabeçalho: troca (ou tira, com
|
|
@@ -10295,7 +10453,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10295
10453
|
* @internal
|
|
10296
10454
|
*/
|
|
10297
10455
|
_userFilterColumn(column, kind, condition) {
|
|
10298
|
-
this.#changeFilter(replaceColumnCondition(this.#filtering.filterValue, column, kind, condition), this.#filtering.searchText, 'user');
|
|
10456
|
+
this.#changeFilter(replaceColumnCondition(this.#filtering.filterValue, column, kind, condition, this.#resolveFilterField), this.#filtering.searchText, 'user');
|
|
10299
10457
|
}
|
|
10300
10458
|
/** @internal */
|
|
10301
10459
|
_userSearch(text) {
|
|
@@ -10308,7 +10466,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10308
10466
|
* @internal
|
|
10309
10467
|
*/
|
|
10310
10468
|
_distinctValues(column) {
|
|
10311
|
-
const others = combineFilters(replaceColumnCondition(this.#filtering.filterValue, column, 'header', null), searchExpression(this.#filtering.searchText, this._searchColumns()));
|
|
10469
|
+
const others = combineFilters(replaceColumnCondition(this.#filtering.filterValue, column, 'header', null, this.#resolveFilterField), searchExpression(this.#filtering.searchText, this._searchColumns()));
|
|
10312
10470
|
let items = this.#items;
|
|
10313
10471
|
try {
|
|
10314
10472
|
items = filterItems(items, compileFilter(others, this._filterContext()));
|
|
@@ -10408,8 +10566,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10408
10566
|
return this.#dataTypes.get(column);
|
|
10409
10567
|
}
|
|
10410
10568
|
#formatContext(column) {
|
|
10411
|
-
|
|
10412
|
-
return { language: this.language, dataType: this.#dataTypeOf(column), trueText, falseText };
|
|
10569
|
+
return { language: this.language, dataType: this.#dataTypeOf(column), ...booleanTexts(column, this.#translation) };
|
|
10413
10570
|
}
|
|
10414
10571
|
#groupValueText(row) {
|
|
10415
10572
|
const { column } = row;
|
|
@@ -10430,9 +10587,9 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10430
10587
|
return formatCellValue(row.value, row.firstItem, column, this.#formatContext(column));
|
|
10431
10588
|
}
|
|
10432
10589
|
// ---------------------------------------------------------------- resumos
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
return { language: this.language,
|
|
10590
|
+
/** Contexto dos resumos; os textos de `true`/`false` são os da coluna do resumo. */
|
|
10591
|
+
#summaryFormatContext(column) {
|
|
10592
|
+
return { language: this.language, ...booleanTexts(column, this.#translation) };
|
|
10436
10593
|
}
|
|
10437
10594
|
#summaryTypeName(item) {
|
|
10438
10595
|
if (item.label) {
|
|
@@ -10457,7 +10614,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
10457
10614
|
/** Texto da célula (`"Sum: 1,234"`) e rótulo completo (`"Sum of Population: 1,234"`). */
|
|
10458
10615
|
#summaryText({ item, spec }, value) {
|
|
10459
10616
|
const translation = this.#translation;
|
|
10460
|
-
const valueText = formatSummaryValue(value, spec, item.format, this.#summaryFormatContext);
|
|
10617
|
+
const valueText = formatSummaryValue(value, spec, item.format, this.#summaryFormatContext(spec.column));
|
|
10461
10618
|
const type = this.#summaryTypeName(item);
|
|
10462
10619
|
const column = spec.column ? columnText(spec.column) : '';
|
|
10463
10620
|
const text = type ? formatMessage(translation.summaryText, { type, value: valueText }) : valueText;
|
|
@@ -11290,7 +11447,9 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
11290
11447
|
const thead = root.querySelector('thead');
|
|
11291
11448
|
const toolbar = root.querySelector('.header');
|
|
11292
11449
|
// Com a barra, o cabeçalho prende logo abaixo dela (\`.header + table thead\`); as fixas do topo, abaixo dele.
|
|
11293
|
-
|
|
11450
|
+
// Cabeçalho alto demais (\`headerWrap\`, regra dos 50%): ele rola com o conteúdo e não cobre nada.
|
|
11451
|
+
const head = this._containerRef.value?.classList.contains('header-rows-scroll') ? 0 : thead?.offsetHeight ?? 0;
|
|
11452
|
+
return head + (toolbar?.offsetHeight ?? 0) + this.#fixedHeight('top');
|
|
11294
11453
|
}
|
|
11295
11454
|
/** Altura do rodapé de totais e das fixas do fundo (presos no fim da rolagem). */
|
|
11296
11455
|
#stickyBottom() {
|
|
@@ -12003,10 +12162,10 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12003
12162
|
class=${`grid-table${fit ? ' fit' : ''}${this.#cellSelectionMode !== 'none' ? ' cell-range-mode' : ''}`}
|
|
12004
12163
|
role=${this._groupColumns.length || this.#treeOn ? 'treegrid' : 'grid'}
|
|
12005
12164
|
aria-label=${ifDefined(this.#hostLabel.name || undefined)}
|
|
12006
|
-
aria-rowcount="${waiting || this.#unknownRowCount ? -1 : this.#bodyRowCount + headerRows + footerRows + fixedTop.length + fixedBottom.length}"
|
|
12165
|
+
aria-rowcount="${waiting || this.#unknownRowCount || this.#loadingPlaceholders ? -1 : this.#bodyRowCount + headerRows + footerRows + fixedTop.length + fixedBottom.length}"
|
|
12007
12166
|
aria-colcount="${navColumns.length}"
|
|
12008
12167
|
aria-multiselectable=${ifDefined(selectionMode === 'multiple' || this.#cellSelectionMode !== 'none' ? 'true' : undefined)}
|
|
12009
|
-
aria-busy=${ifDefined(waiting || (this.#isLoading && !this.#reshapeLoading) || this.#filtering.pending ? 'true' : undefined)}
|
|
12168
|
+
aria-busy=${ifDefined(waiting || (this.#isLoading && !this.#reshapeLoading) || this.#filtering.pending || this.#loadingPlaceholders ? 'true' : undefined)}
|
|
12010
12169
|
${ref(this.#tableRef)}
|
|
12011
12170
|
@pointerover=${this.#updateCellHint}
|
|
12012
12171
|
@keydown=${this.#onGridKeyDown}
|
|
@@ -12180,7 +12339,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12180
12339
|
controller: this.#filterRow,
|
|
12181
12340
|
column: cell.column,
|
|
12182
12341
|
dataType: this.#dataTypeOf(cell.column),
|
|
12183
|
-
filterable:
|
|
12342
|
+
filterable: this.#isFilterable(cell.column),
|
|
12184
12343
|
translation,
|
|
12185
12344
|
className: cell.className,
|
|
12186
12345
|
style: cell.style,
|
|
@@ -12308,8 +12467,12 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12308
12467
|
const idSuffix = `${header.level}-${cell.col + 1}`;
|
|
12309
12468
|
return renderHeaderCell({
|
|
12310
12469
|
column,
|
|
12311
|
-
|
|
12312
|
-
|
|
12470
|
+
classes: {
|
|
12471
|
+
...cell.headerClasses,
|
|
12472
|
+
// Cabeçalho multinível: a folha que fecha a última posição não leva a linha do fim (é a borda do grid).
|
|
12473
|
+
'last-column': header.start + header.span === cells.length,
|
|
12474
|
+
'header-wrap': this.#wrapsHeader(column),
|
|
12475
|
+
},
|
|
12313
12476
|
styles: cell.headerStyles,
|
|
12314
12477
|
colIndex: cell.col + 1,
|
|
12315
12478
|
tabIndex: active === column ? 0 : -1,
|
|
@@ -12332,12 +12495,12 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12332
12495
|
}
|
|
12333
12496
|
: undefined,
|
|
12334
12497
|
trailing: cell.resizable ? this.#renderResizeHandle(cell, idSuffix) : nothing,
|
|
12335
|
-
filterButton: this
|
|
12336
|
-
? renderHeaderFilterButton(this.#headerFilterPopover, column, filterValue, this.#translation, `header-description-${idSuffix}`, idSuffix, this.#textLanguage)
|
|
12498
|
+
filterButton: this.#hasFunnel(column)
|
|
12499
|
+
? renderHeaderFilterButton(this.#headerFilterPopover, column, filterValue, this.#translation, this.#resolveFilterField, `header-description-${idSuffix}`, idSuffix, this.#textLanguage)
|
|
12337
12500
|
: nothing,
|
|
12338
12501
|
menuButton: this.#renderColumnMenuButton(column, idSuffix),
|
|
12339
|
-
filtered: hasColumnCondition(filterValue, column),
|
|
12340
|
-
description: this.#headerDescription(column, rowSorting[position]?.order, position + 1, showIndex, hasColumnCondition(filterValue, column)),
|
|
12502
|
+
filtered: hasColumnCondition(filterValue, column, this.#resolveFilterField),
|
|
12503
|
+
description: this.#headerDescription(column, rowSorting[position]?.order, position + 1, showIndex, hasColumnCondition(filterValue, column, this.#resolveFilterField)),
|
|
12341
12504
|
keyShortcuts: this.#headerKeyShortcuts(column, cell.resizable),
|
|
12342
12505
|
label: column.headerRenderer ? this.#renderHeaderContent(column, cell.id) : headerText(column),
|
|
12343
12506
|
});
|
|
@@ -12416,7 +12579,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12416
12579
|
/** \`aria-keyshortcuts\` do cabeçalho: só as teclas que valem para a coluna (nomes do UI Events). */
|
|
12417
12580
|
#headerKeyShortcuts(column, resizable) {
|
|
12418
12581
|
const keys = [];
|
|
12419
|
-
const funnel = this
|
|
12582
|
+
const funnel = this.#hasFunnel(column);
|
|
12420
12583
|
if (this.#hasColumnMenu(column)) {
|
|
12421
12584
|
keys.push('Shift+F10');
|
|
12422
12585
|
}
|
|
@@ -12540,19 +12703,47 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12540
12703
|
}
|
|
12541
12704
|
}}>${named?.parts ?? nothing}</div>`;
|
|
12542
12705
|
}
|
|
12706
|
+
/** Rótulo do cabeçalho quebra linha: o da coluna ou o padrão do grid. */
|
|
12707
|
+
#wrapsHeader(column) {
|
|
12708
|
+
return column.headerWrap ?? this.headerWrap;
|
|
12709
|
+
}
|
|
12710
|
+
/** Alguma coluna visível quebra o rótulo: o cabeçalho tem altura variável (observado). */
|
|
12711
|
+
get #anyHeaderWrap() {
|
|
12712
|
+
return this.headerWrap || this._visibleColumns.some(column => column.headerWrap);
|
|
12713
|
+
}
|
|
12714
|
+
/** `loading` sem linhas: a contagem de linhas fica desconhecida e o esqueleto é só visual. */
|
|
12715
|
+
get #loadingPlaceholders() {
|
|
12716
|
+
return this.loading && !this.#rows.length && !this.#waitingForState;
|
|
12717
|
+
}
|
|
12718
|
+
/**
|
|
12719
|
+
* Linha do estado vazio: "sem dados" ou, com `loading`, "Carregando…" e
|
|
12720
|
+
* linhas de esqueleto só visuais (`aria-hidden`, sem papel nem foco; spec
|
|
12721
|
+
* 17), no lugar do que caberia na tela. Um template só: ao terminar a carga
|
|
12722
|
+
* o mesmo `<td>` fica e só o conteúdo muda.
|
|
12723
|
+
*/
|
|
12724
|
+
#renderEmptyRow(layout) {
|
|
12725
|
+
const columns = Math.max(this.#totalColumns(layout), 1);
|
|
12726
|
+
const loading = this.loading;
|
|
12727
|
+
return html `
|
|
12728
|
+
<tr role="row" class=${loading ? 'no-data-row loading-row' : 'no-data-row'}>
|
|
12729
|
+
<td role="gridcell" part="no-data" lang=${ifDefined(this.noDataRenderer && !loading ? undefined : this.#textLanguage)} colspan="${columns}">${loading
|
|
12730
|
+
? this.#translation.loading
|
|
12731
|
+
: this.noDataRenderer ? this.#renderNoDataContent(this.noDataRenderer) : this.#translation.noData}</td>
|
|
12732
|
+
</tr>
|
|
12733
|
+
${loading
|
|
12734
|
+
? map(Array.from({ length: this.#placeholderRows }), () => html `
|
|
12735
|
+
<tr class="skeleton-row loading-placeholder" part="row skeleton-row" aria-hidden="true">
|
|
12736
|
+
${map(Array.from({ length: columns }), () => html `<td><span class="skeleton"></span></td>`)}
|
|
12737
|
+
</tr>`)
|
|
12738
|
+
: nothing}`;
|
|
12739
|
+
}
|
|
12543
12740
|
#renderBody(window, headerRows, layout) {
|
|
12544
12741
|
if (!this.#rows.length) {
|
|
12545
12742
|
// Carregando pela 1ª vez (ou esperando o estado): o painel fala; "sem dados" só depois da resposta.
|
|
12546
12743
|
if (this.#waitingForState || (this.#dataSource && !this.#loader.current)) {
|
|
12547
12744
|
return nothing;
|
|
12548
12745
|
}
|
|
12549
|
-
return
|
|
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
|
-
`;
|
|
12746
|
+
return this.#renderEmptyRow(layout);
|
|
12556
12747
|
}
|
|
12557
12748
|
// As linhas ficam no fluxo da tabela, uma após a outra, depois de uma
|
|
12558
12749
|
// linha espaçadora com a altura até a 1ª linha da janela (vale também
|
|
@@ -12622,13 +12813,15 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12622
12813
|
/** Painel de carregamento (consulta inteira) e barra de erro com "tentar de novo". */
|
|
12623
12814
|
#renderLoadState() {
|
|
12624
12815
|
const waiting = this.#waitingForState;
|
|
12625
|
-
|
|
12816
|
+
// `loading` com linhas na tela: o painel por cima, sem `aria-busy` (as células seguem legíveis).
|
|
12817
|
+
const localLoading = this.loading && this.#rows.length > 0;
|
|
12818
|
+
if (!this.#dataSource && !waiting && !localLoading) {
|
|
12626
12819
|
return nothing;
|
|
12627
12820
|
}
|
|
12628
12821
|
const translation = this.#translation;
|
|
12629
12822
|
const failure = this.#dataSource ? this.#loader.error : undefined;
|
|
12630
12823
|
return html `
|
|
12631
|
-
${waiting || this.#isLoading
|
|
12824
|
+
${waiting || this.#isLoading || localLoading
|
|
12632
12825
|
? html `<div class="load-panel" part="load-panel" aria-hidden=${ifDefined(waiting ? undefined : 'true')}>
|
|
12633
12826
|
<span class="load-spinner" aria-hidden="true"></span><span>${translation.loading}</span>
|
|
12634
12827
|
</div>`
|
|
@@ -12930,7 +13123,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
12930
13123
|
const sortText = order && sorting.length > 1 && sortPosition > 0
|
|
12931
13124
|
? formatMessage(translation.columnSortPriority, { order: orderText, priority: String(sortPosition + 1) })
|
|
12932
13125
|
: orderText;
|
|
12933
|
-
const filtered = hasColumnCondition(filterValue, column);
|
|
13126
|
+
const filtered = hasColumnCondition(filterValue, column, this.#resolveFilterField);
|
|
12934
13127
|
const cell = this.#adaptiveCellLayout(column, id);
|
|
12935
13128
|
const removed = pending?.type === 'remove';
|
|
12936
13129
|
const added = pending?.type === 'add';
|
|
@@ -13614,7 +13807,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
13614
13807
|
return rendererContent({
|
|
13615
13808
|
host: this,
|
|
13616
13809
|
slotName: `u-grid-internal:group:${row.key}`,
|
|
13617
|
-
deps: [row.groupKey, column, renderer, this.#renderEpoch(), row.value, row.expanded, row.itemCount, row.summaries, defaultText],
|
|
13810
|
+
deps: [row.groupKey, column, renderer, this.#renderEpoch(), row.value, row.expanded, row.itemCount, row.summaries, defaultText, row.firstItem],
|
|
13618
13811
|
renderer,
|
|
13619
13812
|
invoke: signal => renderer.call(column, {
|
|
13620
13813
|
column,
|
|
@@ -13624,6 +13817,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
13624
13817
|
groupIndex: row.level,
|
|
13625
13818
|
itemCount: row.itemCount,
|
|
13626
13819
|
expanded: row.expanded,
|
|
13820
|
+
firstItem: row.firstItem,
|
|
13627
13821
|
get summaries() {
|
|
13628
13822
|
return summaries();
|
|
13629
13823
|
},
|
|
@@ -13684,7 +13878,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
13684
13878
|
return html `<span class="node-summary">${this.#summaryTexts(summary)}</span>`;
|
|
13685
13879
|
}
|
|
13686
13880
|
const content = renderDataCell(this, row, cell.column, cell.id, cell.format, this.#renderEpoch(), adaptive);
|
|
13687
|
-
return matcher && typeof content === 'string' &&
|
|
13881
|
+
return matcher && typeof content === 'string' && this.#isFilterable(cell.column)
|
|
13688
13882
|
? renderHighlighted(content, matcher)
|
|
13689
13883
|
: content;
|
|
13690
13884
|
}
|
|
@@ -15731,6 +15925,12 @@ __decorate([
|
|
|
15731
15925
|
__decorate([
|
|
15732
15926
|
property({ attribute: false })
|
|
15733
15927
|
], DataGrid.prototype, "noDataRenderer", void 0);
|
|
15928
|
+
__decorate([
|
|
15929
|
+
property({ type: Boolean, converter: booleanAttribute(false) })
|
|
15930
|
+
], DataGrid.prototype, "loading", void 0);
|
|
15931
|
+
__decorate([
|
|
15932
|
+
property({ type: Boolean, converter: booleanAttribute(false), attribute: 'header-wrap' })
|
|
15933
|
+
], DataGrid.prototype, "headerWrap", void 0);
|
|
15734
15934
|
__decorate([
|
|
15735
15935
|
property({ attribute: false })
|
|
15736
15936
|
], DataGrid.prototype, "detailRenderer", void 0);
|