@vaadin/grid 25.4.0-alpha5 → 25.4.0-alpha7
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 +17 -17
- package/package.json +12 -12
- package/src/directives/body-cell-directive.js +43 -0
- package/src/directives/body-row-directive.js +36 -0
- package/src/directives/cell-content-directive.js +11 -2
- package/src/directives/details-cell-directive.js +32 -0
- package/src/directives/sizer-cell-directive.js +33 -0
- package/src/lit/column-renderer-directives.d.ts +1 -0
- package/src/vaadin-grid-a11y-mixin.js +0 -22
- package/src/vaadin-grid-body-rendering-mixin.js +189 -5
- package/src/vaadin-grid-column-mixin.js +4 -44
- package/src/vaadin-grid-column-reordering-mixin.js +5 -17
- package/src/vaadin-grid-dynamic-columns-mixin.js +1 -12
- package/src/vaadin-grid-header-footer-rendering-mixin.js +3 -16
- package/src/vaadin-grid-keyboard-navigation-mixin.js +5 -2
- package/src/vaadin-grid-mixin.js +41 -204
- package/src/vaadin-grid-row-details-mixin.js +15 -53
- package/src/vaadin-grid-scroll-mixin.js +12 -20
- package/src/vaadin-grid-selection-column-base-mixin.d.ts +1 -1
- package/src/vaadin-grid-selection-column-base-mixin.js +15 -13
- package/src/vaadin-grid-selection-column-mixin.js +0 -11
- package/src/vaadin-grid-styling-mixin.js +2 -24
- package/web-types.json +6 -6
- package/web-types.lit.json +5 -5
package/custom-elements.json
CHANGED
|
@@ -4715,7 +4715,7 @@
|
|
|
4715
4715
|
"type": {
|
|
4716
4716
|
"text": "boolean"
|
|
4717
4717
|
},
|
|
4718
|
-
"description": "When true,
|
|
4718
|
+
"description": "When true, activating a row by click or keyboard toggles its selection.",
|
|
4719
4719
|
"attribute": "auto-select"
|
|
4720
4720
|
},
|
|
4721
4721
|
{
|
|
@@ -4775,7 +4775,7 @@
|
|
|
4775
4775
|
"type": {
|
|
4776
4776
|
"text": "boolean"
|
|
4777
4777
|
},
|
|
4778
|
-
"description": "When true,
|
|
4778
|
+
"description": "When true, activating a row by click or keyboard toggles its selection.",
|
|
4779
4779
|
"fieldName": "autoSelect"
|
|
4780
4780
|
},
|
|
4781
4781
|
{
|
|
@@ -4853,7 +4853,7 @@
|
|
|
4853
4853
|
"type": {
|
|
4854
4854
|
"text": "boolean"
|
|
4855
4855
|
},
|
|
4856
|
-
"description": "When true,
|
|
4856
|
+
"description": "When true, activating a row by click or keyboard toggles its selection.",
|
|
4857
4857
|
"attribute": "auto-select",
|
|
4858
4858
|
"inheritedFrom": {
|
|
4859
4859
|
"name": "GridSelectionColumnBaseMixin",
|
|
@@ -4931,13 +4931,24 @@
|
|
|
4931
4931
|
}
|
|
4932
4932
|
}
|
|
4933
4933
|
],
|
|
4934
|
+
"mixins": [
|
|
4935
|
+
{
|
|
4936
|
+
"name": "GridSelectionColumnBaseMixin",
|
|
4937
|
+
"module": "src/vaadin-grid-selection-column-base-mixin.js"
|
|
4938
|
+
}
|
|
4939
|
+
],
|
|
4940
|
+
"parameters": [
|
|
4941
|
+
{
|
|
4942
|
+
"name": "superClass"
|
|
4943
|
+
}
|
|
4944
|
+
],
|
|
4934
4945
|
"attributes": [
|
|
4935
4946
|
{
|
|
4936
4947
|
"name": "auto-select",
|
|
4937
4948
|
"type": {
|
|
4938
4949
|
"text": "boolean"
|
|
4939
4950
|
},
|
|
4940
|
-
"description": "When true,
|
|
4951
|
+
"description": "When true, activating a row by click or keyboard toggles its selection.",
|
|
4941
4952
|
"fieldName": "autoSelect",
|
|
4942
4953
|
"inheritedFrom": {
|
|
4943
4954
|
"name": "GridSelectionColumnBaseMixin",
|
|
@@ -5004,17 +5015,6 @@
|
|
|
5004
5015
|
"module": "src/vaadin-grid-selection-column-base-mixin.js"
|
|
5005
5016
|
}
|
|
5006
5017
|
}
|
|
5007
|
-
],
|
|
5008
|
-
"mixins": [
|
|
5009
|
-
{
|
|
5010
|
-
"name": "GridSelectionColumnBaseMixin",
|
|
5011
|
-
"module": "src/vaadin-grid-selection-column-base-mixin.js"
|
|
5012
|
-
}
|
|
5013
|
-
],
|
|
5014
|
-
"parameters": [
|
|
5015
|
-
{
|
|
5016
|
-
"name": "superClass"
|
|
5017
|
-
}
|
|
5018
5018
|
]
|
|
5019
5019
|
}
|
|
5020
5020
|
],
|
|
@@ -5045,7 +5045,7 @@
|
|
|
5045
5045
|
"type": {
|
|
5046
5046
|
"text": "boolean"
|
|
5047
5047
|
},
|
|
5048
|
-
"description": "When true,
|
|
5048
|
+
"description": "When true, activating a row by click or keyboard toggles its selection.",
|
|
5049
5049
|
"attribute": "auto-select",
|
|
5050
5050
|
"inheritedFrom": {
|
|
5051
5051
|
"name": "GridSelectionColumnBaseMixin",
|
|
@@ -5330,7 +5330,7 @@
|
|
|
5330
5330
|
"type": {
|
|
5331
5331
|
"text": "boolean"
|
|
5332
5332
|
},
|
|
5333
|
-
"description": "When true,
|
|
5333
|
+
"description": "When true, activating a row by click or keyboard toggles its selection.",
|
|
5334
5334
|
"fieldName": "autoSelect",
|
|
5335
5335
|
"inheritedFrom": {
|
|
5336
5336
|
"name": "GridSelectionColumnBaseMixin",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "25.4.0-
|
|
3
|
+
"version": "25.4.0-alpha7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
48
|
-
"@vaadin/a11y-base": "25.4.0-
|
|
49
|
-
"@vaadin/checkbox": "25.4.0-
|
|
50
|
-
"@vaadin/component-base": "25.4.0-
|
|
51
|
-
"@vaadin/lit-renderer": "25.4.0-
|
|
52
|
-
"@vaadin/text-field": "25.4.0-
|
|
53
|
-
"@vaadin/vaadin-themable-mixin": "25.4.0-
|
|
48
|
+
"@vaadin/a11y-base": "25.4.0-alpha7",
|
|
49
|
+
"@vaadin/checkbox": "25.4.0-alpha7",
|
|
50
|
+
"@vaadin/component-base": "25.4.0-alpha7",
|
|
51
|
+
"@vaadin/lit-renderer": "25.4.0-alpha7",
|
|
52
|
+
"@vaadin/text-field": "25.4.0-alpha7",
|
|
53
|
+
"@vaadin/vaadin-themable-mixin": "25.4.0-alpha7",
|
|
54
54
|
"lit": "^3.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@vaadin/aura": "25.4.0-
|
|
58
|
-
"@vaadin/chai-plugins": "25.4.0-
|
|
59
|
-
"@vaadin/test-runner-commands": "25.4.0-
|
|
57
|
+
"@vaadin/aura": "25.4.0-alpha7",
|
|
58
|
+
"@vaadin/chai-plugins": "25.4.0-alpha7",
|
|
59
|
+
"@vaadin/test-runner-commands": "25.4.0-alpha7",
|
|
60
60
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
61
|
-
"@vaadin/vaadin-lumo-styles": "25.4.0-
|
|
61
|
+
"@vaadin/vaadin-lumo-styles": "25.4.0-alpha7",
|
|
62
62
|
"sinon": "^22.0.0"
|
|
63
63
|
},
|
|
64
64
|
"customElements": "custom-elements.json",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"web-types.json",
|
|
67
67
|
"web-types.lit.json"
|
|
68
68
|
],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "368fb0f0df09ec6f51766d9c44047c8d7620d6bd"
|
|
70
70
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { nothing } from 'lit';
|
|
7
|
+
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A directive that keeps a body cell registered in its column
|
|
11
|
+
* for as long as the column is part of the grid.
|
|
12
|
+
*/
|
|
13
|
+
export class BodyCellDirective extends AsyncDirective {
|
|
14
|
+
#grid;
|
|
15
|
+
#cell;
|
|
16
|
+
|
|
17
|
+
update(part, [grid, column]) {
|
|
18
|
+
if (!this.#cell) {
|
|
19
|
+
this.#grid = grid;
|
|
20
|
+
this.#cell = part.element;
|
|
21
|
+
this.#cell._column = column;
|
|
22
|
+
this.register(column, this.#cell);
|
|
23
|
+
}
|
|
24
|
+
return nothing;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
disconnected() {
|
|
28
|
+
const column = this.#cell._column;
|
|
29
|
+
if (!this.#grid._columnTree.at(-1).includes(column)) {
|
|
30
|
+
this.unregister(column, this.#cell);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
register(column, cell) {
|
|
35
|
+
column._cells = [...(column._cells ?? []), cell];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
unregister(column, cell) {
|
|
39
|
+
column._cells = column._cells.filter((c) => c !== cell);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const bodyCell = directive(BodyCellDirective);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { nothing } from 'lit';
|
|
7
|
+
import { Directive, directive } from 'lit/directive.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A directive that sets up a body row element when it is first rendered.
|
|
11
|
+
*/
|
|
12
|
+
class BodyRowDirective extends Directive {
|
|
13
|
+
#row;
|
|
14
|
+
|
|
15
|
+
update(part) {
|
|
16
|
+
if (!this.#row) {
|
|
17
|
+
this.#row = part.element;
|
|
18
|
+
this.#emptyTextNodes();
|
|
19
|
+
}
|
|
20
|
+
return nothing;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Empties the whitespace text nodes of the row template
|
|
25
|
+
* so that a row without cells matches `:empty`.
|
|
26
|
+
*/
|
|
27
|
+
#emptyTextNodes() {
|
|
28
|
+
this.#row.childNodes.forEach((node) => {
|
|
29
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
30
|
+
node.nodeValue = '';
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const bodyRow = directive(BodyRowDirective);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { html } from 'lit';
|
|
7
7
|
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
|
8
|
+
import { ref } from 'lit/directives/ref.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A directive that manages the `<vaadin-grid-cell-content>` element for a cell.
|
|
@@ -12,7 +13,14 @@ import { AsyncDirective, directive } from 'lit/async-directive.js';
|
|
|
12
13
|
class CellContentDirective extends AsyncDirective {
|
|
13
14
|
#cell;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
#setFocusButton = (button) => {
|
|
17
|
+
if (button) {
|
|
18
|
+
this.#cell._focusButton = button;
|
|
19
|
+
this.#cell.focus = (options) => button.focus(options);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
update(part, [grid, slotName, { textAlign, focusButton } = {}]) {
|
|
16
24
|
this.#cell = part.parentNode;
|
|
17
25
|
this.#cell._content ??= document.createElement('vaadin-grid-cell-content');
|
|
18
26
|
this.#cell._content.slot = slotName;
|
|
@@ -22,7 +30,8 @@ class CellContentDirective extends AsyncDirective {
|
|
|
22
30
|
grid.appendChild(this.#cell._content);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
const slot = html`<slot name="${slotName}"></slot>`;
|
|
34
|
+
return focusButton ? html`<div role="button" tabindex="-1" ${ref(this.#setFocusButton)}>${slot}</div>` : slot;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
disconnected() {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { nothing } from 'lit';
|
|
7
|
+
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A directive that observes the size of a details cell while it is rendered.
|
|
11
|
+
*/
|
|
12
|
+
class DetailsCellDirective extends AsyncDirective {
|
|
13
|
+
#grid;
|
|
14
|
+
#cell;
|
|
15
|
+
|
|
16
|
+
update(part, [grid]) {
|
|
17
|
+
if (!this.#cell) {
|
|
18
|
+
this.#grid = grid;
|
|
19
|
+
this.#cell = part.element;
|
|
20
|
+
this.#grid._detailsCellResizeObserver.observe(this.#cell);
|
|
21
|
+
this.#grid._frozenCellsChanged();
|
|
22
|
+
}
|
|
23
|
+
return nothing;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
disconnected() {
|
|
27
|
+
this.#grid._detailsCellResizeObserver.unobserve(this.#cell);
|
|
28
|
+
this.#grid._frozenCellsChanged();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const detailsCell = directive(DetailsCellDirective);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { nothing } from 'lit';
|
|
7
|
+
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A directive that keeps a sizer cell registered as the sizer cell of its column
|
|
11
|
+
* for as long as the cell is rendered.
|
|
12
|
+
*/
|
|
13
|
+
class SizerCellDirective extends AsyncDirective {
|
|
14
|
+
#cell;
|
|
15
|
+
|
|
16
|
+
update(part, [column]) {
|
|
17
|
+
if (!this.#cell) {
|
|
18
|
+
this.#cell = part.element;
|
|
19
|
+
this.#cell._column = column;
|
|
20
|
+
column._cells = [...(column._cells ?? []), this.#cell];
|
|
21
|
+
column._sizerCell = this.#cell;
|
|
22
|
+
}
|
|
23
|
+
return nothing;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
disconnected() {
|
|
27
|
+
const column = this.#cell._column;
|
|
28
|
+
column._cells = column._cells.filter((cell) => cell !== this.#cell);
|
|
29
|
+
column._sizerCell = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const sizerCell = directive(SizerCellDirective);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
/* eslint-disable max-classes-per-file */
|
|
6
7
|
import type { DirectiveResult } from 'lit/directive.js';
|
|
7
8
|
import type { LitRenderer, LitRendererResult } from '@vaadin/lit-renderer';
|
|
8
9
|
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
@@ -85,15 +85,6 @@ export const A11yMixin = (superClass) =>
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* @param {!HTMLElement} row
|
|
90
|
-
* @param {number} index
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
__a11yUpdateRowRowindex(row) {
|
|
94
|
-
row.setAttribute('aria-rowindex', row.index + this.__a11yGetHeaderRowCount(this._columnTree) + 1);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
88
|
/**
|
|
98
89
|
* @param {!HTMLElement} row
|
|
99
90
|
* @param {boolean} selected
|
|
@@ -136,19 +127,6 @@ export const A11yMixin = (superClass) =>
|
|
|
136
127
|
setOrRemoveAttribute(row, 'aria-level', hasLevel && level + 1);
|
|
137
128
|
}
|
|
138
129
|
|
|
139
|
-
/**
|
|
140
|
-
* @param {!HTMLElement} row
|
|
141
|
-
* @param {!HTMLElement} detailsCell
|
|
142
|
-
* @private
|
|
143
|
-
*/
|
|
144
|
-
__a11ySetRowDetailsCell(row, detailsCell) {
|
|
145
|
-
iterateRowCells(row, (cell) => {
|
|
146
|
-
if (cell !== detailsCell) {
|
|
147
|
-
cell.setAttribute('aria-controls', detailsCell.id);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
130
|
/** @private */
|
|
153
131
|
__a11yUpdateSorters() {
|
|
154
132
|
Array.from(this.querySelectorAll('vaadin-grid-sorter')).forEach((sorter) => {
|
|
@@ -3,7 +3,20 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html, render } from 'lit';
|
|
6
|
+
import { html, nothing, render } from 'lit';
|
|
7
|
+
import { cache } from 'lit/directives/cache.js';
|
|
8
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
9
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
11
|
+
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
12
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
13
|
+
import { parsePartNames, partMap } from '@vaadin/component-base/src/directives/part-map.js';
|
|
14
|
+
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
15
|
+
import { bodyCell } from './directives/body-cell-directive.js';
|
|
16
|
+
import { bodyRow } from './directives/body-row-directive.js';
|
|
17
|
+
import { cellContent } from './directives/cell-content-directive.js';
|
|
18
|
+
import { detailsCell } from './directives/details-cell-directive.js';
|
|
19
|
+
import { sizerCell } from './directives/sizer-cell-directive.js';
|
|
7
20
|
|
|
8
21
|
/**
|
|
9
22
|
* A mixin providing rendering of body rows.
|
|
@@ -16,17 +29,188 @@ export const BodyRenderingMixin = (superClass) =>
|
|
|
16
29
|
render(this.#bodyRowTemplate(), renderRoot, { host: this });
|
|
17
30
|
|
|
18
31
|
const row = renderRoot.firstElementChild;
|
|
32
|
+
row.__id = generateUniqueId();
|
|
19
33
|
row.__renderRoot = renderRoot;
|
|
20
34
|
return row;
|
|
21
35
|
}
|
|
22
36
|
|
|
37
|
+
/** @private */
|
|
38
|
+
__scheduleRenderBody() {
|
|
39
|
+
this.__renderBodyDebouncer = Debouncer.debounce(this.__renderBodyDebouncer, microTask, () => {
|
|
40
|
+
this.__renderBody();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @private */
|
|
45
|
+
__renderBody() {
|
|
46
|
+
this.__renderBodyDebouncer?.cancel();
|
|
47
|
+
|
|
48
|
+
[...this.$.items.children].forEach((row) => {
|
|
49
|
+
this.__renderBodyRow(row);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
23
53
|
/** @private */
|
|
24
54
|
__renderBodyRow(row) {
|
|
25
|
-
const
|
|
26
|
-
render(this.#bodyRowTemplate(
|
|
55
|
+
const state = this.#getRowState(row);
|
|
56
|
+
render(this.#bodyRowTemplate(state), row.__renderRoot, { host: this });
|
|
57
|
+
|
|
58
|
+
const cells = [...row.children];
|
|
59
|
+
cells.forEach((cell) => {
|
|
60
|
+
cell.__parentRow = row;
|
|
61
|
+
});
|
|
62
|
+
row.__cells = cells.filter((cell) => cell.classList.contains('body-cell'));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** @private */
|
|
66
|
+
__scheduleRenderSizer() {
|
|
67
|
+
this.__renderSizerDebouncer = Debouncer.debounce(this.__renderSizerDebouncer, microTask, () => {
|
|
68
|
+
this.__renderSizer();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @private */
|
|
73
|
+
__renderSizer() {
|
|
74
|
+
this.__renderSizerDebouncer?.cancel();
|
|
75
|
+
|
|
76
|
+
render(this.#sizerRowTemplate(), this.$.sizer, { host: this });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#getRowState(row) {
|
|
80
|
+
const columns = this._columnTree.at(-1).toSorted((a, b) => a._order - b._order);
|
|
81
|
+
const visibleColumns = columns.filter((column) => !column.hidden);
|
|
82
|
+
const { index } = row;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
rowId: row.__id,
|
|
86
|
+
item: this.__getRowItem(row),
|
|
87
|
+
model: this.__getRowModel(row),
|
|
88
|
+
ariaRowIndex: index === undefined ? undefined : index + this.__a11yGetHeaderRowCount(this._columnTree) + 1,
|
|
89
|
+
isFirstRow: index === 0,
|
|
90
|
+
isLastRow: index === this._flatSize - 1,
|
|
91
|
+
isOddRow: index % 2 === 1,
|
|
92
|
+
isEvenRow: index % 2 === 0,
|
|
93
|
+
cells: columns.map((column) => {
|
|
94
|
+
return {
|
|
95
|
+
column,
|
|
96
|
+
isFirstCell: column === visibleColumns.at(0),
|
|
97
|
+
isLastCell: column === visibleColumns.at(-1),
|
|
98
|
+
};
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
27
101
|
}
|
|
28
102
|
|
|
29
|
-
#bodyRowTemplate = ({
|
|
30
|
-
|
|
103
|
+
#bodyRowTemplate = ({
|
|
104
|
+
rowId,
|
|
105
|
+
item,
|
|
106
|
+
model,
|
|
107
|
+
ariaRowIndex,
|
|
108
|
+
isFirstRow,
|
|
109
|
+
isLastRow,
|
|
110
|
+
isOddRow,
|
|
111
|
+
isEvenRow,
|
|
112
|
+
cells,
|
|
113
|
+
} = {}) => {
|
|
114
|
+
const rowParts = {
|
|
115
|
+
'first-row': isFirstRow,
|
|
116
|
+
'last-row': isLastRow,
|
|
117
|
+
'odd-row': isOddRow,
|
|
118
|
+
'even-row': isEvenRow,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return html`
|
|
122
|
+
<tr
|
|
123
|
+
role="row"
|
|
124
|
+
tabindex="-1"
|
|
125
|
+
part="row body-row${partMap(rowParts)}"
|
|
126
|
+
class="row body-row${classMap(rowParts)}"
|
|
127
|
+
aria-rowindex="${ifDefined(ariaRowIndex)}"
|
|
128
|
+
?first="${isFirstRow}"
|
|
129
|
+
?last="${isLastRow}"
|
|
130
|
+
?odd="${isOddRow}"
|
|
131
|
+
?even="${isEvenRow}"
|
|
132
|
+
?loading="${!item}"
|
|
133
|
+
${bodyRow()}
|
|
134
|
+
>
|
|
135
|
+
${repeat(
|
|
136
|
+
cells ?? [],
|
|
137
|
+
({ column }) => column._id,
|
|
138
|
+
({ column, isFirstCell, isLastCell }) => {
|
|
139
|
+
if (column.hidden || column._bodyContentHidden) {
|
|
140
|
+
return cache(nothing);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const cellParts = {
|
|
144
|
+
'first-column-cell': isFirstCell,
|
|
145
|
+
'last-column-cell': isLastCell,
|
|
146
|
+
'first-row-cell': isFirstRow,
|
|
147
|
+
'last-row-cell': isLastRow,
|
|
148
|
+
'odd-row-cell': isOddRow,
|
|
149
|
+
'even-row-cell': isEvenRow,
|
|
150
|
+
'loading-row-cell': !item,
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const customCellParts = item ? parsePartNames(this.cellPartNameGenerator?.(column, model)) : {};
|
|
154
|
+
|
|
155
|
+
return cache(html`
|
|
156
|
+
<td
|
|
157
|
+
role="${column.rowHeader ? 'rowheader' : 'gridcell'}"
|
|
158
|
+
part="cell body-cell${partMap({ ...cellParts, ...customCellParts })}"
|
|
159
|
+
class="cell body-cell${classMap(cellParts)}"
|
|
160
|
+
?first-column="${isFirstCell}"
|
|
161
|
+
?last-column="${isLastCell}"
|
|
162
|
+
tabindex="${column._focusButtonMode ? nothing : '-1'}"
|
|
163
|
+
aria-controls="${this.rowDetailsRenderer ? `vaadin-grid-details-cell-${rowId}` : nothing}"
|
|
164
|
+
@keydown="${this.__onCellKeyDown}"
|
|
165
|
+
@mousedown="${this.__onCellMouseDown}"
|
|
166
|
+
@mouseenter="${this.__onCellMouseEnter}"
|
|
167
|
+
@mouseleave="${this.__onCellMouseLeave}"
|
|
168
|
+
${bodyCell(this, column)}
|
|
169
|
+
>
|
|
170
|
+
${cellContent(this, `vaadin-grid-body-cell-content-${rowId}-${column._id}`, {
|
|
171
|
+
textAlign: column.textAlign,
|
|
172
|
+
focusButton: column._focusButtonMode,
|
|
173
|
+
})}
|
|
174
|
+
</td>
|
|
175
|
+
`);
|
|
176
|
+
},
|
|
177
|
+
)}
|
|
178
|
+
${
|
|
179
|
+
this.rowDetailsRenderer
|
|
180
|
+
? html`
|
|
181
|
+
<td
|
|
182
|
+
id="vaadin-grid-details-cell-${rowId}"
|
|
183
|
+
role="gridcell"
|
|
184
|
+
part="cell details-cell${partMap(
|
|
185
|
+
item ? parsePartNames(this.cellPartNameGenerator?.(undefined, model)) : {},
|
|
186
|
+
)}"
|
|
187
|
+
class="cell details-cell"
|
|
188
|
+
tabindex="-1"
|
|
189
|
+
frozen
|
|
190
|
+
@keydown="${this.__onCellKeyDown}"
|
|
191
|
+
@mousedown="${this.__onCellMouseDown}"
|
|
192
|
+
@mouseenter="${this.__onCellMouseEnter}"
|
|
193
|
+
@mouseleave="${this.__onCellMouseLeave}"
|
|
194
|
+
${detailsCell(this)}
|
|
195
|
+
>
|
|
196
|
+
${cellContent(this, `vaadin-grid-details-cell-content-${rowId}`)}
|
|
197
|
+
</td>
|
|
198
|
+
`
|
|
199
|
+
: nothing
|
|
200
|
+
}
|
|
201
|
+
</tr>
|
|
202
|
+
`;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
#sizerRowTemplate = () => {
|
|
206
|
+
return repeat(
|
|
207
|
+
this._getColumnsInOrder(),
|
|
208
|
+
(column) => column._id,
|
|
209
|
+
(column) => html`
|
|
210
|
+
<td part="cell body-cell" class="cell body-cell" ${sizerCell(column)}>
|
|
211
|
+
${cellContent(this, `vaadin-grid-sizer-cell-content-${column._id}`)}
|
|
212
|
+
</td>
|
|
213
|
+
`,
|
|
214
|
+
);
|
|
31
215
|
};
|
|
32
216
|
};
|
|
@@ -139,7 +139,6 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
139
139
|
_bodyContentHidden: {
|
|
140
140
|
type: Boolean,
|
|
141
141
|
value: false,
|
|
142
|
-
sync: true,
|
|
143
142
|
},
|
|
144
143
|
|
|
145
144
|
/**
|
|
@@ -257,7 +256,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
257
256
|
'_frozenChanged(frozen, _headerCell, _footerCell, _cells)',
|
|
258
257
|
'_frozenToEndChanged(frozenToEnd, _headerCell, _footerCell, _cells)',
|
|
259
258
|
'_flexGrowChanged(flexGrow, _cells)',
|
|
260
|
-
'_textAlignChanged(textAlign
|
|
259
|
+
'_textAlignChanged(textAlign)',
|
|
261
260
|
'_lastFrozenChanged(_lastFrozen)',
|
|
262
261
|
'_firstFrozenToEndChanged(_firstFrozenToEnd)',
|
|
263
262
|
'_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, path)',
|
|
@@ -299,48 +298,17 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
299
298
|
/**
|
|
300
299
|
* A stable unique id assigned once per column instance. Used to build
|
|
301
300
|
* cell content slot names that stay stable across re-renders, so lit
|
|
302
|
-
*
|
|
301
|
+
* keeps the cell content elements when other columns change.
|
|
303
302
|
*
|
|
304
303
|
* @protected
|
|
305
304
|
*/
|
|
306
305
|
this._id = generateUniqueId();
|
|
307
306
|
}
|
|
308
307
|
|
|
309
|
-
/** @protected */
|
|
310
|
-
connectedCallback() {
|
|
311
|
-
super.connectedCallback();
|
|
312
|
-
|
|
313
|
-
// Adds the column cells to the grid after the column is attached
|
|
314
|
-
requestAnimationFrame(() => {
|
|
315
|
-
// Skip if the column has been detached
|
|
316
|
-
if (!this._grid) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
this._cells?.forEach((cell) => {
|
|
321
|
-
if (!cell._content.parentNode) {
|
|
322
|
-
this._grid.appendChild(cell._content);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
308
|
/** @protected */
|
|
329
309
|
disconnectedCallback() {
|
|
330
310
|
super.disconnectedCallback();
|
|
331
311
|
|
|
332
|
-
// Removes the column cells from the grid after the column is detached
|
|
333
|
-
requestAnimationFrame(() => {
|
|
334
|
-
// Skip if the column has been attached again
|
|
335
|
-
if (this._grid) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
this._cells?.forEach((cell) => {
|
|
340
|
-
cell._content.parentNode?.removeChild(cell._content);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
312
|
this.#cachedGrid = undefined;
|
|
345
313
|
}
|
|
346
314
|
|
|
@@ -491,9 +459,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
491
459
|
|
|
492
460
|
this._grid?.__scheduleRenderHeaderFooter?.();
|
|
493
461
|
|
|
494
|
-
this.
|
|
495
|
-
cell._content.style.textAlign = textAlign;
|
|
496
|
-
});
|
|
462
|
+
this._grid?.__scheduleRenderBody?.();
|
|
497
463
|
}
|
|
498
464
|
|
|
499
465
|
/** @private */
|
|
@@ -501,16 +467,11 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
501
467
|
this.parentElement?._columnPropChanged?.('hidden', hidden);
|
|
502
468
|
|
|
503
469
|
if (!!hidden !== !!this._previousHidden && this._grid) {
|
|
504
|
-
if (hidden === true) {
|
|
505
|
-
this._cells?.forEach((cell) => {
|
|
506
|
-
cell._content.parentNode?.removeChild(cell._content);
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
470
|
this._grid._debouncerHiddenChanged = Debouncer.debounce(
|
|
510
471
|
this._grid._debouncerHiddenChanged,
|
|
511
472
|
animationFrame,
|
|
512
473
|
() => {
|
|
513
|
-
this._grid?._renderColumnTree?.(
|
|
474
|
+
this._grid?._renderColumnTree?.();
|
|
514
475
|
},
|
|
515
476
|
);
|
|
516
477
|
|
|
@@ -865,7 +826,6 @@ export const GridColumnMixin = (superClass) =>
|
|
|
865
826
|
*/
|
|
866
827
|
_cells: {
|
|
867
828
|
type: Array,
|
|
868
|
-
sync: true,
|
|
869
829
|
},
|
|
870
830
|
};
|
|
871
831
|
}
|