@vaadin/grid 23.2.0-dev.8a7678b70 → 23.3.0-alpha1

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 (42) hide show
  1. package/README.md +4 -4
  2. package/package.json +17 -11
  3. package/src/array-data-provider.js +3 -5
  4. package/src/lit/column-renderer-directives.d.ts +7 -6
  5. package/src/lit/renderer-directives.d.ts +3 -3
  6. package/src/vaadin-grid-active-item-mixin.d.ts +2 -2
  7. package/src/vaadin-grid-array-data-provider-mixin.d.ts +2 -2
  8. package/src/vaadin-grid-column-group.d.ts +2 -2
  9. package/src/vaadin-grid-column-group.js +22 -7
  10. package/src/vaadin-grid-column-reordering-mixin.d.ts +2 -2
  11. package/src/vaadin-grid-column-reordering-mixin.js +39 -20
  12. package/src/vaadin-grid-column-resizing-mixin.js +1 -1
  13. package/src/vaadin-grid-column.d.ts +4 -4
  14. package/src/vaadin-grid-column.js +9 -3
  15. package/src/vaadin-grid-data-provider-mixin.d.ts +2 -2
  16. package/src/vaadin-grid-drag-and-drop-mixin.d.ts +5 -5
  17. package/src/vaadin-grid-drag-and-drop-mixin.js +4 -2
  18. package/src/vaadin-grid-event-context-mixin.d.ts +4 -4
  19. package/src/vaadin-grid-event-context-mixin.js +2 -2
  20. package/src/vaadin-grid-filter-column.d.ts +1 -1
  21. package/src/vaadin-grid-filter.d.ts +2 -2
  22. package/src/vaadin-grid-keyboard-navigation-mixin.js +20 -6
  23. package/src/vaadin-grid-row-details-mixin.d.ts +3 -3
  24. package/src/vaadin-grid-scroll-mixin.d.ts +2 -2
  25. package/src/vaadin-grid-scroll-mixin.js +3 -1
  26. package/src/vaadin-grid-selection-column.d.ts +3 -3
  27. package/src/vaadin-grid-selection-column.js +10 -3
  28. package/src/vaadin-grid-selection-mixin.d.ts +2 -2
  29. package/src/vaadin-grid-sort-column.d.ts +4 -4
  30. package/src/vaadin-grid-sort-mixin.d.ts +25 -2
  31. package/src/vaadin-grid-sort-mixin.js +60 -5
  32. package/src/vaadin-grid-sorter.d.ts +2 -2
  33. package/src/vaadin-grid-sorter.js +7 -3
  34. package/src/vaadin-grid-styling-mixin.d.ts +4 -4
  35. package/src/vaadin-grid-tree-column.d.ts +1 -1
  36. package/src/vaadin-grid-tree-toggle.d.ts +2 -2
  37. package/src/vaadin-grid-tree-toggle.js +3 -3
  38. package/src/vaadin-grid.d.ts +26 -24
  39. package/src/vaadin-grid.js +55 -8
  40. package/theme/lumo/vaadin-grid-styles.js +0 -10
  41. package/web-types.json +2176 -0
  42. package/web-types.lit.json +972 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A web component for showing tabular data.
4
4
 
5
- [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/grid)
5
+ [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/components/grid)
6
6
 
7
7
  [![npm version](https://badgen.net/npm/v/@vaadin/grid)](https://www.npmjs.com/package/@vaadin/grid)
8
8
  [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
@@ -29,7 +29,7 @@ A web component for showing tabular data.
29
29
  </script>
30
30
  ```
31
31
 
32
- [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/grid/screenshot.png" alt="Screenshot of vaadin-grid">](https://vaadin.com/docs/latest/ds/components/grid)
32
+ [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/grid/screenshot.png" alt="Screenshot of vaadin-grid">](https://vaadin.com/docs/latest/components/grid)
33
33
 
34
34
  ## Installation
35
35
 
@@ -52,7 +52,7 @@ import '@vaadin/grid/vaadin-grid-tree-column.js';
52
52
 
53
53
  ## Themes
54
54
 
55
- Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
55
+ Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
56
56
  The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/grid/vaadin-grid.js) of the package uses the Lumo theme.
57
57
 
58
58
  To use the Material theme, import the components from the `theme/material` folder:
@@ -88,7 +88,7 @@ import '@vaadin/grid/src/vaadin-grid-tree-column.js';
88
88
 
89
89
  ## Contributing
90
90
 
91
- Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
91
+ Read the [contributing guide](https://vaadin.com/docs/latest/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
92
92
 
93
93
  ## License
94
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/grid",
3
- "version": "23.2.0-dev.8a7678b70",
3
+ "version": "23.3.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -26,7 +26,9 @@
26
26
  "src",
27
27
  "theme",
28
28
  "vaadin-*.d.ts",
29
- "vaadin-*.js"
29
+ "vaadin-*.js",
30
+ "web-types.json",
31
+ "web-types.lit.json"
30
32
  ],
31
33
  "keywords": [
32
34
  "vaadin",
@@ -43,20 +45,24 @@
43
45
  "dependencies": {
44
46
  "@open-wc/dedupe-mixin": "^1.3.0",
45
47
  "@polymer/polymer": "^3.0.0",
46
- "@vaadin/checkbox": "23.2.0-dev.8a7678b70",
47
- "@vaadin/component-base": "23.2.0-dev.8a7678b70",
48
- "@vaadin/lit-renderer": "23.2.0-dev.8a7678b70",
49
- "@vaadin/text-field": "23.2.0-dev.8a7678b70",
50
- "@vaadin/vaadin-lumo-styles": "23.2.0-dev.8a7678b70",
51
- "@vaadin/vaadin-material-styles": "23.2.0-dev.8a7678b70",
52
- "@vaadin/vaadin-themable-mixin": "23.2.0-dev.8a7678b70"
48
+ "@vaadin/checkbox": "23.3.0-alpha1",
49
+ "@vaadin/component-base": "23.3.0-alpha1",
50
+ "@vaadin/lit-renderer": "23.3.0-alpha1",
51
+ "@vaadin/text-field": "23.3.0-alpha1",
52
+ "@vaadin/vaadin-lumo-styles": "23.3.0-alpha1",
53
+ "@vaadin/vaadin-material-styles": "23.3.0-alpha1",
54
+ "@vaadin/vaadin-themable-mixin": "23.3.0-alpha1"
53
55
  },
54
56
  "devDependencies": {
55
57
  "@esm-bundle/chai": "^4.3.4",
56
- "@vaadin/polymer-legacy-adapter": "23.2.0-dev.8a7678b70",
58
+ "@vaadin/polymer-legacy-adapter": "23.3.0-alpha1",
57
59
  "@vaadin/testing-helpers": "^0.3.2",
58
60
  "lit": "^2.0.0",
59
61
  "sinon": "^13.0.2"
60
62
  },
61
- "gitHead": "85b403f96d8282f262322b56c0ff4289f843d02a"
63
+ "web-types": [
64
+ "web-types.json",
65
+ "web-types.lit.json"
66
+ ],
67
+ "gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
62
68
  }
@@ -22,12 +22,10 @@ function checkPaths(arrayToCheck, action, items) {
22
22
 
23
23
  let result = true;
24
24
 
25
- for (const i in arrayToCheck) {
26
- const path = arrayToCheck[i].path;
27
-
25
+ arrayToCheck.forEach(({ path }) => {
28
26
  // Skip simple paths
29
27
  if (!path || path.indexOf('.') === -1) {
30
- continue;
28
+ return;
31
29
  }
32
30
 
33
31
  const parentProperty = path.replace(/\.[^.]*$/, ''); // A.b.c -> a.b
@@ -35,7 +33,7 @@ function checkPaths(arrayToCheck, action, items) {
35
33
  console.warn(`Path "${path}" used for ${action} does not exist in all of the items, ${action} is disabled.`);
36
34
  result = false;
37
35
  }
38
- }
36
+ });
39
37
 
40
38
  return result;
41
39
  }
@@ -4,11 +4,12 @@
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 */
7
- import { TemplateResult } from 'lit';
8
- import { DirectiveResult } from 'lit/directive';
9
- import { LitRenderer, LitRendererDirective } from '@vaadin/lit-renderer';
10
- import { GridItemModel } from '../vaadin-grid.js';
11
- import { GridColumn } from '../vaadin-grid-column.js';
7
+ import type { TemplateResult } from 'lit';
8
+ import type { DirectiveResult } from 'lit/directive';
9
+ import type { LitRenderer } from '@vaadin/lit-renderer';
10
+ import { LitRendererDirective } from '@vaadin/lit-renderer';
11
+ import type { GridItemModel } from '../vaadin-grid.js';
12
+ import type { GridColumn } from '../vaadin-grid-column.js';
12
13
 
13
14
  export type GridColumnBodyLitRenderer<TItem> = (
14
15
  item: TItem,
@@ -26,7 +27,7 @@ declare abstract class AbstractGridColumnRendererDirective<R extends LitRenderer
26
27
  /**
27
28
  * A property to that the renderer callback will be assigned.
28
29
  */
29
- abstract rendererProperty: 'renderer' | 'headerRenderer' | 'footerRenderer';
30
+ abstract rendererProperty: 'footerRenderer' | 'headerRenderer' | 'renderer';
30
31
 
31
32
  /**
32
33
  * Adds the renderer callback to the grid column.
@@ -3,10 +3,10 @@
3
3
  * Copyright (c) 2017 - 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 { TemplateResult } from 'lit';
7
- import { DirectiveResult } from 'lit/directive';
6
+ import type { TemplateResult } from 'lit';
7
+ import type { DirectiveResult } from 'lit/directive';
8
8
  import { LitRendererDirective } from '@vaadin/lit-renderer';
9
- import { Grid, GridItemModel } from '../vaadin-grid.js';
9
+ import type { Grid, GridItemModel } from '../vaadin-grid.js';
10
10
 
11
11
  export type GridRowDetailsLitRenderer<TItem> = (item: TItem, model: GridItemModel<TItem>, grid: Grid) => TemplateResult;
12
12
 
@@ -3,11 +3,11 @@
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 { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ActiveItemMixin<TItem, T extends Constructor<HTMLElement>>(
9
9
  base: T,
10
- ): T & Constructor<ActiveItemMixinClass<TItem>>;
10
+ ): Constructor<ActiveItemMixinClass<TItem>> & T;
11
11
 
12
12
  export declare class ActiveItemMixinClass<TItem> {
13
13
  /**
@@ -3,11 +3,11 @@
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 { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ArrayDataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
9
9
  base: T,
10
- ): T & Constructor<ArrayDataProviderMixinClass<TItem>>;
10
+ ): Constructor<ArrayDataProviderMixinClass<TItem>> & T;
11
11
 
12
12
  export declare class ArrayDataProviderMixinClass<TItem> {
13
13
  /**
@@ -3,8 +3,8 @@
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 { GridDefaultItem } from './vaadin-grid.js';
7
- import { ColumnBaseMixinClass } from './vaadin-grid-column.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
+ import type { ColumnBaseMixinClass } from './vaadin-grid-column.js';
8
8
 
9
9
  /**
10
10
  * A `<vaadin-grid-column-group>` is used to make groups of columns in `<vaadin-grid>` and
@@ -156,7 +156,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
156
156
  const _rootColumns = rootColumns.slice(0);
157
157
 
158
158
  if (!order) {
159
- _rootColumns.forEach((column) => (column._order = 0));
159
+ _rootColumns.forEach((column) => {
160
+ column._order = 0;
161
+ });
160
162
  return;
161
163
  }
162
164
  // The parent column order number cascades downwards to it's children
@@ -190,7 +192,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
190
192
  return;
191
193
  }
192
194
 
193
- rootColumns.forEach((column) => (column._reorderStatus = reorderStatus));
195
+ rootColumns.forEach((column) => {
196
+ column._reorderStatus = reorderStatus;
197
+ });
194
198
  }
195
199
 
196
200
  /** @private */
@@ -199,7 +203,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
199
203
  return;
200
204
  }
201
205
 
202
- rootColumns.forEach((column) => (column.resizable = resizable));
206
+ rootColumns.forEach((column) => {
207
+ column.resizable = resizable;
208
+ });
203
209
  }
204
210
 
205
211
  /** @private */
@@ -217,7 +223,10 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
217
223
 
218
224
  if (this._visibleChildColumns.length > 0) {
219
225
  const width = this._visibleChildColumns
220
- .reduce((prev, curr) => (prev += ` + ${(curr.width || '0px').replace('calc', '')}`), '')
226
+ .reduce((prev, curr) => {
227
+ prev += ` + ${(curr.width || '0px').replace('calc', '')}`;
228
+ return prev;
229
+ }, '')
221
230
  .substring(3);
222
231
  this._setWidth(`calc(${width})`);
223
232
  } else {
@@ -235,7 +244,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
235
244
 
236
245
  // Don’t propagate the default `false` value.
237
246
  if (frozen !== false) {
238
- Array.from(rootColumns).forEach((col) => (col.frozen = frozen));
247
+ Array.from(rootColumns).forEach((col) => {
248
+ col.frozen = frozen;
249
+ });
239
250
  }
240
251
  }
241
252
 
@@ -247,7 +258,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
247
258
 
248
259
  // Don’t propagate the default `false` value.
249
260
  if (frozenToEnd !== false) {
250
- Array.from(rootColumns).forEach((col) => (col.frozenToEnd = frozenToEnd));
261
+ Array.from(rootColumns).forEach((col) => {
262
+ col.frozenToEnd = frozenToEnd;
263
+ });
251
264
  }
252
265
  }
253
266
 
@@ -276,7 +289,9 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
276
289
  /** @private */
277
290
  _synchronizeHidden() {
278
291
  if (this._childColumns && !this._preventHiddenSynchronization) {
279
- this._childColumns.forEach((column) => (column.hidden = this.hidden));
292
+ this._childColumns.forEach((column) => {
293
+ column.hidden = this.hidden;
294
+ });
280
295
  }
281
296
  }
282
297
 
@@ -3,11 +3,11 @@
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 { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  export declare function ColumnReorderingMixin<T extends Constructor<HTMLElement>>(
9
9
  base: T,
10
- ): T & Constructor<ColumnReorderingMixinClass>;
10
+ ): Constructor<ColumnReorderingMixinClass> & T;
11
11
 
12
12
  export declare class ColumnReorderingMixinClass {
13
13
  /**
@@ -32,7 +32,7 @@ export const ColumnReorderingMixin = (superClass) =>
32
32
  }
33
33
 
34
34
  static get observers() {
35
- return ['_updateOrders(_columnTree, _columnTree.*)'];
35
+ return ['_updateOrders(_columnTree)'];
36
36
  }
37
37
 
38
38
  /** @protected */
@@ -120,12 +120,12 @@ export const ColumnReorderingMixin = (superClass) =>
120
120
 
121
121
  // Cancel reordering if there are draggable nodes on the event path
122
122
  const path = e.composedPath && e.composedPath();
123
- if (path && path.filter((node) => node.hasAttribute && node.hasAttribute('draggable'))[0]) {
123
+ if (path && path.some((node) => node.hasAttribute && node.hasAttribute('draggable'))) {
124
124
  return;
125
125
  }
126
126
 
127
127
  const headerCell = this._cellFromPoint(e.detail.x, e.detail.y);
128
- if (!headerCell || headerCell.getAttribute('part').indexOf('header-cell') === -1) {
128
+ if (!headerCell || !headerCell.getAttribute('part').includes('header-cell')) {
129
129
  return;
130
130
  }
131
131
 
@@ -161,7 +161,23 @@ export const ColumnReorderingMixin = (superClass) =>
161
161
  this._isSwapAllowed(this._draggedColumn, targetColumn) &&
162
162
  this._isSwappableByPosition(targetColumn, e.detail.x)
163
163
  ) {
164
- this._swapColumnOrders(this._draggedColumn, targetColumn);
164
+ // Get the header level of the target column (and the dragged column)
165
+ const columnTreeLevel = this._columnTree.findIndex((level) => level.includes(targetColumn));
166
+ // Get the columns on that level in visual order
167
+ const levelColumnsInOrder = this._getColumnsInOrder(columnTreeLevel);
168
+
169
+ // Index of the column being dragged
170
+ const startIndex = levelColumnsInOrder.indexOf(this._draggedColumn);
171
+ // Index of the column being dragged over
172
+ const endIndex = levelColumnsInOrder.indexOf(targetColumn);
173
+
174
+ // Direction of iteration
175
+ const direction = startIndex < endIndex ? 1 : -1;
176
+
177
+ // Iteratively swap all the columns from the dragged column to the target column
178
+ for (let i = startIndex; i !== endIndex; i += direction) {
179
+ this._swapColumnOrders(this._draggedColumn, levelColumnsInOrder[i + direction]);
180
+ }
165
181
  }
166
182
 
167
183
  this._updateGhostPosition(e.detail.x, this._touchDevice ? e.detail.y - 50 : e.detail.y);
@@ -192,15 +208,14 @@ export const ColumnReorderingMixin = (superClass) =>
192
208
  }
193
209
 
194
210
  /**
211
+ * Returns the columns (or column groups) on the specified header level in visual order.
212
+ * By default, the bottom level is used.
213
+ *
195
214
  * @return {!Array<!GridColumn>}
196
215
  * @protected
197
216
  */
198
- _getColumnsInOrder() {
199
- return this._columnTree
200
- .slice(0)
201
- .pop()
202
- .filter((c) => !c.hidden)
203
- .sort((b, a) => b._order - a._order);
217
+ _getColumnsInOrder(headerLevel = this._columnTree.length - 1) {
218
+ return this._columnTree[headerLevel].filter((c) => !c.hidden).sort((b, a) => b._order - a._order);
204
219
  }
205
220
 
206
221
  /**
@@ -263,18 +278,22 @@ export const ColumnReorderingMixin = (superClass) =>
263
278
  'border',
264
279
  'flex-direction',
265
280
  'overflow',
266
- ].forEach((propertyName) => (ghost.style[propertyName] = style[propertyName]));
281
+ ].forEach((propertyName) => {
282
+ ghost.style[propertyName] = style[propertyName];
283
+ });
267
284
  return ghost;
268
285
  }
269
286
 
270
287
  /** @private */
271
- _updateOrders(columnTree, splices) {
272
- if (columnTree === undefined || splices === undefined) {
288
+ _updateOrders(columnTree) {
289
+ if (columnTree === undefined) {
273
290
  return;
274
291
  }
275
292
 
276
293
  // Reset all column orders
277
- columnTree[0].forEach((column) => (column._order = 0));
294
+ columnTree[0].forEach((column) => {
295
+ column._order = 0;
296
+ });
278
297
  // Set order numbers to top-level columns
279
298
  updateColumnOrders(columnTree[0], this._orderBaseScope, 0);
280
299
  }
@@ -287,7 +306,9 @@ export const ColumnReorderingMixin = (superClass) =>
287
306
  _setSiblingsReorderStatus(column, status) {
288
307
  Array.from(column.parentNode.children)
289
308
  .filter((child) => /column/.test(child.localName) && this._isSwapAllowed(child, column))
290
- .forEach((sibling) => (sibling._reorderStatus = status));
309
+ .forEach((sibling) => {
310
+ sibling._reorderStatus = status;
311
+ });
291
312
  }
292
313
 
293
314
  /** @protected */
@@ -333,9 +354,9 @@ export const ColumnReorderingMixin = (superClass) =>
333
354
  * @protected
334
355
  */
335
356
  _isSwappableByPosition(targetColumn, clientX) {
336
- const targetCell = Array.from(this.$.header.querySelectorAll('tr:not([hidden]) [part~="cell"]')).filter((cell) =>
357
+ const targetCell = Array.from(this.$.header.querySelectorAll('tr:not([hidden]) [part~="cell"]')).find((cell) =>
337
358
  targetColumn.contains(cell._column),
338
- )[0];
359
+ );
339
360
  const sourceCellRect = this.$.header
340
361
  .querySelector('tr:not([hidden]) [reorder-status=dragging]')
341
362
  .getBoundingClientRect();
@@ -352,9 +373,7 @@ export const ColumnReorderingMixin = (superClass) =>
352
373
  * @protected
353
374
  */
354
375
  _swapColumnOrders(column1, column2) {
355
- const _order = column1._order;
356
- column1._order = column2._order;
357
- column2._order = _order;
376
+ [column1._order, column2._order] = [column2._order, column1._order];
358
377
  this._updateFrozenColumn();
359
378
  this._updateFirstAndLastColumn();
360
379
  }
@@ -52,7 +52,7 @@ export const ColumnResizingMixin = (superClass) =>
52
52
 
53
53
  const eventX = e.detail.x;
54
54
  const columnRowCells = Array.from(this.$.header.querySelectorAll('[part~="row"]:last-child [part~="cell"]'));
55
- const targetCell = columnRowCells.filter((cell) => cell._column === column)[0];
55
+ const targetCell = columnRowCells.find((cell) => cell._column === column);
56
56
  // Resize the target column
57
57
  if (targetCell.offsetWidth) {
58
58
  const style = getComputedStyle(targetCell._content);
@@ -3,8 +3,8 @@
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 { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridDefaultItem, GridItemModel } from './vaadin-grid.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridDefaultItem, GridItemModel } from './vaadin-grid.js';
8
8
 
9
9
  export type GridBodyRenderer<TItem> = (
10
10
  root: HTMLElement,
@@ -12,13 +12,13 @@ export type GridBodyRenderer<TItem> = (
12
12
  model: GridItemModel<TItem>,
13
13
  ) => void;
14
14
 
15
- export type GridColumnTextAlign = 'start' | 'center' | 'end' | null;
15
+ export type GridColumnTextAlign = 'center' | 'end' | 'start' | null;
16
16
 
17
17
  export type GridHeaderFooterRenderer<TItem> = (root: HTMLElement, column: GridColumn<TItem>) => void;
18
18
 
19
19
  export declare function ColumnBaseMixin<TItem, T extends Constructor<HTMLElement>>(
20
20
  base: T,
21
- ): T & Constructor<ColumnBaseMixinClass<TItem>>;
21
+ ): Constructor<ColumnBaseMixinClass<TItem>> & T;
22
22
 
23
23
  export declare class ColumnBaseMixinClass<TItem> {
24
24
  /**
@@ -312,12 +312,16 @@ export const ColumnBaseMixin = (superClass) =>
312
312
  this.parentElement._columnPropChanged('flexGrow');
313
313
  }
314
314
 
315
- this._allCells.forEach((cell) => (cell.style.flexGrow = flexGrow));
315
+ this._allCells.forEach((cell) => {
316
+ cell.style.flexGrow = flexGrow;
317
+ });
316
318
  }
317
319
 
318
320
  /** @private */
319
321
  _orderChanged(order) {
320
- this._allCells.forEach((cell) => (cell.style.order = order));
322
+ this._allCells.forEach((cell) => {
323
+ cell.style.order = order;
324
+ });
321
325
  }
322
326
 
323
327
  /** @private */
@@ -326,7 +330,9 @@ export const ColumnBaseMixin = (superClass) =>
326
330
  this.parentElement._columnPropChanged('width');
327
331
  }
328
332
 
329
- this._allCells.forEach((cell) => (cell.style.width = width));
333
+ this._allCells.forEach((cell) => {
334
+ cell.style.width = width;
335
+ });
330
336
  }
331
337
 
332
338
  /** @private */
@@ -3,7 +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 { Constructor } from '@open-wc/dedupe-mixin';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import { GridSorterDirection } from './vaadin-grid-sorter.js';
8
8
 
9
9
  export { GridSorterDirection };
@@ -58,7 +58,7 @@ export declare class ItemCache<TItem> {
58
58
 
59
59
  export declare function DataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
60
60
  base: T,
61
- ): T & Constructor<DataProviderMixinClass<TItem>>;
61
+ ): Constructor<DataProviderMixinClass<TItem>> & T;
62
62
 
63
63
  export declare class DataProviderMixinClass<TItem> {
64
64
  /**
@@ -3,18 +3,18 @@
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 { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridItemModel } from './vaadin-grid.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridItemModel } from './vaadin-grid.js';
8
8
 
9
9
  export type GridDragAndDropFilter<TItem> = (model: GridItemModel<TItem>) => boolean;
10
10
 
11
- export type GridDropLocation = 'above' | 'on-top' | 'below' | 'empty';
11
+ export type GridDropLocation = 'above' | 'below' | 'empty' | 'on-top';
12
12
 
13
- export type GridDropMode = 'between' | 'on-top' | 'on-top-or-between' | 'on-grid';
13
+ export type GridDropMode = 'between' | 'on-grid' | 'on-top-or-between' | 'on-top';
14
14
 
15
15
  export declare function DragAndDropMixin<TItem, T extends Constructor<HTMLElement>>(
16
16
  base: T,
17
- ): T & Constructor<DragAndDropMixinClass<TItem>>;
17
+ ): Constructor<DragAndDropMixinClass<TItem>> & T;
18
18
 
19
19
  export declare class DragAndDropMixinClass<TItem> {
20
20
  /**
@@ -196,7 +196,7 @@ export const DragAndDropMixin = (superClass) =>
196
196
  return;
197
197
  }
198
198
 
199
- let row = e.composedPath().filter((node) => node.localName === 'tr')[0];
199
+ let row = e.composedPath().find((node) => node.localName === 'tr');
200
200
 
201
201
  if (!this._effectiveSize || this.dropMode === DropMode.ON_GRID) {
202
202
  // The grid is empty or "on-grid" drop mode was used, always default to "empty"
@@ -280,7 +280,9 @@ export const DragAndDropMixin = (superClass) =>
280
280
  if (scrollTopChanged) {
281
281
  this.__dndAutoScrolling = true;
282
282
  // Disallow more auto-scrolls within 20ms
283
- setTimeout(() => (this.__dndAutoScrolling = false), 20);
283
+ setTimeout(() => {
284
+ this.__dndAutoScrolling = false;
285
+ }, 20);
284
286
  return true;
285
287
  }
286
288
  }
@@ -3,11 +3,11 @@
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 { Constructor } from '@open-wc/dedupe-mixin';
7
- import { GridColumn } from './vaadin-grid-column.js';
6
+ import type { Constructor } from '@open-wc/dedupe-mixin';
7
+ import type { GridColumn } from './vaadin-grid-column.js';
8
8
 
9
9
  export interface GridEventContext<TItem> {
10
- section?: 'body' | 'header' | 'footer' | 'details';
10
+ section?: 'body' | 'details' | 'footer' | 'header';
11
11
  item?: TItem;
12
12
  column?: GridColumn<TItem>;
13
13
  index?: number;
@@ -19,7 +19,7 @@ export interface GridEventContext<TItem> {
19
19
 
20
20
  export declare function EventContextMixin<TItem, T extends Constructor<HTMLElement>>(
21
21
  base: T,
22
- ): T & Constructor<EventContextMixinClass<TItem>>;
22
+ ): Constructor<EventContextMixinClass<TItem>> & T;
23
23
 
24
24
  export declare class EventContextMixinClass<TItem> {
25
25
  /**
@@ -42,9 +42,9 @@ export const EventContextMixin = (superClass) =>
42
42
  return context;
43
43
  }
44
44
 
45
- context.section = ['body', 'header', 'footer', 'details'].filter(
45
+ context.section = ['body', 'header', 'footer', 'details'].find(
46
46
  (section) => cell.getAttribute('part').indexOf(section) > -1,
47
- )[0];
47
+ );
48
48
 
49
49
  if (cell._column) {
50
50
  context.column = cell._column;
@@ -3,7 +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 { GridDefaultItem } from './vaadin-grid.js';
6
+ import type { GridDefaultItem } from './vaadin-grid.js';
7
7
  import { GridColumn } from './vaadin-grid-column.js';
8
8
 
9
9
  /**
@@ -54,13 +54,13 @@ declare class GridFilter extends HTMLElement {
54
54
  addEventListener<K extends keyof GridFilterEventMap>(
55
55
  type: K,
56
56
  listener: (this: GridFilter, ev: GridFilterEventMap[K]) => void,
57
- options?: boolean | AddEventListenerOptions,
57
+ options?: AddEventListenerOptions | boolean,
58
58
  ): void;
59
59
 
60
60
  removeEventListener<K extends keyof GridFilterEventMap>(
61
61
  type: K,
62
62
  listener: (this: GridFilter, ev: GridFilterEventMap[K]) => void,
63
- options?: boolean | EventListenerOptions,
63
+ options?: EventListenerOptions | boolean,
64
64
  ): void;
65
65
  }
66
66