@universal-material/data-grid 0.3.1 → 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 +2 -2
- package/dist/grid.d.ts +19 -6
- package/dist/grid.js +71 -4
- package/dist/grid.js.map +1 -1
- package/dist/grid.min.js +291 -269
- package/dist/grid.styles.js +22 -0
- 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';
|
|
@@ -5641,9 +5641,12 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5641
5641
|
/**
|
|
5642
5642
|
* Scrolls to the cell of the row `rowKey` and `column` (default: the first
|
|
5643
5643
|
* 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
|
-
*
|
|
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`
|
|
5647
5650
|
* opens the row details (`u-grid-row-expansion-change`, `source: 'api'`)
|
|
5648
5651
|
* and focuses its value. Before the
|
|
5649
5652
|
* first render it only sets the active cell (the focus moves when it is
|
|
@@ -5655,6 +5658,16 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5655
5658
|
focusCell(rowKey, column, options) {
|
|
5656
5659
|
this.#ensureRows();
|
|
5657
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
|
+
}
|
|
5658
5671
|
const fixedPosition = fixed ? this.#fixedRows()[fixed].findIndex(entry => this.#keyOf(entry.item) === rowKey) : -1;
|
|
5659
5672
|
const row = fixed ? fixedPosition < 0 ? -1 : this.#fixedIndex(fixed, fixedPosition) : this.#rowIndexOfKey(rowKey);
|
|
5660
5673
|
if (row < 0) {
|
|
@@ -5673,6 +5686,60 @@ let DataGrid = class DataGrid extends LitElement {
|
|
|
5673
5686
|
this.#setActive({ row, col: Math.max(col, 0) }, 'api', { focus: true, reveal: true });
|
|
5674
5687
|
return true;
|
|
5675
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
|
+
}
|
|
5676
5743
|
// ------------------------------------------------------------- edição
|
|
5677
5744
|
/** Mudanças pendentes por chave de linha (o grid nunca muta o item do hospedeiro). */
|
|
5678
5745
|
#edits;
|