@vaadin/grid 22.0.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/LICENSE +190 -0
- package/README.md +79 -0
- package/all-imports.js +1 -0
- package/package.json +58 -0
- package/src/all-imports.js +14 -0
- package/src/array-data-provider.js +145 -0
- package/src/interfaces.d.ts +75 -0
- package/src/vaadin-grid-a11y-mixin.js +158 -0
- package/src/vaadin-grid-active-item-mixin.d.ts +19 -0
- package/src/vaadin-grid-active-item-mixin.js +117 -0
- package/src/vaadin-grid-array-data-provider-mixin.d.ts +16 -0
- package/src/vaadin-grid-array-data-provider-mixin.js +75 -0
- package/src/vaadin-grid-column-group.d.ts +54 -0
- package/src/vaadin-grid-column-group.js +320 -0
- package/src/vaadin-grid-column-reordering-mixin.d.ts +19 -0
- package/src/vaadin-grid-column-reordering-mixin.js +387 -0
- package/src/vaadin-grid-column-resizing-mixin.js +111 -0
- package/src/vaadin-grid-column.d.ts +133 -0
- package/src/vaadin-grid-column.js +745 -0
- package/src/vaadin-grid-data-provider-mixin.d.ts +108 -0
- package/src/vaadin-grid-data-provider-mixin.js +520 -0
- package/src/vaadin-grid-drag-and-drop-mixin.d.ts +69 -0
- package/src/vaadin-grid-drag-and-drop-mixin.js +433 -0
- package/src/vaadin-grid-dynamic-columns-mixin.js +180 -0
- package/src/vaadin-grid-event-context-mixin.d.ts +33 -0
- package/src/vaadin-grid-event-context-mixin.js +57 -0
- package/src/vaadin-grid-filter-column.d.ts +35 -0
- package/src/vaadin-grid-filter-column.js +120 -0
- package/src/vaadin-grid-filter-mixin.js +76 -0
- package/src/vaadin-grid-filter.d.ts +67 -0
- package/src/vaadin-grid-filter.js +125 -0
- package/src/vaadin-grid-helpers.js +23 -0
- package/src/vaadin-grid-keyboard-navigation-mixin.js +891 -0
- package/src/vaadin-grid-row-details-mixin.d.ts +44 -0
- package/src/vaadin-grid-row-details-mixin.js +200 -0
- package/src/vaadin-grid-scroll-mixin.d.ts +18 -0
- package/src/vaadin-grid-scroll-mixin.js +202 -0
- package/src/vaadin-grid-selection-column.d.ts +71 -0
- package/src/vaadin-grid-selection-column.js +285 -0
- package/src/vaadin-grid-selection-mixin.d.ts +30 -0
- package/src/vaadin-grid-selection-mixin.js +93 -0
- package/src/vaadin-grid-sort-column.d.ts +63 -0
- package/src/vaadin-grid-sort-column.js +118 -0
- package/src/vaadin-grid-sort-mixin.d.ts +15 -0
- package/src/vaadin-grid-sort-mixin.js +139 -0
- package/src/vaadin-grid-sorter.d.ts +94 -0
- package/src/vaadin-grid-sorter.js +230 -0
- package/src/vaadin-grid-styles.js +297 -0
- package/src/vaadin-grid-styling-mixin.d.ts +37 -0
- package/src/vaadin-grid-styling-mixin.js +71 -0
- package/src/vaadin-grid-tree-column.d.ts +36 -0
- package/src/vaadin-grid-tree-column.js +119 -0
- package/src/vaadin-grid-tree-toggle.d.ts +104 -0
- package/src/vaadin-grid-tree-toggle.js +205 -0
- package/src/vaadin-grid.d.ts +397 -0
- package/src/vaadin-grid.js +1004 -0
- package/theme/lumo/all-imports.js +11 -0
- package/theme/lumo/vaadin-grid-column-group.js +1 -0
- package/theme/lumo/vaadin-grid-column.js +1 -0
- package/theme/lumo/vaadin-grid-filter-column.js +2 -0
- package/theme/lumo/vaadin-grid-filter.js +2 -0
- package/theme/lumo/vaadin-grid-selection-column.js +2 -0
- package/theme/lumo/vaadin-grid-sort-column.js +2 -0
- package/theme/lumo/vaadin-grid-sorter-styles.js +53 -0
- package/theme/lumo/vaadin-grid-sorter.js +2 -0
- package/theme/lumo/vaadin-grid-styles.js +378 -0
- package/theme/lumo/vaadin-grid-tree-column.js +2 -0
- package/theme/lumo/vaadin-grid-tree-toggle-styles.js +112 -0
- package/theme/lumo/vaadin-grid-tree-toggle.js +2 -0
- package/theme/lumo/vaadin-grid.js +9 -0
- package/theme/material/all-imports.js +11 -0
- package/theme/material/vaadin-grid-column-group.js +1 -0
- package/theme/material/vaadin-grid-column.js +1 -0
- package/theme/material/vaadin-grid-filter-column.js +2 -0
- package/theme/material/vaadin-grid-filter.js +2 -0
- package/theme/material/vaadin-grid-selection-column.js +2 -0
- package/theme/material/vaadin-grid-sort-column.js +2 -0
- package/theme/material/vaadin-grid-sorter-styles.js +72 -0
- package/theme/material/vaadin-grid-sorter.js +2 -0
- package/theme/material/vaadin-grid-styles.js +252 -0
- package/theme/material/vaadin-grid-tree-column.js +2 -0
- package/theme/material/vaadin-grid-tree-toggle-styles.js +42 -0
- package/theme/material/vaadin-grid-tree-toggle.js +2 -0
- package/theme/material/vaadin-grid.js +2 -0
- package/vaadin-grid-column-group.d.ts +1 -0
- package/vaadin-grid-column-group.js +3 -0
- package/vaadin-grid-column.d.ts +1 -0
- package/vaadin-grid-column.js +3 -0
- package/vaadin-grid-filter-column.d.ts +1 -0
- package/vaadin-grid-filter-column.js +3 -0
- package/vaadin-grid-filter.d.ts +1 -0
- package/vaadin-grid-filter.js +3 -0
- package/vaadin-grid-selection-column.d.ts +1 -0
- package/vaadin-grid-selection-column.js +3 -0
- package/vaadin-grid-sort-column.d.ts +1 -0
- package/vaadin-grid-sort-column.js +3 -0
- package/vaadin-grid-sorter.d.ts +1 -0
- package/vaadin-grid-sorter.js +3 -0
- package/vaadin-grid-tree-column.d.ts +1 -0
- package/vaadin-grid-tree-column.js +3 -0
- package/vaadin-grid-tree-toggle.d.ts +1 -0
- package/vaadin-grid-tree-toggle.js +3 -0
- package/vaadin-grid.d.ts +3 -0
- package/vaadin-grid.js +4 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @polymerMixin
|
|
9
|
+
*/
|
|
10
|
+
export const A11yMixin = (superClass) =>
|
|
11
|
+
class A11yMixin extends superClass {
|
|
12
|
+
static get observers() {
|
|
13
|
+
return ['_a11yUpdateGridSize(size, _columnTree, _columnTree.*)'];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @private */
|
|
17
|
+
_a11yGetHeaderRowCount(_columnTree) {
|
|
18
|
+
return _columnTree.filter((level) => level.some((col) => col.headerRenderer || col.path || col.header)).length;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @private */
|
|
22
|
+
_a11yGetFooterRowCount(_columnTree) {
|
|
23
|
+
return _columnTree.filter((level) => level.some((col) => col.headerRenderer)).length;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @private */
|
|
27
|
+
_a11yUpdateGridSize(size, _columnTree) {
|
|
28
|
+
if (size === undefined || _columnTree === undefined) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const bodyColumns = _columnTree[_columnTree.length - 1];
|
|
33
|
+
this.$.table.setAttribute(
|
|
34
|
+
'aria-rowcount',
|
|
35
|
+
size + this._a11yGetHeaderRowCount(_columnTree) + this._a11yGetFooterRowCount(_columnTree)
|
|
36
|
+
);
|
|
37
|
+
this.$.table.setAttribute('aria-colcount', (bodyColumns && bodyColumns.length) || 0);
|
|
38
|
+
|
|
39
|
+
this._a11yUpdateHeaderRows();
|
|
40
|
+
this._a11yUpdateFooterRows();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @protected */
|
|
44
|
+
_a11yUpdateHeaderRows() {
|
|
45
|
+
Array.from(this.$.header.children).forEach((headerRow, index) =>
|
|
46
|
+
headerRow.setAttribute('aria-rowindex', index + 1)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @protected */
|
|
51
|
+
_a11yUpdateFooterRows() {
|
|
52
|
+
Array.from(this.$.footer.children).forEach((footerRow, index) =>
|
|
53
|
+
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {!HTMLElement} row
|
|
59
|
+
* @param {number} index
|
|
60
|
+
* @protected
|
|
61
|
+
*/
|
|
62
|
+
_a11yUpdateRowRowindex(row, index) {
|
|
63
|
+
row.setAttribute('aria-rowindex', index + this._a11yGetHeaderRowCount(this._columnTree) + 1);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {!HTMLElement} row
|
|
68
|
+
* @param {boolean} selected
|
|
69
|
+
* @protected
|
|
70
|
+
*/
|
|
71
|
+
_a11yUpdateRowSelected(row, selected) {
|
|
72
|
+
// Jaws reads selection only for rows, NVDA only for cells
|
|
73
|
+
row.setAttribute('aria-selected', Boolean(selected));
|
|
74
|
+
Array.from(row.children).forEach((cell) => cell.setAttribute('aria-selected', Boolean(selected)));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {!HTMLElement} row
|
|
79
|
+
* @protected
|
|
80
|
+
*/
|
|
81
|
+
_a11yUpdateRowExpanded(row) {
|
|
82
|
+
if (this.__isRowExpandable(row)) {
|
|
83
|
+
row.setAttribute('aria-expanded', 'false');
|
|
84
|
+
} else if (this.__isRowCollapsible(row)) {
|
|
85
|
+
row.setAttribute('aria-expanded', 'true');
|
|
86
|
+
} else {
|
|
87
|
+
row.removeAttribute('aria-expanded');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {!HTMLElement} row
|
|
93
|
+
* @param {number} level
|
|
94
|
+
* @protected
|
|
95
|
+
*/
|
|
96
|
+
_a11yUpdateRowLevel(row, level) {
|
|
97
|
+
row.setAttribute('aria-level', level + 1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {!HTMLElement} row
|
|
102
|
+
* @param {boolean} detailsOpened
|
|
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
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @param {!HTMLElement} row
|
|
119
|
+
* @param {!HTMLElement} detailsCell
|
|
120
|
+
* @protected
|
|
121
|
+
*/
|
|
122
|
+
_a11ySetRowDetailsCell(row, detailsCell) {
|
|
123
|
+
Array.from(row.children).forEach((cell) => {
|
|
124
|
+
if (cell !== detailsCell) {
|
|
125
|
+
cell.setAttribute('aria-controls', detailsCell.id);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {!HTMLElement} row
|
|
132
|
+
* @param {number} colspan
|
|
133
|
+
* @protected
|
|
134
|
+
*/
|
|
135
|
+
_a11yUpdateCellColspan(cell, colspan) {
|
|
136
|
+
cell.setAttribute('aria-colspan', Number(colspan));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** @protected */
|
|
140
|
+
_a11yUpdateSorters() {
|
|
141
|
+
Array.from(this.querySelectorAll('vaadin-grid-sorter')).forEach((sorter) => {
|
|
142
|
+
let cellContent = sorter.parentNode;
|
|
143
|
+
while (cellContent && cellContent.localName !== 'vaadin-grid-cell-content') {
|
|
144
|
+
cellContent = cellContent.parentNode;
|
|
145
|
+
}
|
|
146
|
+
if (cellContent && cellContent.assignedSlot) {
|
|
147
|
+
const cell = cellContent.assignedSlot.parentNode;
|
|
148
|
+
cell.setAttribute(
|
|
149
|
+
'aria-sort',
|
|
150
|
+
{
|
|
151
|
+
asc: 'ascending',
|
|
152
|
+
desc: 'descending'
|
|
153
|
+
}[String(sorter.direction)] || 'none'
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare function ActiveItemMixin<TItem, T extends new (...args: any[]) => {}>(
|
|
2
|
+
base: T
|
|
3
|
+
): T & ActiveItemMixinConstructor<TItem>;
|
|
4
|
+
|
|
5
|
+
interface ActiveItemMixinConstructor<TItem> {
|
|
6
|
+
new (...args: any[]): ActiveItemMixin<TItem>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ActiveItemMixin<TItem> {
|
|
10
|
+
/**
|
|
11
|
+
* The item user has last interacted with. Turns to `null` after user deactivates
|
|
12
|
+
* the item by re-interacting with the currently active item.
|
|
13
|
+
*/
|
|
14
|
+
activeItem: TItem | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare function isFocusable(target: Element): boolean;
|
|
18
|
+
|
|
19
|
+
export { ActiveItemMixin, ActiveItemMixinConstructor, isFocusable };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @polymerMixin
|
|
9
|
+
*/
|
|
10
|
+
export const ActiveItemMixin = (superClass) =>
|
|
11
|
+
class ActiveItemMixin extends superClass {
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
/**
|
|
15
|
+
* The item user has last interacted with. Turns to `null` after user deactivates
|
|
16
|
+
* the item by re-interacting with the currently active item.
|
|
17
|
+
* @type {GridItem}
|
|
18
|
+
*/
|
|
19
|
+
activeItem: {
|
|
20
|
+
type: Object,
|
|
21
|
+
notify: true,
|
|
22
|
+
value: null
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
ready() {
|
|
28
|
+
super.ready();
|
|
29
|
+
|
|
30
|
+
this.$.scroller.addEventListener('click', this._onClick.bind(this));
|
|
31
|
+
this.addEventListener('cell-activate', this._activateItem.bind(this));
|
|
32
|
+
this.addEventListener('row-activate', this._activateItem.bind(this));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @private */
|
|
36
|
+
_activateItem(e) {
|
|
37
|
+
const model = e.detail.model;
|
|
38
|
+
const clickedItem = model ? model.item : null;
|
|
39
|
+
|
|
40
|
+
if (clickedItem) {
|
|
41
|
+
this.activeItem = !this._itemsEqual(this.activeItem, clickedItem) ? clickedItem : null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* We need to listen to click instead of tap because on mobile safari, the
|
|
47
|
+
* document.activeElement has not been updated (focus has not been shifted)
|
|
48
|
+
* yet at the point when tap event is being executed.
|
|
49
|
+
* @param {!MouseEvent} e
|
|
50
|
+
* @protected
|
|
51
|
+
*/
|
|
52
|
+
_onClick(e) {
|
|
53
|
+
if (e.defaultPrevented) {
|
|
54
|
+
// Something has handled this click already, e. g., <vaadin-grid-sorter>
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const path = e.composedPath();
|
|
59
|
+
const cell = path[path.indexOf(this.$.table) - 3];
|
|
60
|
+
if (!cell || cell.getAttribute('part').indexOf('details-cell') > -1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const cellContent = cell._content;
|
|
64
|
+
|
|
65
|
+
const activeElement = this.getRootNode().activeElement;
|
|
66
|
+
const cellContentHasFocus = cellContent.contains(activeElement);
|
|
67
|
+
if (!cellContentHasFocus && !this._isFocusable(e.target)) {
|
|
68
|
+
this.dispatchEvent(
|
|
69
|
+
new CustomEvent('cell-activate', {
|
|
70
|
+
detail: {
|
|
71
|
+
model: this.__getRowModel(cell.parentElement)
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {!Element} target
|
|
80
|
+
* @return {boolean}
|
|
81
|
+
* @protected
|
|
82
|
+
*/
|
|
83
|
+
_isFocusable(target) {
|
|
84
|
+
return isFocusable(target);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Fired when the `activeItem` property changes.
|
|
89
|
+
*
|
|
90
|
+
* @event active-item-changed
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Fired when the cell is activated with click or keyboard.
|
|
95
|
+
*
|
|
96
|
+
* @event cell-activate
|
|
97
|
+
*/
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {!Element} target
|
|
102
|
+
* @return {boolean}
|
|
103
|
+
* @protected
|
|
104
|
+
*/
|
|
105
|
+
export const isFocusable = (target) => {
|
|
106
|
+
if (!target.parentNode) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const focusables = Array.from(
|
|
110
|
+
target.parentNode.querySelectorAll(
|
|
111
|
+
'[tabindex], button, input, select, textarea, object, iframe, label, a[href], area[href]'
|
|
112
|
+
)
|
|
113
|
+
).filter((element) => element.getAttribute('part') !== 'cell body-cell');
|
|
114
|
+
|
|
115
|
+
const isFocusableElement = focusables.indexOf(target) !== -1;
|
|
116
|
+
return !target.disabled && isFocusableElement;
|
|
117
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare function ArrayDataProviderMixin<TItem, T extends new (...args: any[]) => {}>(
|
|
2
|
+
base: T
|
|
3
|
+
): T & ArrayDataProviderMixinConstructor<TItem>;
|
|
4
|
+
|
|
5
|
+
interface ArrayDataProviderMixinConstructor<TItem> {
|
|
6
|
+
new (...args: any[]): ArrayDataProviderMixin<TItem>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare interface ArrayDataProviderMixin<TItem> {
|
|
10
|
+
/**
|
|
11
|
+
* An array containing the items which will be passed to renderer functions.
|
|
12
|
+
*/
|
|
13
|
+
items: TItem[] | null | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { ArrayDataProviderMixin, ArrayDataProviderMixinConstructor };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { createArrayDataProvider } from './array-data-provider.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @polymerMixin
|
|
10
|
+
*/
|
|
11
|
+
export const ArrayDataProviderMixin = (superClass) =>
|
|
12
|
+
class ArrayDataProviderMixin extends superClass {
|
|
13
|
+
static get properties() {
|
|
14
|
+
return {
|
|
15
|
+
/**
|
|
16
|
+
* An array containing the items which will be passed to renderer functions.
|
|
17
|
+
*
|
|
18
|
+
* @type {Array<!GridItem> | undefined}
|
|
19
|
+
*/
|
|
20
|
+
items: Array
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static get observers() {
|
|
25
|
+
return ['__dataProviderOrItemsChanged(dataProvider, items, isAttached, items.*, _filters, _sorters)'];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @private */
|
|
29
|
+
__setArrayDataProvider(items) {
|
|
30
|
+
const arrayDataProvider = createArrayDataProvider(this.items, {});
|
|
31
|
+
arrayDataProvider.__items = items;
|
|
32
|
+
this.setProperties({
|
|
33
|
+
_arrayDataProvider: arrayDataProvider,
|
|
34
|
+
size: items.length,
|
|
35
|
+
dataProvider: arrayDataProvider
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @private */
|
|
40
|
+
__dataProviderOrItemsChanged(dataProvider, items, isAttached) {
|
|
41
|
+
if (!isAttached) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (this._arrayDataProvider) {
|
|
46
|
+
// Has an items array data provider beforehand
|
|
47
|
+
|
|
48
|
+
if (dataProvider !== this._arrayDataProvider) {
|
|
49
|
+
// A custom data provider was set externally
|
|
50
|
+
this.setProperties({
|
|
51
|
+
_arrayDataProvider: undefined,
|
|
52
|
+
items: undefined
|
|
53
|
+
});
|
|
54
|
+
} else if (!items) {
|
|
55
|
+
// The items array was unset
|
|
56
|
+
this.setProperties({
|
|
57
|
+
_arrayDataProvider: undefined,
|
|
58
|
+
dataProvider: undefined,
|
|
59
|
+
size: 0
|
|
60
|
+
});
|
|
61
|
+
this.clearCache();
|
|
62
|
+
} else if (this._arrayDataProvider.__items === items) {
|
|
63
|
+
// The items array was modified
|
|
64
|
+
this.clearCache();
|
|
65
|
+
this.size = this._effectiveSize;
|
|
66
|
+
} else {
|
|
67
|
+
// The items array was replaced
|
|
68
|
+
this.__setArrayDataProvider(items);
|
|
69
|
+
}
|
|
70
|
+
} else if (items) {
|
|
71
|
+
// There was no array data provider before items was set
|
|
72
|
+
this.__setArrayDataProvider(items);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { GridDefaultItem } from './interfaces';
|
|
2
|
+
import { ColumnBaseMixin } from './vaadin-grid-column.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A `<vaadin-grid-column-group>` is used to make groups of columns in `<vaadin-grid>` and
|
|
6
|
+
* to configure additional headers and footers.
|
|
7
|
+
*
|
|
8
|
+
* Groups can be nested to create complex header and footer configurations.
|
|
9
|
+
*
|
|
10
|
+
* #### Example:
|
|
11
|
+
* ```html
|
|
12
|
+
* <vaadin-grid-column-group resizable id="columnGroup">
|
|
13
|
+
* <vaadin-grid-column id="column1"></vaadin-grid-column>
|
|
14
|
+
* <vaadin-grid-column id="column2"></vaadin-grid-column>
|
|
15
|
+
* </vaadin-grid-column-group>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* ```js
|
|
19
|
+
* const columnGroup = document.querySelector('#columnGroup');
|
|
20
|
+
* columnGroup.headerRenderer = (root, columnGroup) => {
|
|
21
|
+
* root.textContent = 'header';
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* const column1 = document.querySelector('#column1');
|
|
25
|
+
* column1.headerRenderer = (root, column) => { ... };
|
|
26
|
+
* column1.renderer = (root, column, model) => { ... };
|
|
27
|
+
*
|
|
28
|
+
* const column2 = document.querySelector('#column2');
|
|
29
|
+
* column2.headerRenderer = (root, column) => { ... };
|
|
30
|
+
* column2.renderer = (root, column, model) => { ... };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare class GridColumnGroup extends HTMLElement {
|
|
34
|
+
/**
|
|
35
|
+
* Flex grow ratio for the column group as the sum of the ratios of its child columns.
|
|
36
|
+
* @attr {number} flex-grow
|
|
37
|
+
*/
|
|
38
|
+
readonly flexGrow: number | null | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Width of the column group as the sum of the widths of its child columns.
|
|
42
|
+
*/
|
|
43
|
+
readonly width: string | null | undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface GridColumnGroup<TItem = GridDefaultItem> extends ColumnBaseMixin<TItem> {}
|
|
47
|
+
|
|
48
|
+
declare global {
|
|
49
|
+
interface HTMLElementTagNameMap {
|
|
50
|
+
'vaadin-grid-column-group': GridColumnGroup<GridDefaultItem>;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { GridColumnGroup };
|