@universal-material/data-grid 0.3.0 → 0.3.2
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/custom-elements.json +8 -4
- package/dist/features/scroll-port.d.ts +7 -0
- package/dist/features/scroll-port.js +22 -0
- package/dist/features/scroll-port.js.map +1 -1
- package/dist/grid-column-def.d.ts +2 -2
- package/dist/grid-column-def.js.map +1 -1
- package/dist/grid.d.ts +28 -10
- package/dist/grid.js +118 -9
- package/dist/grid.js.map +1 -1
- package/dist/grid.min.js +297 -256
- package/dist/grid.styles.js +45 -4
- package/dist/grid.styles.js.map +1 -1
- package/dist/row-model/group.d.ts +2 -0
- package/dist/row-model/group.js +2 -0
- package/dist/row-model/group.js.map +1 -1
- package/package.json +1 -1
package/dist/grid.js
CHANGED
|
@@ -59,7 +59,7 @@ import { allValuesConvert, applyMask, combineFilters, compileFilter, filterItems
|
|
|
59
59
|
import { flattenRows, pageBounds, RowList, RowPage } from './row-model/flatten.js';
|
|
60
60
|
import { createTextMatcher, foldText } from './row-model/fold.js';
|
|
61
61
|
import { DEFAULT_DATE, displayAlphabet, formatCell, formatCellValue, getDateTimeFormat, getNumberFormat, resolveAlignment, resolveDataType, toDate, } from './row-model/format.js';
|
|
62
|
-
import { buildGroups, groupKeyOf } from './row-model/group.js';
|
|
62
|
+
import { buildGroups, groupKeyOf, groupValuesOf } from './row-model/group.js';
|
|
63
63
|
import { LruCache } from './row-model/lru.js';
|
|
64
64
|
import { sortOrder } from './row-model/sort.js';
|
|
65
65
|
import { formatSummaryValue, summarize } from './row-model/summary.js';
|
|
@@ -542,6 +542,7 @@ const isRenderResult = (value) => value === null || value === undefined || value
|
|
|
542
542
|
* @cssprop --u-grid-header-cell-padding - Header cell padding.
|
|
543
543
|
* @cssprop --u-grid-header-cell-font-size - Header cell font size. Default `0.8125rem`.
|
|
544
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).
|
|
545
546
|
* @cssprop --u-grid-cell-padding - Data cell padding (shorthand; wins over the longhands). Default `13px 16px`.
|
|
546
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`.
|
|
547
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`.
|
|
@@ -718,10 +719,14 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
718
719
|
this.loading = false;
|
|
719
720
|
/**
|
|
720
721
|
* 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).
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
* the
|
|
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).
|
|
725
730
|
*/
|
|
726
731
|
this.headerWrap = false;
|
|
727
732
|
/** Linhas de esqueleto do `loading` sem linhas: fixo no servidor e no 1º render (hidratação); depois, o que cabe. */
|
|
@@ -1393,6 +1398,19 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
1393
1398
|
/** Barra (painel de grupos, busca, seletor) observada para a altura que prende o cabeçalho. */
|
|
1394
1399
|
this.#observedToolbar = null;
|
|
1395
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
|
+
};
|
|
1396
1414
|
/**
|
|
1397
1415
|
* Linhas de detalhe de um bloco de itens: posições dos itens cuja expansão
|
|
1398
1416
|
* difere do padrão. Poucas chaves sem `keyExpr`: `indexOf` por chave
|
|
@@ -1680,7 +1698,21 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
1680
1698
|
* ao passar o mouse — medir todas as células a cada render custaria caro.
|
|
1681
1699
|
*/
|
|
1682
1700
|
this.#updateCellHint = (event) => {
|
|
1683
|
-
const
|
|
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');
|
|
1684
1716
|
if (!(cell instanceof HTMLElement)) {
|
|
1685
1717
|
return;
|
|
1686
1718
|
}
|
|
@@ -4494,12 +4526,20 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
4494
4526
|
}
|
|
4495
4527
|
return result;
|
|
4496
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;
|
|
4497
4535
|
connectedCallback() {
|
|
4498
4536
|
// Shadow root declarativo antes do 1º update: hidratação do SSR.
|
|
4499
4537
|
const hydrating = !this.hasUpdated && !!this.shadowRoot;
|
|
4500
4538
|
super.connectedCallback();
|
|
4501
4539
|
this.#readDeclarativeColumns();
|
|
4502
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);
|
|
4503
4543
|
this.#hostLabel.update();
|
|
4504
4544
|
this.#dragAndDropDirty = true;
|
|
4505
4545
|
this.#layoutDirty = true;
|
|
@@ -4534,6 +4574,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
4534
4574
|
super.disconnectedCallback();
|
|
4535
4575
|
this.#unobserveDocumentLanguage?.();
|
|
4536
4576
|
this.#unobserveDocumentLanguage = undefined;
|
|
4577
|
+
document.fonts?.removeEventListener('loadingdone', this.#onFontsLoaded);
|
|
4537
4578
|
this.#columnDragAndDrop.detach();
|
|
4538
4579
|
this.#groupDragAndDrop.detach();
|
|
4539
4580
|
releaseInteractions(this);
|
|
@@ -5600,9 +5641,12 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5600
5641
|
/**
|
|
5601
5642
|
* Scrolls to the cell of the row `rowKey` and `column` (default: the first
|
|
5602
5643
|
* visible column) and moves the DOM focus to it. Returns `false` when the
|
|
5603
|
-
* row is not in the grid (filtered out or in a collapsed group
|
|
5604
|
-
*
|
|
5605
|
-
*
|
|
5644
|
+
* row is not in the grid (filtered out, or in a collapsed group or tree
|
|
5645
|
+
* node — unless `options.expandAncestors`, which expands them first, from
|
|
5646
|
+
* the outer level in, firing `u-grid-group-expansion-change` /
|
|
5647
|
+
* `u-grid-node-expansion-change` with `source: 'api'`) or `column` is not
|
|
5648
|
+
* a shown (user-visible), ungrouped column (a band returns `false`). A
|
|
5649
|
+
* `false` result changes nothing. A column hidden by `autoHideColumns`
|
|
5606
5650
|
* opens the row details (`u-grid-row-expansion-change`, `source: 'api'`)
|
|
5607
5651
|
* and focuses its value. Before the
|
|
5608
5652
|
* first render it only sets the active cell (the focus moves when it is
|
|
@@ -5614,6 +5658,16 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5614
5658
|
focusCell(rowKey, column, options) {
|
|
5615
5659
|
this.#ensureRows();
|
|
5616
5660
|
const fixed = options?.rowFixed;
|
|
5661
|
+
// Linha num grupo (ou nó da árvore) fechado: abre o caminho até ela (opcional; padrão: não abre).
|
|
5662
|
+
// Antes, o que é síncrono: com coluna inválida o \`false\` não pode deixar grupos abertos.
|
|
5663
|
+
if (options?.expandAncestors && !fixed && this.#rowIndexOfKey(rowKey) < 0) {
|
|
5664
|
+
const wanted = column === undefined || column === null ? undefined : this.#leafColumn(column);
|
|
5665
|
+
const usable = column === undefined || column === null
|
|
5666
|
+
|| (!!wanted && (this._visibleColumns.includes(wanted) || this.#adaptiveColumns.includes(wanted)) && !this._groupColumns.includes(wanted));
|
|
5667
|
+
if (usable && this.#expandToRow(rowKey)) {
|
|
5668
|
+
this.#ensureRows();
|
|
5669
|
+
}
|
|
5670
|
+
}
|
|
5617
5671
|
const fixedPosition = fixed ? this.#fixedRows()[fixed].findIndex(entry => this.#keyOf(entry.item) === rowKey) : -1;
|
|
5618
5672
|
const row = fixed ? fixedPosition < 0 ? -1 : this.#fixedIndex(fixed, fixedPosition) : this.#rowIndexOfKey(rowKey);
|
|
5619
5673
|
if (row < 0) {
|
|
@@ -5632,6 +5686,60 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5632
5686
|
this.#setActive({ row, col: Math.max(col, 0) }, 'api', { focus: true, reveal: true });
|
|
5633
5687
|
return true;
|
|
5634
5688
|
}
|
|
5689
|
+
/**
|
|
5690
|
+
* Abre os grupos fechados que contêm a linha (do nível de fora para dentro;
|
|
5691
|
+
* um \`u-grid-group-expansion-change\` por grupo, \`source: 'api'\`) ou, na
|
|
5692
|
+
* árvore, os nós fechados acima dela. Nada com fonte remota (os grupos vêm
|
|
5693
|
+
* do servidor) nem para uma linha filtrada. \`true\` se abriu algo.
|
|
5694
|
+
*/
|
|
5695
|
+
#expandToRow(rowKey) {
|
|
5696
|
+
if (this.#dataSource) {
|
|
5697
|
+
return false;
|
|
5698
|
+
}
|
|
5699
|
+
if (this.#treeOn) {
|
|
5700
|
+
const index = this.#tree.index;
|
|
5701
|
+
const node = this.#nodeOfKey(rowKey);
|
|
5702
|
+
if (!index || node < 0) {
|
|
5703
|
+
return false;
|
|
5704
|
+
}
|
|
5705
|
+
const chain = [];
|
|
5706
|
+
for (let parent = index.parent[node]; parent >= 0; parent = index.parent[parent]) {
|
|
5707
|
+
chain.unshift(parent);
|
|
5708
|
+
}
|
|
5709
|
+
let opened = false;
|
|
5710
|
+
for (const parent of chain) {
|
|
5711
|
+
if (!this.#nodeShownExpanded(parent)) {
|
|
5712
|
+
void this.#setNodeExpanded(this.#keyOf(index.nodes[parent]), true, 'api');
|
|
5713
|
+
opened = true;
|
|
5714
|
+
}
|
|
5715
|
+
}
|
|
5716
|
+
return opened;
|
|
5717
|
+
}
|
|
5718
|
+
const columns = this._groupColumns;
|
|
5719
|
+
if (!columns.length) {
|
|
5720
|
+
return false;
|
|
5721
|
+
}
|
|
5722
|
+
const item = this.items.find(candidate => this.#keyOf(candidate) === rowKey);
|
|
5723
|
+
if (item === undefined) {
|
|
5724
|
+
return false;
|
|
5725
|
+
}
|
|
5726
|
+
// O grupo de dentro precisa existir e conter o item (filtrado: nada abre).
|
|
5727
|
+
const values = groupValuesOf(item, columns);
|
|
5728
|
+
const leaf = this.#findGroup(values);
|
|
5729
|
+
if (!leaf?.items.includes(item)) {
|
|
5730
|
+
return false;
|
|
5731
|
+
}
|
|
5732
|
+
let opened = false;
|
|
5733
|
+
for (let level = 0; level < values.length; level++) {
|
|
5734
|
+
const path = Object.freeze(values.slice(0, level + 1));
|
|
5735
|
+
const key = groupKeyOf(path, columns);
|
|
5736
|
+
if (key !== undefined && !this.#isExpanded(key, level)) {
|
|
5737
|
+
this.#setGroupExpanded(key, level, path, true, 'api');
|
|
5738
|
+
opened = true;
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5741
|
+
return opened;
|
|
5742
|
+
}
|
|
5635
5743
|
// ------------------------------------------------------------- edição
|
|
5636
5744
|
/** Mudanças pendentes por chave de linha (o grid nunca muta o item do hospedeiro). */
|
|
5637
5745
|
#edits;
|
|
@@ -9560,6 +9668,7 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9560
9668
|
this.#syncFixedRows();
|
|
9561
9669
|
this.#syncRevealMargins();
|
|
9562
9670
|
this.#scrollPort.checkHeight();
|
|
9671
|
+
this.#scrollPort.checkHorizontalClip(this.#tableRef.value?.offsetWidth ?? 0);
|
|
9563
9672
|
}
|
|
9564
9673
|
/**
|
|
9565
9674
|
* Classe, deslocamento `sticky` e limites de cada coluna visível. Os
|