@vaadin/grid 24.0.0-alpha1 → 24.0.0-alpha11
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/all-imports.d.ts +10 -0
- package/all-imports.js +11 -0
- package/package.json +11 -10
- package/src/all-imports.js +1 -1
- package/src/array-data-provider.js +1 -1
- package/src/lit/column-renderer-directives.d.ts +1 -1
- package/src/lit/column-renderer-directives.js +1 -1
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/vaadin-grid-a11y-mixin.js +12 -9
- package/src/vaadin-grid-active-item-mixin.d.ts +1 -1
- package/src/vaadin-grid-active-item-mixin.js +10 -5
- package/src/vaadin-grid-array-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-grid-array-data-provider-mixin.js +1 -1
- package/src/vaadin-grid-column-group.d.ts +1 -1
- package/src/vaadin-grid-column-group.js +17 -17
- package/src/vaadin-grid-column-reordering-mixin.d.ts +1 -1
- package/src/vaadin-grid-column-reordering-mixin.js +8 -10
- package/src/vaadin-grid-column-resizing-mixin.js +6 -5
- package/src/vaadin-grid-column.d.ts +1 -1
- package/src/vaadin-grid-column.js +54 -40
- package/src/vaadin-grid-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-grid-data-provider-mixin.js +34 -7
- package/src/vaadin-grid-drag-and-drop-mixin.d.ts +1 -1
- package/src/vaadin-grid-drag-and-drop-mixin.js +23 -18
- package/src/vaadin-grid-dynamic-columns-mixin.js +5 -4
- package/src/vaadin-grid-event-context-mixin.d.ts +1 -1
- package/src/vaadin-grid-event-context-mixin.js +1 -1
- package/src/vaadin-grid-filter-column.d.ts +1 -1
- package/src/vaadin-grid-filter-column.js +1 -2
- package/src/vaadin-grid-filter-mixin.js +1 -1
- package/src/vaadin-grid-filter.d.ts +3 -2
- package/src/vaadin-grid-filter.js +27 -22
- package/src/vaadin-grid-helpers.js +104 -1
- package/src/vaadin-grid-keyboard-navigation-mixin.js +48 -35
- package/src/vaadin-grid-row-details-mixin.d.ts +2 -6
- package/src/vaadin-grid-row-details-mixin.js +5 -4
- package/src/vaadin-grid-scroll-mixin.d.ts +1 -1
- package/src/vaadin-grid-scroll-mixin.js +18 -10
- package/src/vaadin-grid-selection-column.d.ts +1 -1
- package/src/vaadin-grid-selection-column.js +1 -1
- package/src/vaadin-grid-selection-mixin.d.ts +1 -1
- package/src/vaadin-grid-selection-mixin.js +1 -1
- package/src/vaadin-grid-sort-column.d.ts +1 -1
- package/src/vaadin-grid-sort-column.js +1 -1
- package/src/vaadin-grid-sort-mixin.d.ts +10 -1
- package/src/vaadin-grid-sort-mixin.js +22 -6
- package/src/vaadin-grid-sorter.d.ts +7 -2
- package/src/vaadin-grid-sorter.js +18 -2
- package/src/vaadin-grid-styles.js +5 -1
- package/src/vaadin-grid-styling-mixin.d.ts +38 -2
- package/src/vaadin-grid-styling-mixin.js +78 -6
- package/src/vaadin-grid-tree-column.d.ts +1 -8
- package/src/vaadin-grid-tree-column.js +2 -25
- package/src/vaadin-grid-tree-toggle.d.ts +1 -1
- package/src/vaadin-grid-tree-toggle.js +2 -2
- package/src/vaadin-grid.d.ts +100 -50
- package/src/vaadin-grid.js +198 -105
- package/theme/lumo/vaadin-grid-styles.js +14 -14
- package/theme/lumo/vaadin-grid.js +0 -7
- package/theme/material/vaadin-grid-styles.js +1 -1
- package/web-types.json +33 -26
- package/web-types.lit.json +18 -11
package/all-imports.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './vaadin-grid-column-group.js';
|
|
2
|
+
export * from './vaadin-grid-column.js';
|
|
3
|
+
export * from './vaadin-grid-filter.js';
|
|
4
|
+
export * from './vaadin-grid-filter-column.js';
|
|
5
|
+
export * from './vaadin-grid-selection-column.js';
|
|
6
|
+
export * from './vaadin-grid-sorter.js';
|
|
7
|
+
export * from './vaadin-grid-sort-column.js';
|
|
8
|
+
export * from './vaadin-grid-tree-column.js';
|
|
9
|
+
export * from './vaadin-grid-tree-toggle.js';
|
|
10
|
+
export * from './vaadin-grid.js';
|
package/all-imports.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
1
|
import './theme/lumo/all-imports.js';
|
|
2
|
+
|
|
3
|
+
export * from './vaadin-grid-column-group.js';
|
|
4
|
+
export * from './vaadin-grid-column.js';
|
|
5
|
+
export * from './vaadin-grid-filter.js';
|
|
6
|
+
export * from './vaadin-grid-filter-column.js';
|
|
7
|
+
export * from './vaadin-grid-selection-column.js';
|
|
8
|
+
export * from './vaadin-grid-sorter.js';
|
|
9
|
+
export * from './vaadin-grid-sort-column.js';
|
|
10
|
+
export * from './vaadin-grid-tree-column.js';
|
|
11
|
+
export * from './vaadin-grid-tree-toggle.js';
|
|
12
|
+
export * from './vaadin-grid.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"module": "vaadin-grid.js",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
|
+
"all-imports.d.ts",
|
|
23
24
|
"all-imports.js",
|
|
24
25
|
"lit.d.ts",
|
|
25
26
|
"lit.js",
|
|
@@ -45,17 +46,17 @@
|
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
47
48
|
"@polymer/polymer": "^3.0.0",
|
|
48
|
-
"@vaadin/checkbox": "24.0.0-
|
|
49
|
-
"@vaadin/component-base": "24.0.0-
|
|
50
|
-
"@vaadin/lit-renderer": "24.0.0-
|
|
51
|
-
"@vaadin/text-field": "24.0.0-
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
53
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
54
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
49
|
+
"@vaadin/checkbox": "24.0.0-alpha11",
|
|
50
|
+
"@vaadin/component-base": "24.0.0-alpha11",
|
|
51
|
+
"@vaadin/lit-renderer": "24.0.0-alpha11",
|
|
52
|
+
"@vaadin/text-field": "24.0.0-alpha11",
|
|
53
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha11",
|
|
54
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha11",
|
|
55
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha11"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@esm-bundle/chai": "^4.3.4",
|
|
58
|
-
"@vaadin/polymer-legacy-adapter": "24.0.0-
|
|
59
|
+
"@vaadin/polymer-legacy-adapter": "24.0.0-alpha11",
|
|
59
60
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
60
61
|
"lit": "^2.0.0",
|
|
61
62
|
"sinon": "^13.0.2"
|
|
@@ -64,5 +65,5 @@
|
|
|
64
65
|
"web-types.json",
|
|
65
66
|
"web-types.lit.json"
|
|
66
67
|
],
|
|
67
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "641b3d96ceeb3e503a093682ebe686afdd8c3a68"
|
|
68
69
|
}
|
package/src/all-imports.js
CHANGED
|
@@ -28,7 +28,7 @@ function checkPaths(arrayToCheck, action, items) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const parentProperty = path.replace(/\.[^.]
|
|
31
|
+
const parentProperty = path.replace(/\.[^.]*$/u, ''); // A.b.c -> a.b
|
|
32
32
|
if (get(parentProperty, items[0]) === undefined) {
|
|
33
33
|
console.warn(`Path "${path}" used for ${action} does not exist in all of the items, ${action} is disabled.`);
|
|
34
34
|
result = false;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { iterateChildren } from './vaadin-grid-helpers.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @polymerMixin
|
|
@@ -42,16 +43,16 @@ export const A11yMixin = (superClass) =>
|
|
|
42
43
|
|
|
43
44
|
/** @protected */
|
|
44
45
|
_a11yUpdateHeaderRows() {
|
|
45
|
-
|
|
46
|
-
headerRow.setAttribute('aria-rowindex', index + 1)
|
|
47
|
-
);
|
|
46
|
+
iterateChildren(this.$.header, (headerRow, index) => {
|
|
47
|
+
headerRow.setAttribute('aria-rowindex', index + 1);
|
|
48
|
+
});
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/** @protected */
|
|
51
52
|
_a11yUpdateFooterRows() {
|
|
52
|
-
|
|
53
|
-
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1)
|
|
54
|
-
);
|
|
53
|
+
iterateChildren(this.$.footer, (footerRow, index) => {
|
|
54
|
+
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1);
|
|
55
|
+
});
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -71,7 +72,9 @@ export const A11yMixin = (superClass) =>
|
|
|
71
72
|
_a11yUpdateRowSelected(row, selected) {
|
|
72
73
|
// Jaws reads selection only for rows, NVDA only for cells
|
|
73
74
|
row.setAttribute('aria-selected', Boolean(selected));
|
|
74
|
-
|
|
75
|
+
iterateChildren(row, (cell) => {
|
|
76
|
+
cell.setAttribute('aria-selected', Boolean(selected));
|
|
77
|
+
});
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
/**
|
|
@@ -108,7 +111,7 @@ export const A11yMixin = (superClass) =>
|
|
|
108
111
|
* @protected
|
|
109
112
|
*/
|
|
110
113
|
_a11ySetRowDetailsCell(row, detailsCell) {
|
|
111
|
-
|
|
114
|
+
iterateChildren(row, (cell) => {
|
|
112
115
|
if (cell !== detailsCell) {
|
|
113
116
|
cell.setAttribute('aria-controls', detailsCell.id);
|
|
114
117
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -65,7 +65,7 @@ export const ActiveItemMixin = (superClass) =>
|
|
|
65
65
|
|
|
66
66
|
const activeElement = this.getRootNode().activeElement;
|
|
67
67
|
const cellContentHasFocus = cellContent.contains(activeElement);
|
|
68
|
-
if (!cellContentHasFocus && !this._isFocusable(e.target)) {
|
|
68
|
+
if (!cellContentHasFocus && !this._isFocusable(e.target) && !(e.target instanceof HTMLLabelElement)) {
|
|
69
69
|
this.dispatchEvent(
|
|
70
70
|
new CustomEvent('cell-activate', {
|
|
71
71
|
detail: {
|
|
@@ -109,10 +109,15 @@ export const isFocusable = (target) => {
|
|
|
109
109
|
}
|
|
110
110
|
const focusables = Array.from(
|
|
111
111
|
target.parentNode.querySelectorAll(
|
|
112
|
-
'[tabindex], button, input, select, textarea, object, iframe,
|
|
112
|
+
'[tabindex], button, input, select, textarea, object, iframe, a[href], area[href]',
|
|
113
113
|
),
|
|
114
|
-
).filter((element) =>
|
|
114
|
+
).filter((element) => {
|
|
115
|
+
const part = element.getAttribute('part');
|
|
116
|
+
return !(part && part.includes('body-cell'));
|
|
117
|
+
});
|
|
115
118
|
|
|
116
119
|
const isFocusableElement = focusables.includes(target);
|
|
117
|
-
return
|
|
120
|
+
return (
|
|
121
|
+
!target.disabled && isFocusableElement && target.offsetParent && getComputedStyle(target).visibility !== 'hidden'
|
|
122
|
+
);
|
|
118
123
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { createArrayDataProvider } from './array-data-provider.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { GridDefaultItem } from './vaadin-grid.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
@@ -126,28 +126,28 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
|
|
|
126
126
|
this._preventHiddenSynchronization = false;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
if (/flexGrow|width|hidden|_childColumns
|
|
129
|
+
if (/flexGrow|width|hidden|_childColumns/u.test(path)) {
|
|
130
130
|
this._updateFlexAndWidth();
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.frozen =
|
|
133
|
+
// Don’t unfreeze the frozen group because of a non-frozen child
|
|
134
|
+
if (path === 'frozen' && !this.frozen) {
|
|
135
|
+
this.frozen = value;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this._lastFrozen =
|
|
138
|
+
// Don’t unfreeze the frozen group because of a non-frozen child
|
|
139
|
+
if (path === 'lastFrozen' && !this._lastFrozen) {
|
|
140
|
+
this._lastFrozen = value;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.frozenToEnd =
|
|
143
|
+
// Don’t unfreeze the frozen group because of a non-frozen child
|
|
144
|
+
if (path === 'frozenToEnd' && !this.frozenToEnd) {
|
|
145
|
+
this.frozenToEnd = value;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this._firstFrozenToEnd =
|
|
148
|
+
// Don’t unfreeze the frozen group because of a non-frozen child
|
|
149
|
+
if (path === 'firstFrozenToEnd' && !this._firstFrozenToEnd) {
|
|
150
|
+
this._firstFrozenToEnd = value;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -169,7 +169,7 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
|
|
|
169
169
|
// [1110] | [1120] | [1210] | [1220]
|
|
170
170
|
|
|
171
171
|
// Trailing zeros are counted so we know the level on which we're working on.
|
|
172
|
-
const trailingZeros = /(0+)
|
|
172
|
+
const trailingZeros = /(0+)$/u.exec(order).pop().length;
|
|
173
173
|
|
|
174
174
|
// In an unlikely situation where a group has more than 9 child columns,
|
|
175
175
|
// the child scope must have 1 digit less...
|
|
@@ -247,7 +247,7 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
|
|
|
247
247
|
__scheduleAutoFreezeWarning(columns, frozenProp) {
|
|
248
248
|
if (this._grid) {
|
|
249
249
|
// Derive the attribute name from the property name
|
|
250
|
-
const frozenAttr = frozenProp.replace(/([A-Z])/
|
|
250
|
+
const frozenAttr = frozenProp.replace(/([A-Z])/gu, '-$1').toLowerCase();
|
|
251
251
|
|
|
252
252
|
// Check if all the columns have the same frozen value
|
|
253
253
|
const firstColumnFrozen = columns[0][frozenProp] || columns[0].hasAttribute(frozenAttr);
|
|
@@ -394,7 +394,7 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
|
|
|
394
394
|
* @protected
|
|
395
395
|
*/
|
|
396
396
|
_isColumnElement(node) {
|
|
397
|
-
return node.nodeType === Node.ELEMENT_NODE && /\bcolumn\b
|
|
397
|
+
return node.nodeType === Node.ELEMENT_NODE && /\bcolumn\b/u.test(node.localName);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
7
|
-
import { updateColumnOrders } from './vaadin-grid-helpers.js';
|
|
7
|
+
import { iterateChildren, updateColumnOrders } from './vaadin-grid-helpers.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @polymerMixin
|
|
@@ -224,9 +224,7 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
224
224
|
* @return {HTMLElement | undefined}
|
|
225
225
|
* @protected
|
|
226
226
|
*/
|
|
227
|
-
_cellFromPoint(x, y) {
|
|
228
|
-
x = x || 0;
|
|
229
|
-
y = y || 0;
|
|
227
|
+
_cellFromPoint(x = 0, y = 0) {
|
|
230
228
|
if (!this._draggedColumn) {
|
|
231
229
|
this.$.scroller.toggleAttribute('no-content-pointer-events', true);
|
|
232
230
|
}
|
|
@@ -304,11 +302,11 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
304
302
|
* @protected
|
|
305
303
|
*/
|
|
306
304
|
_setSiblingsReorderStatus(column, status) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
.forEach((sibling) => {
|
|
305
|
+
iterateChildren(column.parentNode, (sibling) => {
|
|
306
|
+
if (/column/u.test(sibling.localName) && this._isSwapAllowed(sibling, column)) {
|
|
310
307
|
sibling._reorderStatus = status;
|
|
311
|
-
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
312
310
|
}
|
|
313
311
|
|
|
314
312
|
/** @protected */
|
|
@@ -374,7 +372,7 @@ export const ColumnReorderingMixin = (superClass) =>
|
|
|
374
372
|
*/
|
|
375
373
|
_swapColumnOrders(column1, column2) {
|
|
376
374
|
[column1._order, column2._order] = [column2._order, column1._order];
|
|
377
|
-
this.
|
|
375
|
+
this._debounceUpdateFrozenColumn();
|
|
378
376
|
this._updateFirstAndLastColumn();
|
|
379
377
|
}
|
|
380
378
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { addListener } from '@vaadin/component-base/src/gestures.js';
|
|
@@ -50,6 +50,7 @@ export const ColumnResizingMixin = (superClass) =>
|
|
|
50
50
|
.pop();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const isRTL = this.__isRTL;
|
|
53
54
|
const eventX = e.detail.x;
|
|
54
55
|
const columnRowCells = Array.from(this.$.header.querySelectorAll('[part~="row"]:last-child [part~="cell"]'));
|
|
55
56
|
const targetCell = columnRowCells.find((cell) => cell._column === column);
|
|
@@ -72,9 +73,9 @@ export const ColumnResizingMixin = (superClass) =>
|
|
|
72
73
|
|
|
73
74
|
// For cells frozen to end, resize handle is flipped horizontally.
|
|
74
75
|
if (targetCell.hasAttribute('frozen-to-end')) {
|
|
75
|
-
maxWidth = cellWidth + (
|
|
76
|
+
maxWidth = cellWidth + (isRTL ? eventX - cellRect.right : cellRect.left - eventX);
|
|
76
77
|
} else {
|
|
77
|
-
maxWidth = cellWidth + (
|
|
78
|
+
maxWidth = cellWidth + (isRTL ? cellRect.left - eventX : eventX - cellRect.right);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
column.width = `${Math.max(minWidth, maxWidth)}px`;
|
|
@@ -95,9 +96,9 @@ export const ColumnResizingMixin = (superClass) =>
|
|
|
95
96
|
// When handle moves below the cell frozen to end, scroll into view.
|
|
96
97
|
if (cellFrozenToEnd && this.$.table.scrollWidth > this.$.table.offsetWidth) {
|
|
97
98
|
const frozenRect = cellFrozenToEnd.getBoundingClientRect();
|
|
98
|
-
const offset = eventX - (
|
|
99
|
+
const offset = eventX - (isRTL ? frozenRect.right : frozenRect.left);
|
|
99
100
|
|
|
100
|
-
if ((
|
|
101
|
+
if ((isRTL && offset <= 0) || (!isRTL && offset >= 0)) {
|
|
101
102
|
this.$.table.scrollLeft += offset;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -8,6 +8,7 @@ import { animationFrame } from '@vaadin/component-base/src/async.js';
|
|
|
8
8
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
9
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
10
10
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
11
|
+
import { updateCellState } from './vaadin-grid-helpers.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @polymerMixin
|
|
@@ -215,6 +216,30 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
215
216
|
];
|
|
216
217
|
}
|
|
217
218
|
|
|
219
|
+
/**
|
|
220
|
+
* @return {!Grid | undefined}
|
|
221
|
+
* @protected
|
|
222
|
+
*/
|
|
223
|
+
get _grid() {
|
|
224
|
+
if (!this._gridValue) {
|
|
225
|
+
this._gridValue = this._findHostGrid();
|
|
226
|
+
}
|
|
227
|
+
return this._gridValue;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @return {!Array<!HTMLElement>}
|
|
232
|
+
* @protected
|
|
233
|
+
*/
|
|
234
|
+
get _allCells() {
|
|
235
|
+
return []
|
|
236
|
+
.concat(this._cells || [])
|
|
237
|
+
.concat(this._emptyCells || [])
|
|
238
|
+
.concat(this._headerCell)
|
|
239
|
+
.concat(this._footerCell)
|
|
240
|
+
.filter((cell) => cell);
|
|
241
|
+
}
|
|
242
|
+
|
|
218
243
|
/** @protected */
|
|
219
244
|
connectedCallback() {
|
|
220
245
|
super.connectedCallback();
|
|
@@ -270,36 +295,12 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
270
295
|
// eslint-disable-next-line @typescript-eslint/no-this-alias, consistent-this
|
|
271
296
|
let el = this;
|
|
272
297
|
// Custom elements extending grid must have a specific localName
|
|
273
|
-
while (el && !/^vaadin.*grid(-pro)
|
|
298
|
+
while (el && !/^vaadin.*grid(-pro)?$/u.test(el.localName)) {
|
|
274
299
|
el = el.assignedSlot ? el.assignedSlot.parentNode : el.parentNode;
|
|
275
300
|
}
|
|
276
301
|
return el || undefined;
|
|
277
302
|
}
|
|
278
303
|
|
|
279
|
-
/**
|
|
280
|
-
* @return {!Grid | undefined}
|
|
281
|
-
* @protected
|
|
282
|
-
*/
|
|
283
|
-
get _grid() {
|
|
284
|
-
if (!this._gridValue) {
|
|
285
|
-
this._gridValue = this._findHostGrid();
|
|
286
|
-
}
|
|
287
|
-
return this._gridValue;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* @return {!Array<!HTMLElement>}
|
|
292
|
-
* @protected
|
|
293
|
-
*/
|
|
294
|
-
get _allCells() {
|
|
295
|
-
return []
|
|
296
|
-
.concat(this._cells || [])
|
|
297
|
-
.concat(this._emptyCells || [])
|
|
298
|
-
.concat(this._headerCell)
|
|
299
|
-
.concat(this._footerCell)
|
|
300
|
-
.filter((cell) => cell);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
304
|
/** @protected */
|
|
304
305
|
_renderHeaderAndFooter() {
|
|
305
306
|
this._renderHeaderCellContent(this._headerRenderer, this._headerCell);
|
|
@@ -341,7 +342,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
341
342
|
this.parentElement._columnPropChanged('frozen', frozen);
|
|
342
343
|
}
|
|
343
344
|
|
|
344
|
-
this._allCells.forEach((cell) =>
|
|
345
|
+
this._allCells.forEach((cell) => {
|
|
346
|
+
updateCellState(cell, 'frozen', frozen);
|
|
347
|
+
});
|
|
345
348
|
|
|
346
349
|
if (this._grid && this._grid._frozenCellsChanged) {
|
|
347
350
|
this._grid._frozenCellsChanged();
|
|
@@ -359,7 +362,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
359
362
|
if (this._grid && cell.parentElement === this._grid.$.sizer) {
|
|
360
363
|
return;
|
|
361
364
|
}
|
|
362
|
-
|
|
365
|
+
|
|
366
|
+
updateCellState(cell, 'frozen-to-end', frozenToEnd);
|
|
363
367
|
});
|
|
364
368
|
|
|
365
369
|
if (this._grid && this._grid._frozenCellsChanged) {
|
|
@@ -369,7 +373,9 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
369
373
|
|
|
370
374
|
/** @private */
|
|
371
375
|
_lastFrozenChanged(lastFrozen) {
|
|
372
|
-
this._allCells.forEach((cell) =>
|
|
376
|
+
this._allCells.forEach((cell) => {
|
|
377
|
+
updateCellState(cell, 'last-frozen', lastFrozen);
|
|
378
|
+
});
|
|
373
379
|
|
|
374
380
|
if (this.parentElement && this.parentElement._columnPropChanged) {
|
|
375
381
|
this.parentElement._lastFrozen = lastFrozen;
|
|
@@ -384,7 +390,7 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
384
390
|
return;
|
|
385
391
|
}
|
|
386
392
|
|
|
387
|
-
cell
|
|
393
|
+
updateCellState(cell, 'first-frozen-to-end', firstFrozenToEnd);
|
|
388
394
|
});
|
|
389
395
|
|
|
390
396
|
if (this.parentElement && this.parentElement._columnPropChanged) {
|
|
@@ -400,15 +406,23 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
400
406
|
_generateHeader(path) {
|
|
401
407
|
return path
|
|
402
408
|
.substr(path.lastIndexOf('.') + 1)
|
|
403
|
-
.replace(/([A-Z])/
|
|
409
|
+
.replace(/([A-Z])/gu, '-$1')
|
|
404
410
|
.toLowerCase()
|
|
405
|
-
.replace(/-/
|
|
406
|
-
.replace(
|
|
411
|
+
.replace(/-/gu, ' ')
|
|
412
|
+
.replace(/^./u, (match) => match.toUpperCase());
|
|
407
413
|
}
|
|
408
414
|
|
|
409
415
|
/** @private */
|
|
410
416
|
_reorderStatusChanged(reorderStatus) {
|
|
411
|
-
|
|
417
|
+
const prevStatus = this.__previousReorderStatus;
|
|
418
|
+
const oldPart = prevStatus ? `reorder-${prevStatus}-cell` : '';
|
|
419
|
+
const newPart = `reorder-${reorderStatus}-cell`;
|
|
420
|
+
|
|
421
|
+
this._allCells.forEach((cell) => {
|
|
422
|
+
updateCellState(cell, 'reorder-status', reorderStatus, newPart, oldPart);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
this.__previousReorderStatus = reorderStatus;
|
|
412
426
|
}
|
|
413
427
|
|
|
414
428
|
/** @private */
|
|
@@ -490,8 +504,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
490
504
|
},
|
|
491
505
|
);
|
|
492
506
|
|
|
493
|
-
if (this._grid.
|
|
494
|
-
this._grid.
|
|
507
|
+
if (this._grid._debounceUpdateFrozenColumn) {
|
|
508
|
+
this._grid._debounceUpdateFrozenColumn();
|
|
495
509
|
}
|
|
496
510
|
|
|
497
511
|
if (this._grid._resetKeyboardNavigation) {
|
|
@@ -571,8 +585,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
571
585
|
}
|
|
572
586
|
|
|
573
587
|
this.__renderCellsContent(headerRenderer, [headerCell]);
|
|
574
|
-
if (this._grid) {
|
|
575
|
-
this._grid.
|
|
588
|
+
if (this._grid && headerCell.parentElement) {
|
|
589
|
+
this._grid.__debounceUpdateHeaderFooterRowVisibility(headerCell.parentElement);
|
|
576
590
|
}
|
|
577
591
|
}
|
|
578
592
|
|
|
@@ -612,8 +626,8 @@ export const ColumnBaseMixin = (superClass) =>
|
|
|
612
626
|
}
|
|
613
627
|
|
|
614
628
|
this.__renderCellsContent(footerRenderer, [footerCell]);
|
|
615
|
-
if (this._grid) {
|
|
616
|
-
this._grid.
|
|
629
|
+
if (this._grid && footerCell.parentElement) {
|
|
630
|
+
this._grid.__debounceUpdateHeaderFooterRowVisibility(footerCell.parentElement);
|
|
617
631
|
}
|
|
618
632
|
}
|
|
619
633
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2016 -
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|