@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
@@ -8,9 +8,11 @@ import './vaadin-grid-styles.js';
8
8
  import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
9
9
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
10
10
  import { isAndroid, isChrome, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
11
+ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
11
12
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
13
  import { TabindexMixin } from '@vaadin/component-base/src/tabindex-mixin.js';
13
14
  import { processTemplates } from '@vaadin/component-base/src/templates.js';
15
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
14
16
  import { Virtualizer } from '@vaadin/component-base/src/virtualizer.js';
15
17
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
16
18
  import { A11yMixin } from './vaadin-grid-a11y-mixin.js';
@@ -191,7 +193,7 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
191
193
  * `overflow` | Set when rows are overflowing the grid viewport. Possible values: `top`, `bottom`, `start`, `end` | :host
192
194
  * `reordering` | Set when the grid's columns are being reordered | :host
193
195
  * `dragover` | Set when the grid (not a specific row) is dragged over | :host
194
- * `dragging-rows` : Set when grid rows are dragged | :host
196
+ * `dragging-rows` | Set when grid rows are dragged | :host
195
197
  * `reorder-status` | Reflects the status of a cell while columns are being reordered | cell
196
198
  * `frozen` | Frozen cell | cell
197
199
  * `last-frozen` | Last frozen cell | cell
@@ -209,7 +211,7 @@ import { StylingMixin } from './vaadin-grid-styling-mixin.js';
209
211
  * `drag-disabled` | Set to a row that isn't available for dragging | row
210
212
  * `drop-disabled` | Set to a row that can't be dropped on top of | row
211
213
  *
212
- * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
214
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
213
215
  *
214
216
  * @fires {CustomEvent} active-item-changed - Fired when the `activeItem` property changes.
215
217
  * @fires {CustomEvent} cell-activate - Fired when the cell is activated with click or keyboard.
@@ -258,7 +260,9 @@ class Grid extends ElementMixin(
258
260
  FilterMixin(
259
261
  ColumnReorderingMixin(
260
262
  ColumnResizingMixin(
261
- EventContextMixin(DragAndDropMixin(StylingMixin(TabindexMixin(PolymerElement)))),
263
+ ControllerMixin(
264
+ EventContextMixin(DragAndDropMixin(StylingMixin(TabindexMixin(PolymerElement)))),
265
+ ),
262
266
  ),
263
267
  ),
264
268
  ),
@@ -293,6 +297,8 @@ class Grid extends ElementMixin(
293
297
  <div part="reorder-ghost"></div>
294
298
  </div>
295
299
 
300
+ <slot name="tooltip"></slot>
301
+
296
302
  <div id="focusexit" tabindex="0"></div>
297
303
  `;
298
304
  }
@@ -394,6 +400,7 @@ class Grid extends ElementMixin(
394
400
  disconnectedCallback() {
395
401
  super.disconnectedCallback();
396
402
  this.isAttached = false;
403
+ this._hideTooltip();
397
404
  }
398
405
 
399
406
  /** @private */
@@ -453,6 +460,10 @@ class Grid extends ElementMixin(
453
460
  new ResizeObserver(() => setTimeout(() => this.__updateFooterPositioning())).observe(this.$.footer);
454
461
 
455
462
  processTemplates(this);
463
+
464
+ this._tooltipController = new TooltipController(this);
465
+ this.addController(this._tooltipController);
466
+ this._tooltipController.setManual(true);
456
467
  }
457
468
 
458
469
  /**
@@ -594,6 +605,11 @@ class Grid extends ElementMixin(
594
605
  // Flush to make sure DOM is up-to-date when measuring the column widths
595
606
  this.__virtualizer.flush();
596
607
 
608
+ // Flush to account for any changes to the visibility of the columns
609
+ if (this._debouncerHiddenChanged) {
610
+ this._debouncerHiddenChanged.flush();
611
+ }
612
+
597
613
  cols.forEach((col) => {
598
614
  col.width = `${this.__getDistributedWidth(col)}px`;
599
615
  });
@@ -655,6 +671,15 @@ class Grid extends ElementMixin(
655
671
  cell.id = slotName.replace('-content-', '-');
656
672
  cell.setAttribute('tabindex', '-1');
657
673
  cell.setAttribute('role', tagName === 'td' ? 'gridcell' : 'columnheader');
674
+ cell.addEventListener('mouseenter', (event) => {
675
+ this._showTooltip(event);
676
+ });
677
+ cell.addEventListener('mouseleave', () => {
678
+ this._hideTooltip();
679
+ });
680
+ cell.addEventListener('mousedown', () => {
681
+ this._hideTooltip();
682
+ });
658
683
 
659
684
  const slot = document.createElement('slot');
660
685
  slot.setAttribute('name', slotName);
@@ -708,7 +733,9 @@ class Grid extends ElementMixin(
708
733
 
709
734
  const contentsFragment = document.createDocumentFragment();
710
735
 
711
- Array.from(row.children).forEach((cell) => (cell._vacant = true));
736
+ Array.from(row.children).forEach((cell) => {
737
+ cell._vacant = true;
738
+ });
712
739
  row.innerHTML = '';
713
740
 
714
741
  columns
@@ -719,7 +746,7 @@ class Grid extends ElementMixin(
719
746
  if (section === 'body') {
720
747
  // Body
721
748
  column._cells = column._cells || [];
722
- cell = column._cells.filter((cell) => cell._vacant)[0];
749
+ cell = column._cells.find((cell) => cell._vacant);
723
750
  if (!cell) {
724
751
  cell = this._createCell('td');
725
752
  column._cells.push(cell);
@@ -730,7 +757,7 @@ class Grid extends ElementMixin(
730
757
  if (index === cols.length - 1 && this.rowDetailsRenderer) {
731
758
  // Add details cell as last cell to body rows
732
759
  this._detailsCells = this._detailsCells || [];
733
- const detailsCell = this._detailsCells.filter((cell) => cell._vacant)[0] || this._createCell('td');
760
+ const detailsCell = this._detailsCells.find((cell) => cell._vacant) || this._createCell('td');
734
761
  if (this._detailsCells.indexOf(detailsCell) === -1) {
735
762
  this._detailsCells.push(detailsCell);
736
763
  }
@@ -756,7 +783,7 @@ class Grid extends ElementMixin(
756
783
  column[`_${section}Cell`] = cell;
757
784
  } else {
758
785
  column._emptyCells = column._emptyCells || [];
759
- cell = column._emptyCells.filter((cell) => cell._vacant)[0] || this._createCell(tagName);
786
+ cell = column._emptyCells.find((cell) => cell._vacant) || this._createCell(tagName);
760
787
  cell._column = column;
761
788
  row.appendChild(cell);
762
789
  if (column._emptyCells.indexOf(cell) === -1) {
@@ -977,6 +1004,24 @@ class Grid extends ElementMixin(
977
1004
  };
978
1005
  }
979
1006
 
1007
+ /**
1008
+ * @param {Event} event
1009
+ * @protected
1010
+ */
1011
+ _showTooltip(event) {
1012
+ // Check if there is a slotted vaadin-tooltip element.
1013
+ if (this._tooltipController.node && this._tooltipController.node.isConnected) {
1014
+ this._tooltipController.setTarget(event.target);
1015
+ this._tooltipController.setContext(this.getEventContext(event));
1016
+ this._tooltipController.setOpened(true);
1017
+ }
1018
+ }
1019
+
1020
+ /** @protected */
1021
+ _hideTooltip() {
1022
+ this._tooltipController.setOpened(false);
1023
+ }
1024
+
980
1025
  /**
981
1026
  * Requests an update for the content of cells.
982
1027
  *
@@ -993,7 +1038,9 @@ class Grid extends ElementMixin(
993
1038
  // Header and footer renderers
994
1039
  this._columnTree.forEach((level) => {
995
1040
  level.forEach((column) => {
996
- column._renderHeaderAndFooter();
1041
+ if (column._renderHeaderAndFooter) {
1042
+ column._renderHeaderAndFooter();
1043
+ }
997
1044
  });
998
1045
  });
999
1046
 
@@ -395,13 +395,3 @@ registerStyles(
395
395
  `,
396
396
  { moduleId: 'lumo-grid' },
397
397
  );
398
-
399
- registerStyles(
400
- 'vaadin-checkbox',
401
- css`
402
- :host(.vaadin-grid-select-all-checkbox) {
403
- font-size: var(--lumo-font-size-m);
404
- }
405
- `,
406
- { moduleId: 'vaadin-grid-select-all-checkbox-lumo' },
407
- );