@vaadin/grid 23.0.0-alpha4 → 23.0.0-beta3
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/package.json +9 -9
- package/src/vaadin-grid-a11y-mixin.js +6 -18
- package/src/vaadin-grid-column.js +10 -2
- package/src/vaadin-grid-keyboard-navigation-mixin.js +38 -1
- package/src/vaadin-grid-row-details-mixin.js +2 -1
- package/src/vaadin-grid-selection-mixin.js +2 -6
- package/src/vaadin-grid-styles.js +4 -0
- package/src/vaadin-grid.d.ts +3 -1
- package/src/vaadin-grid.js +29 -2
- package/theme/lumo/vaadin-grid-styles.js +4 -0
- package/theme/material/vaadin-grid-styles.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-beta3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
43
43
|
"@polymer/polymer": "^3.0.0",
|
|
44
|
-
"@vaadin/checkbox": "23.0.0-
|
|
45
|
-
"@vaadin/component-base": "23.0.0-
|
|
46
|
-
"@vaadin/text-field": "23.0.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
48
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
44
|
+
"@vaadin/checkbox": "23.0.0-beta3",
|
|
45
|
+
"@vaadin/component-base": "23.0.0-beta3",
|
|
46
|
+
"@vaadin/text-field": "23.0.0-beta3",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-beta3",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "23.0.0-beta3",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-beta3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/polymer-legacy-adapter": "23.0.0-
|
|
53
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-beta3",
|
|
54
54
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
55
55
|
"lit": "^2.0.0",
|
|
56
56
|
"sinon": "^9.2.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "4c87216666541f9eb58f56c475964727822aad53"
|
|
59
59
|
}
|
|
@@ -94,24 +94,12 @@ export const A11yMixin = (superClass) =>
|
|
|
94
94
|
* @protected
|
|
95
95
|
*/
|
|
96
96
|
_a11yUpdateRowLevel(row, level) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* @protected
|
|
104
|
-
*/
|
|
105
|
-
_a11yUpdateRowDetailsOpened(row, detailsOpened) {
|
|
106
|
-
const detailsCell = row.querySelector('[part~=details-cell]');
|
|
107
|
-
|
|
108
|
-
Array.from(row.children).forEach((cell) => {
|
|
109
|
-
if (detailsCell) {
|
|
110
|
-
cell.setAttribute('aria-expanded', detailsOpened);
|
|
111
|
-
} else {
|
|
112
|
-
cell.removeAttribute('aria-expanded');
|
|
113
|
-
}
|
|
114
|
-
});
|
|
97
|
+
// Set level for the expandable rows itself, and all the nested rows.
|
|
98
|
+
if (level > 0 || this.__isRowCollapsible(row) || this.__isRowExpandable(row)) {
|
|
99
|
+
row.setAttribute('aria-level', level + 1);
|
|
100
|
+
} else {
|
|
101
|
+
row.removeAttribute('aria-level');
|
|
102
|
+
}
|
|
115
103
|
}
|
|
116
104
|
|
|
117
105
|
/**
|
|
@@ -449,6 +449,10 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
cells.forEach((cell) => {
|
|
452
|
+
if (!cell.parentElement) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
|
|
452
456
|
const model = this._grid.__getRowModel(cell.parentElement);
|
|
453
457
|
|
|
454
458
|
if (!renderer) {
|
|
@@ -493,7 +497,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
493
497
|
}
|
|
494
498
|
|
|
495
499
|
this.__renderCellsContent(headerRenderer, [headerCell]);
|
|
496
|
-
this._grid
|
|
500
|
+
if (this._grid) {
|
|
501
|
+
this._grid.__updateHeaderFooterRowVisibility(headerCell.parentElement);
|
|
502
|
+
}
|
|
497
503
|
}
|
|
498
504
|
|
|
499
505
|
/** @protected */
|
|
@@ -532,7 +538,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
532
538
|
}
|
|
533
539
|
|
|
534
540
|
this.__renderCellsContent(footerRenderer, [footerCell]);
|
|
535
|
-
this._grid
|
|
541
|
+
if (this._grid) {
|
|
542
|
+
this._grid.__updateHeaderFooterRowVisibility(footerCell.parentElement);
|
|
543
|
+
}
|
|
536
544
|
}
|
|
537
545
|
|
|
538
546
|
/** @protected */
|
|
@@ -130,6 +130,37 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
130
130
|
this._updateGridSectionFocusTarget(this._footerFocusable);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Since the focused cell/row state is stored as an element reference, the reference may get
|
|
135
|
+
* out of sync when the virtual indexes for elements update due to effective size change.
|
|
136
|
+
* This function updates the reference to the correct element after a possible index change.
|
|
137
|
+
* @private
|
|
138
|
+
*/
|
|
139
|
+
__updateItemsFocusable() {
|
|
140
|
+
if (!this._itemsFocusable) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const wasFocused = this.shadowRoot.activeElement === this._itemsFocusable;
|
|
145
|
+
|
|
146
|
+
this._getVisibleRows().forEach((row) => {
|
|
147
|
+
if (row.index === this._focusedItemIndex) {
|
|
148
|
+
if (this.__rowFocusMode) {
|
|
149
|
+
// Row focus mode
|
|
150
|
+
this._itemsFocusable = row;
|
|
151
|
+
} else if (this._itemsFocusable.parentElement) {
|
|
152
|
+
// Cell focus mode
|
|
153
|
+
const cellIndex = [...this._itemsFocusable.parentElement.children].indexOf(this._itemsFocusable);
|
|
154
|
+
this._itemsFocusable = row.children[cellIndex];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (wasFocused) {
|
|
160
|
+
this._itemsFocusable.focus();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
133
164
|
/**
|
|
134
165
|
* @param {!KeyboardEvent} e
|
|
135
166
|
* @protected
|
|
@@ -531,7 +562,11 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
531
562
|
|
|
532
563
|
if (this.interacting !== wantInteracting && cell !== null) {
|
|
533
564
|
if (wantInteracting) {
|
|
534
|
-
const focusTarget =
|
|
565
|
+
const focusTarget =
|
|
566
|
+
cell._content.querySelector('[focus-target]') ||
|
|
567
|
+
// If a child element hasn't been explicitly marked as a focus target,
|
|
568
|
+
// fall back to any focusable element inside the cell.
|
|
569
|
+
[...cell._content.querySelectorAll('*')].find((node) => this._isFocusable(node));
|
|
535
570
|
if (focusTarget) {
|
|
536
571
|
e.preventDefault();
|
|
537
572
|
focusTarget.focus();
|
|
@@ -805,6 +840,8 @@ export const KeyboardNavigationMixin = (superClass) =>
|
|
|
805
840
|
delete this._focusedColumnOrder;
|
|
806
841
|
this._itemsFocusable = this.__rowFocusMode ? firstVisibleRow : firstVisibleCell;
|
|
807
842
|
}
|
|
843
|
+
} else {
|
|
844
|
+
this.__updateItemsFocusable();
|
|
808
845
|
}
|
|
809
846
|
}
|
|
810
847
|
|
|
@@ -83,7 +83,8 @@ export const RowDetailsMixin = (superClass) =>
|
|
|
83
83
|
Array.from(this.$.items.children).forEach((row) => {
|
|
84
84
|
if (!row.querySelector('[part~=details-cell]')) {
|
|
85
85
|
this._updateRow(row, this._columnTree[this._columnTree.length - 1]);
|
|
86
|
-
this.
|
|
86
|
+
const isDetailsOpened = this._isDetailsOpened(row._item);
|
|
87
|
+
this._toggleDetailsCell(row, isDetailsOpened);
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
90
|
}
|
|
@@ -77,12 +77,8 @@ export const SelectionMixin = (superClass) =>
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** @private */
|
|
80
|
-
_selectedItemsChanged(
|
|
81
|
-
|
|
82
|
-
Array.from(this.$.items.children).forEach((row) => {
|
|
83
|
-
this._updateItem(row, row._item);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
80
|
+
_selectedItemsChanged() {
|
|
81
|
+
this.requestContentUpdate();
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
/**
|
package/src/vaadin-grid.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
6
7
|
import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
8
|
import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
9
|
import { ActiveItemMixinClass } from './vaadin-grid-active-item-mixin.js';
|
|
@@ -389,7 +390,8 @@ declare class Grid<TItem = GridDefaultItem> extends HTMLElement {
|
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
interface Grid<TItem = GridDefaultItem>
|
|
392
|
-
extends
|
|
393
|
+
extends DisabledMixinClass,
|
|
394
|
+
ElementMixinClass,
|
|
393
395
|
ThemableMixinClass,
|
|
394
396
|
ActiveItemMixinClass<TItem>,
|
|
395
397
|
ArrayDataProviderMixinClass<TItem>,
|
package/src/vaadin-grid.js
CHANGED
|
@@ -9,6 +9,7 @@ import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
|
9
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
10
10
|
import { isAndroid, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
11
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
12
|
+
import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
|
|
12
13
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
13
14
|
import { Virtualizer } from '@vaadin/component-base/src/virtualizer.js';
|
|
14
15
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
@@ -256,7 +257,9 @@ class Grid extends ElementMixin(
|
|
|
256
257
|
A11yMixin(
|
|
257
258
|
FilterMixin(
|
|
258
259
|
ColumnReorderingMixin(
|
|
259
|
-
ColumnResizingMixin(
|
|
260
|
+
ColumnResizingMixin(
|
|
261
|
+
EventContextMixin(DragAndDropMixin(StylingMixin(TabindexMixin(PolymerElement))))
|
|
262
|
+
)
|
|
260
263
|
)
|
|
261
264
|
)
|
|
262
265
|
)
|
|
@@ -337,6 +340,11 @@ class Grid extends ElementMixin(
|
|
|
337
340
|
value: isTouch
|
|
338
341
|
},
|
|
339
342
|
|
|
343
|
+
/** @protected */
|
|
344
|
+
tabindex: {
|
|
345
|
+
value: undefined
|
|
346
|
+
},
|
|
347
|
+
|
|
340
348
|
/**
|
|
341
349
|
* If true, the grid's height is defined by its rows.
|
|
342
350
|
*
|
|
@@ -465,6 +473,23 @@ class Grid extends ElementMixin(
|
|
|
465
473
|
}
|
|
466
474
|
}
|
|
467
475
|
|
|
476
|
+
/**
|
|
477
|
+
* Override an observer from `DisabledMixin` to not
|
|
478
|
+
* set `tabindex` on the grid when it is re-enabled.
|
|
479
|
+
*
|
|
480
|
+
* @param {boolean} disabled
|
|
481
|
+
* @param {boolean} oldDisabled
|
|
482
|
+
* @protected
|
|
483
|
+
* @override
|
|
484
|
+
*/
|
|
485
|
+
_disabledChanged(disabled, oldDisabled) {
|
|
486
|
+
super._disabledChanged(disabled, oldDisabled);
|
|
487
|
+
|
|
488
|
+
if (oldDisabled) {
|
|
489
|
+
this.removeAttribute('tabindex');
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
468
493
|
/** @private */
|
|
469
494
|
__getBodyCellCoordinates(cell) {
|
|
470
495
|
if (this.$.items.contains(cell) && cell.localName === 'td') {
|
|
@@ -584,6 +609,9 @@ class Grid extends ElementMixin(
|
|
|
584
609
|
* @private
|
|
585
610
|
*/
|
|
586
611
|
_recalculateColumnWidths(cols) {
|
|
612
|
+
// Flush to make sure DOM is up-to-date when measuring the column widths
|
|
613
|
+
this.__virtualizer.flush();
|
|
614
|
+
|
|
587
615
|
cols.forEach((col) => {
|
|
588
616
|
col.width = `${this.__getDistributedWidth(col)}px`;
|
|
589
617
|
});
|
|
@@ -907,7 +935,6 @@ class Grid extends ElementMixin(
|
|
|
907
935
|
|
|
908
936
|
this._a11yUpdateRowLevel(row, model.level);
|
|
909
937
|
this._a11yUpdateRowSelected(row, model.selected);
|
|
910
|
-
this._a11yUpdateRowDetailsOpened(row, model.detailsOpened);
|
|
911
938
|
|
|
912
939
|
row.toggleAttribute('expanded', model.expanded);
|
|
913
940
|
row.toggleAttribute('selected', model.selected);
|