@vaadin/grid 24.0.0-alpha1 → 24.0.0-alpha10

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.
Files changed (63) hide show
  1. package/all-imports.d.ts +10 -0
  2. package/all-imports.js +11 -0
  3. package/package.json +11 -10
  4. package/src/all-imports.js +1 -1
  5. package/src/array-data-provider.js +1 -1
  6. package/src/lit/column-renderer-directives.d.ts +1 -1
  7. package/src/lit/column-renderer-directives.js +1 -1
  8. package/src/lit/renderer-directives.d.ts +1 -1
  9. package/src/lit/renderer-directives.js +1 -1
  10. package/src/vaadin-grid-a11y-mixin.js +12 -9
  11. package/src/vaadin-grid-active-item-mixin.d.ts +1 -1
  12. package/src/vaadin-grid-active-item-mixin.js +9 -4
  13. package/src/vaadin-grid-array-data-provider-mixin.d.ts +1 -1
  14. package/src/vaadin-grid-array-data-provider-mixin.js +1 -1
  15. package/src/vaadin-grid-column-group.d.ts +1 -1
  16. package/src/vaadin-grid-column-group.js +17 -17
  17. package/src/vaadin-grid-column-reordering-mixin.d.ts +1 -1
  18. package/src/vaadin-grid-column-reordering-mixin.js +8 -10
  19. package/src/vaadin-grid-column-resizing-mixin.js +6 -5
  20. package/src/vaadin-grid-column.d.ts +1 -1
  21. package/src/vaadin-grid-column.js +54 -40
  22. package/src/vaadin-grid-data-provider-mixin.d.ts +1 -1
  23. package/src/vaadin-grid-data-provider-mixin.js +34 -7
  24. package/src/vaadin-grid-drag-and-drop-mixin.d.ts +1 -1
  25. package/src/vaadin-grid-drag-and-drop-mixin.js +23 -18
  26. package/src/vaadin-grid-dynamic-columns-mixin.js +5 -4
  27. package/src/vaadin-grid-event-context-mixin.d.ts +1 -1
  28. package/src/vaadin-grid-event-context-mixin.js +1 -1
  29. package/src/vaadin-grid-filter-column.d.ts +1 -1
  30. package/src/vaadin-grid-filter-column.js +1 -2
  31. package/src/vaadin-grid-filter-mixin.js +1 -1
  32. package/src/vaadin-grid-filter.d.ts +3 -2
  33. package/src/vaadin-grid-filter.js +27 -22
  34. package/src/vaadin-grid-helpers.js +104 -1
  35. package/src/vaadin-grid-keyboard-navigation-mixin.js +48 -35
  36. package/src/vaadin-grid-row-details-mixin.d.ts +2 -6
  37. package/src/vaadin-grid-row-details-mixin.js +5 -4
  38. package/src/vaadin-grid-scroll-mixin.d.ts +1 -1
  39. package/src/vaadin-grid-scroll-mixin.js +18 -10
  40. package/src/vaadin-grid-selection-column.d.ts +1 -1
  41. package/src/vaadin-grid-selection-column.js +1 -1
  42. package/src/vaadin-grid-selection-mixin.d.ts +1 -1
  43. package/src/vaadin-grid-selection-mixin.js +1 -1
  44. package/src/vaadin-grid-sort-column.d.ts +1 -1
  45. package/src/vaadin-grid-sort-column.js +1 -1
  46. package/src/vaadin-grid-sort-mixin.d.ts +10 -1
  47. package/src/vaadin-grid-sort-mixin.js +19 -6
  48. package/src/vaadin-grid-sorter.d.ts +7 -2
  49. package/src/vaadin-grid-sorter.js +20 -2
  50. package/src/vaadin-grid-styles.js +5 -1
  51. package/src/vaadin-grid-styling-mixin.d.ts +38 -2
  52. package/src/vaadin-grid-styling-mixin.js +78 -6
  53. package/src/vaadin-grid-tree-column.d.ts +1 -8
  54. package/src/vaadin-grid-tree-column.js +2 -25
  55. package/src/vaadin-grid-tree-toggle.d.ts +1 -1
  56. package/src/vaadin-grid-tree-toggle.js +1 -1
  57. package/src/vaadin-grid.d.ts +100 -50
  58. package/src/vaadin-grid.js +198 -105
  59. package/theme/lumo/vaadin-grid-styles.js +14 -14
  60. package/theme/lumo/vaadin-grid.js +0 -7
  61. package/theme/material/vaadin-grid-styles.js +1 -1
  62. package/web-types.json +33 -26
  63. package/web-types.lit.json +18 -11
@@ -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-alpha1",
3
+ "version": "24.0.0-alpha10",
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-alpha1",
49
- "@vaadin/component-base": "24.0.0-alpha1",
50
- "@vaadin/lit-renderer": "24.0.0-alpha1",
51
- "@vaadin/text-field": "24.0.0-alpha1",
52
- "@vaadin/vaadin-lumo-styles": "24.0.0-alpha1",
53
- "@vaadin/vaadin-material-styles": "24.0.0-alpha1",
54
- "@vaadin/vaadin-themable-mixin": "24.0.0-alpha1"
49
+ "@vaadin/checkbox": "24.0.0-alpha10",
50
+ "@vaadin/component-base": "24.0.0-alpha10",
51
+ "@vaadin/lit-renderer": "24.0.0-alpha10",
52
+ "@vaadin/text-field": "24.0.0-alpha10",
53
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
54
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha10",
55
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@esm-bundle/chai": "^4.3.4",
58
- "@vaadin/polymer-legacy-adapter": "24.0.0-alpha1",
59
+ "@vaadin/polymer-legacy-adapter": "24.0.0-alpha10",
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": "427527c27c4b27822d61fd41d38d7b170134770b"
68
+ "gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
68
69
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
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 './vaadin-grid.js';
@@ -28,7 +28,7 @@ function checkPaths(arrayToCheck, action, items) {
28
28
  return;
29
29
  }
30
30
 
31
- const parentProperty = path.replace(/\.[^.]*$/, ''); // A.b.c -> a.b
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,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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
  /* eslint-disable max-classes-per-file */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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
  /* eslint-disable max-classes-per-file */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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 { TemplateResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 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 { directive } from 'lit/directive.js';
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
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
- Array.from(this.$.header.children).forEach((headerRow, index) =>
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
- Array.from(this.$.footer.children).forEach((footerRow, index) =>
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
- Array.from(row.children).forEach((cell) => cell.setAttribute('aria-selected', Boolean(selected)));
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
- Array.from(row.children).forEach((cell) => {
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 - 2022 Vaadin Ltd.
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 - 2022 Vaadin Ltd.
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
 
@@ -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, label, a[href], area[href]',
112
+ '[tabindex], button, input, select, textarea, object, iframe, a[href], area[href]',
113
113
  ),
114
- ).filter((element) => element.getAttribute('part') !== 'cell body-cell');
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 !target.disabled && isFocusableElement;
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 - 2022 Vaadin Ltd.
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 - 2022 Vaadin Ltd.
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 - 2022 Vaadin Ltd.
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 - 2022 Vaadin Ltd.
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/.test(path)) {
129
+ if (/flexGrow|width|hidden|_childColumns/u.test(path)) {
130
130
  this._updateFlexAndWidth();
131
131
  }
132
132
 
133
- if (path === 'frozen') {
134
- // Don’t unfreeze the frozen group because of a non-frozen child
135
- this.frozen = this.frozen || value;
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
- if (path === 'lastFrozen') {
139
- // Don’t unfreeze the frozen group because of a non-frozen child
140
- this._lastFrozen = this._lastFrozen || value;
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
- if (path === 'frozenToEnd') {
144
- // Don’t unfreeze the frozen group because of a non-frozen child
145
- this.frozenToEnd = this.frozenToEnd || value;
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
- if (path === 'firstFrozenToEnd') {
149
- // Don’t unfreeze the frozen group because of a non-frozen child
150
- this._firstFrozenToEnd = this._firstFrozenToEnd || value;
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+)$/.exec(order).pop().length;
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])/g, '-$1').toLowerCase();
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/.test(node.localName);
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 - 2022 Vaadin Ltd.
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 - 2022 Vaadin Ltd.
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
- Array.from(column.parentNode.children)
308
- .filter((child) => /column/.test(child.localName) && this._isSwapAllowed(child, column))
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._updateFrozenColumn();
375
+ this._debounceUpdateFrozenColumn();
378
376
  this._updateFirstAndLastColumn();
379
377
  }
380
378
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2016 - 2022 Vaadin Ltd.
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 + (this.__isRTL ? eventX - cellRect.right : cellRect.left - eventX);
76
+ maxWidth = cellWidth + (isRTL ? eventX - cellRect.right : cellRect.left - eventX);
76
77
  } else {
77
- maxWidth = cellWidth + (this.__isRTL ? cellRect.left - eventX : eventX - cellRect.right);
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 - (this.__isRTL ? frozenRect.right : frozenRect.left);
99
+ const offset = eventX - (isRTL ? frozenRect.right : frozenRect.left);
99
100
 
100
- if ((this.__isRTL && offset <= 0) || (!this.__isRTL && offset >= 0)) {
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 - 2022 Vaadin Ltd.
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 - 2022 Vaadin Ltd.
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)?$/.test(el.localName)) {
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) => cell.toggleAttribute('frozen', frozen));
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
- cell.toggleAttribute('frozen-to-end', frozenToEnd);
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) => cell.toggleAttribute('last-frozen', lastFrozen));
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.toggleAttribute('first-frozen-to-end', firstFrozenToEnd);
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])/g, '-$1')
409
+ .replace(/([A-Z])/gu, '-$1')
404
410
  .toLowerCase()
405
- .replace(/-/g, ' ')
406
- .replace(/^./, (match) => match.toUpperCase());
411
+ .replace(/-/gu, ' ')
412
+ .replace(/^./u, (match) => match.toUpperCase());
407
413
  }
408
414
 
409
415
  /** @private */
410
416
  _reorderStatusChanged(reorderStatus) {
411
- this._allCells.forEach((cell) => cell.setAttribute('reorder-status', reorderStatus));
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._updateFrozenColumn) {
494
- this._grid._updateFrozenColumn();
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.__updateHeaderFooterRowVisibility(headerCell.parentElement);
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.__updateHeaderFooterRowVisibility(footerCell.parentElement);
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 - 2022 Vaadin Ltd.
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';