@universal-material/data-grid 0.3.1 → 0.3.3
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 +2 -2
- package/dist/grid.d.ts +19 -6
- package/dist/grid.js +105 -10
- package/dist/grid.js.map +1 -1
- package/dist/grid.min.js +353 -311
- package/dist/grid.styles.js +44 -2
- 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/custom-elements.json
CHANGED
|
@@ -2204,11 +2204,11 @@
|
|
|
2204
2204
|
"name": "options",
|
|
2205
2205
|
"optional": true,
|
|
2206
2206
|
"type": {
|
|
2207
|
-
"text": "
|
|
2207
|
+
"text": "GridFocusCellOptions | null"
|
|
2208
2208
|
}
|
|
2209
2209
|
}
|
|
2210
2210
|
],
|
|
2211
|
-
"description": "Scrolls to the cell of the row `rowKey` and `column` (default: the first\nvisible column) and moves the DOM focus to it. Returns `false` when the\nrow is not in the grid (filtered out or in a collapsed group —
|
|
2211
|
+
"description": "Scrolls to the cell of the row `rowKey` and `column` (default: the first\nvisible column) and moves the DOM focus to it. Returns `false` when the\nrow is not in the grid (filtered out, or in a collapsed group or tree\nnode — unless `options.expandAncestors`, which expands them first, from\nthe outer level in, firing `u-grid-group-expansion-change` /\n`u-grid-node-expansion-change` with `source: 'api'`) or `column` is not\na shown (user-visible), ungrouped column (a band returns `false`). A\n`false` result changes nothing. A column hidden by `autoHideColumns`\nopens the row details (`u-grid-row-expansion-change`, `source: 'api'`)\nand focuses its value. Before the\nfirst render it only sets the active cell (the focus moves when it is\nrendered) and fires no event. `options.rowFixed` looks for the row among\nthe fixed rows of that side (`fixedTopItems`/`fixedBottomItems`) instead\nof the body (`false` when the key is not among them). In a full-width\nrow (`rowRenderer`) the focus goes to its single cell for any `column`."
|
|
2212
2212
|
},
|
|
2213
2213
|
{
|
|
2214
2214
|
"kind": "method",
|
package/dist/grid.d.ts
CHANGED
|
@@ -91,6 +91,18 @@ export interface GridNodeExpansionChangeEventDetail {
|
|
|
91
91
|
/** `user` (expand button, keyboard) or `api` (`expandNode`, `collapseNode`…; also a failed child load). */
|
|
92
92
|
source: GridChangeSource;
|
|
93
93
|
}
|
|
94
|
+
/** Options of `focusCell`. */
|
|
95
|
+
export interface GridFocusCellOptions {
|
|
96
|
+
/** Look for the row among the fixed rows of that side (`fixedTopItems`/`fixedBottomItems`) instead of the body. */
|
|
97
|
+
rowFixed?: GridRowFixed;
|
|
98
|
+
/**
|
|
99
|
+
* Expand the collapsed groups (or tree nodes) that contain the row, from
|
|
100
|
+
* the outer level in, before focusing it. Default `false`. Ignored with
|
|
101
|
+
* `rowFixed`; nothing expands with a remote `dataSource` or for a row that
|
|
102
|
+
* is filtered out (`false`).
|
|
103
|
+
*/
|
|
104
|
+
expandAncestors?: boolean;
|
|
105
|
+
}
|
|
94
106
|
/** Options of `addRow`. */
|
|
95
107
|
export interface GridAddRowOptions {
|
|
96
108
|
/** Tree data: key of the parent node — the new row is its first child (the node expands). */
|
|
@@ -1337,9 +1349,12 @@ export declare class DataGrid extends LitElement {
|
|
|
1337
1349
|
/**
|
|
1338
1350
|
* Scrolls to the cell of the row `rowKey` and `column` (default: the first
|
|
1339
1351
|
* visible column) and moves the DOM focus to it. Returns `false` when the
|
|
1340
|
-
* row is not in the grid (filtered out or in a collapsed group
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1352
|
+
* row is not in the grid (filtered out, or in a collapsed group or tree
|
|
1353
|
+
* node — unless `options.expandAncestors`, which expands them first, from
|
|
1354
|
+
* the outer level in, firing `u-grid-group-expansion-change` /
|
|
1355
|
+
* `u-grid-node-expansion-change` with `source: 'api'`) or `column` is not
|
|
1356
|
+
* a shown (user-visible), ungrouped column (a band returns `false`). A
|
|
1357
|
+
* `false` result changes nothing. A column hidden by `autoHideColumns`
|
|
1343
1358
|
* opens the row details (`u-grid-row-expansion-change`, `source: 'api'`)
|
|
1344
1359
|
* and focuses its value. Before the
|
|
1345
1360
|
* first render it only sets the active cell (the focus moves when it is
|
|
@@ -1348,9 +1363,7 @@ export declare class DataGrid extends LitElement {
|
|
|
1348
1363
|
* of the body (`false` when the key is not among them). In a full-width
|
|
1349
1364
|
* row (`rowRenderer`) the focus goes to its single cell for any `column`.
|
|
1350
1365
|
*/
|
|
1351
|
-
focusCell(rowKey: unknown, column?: GridColumnRef | null, options?:
|
|
1352
|
-
rowFixed?: GridRowFixed;
|
|
1353
|
-
} | null): boolean;
|
|
1366
|
+
focusCell(rowKey: unknown, column?: GridColumnRef | null, options?: GridFocusCellOptions | null): boolean;
|
|
1354
1367
|
/**
|
|
1355
1368
|
* Opens the editor of a cell (focus goes to it). In `row` mode it opens the
|
|
1356
1369
|
* whole row with the focus on that cell. A column hidden by
|
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';
|
|
@@ -1643,6 +1643,8 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
1643
1643
|
/** Largura visível da porta externa sobre a tabela (0 = rolagem interna). */
|
|
1644
1644
|
this.#visibleWidth = 0;
|
|
1645
1645
|
this.#syncedVisibleWidth = -1;
|
|
1646
|
+
/** Aviso de \`overflow-x\` adiado para depois do render que esconde as colunas (\`autoHideColumns\`). */
|
|
1647
|
+
this.#clipCheckPending = false;
|
|
1646
1648
|
this.#isExpanded = (key, level) => this.#expansion.get(key)?.expanded ?? this.#defaultExpanded(level);
|
|
1647
1649
|
this.#typesVersion = -1;
|
|
1648
1650
|
this.#warnedInfinitePaging = false;
|
|
@@ -4759,6 +4761,11 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
4759
4761
|
this.#observeToolbar();
|
|
4760
4762
|
this.#observeFixedSections();
|
|
4761
4763
|
this.#syncTableLabel();
|
|
4764
|
+
// Só com a largura da porta medida: antes disso o responsivo ainda não escondeu nada.
|
|
4765
|
+
if (this.#clipCheckPending && !this.#adaptiveDirty && this.#viewportWidth > 0) {
|
|
4766
|
+
this.#clipCheckPending = false;
|
|
4767
|
+
this.#scrollPort.checkHorizontalClip(this.#tableRef.value?.offsetWidth ?? 0);
|
|
4768
|
+
}
|
|
4762
4769
|
// Editor fechou (ou o foco saiu sem focusout no corpo): o reshape adiado roda agora.
|
|
4763
4770
|
if (this.#reshapePending && !this.#reshapeFrozen) {
|
|
4764
4771
|
queueMicrotask(() => this.#flushReshape());
|
|
@@ -5641,9 +5648,12 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5641
5648
|
/**
|
|
5642
5649
|
* Scrolls to the cell of the row `rowKey` and `column` (default: the first
|
|
5643
5650
|
* visible column) and moves the DOM focus to it. Returns `false` when the
|
|
5644
|
-
* row is not in the grid (filtered out or in a collapsed group
|
|
5645
|
-
*
|
|
5646
|
-
*
|
|
5651
|
+
* row is not in the grid (filtered out, or in a collapsed group or tree
|
|
5652
|
+
* node — unless `options.expandAncestors`, which expands them first, from
|
|
5653
|
+
* the outer level in, firing `u-grid-group-expansion-change` /
|
|
5654
|
+
* `u-grid-node-expansion-change` with `source: 'api'`) or `column` is not
|
|
5655
|
+
* a shown (user-visible), ungrouped column (a band returns `false`). A
|
|
5656
|
+
* `false` result changes nothing. A column hidden by `autoHideColumns`
|
|
5647
5657
|
* opens the row details (`u-grid-row-expansion-change`, `source: 'api'`)
|
|
5648
5658
|
* and focuses its value. Before the
|
|
5649
5659
|
* first render it only sets the active cell (the focus moves when it is
|
|
@@ -5655,6 +5665,16 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5655
5665
|
focusCell(rowKey, column, options) {
|
|
5656
5666
|
this.#ensureRows();
|
|
5657
5667
|
const fixed = options?.rowFixed;
|
|
5668
|
+
// Linha num grupo (ou nó da árvore) fechado: abre o caminho até ela (opcional; padrão: não abre).
|
|
5669
|
+
// Antes, o que é síncrono: com coluna inválida o \`false\` não pode deixar grupos abertos.
|
|
5670
|
+
if (options?.expandAncestors && !fixed && this.#rowIndexOfKey(rowKey) < 0) {
|
|
5671
|
+
const wanted = column === undefined || column === null ? undefined : this.#leafColumn(column);
|
|
5672
|
+
const usable = column === undefined || column === null
|
|
5673
|
+
|| (!!wanted && (this._visibleColumns.includes(wanted) || this.#adaptiveColumns.includes(wanted)) && !this._groupColumns.includes(wanted));
|
|
5674
|
+
if (usable && this.#expandToRow(rowKey)) {
|
|
5675
|
+
this.#ensureRows();
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5658
5678
|
const fixedPosition = fixed ? this.#fixedRows()[fixed].findIndex(entry => this.#keyOf(entry.item) === rowKey) : -1;
|
|
5659
5679
|
const row = fixed ? fixedPosition < 0 ? -1 : this.#fixedIndex(fixed, fixedPosition) : this.#rowIndexOfKey(rowKey);
|
|
5660
5680
|
if (row < 0) {
|
|
@@ -5673,6 +5693,60 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5673
5693
|
this.#setActive({ row, col: Math.max(col, 0) }, 'api', { focus: true, reveal: true });
|
|
5674
5694
|
return true;
|
|
5675
5695
|
}
|
|
5696
|
+
/**
|
|
5697
|
+
* Abre os grupos fechados que contêm a linha (do nível de fora para dentro;
|
|
5698
|
+
* um \`u-grid-group-expansion-change\` por grupo, \`source: 'api'\`) ou, na
|
|
5699
|
+
* árvore, os nós fechados acima dela. Nada com fonte remota (os grupos vêm
|
|
5700
|
+
* do servidor) nem para uma linha filtrada. \`true\` se abriu algo.
|
|
5701
|
+
*/
|
|
5702
|
+
#expandToRow(rowKey) {
|
|
5703
|
+
if (this.#dataSource) {
|
|
5704
|
+
return false;
|
|
5705
|
+
}
|
|
5706
|
+
if (this.#treeOn) {
|
|
5707
|
+
const index = this.#tree.index;
|
|
5708
|
+
const node = this.#nodeOfKey(rowKey);
|
|
5709
|
+
if (!index || node < 0) {
|
|
5710
|
+
return false;
|
|
5711
|
+
}
|
|
5712
|
+
const chain = [];
|
|
5713
|
+
for (let parent = index.parent[node]; parent >= 0; parent = index.parent[parent]) {
|
|
5714
|
+
chain.unshift(parent);
|
|
5715
|
+
}
|
|
5716
|
+
let opened = false;
|
|
5717
|
+
for (const parent of chain) {
|
|
5718
|
+
if (!this.#nodeShownExpanded(parent)) {
|
|
5719
|
+
void this.#setNodeExpanded(this.#keyOf(index.nodes[parent]), true, 'api');
|
|
5720
|
+
opened = true;
|
|
5721
|
+
}
|
|
5722
|
+
}
|
|
5723
|
+
return opened;
|
|
5724
|
+
}
|
|
5725
|
+
const columns = this._groupColumns;
|
|
5726
|
+
if (!columns.length) {
|
|
5727
|
+
return false;
|
|
5728
|
+
}
|
|
5729
|
+
const item = this.items.find(candidate => this.#keyOf(candidate) === rowKey);
|
|
5730
|
+
if (item === undefined) {
|
|
5731
|
+
return false;
|
|
5732
|
+
}
|
|
5733
|
+
// O grupo de dentro precisa existir e conter o item (filtrado: nada abre).
|
|
5734
|
+
const values = groupValuesOf(item, columns);
|
|
5735
|
+
const leaf = this.#findGroup(values);
|
|
5736
|
+
if (!leaf?.items.includes(item)) {
|
|
5737
|
+
return false;
|
|
5738
|
+
}
|
|
5739
|
+
let opened = false;
|
|
5740
|
+
for (let level = 0; level < values.length; level++) {
|
|
5741
|
+
const path = Object.freeze(values.slice(0, level + 1));
|
|
5742
|
+
const key = groupKeyOf(path, columns);
|
|
5743
|
+
if (key !== undefined && !this.#isExpanded(key, level)) {
|
|
5744
|
+
this.#setGroupExpanded(key, level, path, true, 'api');
|
|
5745
|
+
opened = true;
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
return opened;
|
|
5749
|
+
}
|
|
5676
5750
|
// ------------------------------------------------------------- edição
|
|
5677
5751
|
/** Mudanças pendentes por chave de linha (o grid nunca muta o item do hospedeiro). */
|
|
5678
5752
|
#edits;
|
|
@@ -8704,15 +8778,27 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
8704
8778
|
const kept = inputs.filter((_, index) => !hidden.includes(index));
|
|
8705
8779
|
const overflow = kept.reduce((sum, input) => sum + input.width, 0) - available;
|
|
8706
8780
|
if (hidden.length && overflow > 0) {
|
|
8707
|
-
|
|
8781
|
+
const capOf = (index) => {
|
|
8708
8782
|
const column = shown[index];
|
|
8709
8783
|
const width = this.#widthOf(column);
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8784
|
+
const min = Math.max(column.minWidth ?? 0, DEFAULT_MIN_COLUMN_WIDTH);
|
|
8785
|
+
return width === undefined || hidden.includes(index) ? undefined : { column, width: Math.max(min, width - overflow) };
|
|
8786
|
+
};
|
|
8787
|
+
for (let index = shown.length - 1; index >= 0 && !this.#adaptiveCap; index--) {
|
|
8788
|
+
if (!inputs[index].fixed) {
|
|
8789
|
+
this.#adaptiveCap = capOf(index);
|
|
8714
8790
|
}
|
|
8715
8791
|
}
|
|
8792
|
+
// Só fixas sobraram (ex.: "Nome" fixa no início com column-auto-width, relato 0.3.2): a mais larga encolhe.
|
|
8793
|
+
if (!this.#adaptiveCap) {
|
|
8794
|
+
let widest = -1;
|
|
8795
|
+
inputs.forEach((input, index) => {
|
|
8796
|
+
if (input.fixed && !hidden.includes(index) && (widest < 0 || input.width > inputs[widest].width)) {
|
|
8797
|
+
widest = index;
|
|
8798
|
+
}
|
|
8799
|
+
});
|
|
8800
|
+
this.#adaptiveCap = widest >= 0 ? capOf(widest) : undefined;
|
|
8801
|
+
}
|
|
8716
8802
|
}
|
|
8717
8803
|
return hidden.map(index => shown[index]);
|
|
8718
8804
|
}
|
|
@@ -9601,8 +9687,17 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
9601
9687
|
this.#syncFixedRows();
|
|
9602
9688
|
this.#syncRevealMargins();
|
|
9603
9689
|
this.#scrollPort.checkHeight();
|
|
9604
|
-
|
|
9690
|
+
if (this.autoHideColumns) {
|
|
9691
|
+
// As colunas ocultas por falta de espaço saem no próximo render: medir antes avisaria à toa (relato 0.3.2).
|
|
9692
|
+
this.#clipCheckPending = true;
|
|
9693
|
+
this.requestUpdate();
|
|
9694
|
+
}
|
|
9695
|
+
else {
|
|
9696
|
+
this.#scrollPort.checkHorizontalClip(this.#tableRef.value?.offsetWidth ?? 0);
|
|
9697
|
+
}
|
|
9605
9698
|
}
|
|
9699
|
+
/** Aviso de \`overflow-x\` adiado para depois do render que esconde as colunas (\`autoHideColumns\`). */
|
|
9700
|
+
#clipCheckPending;
|
|
9606
9701
|
/**
|
|
9607
9702
|
* Classe, deslocamento `sticky` e limites de cada coluna visível. Os
|
|
9608
9703
|
* deslocamentos usam a largura medida (a tabela pode esticar as colunas).
|