@vaadin/grid 25.0.0-alpha3 → 25.0.0-alpha5

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 (35) hide show
  1. package/package.json +13 -11
  2. package/src/array-data-provider.js +6 -0
  3. package/src/lit/column-renderer-directives.d.ts +0 -1
  4. package/src/styles/vaadin-grid-base-styles.d.ts +8 -0
  5. package/src/styles/vaadin-grid-base-styles.js +505 -0
  6. package/src/styles/vaadin-grid-core-styles.d.ts +8 -0
  7. package/src/{vaadin-grid-styles.js → styles/vaadin-grid-core-styles.js} +2 -3
  8. package/src/styles/vaadin-grid-filter-base-styles.d.ts +8 -0
  9. package/src/styles/vaadin-grid-filter-base-styles.js +20 -0
  10. package/src/styles/vaadin-grid-filter-core-styles.d.ts +8 -0
  11. package/src/styles/vaadin-grid-filter-core-styles.js +18 -0
  12. package/src/styles/vaadin-grid-sorter-base-styles.d.ts +8 -0
  13. package/src/styles/vaadin-grid-sorter-base-styles.js +65 -0
  14. package/src/styles/vaadin-grid-sorter-core-styles.d.ts +8 -0
  15. package/src/styles/vaadin-grid-sorter-core-styles.js +61 -0
  16. package/src/styles/vaadin-grid-tree-toggle-base-styles.d.ts +8 -0
  17. package/src/styles/vaadin-grid-tree-toggle-base-styles.js +78 -0
  18. package/src/styles/vaadin-grid-tree-toggle-core-styles.d.ts +8 -0
  19. package/src/styles/vaadin-grid-tree-toggle-core-styles.js +78 -0
  20. package/src/vaadin-grid-data-provider-mixin.js +0 -29
  21. package/src/vaadin-grid-drag-and-drop-mixin.js +3 -0
  22. package/src/vaadin-grid-filter-element-mixin.js +0 -17
  23. package/src/vaadin-grid-filter.js +5 -0
  24. package/src/vaadin-grid-keyboard-navigation-mixin.js +1 -1
  25. package/src/vaadin-grid-mixin.js +5 -17
  26. package/src/vaadin-grid-scroll-mixin.js +52 -21
  27. package/src/vaadin-grid-sorter-mixin.js +0 -60
  28. package/src/vaadin-grid-sorter.js +5 -0
  29. package/src/vaadin-grid-tree-toggle-mixin.js +0 -77
  30. package/src/vaadin-grid-tree-toggle.js +5 -0
  31. package/src/vaadin-grid.d.ts +1 -1
  32. package/src/vaadin-grid.js +2 -2
  33. package/theme/lumo/vaadin-grid-styles.js +1 -1
  34. package/web-types.json +4 -4
  35. package/web-types.lit.json +4 -4
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/component-base/src/style-props.js';
7
+ import { css } from 'lit';
8
+
9
+ export const gridSorterStyles = css`
10
+ @layer base {
11
+ :host {
12
+ display: inline-flex;
13
+ align-items: center;
14
+ cursor: pointer;
15
+ max-width: 100%;
16
+ gap: var(--_vaadin-gap-container-inline);
17
+ -webkit-user-select: none;
18
+ user-select: none;
19
+ -webkit-tap-highlight-color: transparent;
20
+ }
21
+
22
+ [part='content'] {
23
+ flex: 1 1 auto;
24
+ overflow: hidden;
25
+ text-overflow: ellipsis;
26
+ }
27
+
28
+ [part='indicators'] {
29
+ position: relative;
30
+ flex: none;
31
+ }
32
+
33
+ [part='order'] {
34
+ display: inline;
35
+ vertical-align: super;
36
+ font-size: 0.75em;
37
+ line-height: 1;
38
+ }
39
+
40
+ [part='indicators']::before {
41
+ content: '';
42
+ display: inline-block;
43
+ height: 12px;
44
+ width: 8px;
45
+ mask-image: var(--_vaadin-icon-sort);
46
+ background: currentColor;
47
+ }
48
+
49
+ :host([direction]) [part='indicators']::before {
50
+ padding-bottom: 6px;
51
+ height: 6px;
52
+ mask-clip: content-box;
53
+ }
54
+
55
+ :host([direction='desc']) [part='indicators']::before {
56
+ padding-block: 6px 0;
57
+ }
58
+
59
+ @media (forced-colors: active) {
60
+ [part='indicators']::before {
61
+ background: CanvasText;
62
+ }
63
+ }
64
+ }
65
+ `;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const gridSorterStyles: CSSResult;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from 'lit';
7
+
8
+ const template = document.createElement('template');
9
+
10
+ template.innerHTML = `
11
+ <style>
12
+ @font-face {
13
+ font-family: 'vaadin-grid-sorter-icons';
14
+ src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAQwAA0AAAAABuwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAEFAAAABkAAAAcfep+mUdERUYAAAP4AAAAHAAAAB4AJwAOT1MvMgAAAZgAAAA/AAAAYA8TBPpjbWFwAAAB7AAAAFUAAAFeF1fZ4mdhc3AAAAPwAAAACAAAAAgAAAAQZ2x5ZgAAAlgAAABcAAAAnMvguMloZWFkAAABMAAAAC8AAAA2C5Ap72hoZWEAAAFgAAAAHQAAACQGbQPHaG10eAAAAdgAAAAUAAAAHAoAAABsb2NhAAACRAAAABIAAAASAIwAYG1heHAAAAGAAAAAFgAAACAACwAKbmFtZQAAArQAAAECAAACZxWCgKhwb3N0AAADuAAAADUAAABZCrApUXicY2BkYGAA4rDECVrx/DZfGbhZGEDgyqNPOxH0/wNMq5kPALkcDEwgUQBWRA0dAHicY2BkYGA+8P8AAwMLAwgwrWZgZEAFbABY4QM8AAAAeJxjYGRgYOAAQiYGEICQSAAAAi8AFgAAeJxjYGY6yziBgZWBgWkm0xkGBoZ+CM34msGYkZMBFTAKoAkwODAwvmRiPvD/AIMDMxCD1CDJKjAwAgBktQsXAHicY2GAAMZQCM0EwqshbAALxAEKeJxjYGBgZoBgGQZGBhCIAPIYwXwWBhsgzcXAwcAEhIwMCi+Z/v/9/x+sSuElA4T9/4k4K1gHFwMMMILMY2QDYmaoABOQYGJABUA7WBiGNwAAJd4NIQAAAAAAAAAACAAIABAAGAAmAEAATgAAeJyNjLENgDAMBP9tIURJwQCMQccSZgk2i5fIYBDAidJjycXr7x5EPwE2wY8si7jmyBNXGo/bNBerxJNrpxhbO3/fEFpx8ZICpV+ghxJ74fAMe+h7Ox14AbrsHB14nK2QQWrDMBRER4mTkhQK3ZRQKOgCNk7oGQqhhEIX2WSlWEI1BAlkJ5CDdNsj5Ey9Rncdi38ES+jzNJo/HwTgATcoDEthhY3wBHc4CE+pfwsX5F/hGe7Vo/AcK/UhvMSz+mGXKhZU6pww8ISz3oWn1BvhgnwTnuEJf8Jz1OpFeIlX9YULDLdFi4ASHolkSR0iuYdjLak1vAequBhj21D61Nqyi6l3qWybGPjySbPHGScGJl6dP58MYcQRI0bts7mjebBqrFENH7t3qWtj0OuqHnXcW7b0HOTZFnKryRGW2hFX1m0O2vEM3opNMfTau+CS6Z3Vx6veNnEXY6jwDxhsc2gAAHicY2BiwA84GBgYmRiYGJkZmBlZGFkZ2djScyoLMgzZS/MyDQwMwLSrpYEBlIbxjQDrzgsuAAAAAAEAAf//AA94nGNgZGBg4AFiMSBmYmAEQnYgZgHzGAAD6wA2eJxjYGBgZACCKyoz1cD0o087YTQATOcIewAAAA==) format('woff');
15
+ font-weight: normal;
16
+ font-style: normal;
17
+ }
18
+ </style>
19
+ `;
20
+
21
+ document.head.appendChild(template.content);
22
+
23
+ export const gridSorterStyles = css`
24
+ :host {
25
+ display: inline-flex;
26
+ cursor: pointer;
27
+ max-width: 100%;
28
+ }
29
+
30
+ [part='content'] {
31
+ flex: 1 1 auto;
32
+ }
33
+
34
+ [part='indicators'] {
35
+ position: relative;
36
+ align-self: center;
37
+ flex: none;
38
+ }
39
+
40
+ [part='order'] {
41
+ display: inline;
42
+ vertical-align: super;
43
+ }
44
+
45
+ [part='indicators']::before {
46
+ font-family: 'vaadin-grid-sorter-icons';
47
+ display: inline-block;
48
+ }
49
+
50
+ :host(:not([direction])) [part='indicators']::before {
51
+ content: '\\e901';
52
+ }
53
+
54
+ :host([direction='asc']) [part='indicators']::before {
55
+ content: '\\e900';
56
+ }
57
+
58
+ :host([direction='desc']) [part='indicators']::before {
59
+ content: '\\e902';
60
+ }
61
+ `;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const gridTreeToggleStyles: CSSResult;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/component-base/src/style-props.js';
7
+ import { css } from 'lit';
8
+
9
+ export const gridTreeToggleStyles = css`
10
+ @layer base {
11
+ :host {
12
+ display: flex;
13
+ max-width: 100%;
14
+ pointer-events: none;
15
+ }
16
+
17
+ /* Don't expand/collapse when clicking #level-spacer */
18
+ [part] {
19
+ pointer-events: auto;
20
+ }
21
+
22
+ :host([hidden]) {
23
+ display: none !important;
24
+ }
25
+
26
+ :host(:not([leaf])) {
27
+ cursor: var(--vaadin-clickable-cursor);
28
+ }
29
+
30
+ #level-spacer,
31
+ [part='toggle'] {
32
+ flex: none;
33
+ }
34
+
35
+ #level-spacer {
36
+ width: calc(var(--_level, 0) * var(--vaadin-grid-tree-toggle-level-offset, 1em));
37
+ }
38
+
39
+ [part='toggle'] {
40
+ margin-inline-end: var(--_vaadin-gap-container-inline);
41
+ }
42
+
43
+ [part='toggle']::before {
44
+ content: '';
45
+ display: block;
46
+ width: var(--vaadin-icon-size, 1lh);
47
+ height: var(--vaadin-icon-size, 1lh);
48
+ background: currentColor;
49
+ mask-image: var(--_vaadin-icon-chevron-down);
50
+ }
51
+
52
+ :host(:not([expanded])) [part='toggle']::before {
53
+ rotate: -90deg;
54
+ }
55
+
56
+ @media (prefers-reduced-motion: no-preference) {
57
+ [part='toggle']::before {
58
+ transition: rotate 120ms;
59
+ }
60
+ }
61
+
62
+ :host([leaf]) [part='toggle'] {
63
+ visibility: hidden;
64
+ }
65
+
66
+ slot {
67
+ display: block;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
70
+ }
71
+
72
+ @media (forced-colors: active) {
73
+ [part='toggle']::before {
74
+ background: CanvasText;
75
+ }
76
+ }
77
+ }
78
+ `;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const gridTreeToggleStyles: CSSResult;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from 'lit';
7
+
8
+ const template = document.createElement('template');
9
+
10
+ template.innerHTML = `
11
+ <style>
12
+ @font-face {
13
+ font-family: "vaadin-grid-tree-icons";
14
+ src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAQkAA0AAAAABrwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAECAAAABoAAAAcgHwa6EdERUYAAAPsAAAAHAAAAB4AJwAOT1MvMgAAAZQAAAA/AAAAYA8TBIJjbWFwAAAB8AAAAFUAAAFeGJvXWmdhc3AAAAPkAAAACAAAAAgAAAAQZ2x5ZgAAAlwAAABLAAAAhIrPOhFoZWFkAAABMAAAACsAAAA2DsJI02hoZWEAAAFcAAAAHQAAACQHAgPHaG10eAAAAdQAAAAZAAAAHAxVAgBsb2NhAAACSAAAABIAAAASAIAAVG1heHAAAAF8AAAAGAAAACAACgAFbmFtZQAAAqgAAAECAAACTwflzbdwb3N0AAADrAAAADYAAABZQ7Ajh3icY2BkYGAA4twv3Vfi+W2+MnCzMIDANSOmbGSa2YEZRHEwMIEoAAoiB6sAeJxjYGRgYD7w/wADAwsDCDA7MDAyoAI2AFEEAtIAAAB4nGNgZGBg4GBgZgDRDAxMDGgAAAGbABB4nGNgZp7JOIGBlYGBaSbTGQYGhn4IzfiawZiRkwEVMAqgCTA4MDA+38d84P8BBgdmIAapQZJVYGAEAGc/C54AeJxjYYAAxlAIzQTELAwMBxgZGB0ACy0BYwAAAHicY2BgYGaAYBkGRgYQiADyGMF8FgYbIM3FwMHABISMDArP9/3/+/8/WJXC8z0Q9v8nEp5gHVwMMMAIMo+RDYiZoQJMQIKJARUA7WBhGN4AACFKDtoAAAAAAAAAAAgACAAQABgAJgA0AEIAAHichYvBEYBADAKBVHBjBT4swl9KS2k05o0XHd/yW1hAfBFwCv9sIlJu3nZaNS3PXAaXXHI8Lge7DlzF7C1RgXc7xkK6+gvcD2URmQB4nK2RQWoCMRiFX3RUqtCli65yADModOMBLLgQSqHddRFnQghIAnEUvEA3vUUP0LP0Fj1G+yb8R5iEhO9/ef/7FwFwj28o9EthiVp4hBlehcfUP4Ur8o/wBAv8CU+xVFvhOR7UB7tUdUdlVRJ6HnHWTnhM/V24In8JT5j/KzzFSi2E53hUz7jCcrcIiDDwyKSW1JEct2HdIPH1DFytbUM0PofWdNk5E5oUqb/Q6HHBiVGZpfOXkyUMEj5IyBuNmYZQjBobfsuassvnkKLe1OuBBj0VQ8cRni2xjLWsHaM0jrjx3peYA0/vrdmUYqe9iy7bzrX6eNP7Jh1SijX+AaUVbB8AAHicY2BiwA84GBgYmRiYGJkZmBlZGFkZ2djScyoLMgzZS/MyDQwMwLSruZMzlHaB0q4A76kLlwAAAAEAAf//AA94nGNgZGBg4AFiMSBmYmAEQnYgZgHzGAAD6wA2eJxjYGBgZACCKxJigiD6mhFTNowGACmcA/8AAA==) format('woff');
15
+ font-weight: normal;
16
+ font-style: normal;
17
+ }
18
+ </style>
19
+ `;
20
+
21
+ document.head.appendChild(template.content);
22
+
23
+ export const gridTreeToggleStyles = css`
24
+ :host {
25
+ display: inline-flex;
26
+ align-items: baseline;
27
+ max-width: 100%;
28
+
29
+ /* CSS API for :host */
30
+ --vaadin-grid-tree-toggle-level-offset: 1em;
31
+ --_collapsed-icon: '\\e7be\\00a0';
32
+ }
33
+
34
+ :host([dir='rtl']) {
35
+ --_collapsed-icon: '\\e7bd\\00a0';
36
+ }
37
+
38
+ :host([hidden]) {
39
+ display: none !important;
40
+ }
41
+
42
+ :host(:not([leaf])) {
43
+ cursor: pointer;
44
+ }
45
+
46
+ #level-spacer,
47
+ [part='toggle'] {
48
+ flex: none;
49
+ }
50
+
51
+ #level-spacer {
52
+ display: inline-block;
53
+ width: calc(var(--_level, '0') * var(--vaadin-grid-tree-toggle-level-offset));
54
+ }
55
+
56
+ [part='toggle']::before {
57
+ font-family: 'vaadin-grid-tree-icons';
58
+ line-height: 1em; /* make icon font metrics not affect baseline */
59
+ }
60
+
61
+ :host(:not([expanded])) [part='toggle']::before {
62
+ content: var(--_collapsed-icon);
63
+ }
64
+
65
+ :host([expanded]) [part='toggle']::before {
66
+ content: '\\e7bc\\00a0'; /* icon glyph + single non-breaking space */
67
+ }
68
+
69
+ :host([leaf]) [part='toggle'] {
70
+ visibility: hidden;
71
+ }
72
+
73
+ slot {
74
+ display: block;
75
+ overflow: hidden;
76
+ text-overflow: ellipsis;
77
+ }
78
+ `;
@@ -166,24 +166,6 @@ export const DataProviderMixin = (superClass) =>
166
166
  this._dataProviderController.addEventListener('page-loaded', this._onDataProviderPageLoaded.bind(this));
167
167
  }
168
168
 
169
- /**
170
- * @protected
171
- * @deprecated since 24.3 and will be removed in Vaadin 25.
172
- */
173
- get _cache() {
174
- console.warn('<vaadin-grid> The `_cache` property is deprecated and will be removed in Vaadin 25.');
175
- return this._dataProviderController.rootCache;
176
- }
177
-
178
- /**
179
- * @protected
180
- * @deprecated since 24.3 and will be removed in Vaadin 25.
181
- */
182
- get _effectiveSize() {
183
- console.warn('<vaadin-grid> The `_effectiveSize` property is deprecated and will be removed in Vaadin 25.');
184
- return this._flatSize;
185
- }
186
-
187
169
  /** @private */
188
170
  _sizeChanged(size) {
189
171
  this._dataProviderController.rootCache.size = size;
@@ -309,17 +291,6 @@ export const DataProviderMixin = (superClass) =>
309
291
  return level;
310
292
  }
311
293
 
312
- /**
313
- * @param {number} page
314
- * @param {ItemCache} cache
315
- * @protected
316
- * @deprecated since 24.3 and will be removed in Vaadin 25.
317
- */
318
- _loadPage(page, cache) {
319
- console.warn('<vaadin-grid> The `_loadPage` method is deprecated and will be removed in Vaadin 25.');
320
- this._dataProviderController.__loadCachePage(cache, page);
321
- }
322
-
323
294
  /** @protected */
324
295
  _onDataProviderPageRequested() {
325
296
  this._setLoading(true);
@@ -247,6 +247,9 @@ export const DragAndDropMixin = (superClass) =>
247
247
 
248
248
  let row = e.composedPath().find((node) => node.localName === 'tr');
249
249
 
250
+ // Update the horizontal scroll position property of the row being dragged over
251
+ this.__updateRowScrollPositionProperty(row);
252
+
250
253
  if (!this._flatSize || this.dropMode === DropMode.ON_GRID) {
251
254
  // The grid is empty or "on-grid" drop mode was used, always default to "empty"
252
255
  this._dropLocation = DropLocation.EMPTY;
@@ -6,23 +6,6 @@
6
6
  import { timeOut } from '@vaadin/component-base/src/async.js';
7
7
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
8
8
  import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
9
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin';
10
-
11
- registerStyles(
12
- 'vaadin-grid-filter',
13
- css`
14
- :host {
15
- display: inline-flex;
16
- max-width: 100%;
17
- }
18
-
19
- ::slotted(*) {
20
- width: 100%;
21
- box-sizing: border-box;
22
- }
23
- `,
24
- { moduleId: 'vaadin-grid-filter-styles' },
25
- );
26
9
 
27
10
  /**
28
11
  * @polymerMixin
@@ -8,6 +8,7 @@ import { html, LitElement } from 'lit';
8
8
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
11
+ import { gridFilterStyles } from './styles/vaadin-grid-filter-core-styles.js';
11
12
  import { GridFilterElementMixin } from './vaadin-grid-filter-element-mixin.js';
12
13
 
13
14
  /**
@@ -44,6 +45,10 @@ class GridFilter extends GridFilterElementMixin(ThemableMixin(PolylitMixin(LitEl
44
45
  return 'vaadin-grid-filter';
45
46
  }
46
47
 
48
+ static get styles() {
49
+ return gridFilterStyles;
50
+ }
51
+
47
52
  /** @protected */
48
53
  render() {
49
54
  return html`<slot></slot>`;
@@ -280,7 +280,7 @@ export const KeyboardNavigationMixin = (superClass) =>
280
280
  if (!targetRowInDom) {
281
281
  this._scrollToFlatIndex(index);
282
282
  } else {
283
- this.__scrollIntoViewport(index);
283
+ this.__scrollIntoViewport(targetRowInDom);
284
284
  }
285
285
  }
286
286
 
@@ -5,15 +5,7 @@
5
5
  */
6
6
  import { TabindexMixin } from '@vaadin/a11y-base/src/tabindex-mixin.js';
7
7
  import { animationFrame, microTask } from '@vaadin/component-base/src/async.js';
8
- import {
9
- isAndroid,
10
- isChrome,
11
- isFirefox,
12
- isIOS,
13
- isSafari,
14
- isTouch,
15
- supportsAdoptingStyleSheets,
16
- } from '@vaadin/component-base/src/browser-utils.js';
8
+ import { isAndroid, isChrome, isFirefox, isIOS, isSafari, isTouch } from '@vaadin/component-base/src/browser-utils.js';
17
9
  import { Debouncer } from '@vaadin/component-base/src/debounce.js';
18
10
  import { getClosestElement } from '@vaadin/component-base/src/dom-utils.js';
19
11
  import { SlotObserver } from '@vaadin/component-base/src/slot-observer.js';
@@ -929,15 +921,11 @@ export const GridMixin = (superClass) =>
929
921
 
930
922
  // The style is set to host instead of the scroller so that the value can be overridden by the user with "grid { min-height: 0 }"
931
923
  // Prefer setting style in adopted style sheet to avoid the need to add a confusing inline style on the host element
932
- // If adopted style sheets are not supported, the style is set inline
933
- if (!this.__minHeightStyleSheet && supportsAdoptingStyleSheets) {
924
+ if (!this.__minHeightStyleSheet) {
934
925
  this.__minHeightStyleSheet = new CSSStyleSheet();
935
- this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.__minHeightStyleSheet];
936
- }
937
- if (this.__minHeightStyleSheet) {
938
- this.__minHeightStyleSheet.replaceSync(`:host { --_grid-min-height: ${minHeight}px; }`);
939
- } else {
940
- this.style.setProperty('--_grid-min-height', `${minHeight}px`);
926
+ this.shadowRoot.adoptedStyleSheets.push(this.__minHeightStyleSheet);
941
927
  }
928
+
929
+ this.__minHeightStyleSheet.replaceSync(`:host { --_grid-min-height: ${minHeight}px; }`);
942
930
  }
943
931
  };
@@ -122,10 +122,23 @@ export const ScrollMixin = (superClass) =>
122
122
  const row = composedPath[composedPath.indexOf(this.$.items) - 1];
123
123
 
124
124
  if (row) {
125
- // Make sure the row with the focused element is fully inside the visible viewport
126
- // Don't change scroll position if the user is interacting with the mouse
125
+ // Don't change scroll position if the user is interacting with the mouse.
127
126
  if (!this._isMousedown) {
128
- this.__scrollIntoViewport(row.index);
127
+ // Make sure the focused element (row, cell, or focusable element inside a cell)
128
+ // is inside the viewport. If the whole row fits into the viewport, then scroll
129
+ // the row into view. This ensures that labels, helper texts and other related
130
+ // elements of focusable elements within cells also become visible. When the row
131
+ // is larger than the viewport, scroll the focus event target into the viewport.
132
+ // This works better when focusing elements within cells, which could otherwise
133
+ // still be outside the viewport when scrolling to the top or bottom of the row.
134
+ const tableHeight = this.$.table.clientHeight;
135
+ const headerHeight = this.$.header.clientHeight;
136
+ const footerHeight = this.$.footer.clientHeight;
137
+ const viewportHeight = tableHeight - headerHeight - footerHeight;
138
+ const isRowLargerThanViewport = row.clientHeight > viewportHeight;
139
+ const scrollTarget = isRowLargerThanViewport ? e.target : row;
140
+
141
+ this.__scrollIntoViewport(scrollTarget);
129
142
  }
130
143
 
131
144
  if (!this.$.table.contains(e.relatedTarget)) {
@@ -171,25 +184,27 @@ export const ScrollMixin = (superClass) =>
171
184
  _scrollToFlatIndex(index) {
172
185
  index = Math.min(this._flatSize - 1, Math.max(0, index));
173
186
  this.__virtualizer.scrollToIndex(index);
174
- this.__scrollIntoViewport(index);
187
+ const rowElement = [...this.$.items.children].find((child) => child.index === index);
188
+ this.__scrollIntoViewport(rowElement);
175
189
  }
176
190
 
177
191
  /**
178
- * Makes sure the row with the given index (if found in the DOM) is fully
179
- * inside the visible viewport, taking header/footer into account.
192
+ * Makes sure the given element is fully inside the visible viewport,
193
+ * taking header/footer into account.
180
194
  * @private
181
195
  */
182
- __scrollIntoViewport(index) {
183
- const rowElement = [...this.$.items.children].find((child) => child.index === index);
184
- if (rowElement) {
185
- const dstRect = rowElement.getBoundingClientRect();
186
- const footerTop = this.$.footer.getBoundingClientRect().top;
187
- const headerBottom = this.$.header.getBoundingClientRect().bottom;
188
- if (dstRect.bottom > footerTop) {
189
- this.$.table.scrollTop += dstRect.bottom - footerTop;
190
- } else if (dstRect.top < headerBottom) {
191
- this.$.table.scrollTop -= headerBottom - dstRect.top;
192
- }
196
+ __scrollIntoViewport(element) {
197
+ if (!element) {
198
+ return;
199
+ }
200
+
201
+ const dstRect = element.getBoundingClientRect();
202
+ const footerTop = this.$.footer.getBoundingClientRect().top;
203
+ const headerBottom = this.$.header.getBoundingClientRect().bottom;
204
+ if (dstRect.bottom > footerTop) {
205
+ this.$.table.scrollTop += dstRect.bottom - footerTop;
206
+ } else if (dstRect.top < headerBottom) {
207
+ this.$.table.scrollTop -= headerBottom - dstRect.top;
193
208
  }
194
209
  }
195
210
 
@@ -476,6 +491,7 @@ export const ScrollMixin = (superClass) =>
476
491
 
477
492
  // Position frozen cells
478
493
  const x = this.__isRTL ? normalizedScrollLeft + clientWidth - scrollWidth : scrollLeft;
494
+ this.__horizontalScrollPosition = x;
479
495
  const transformFrozen = `translate(${x}px, 0)`;
480
496
  this._frozenCells.forEach((cell) => {
481
497
  cell.style.transform = transformFrozen;
@@ -511,10 +527,25 @@ export const ScrollMixin = (superClass) =>
511
527
  }
512
528
  });
513
529
 
514
- // Only update the --_grid-horizontal-scroll-position custom property when navigating
515
- // on row focus mode to avoid performance issues.
516
- if (this.hasAttribute('navigating') && this.__rowFocusMode) {
517
- this.$.table.style.setProperty('--_grid-horizontal-scroll-position', `${-x}px`);
530
+ const focusedRow = this.shadowRoot.querySelector("[part~='row']:focus");
531
+ if (focusedRow) {
532
+ // Update the horizontal scroll position property of the focused row
533
+ this.__updateRowScrollPositionProperty(focusedRow);
534
+ }
535
+ }
536
+
537
+ /**
538
+ * Synchronizes the internal `--_grid-horizontal-scroll-position` CSS property
539
+ * of the given row with the current horizontal scroll position of the grid.
540
+ * @private
541
+ */
542
+ __updateRowScrollPositionProperty(row) {
543
+ if (row instanceof HTMLTableRowElement === false) {
544
+ return;
545
+ }
546
+ const newValue = `${this.__horizontalScrollPosition}px`;
547
+ if (row.style.getPropertyValue('--_grid-horizontal-scroll-position') !== newValue) {
548
+ row.style.setProperty('--_grid-horizontal-scroll-position', newValue);
518
549
  }
519
550
  }
520
551
 
@@ -3,66 +3,6 @@
3
3
  * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
-
8
- const template = document.createElement('template');
9
-
10
- template.innerHTML = `
11
- <style>
12
- @font-face {
13
- font-family: 'vaadin-grid-sorter-icons';
14
- src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAQwAA0AAAAABuwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAEFAAAABkAAAAcfep+mUdERUYAAAP4AAAAHAAAAB4AJwAOT1MvMgAAAZgAAAA/AAAAYA8TBPpjbWFwAAAB7AAAAFUAAAFeF1fZ4mdhc3AAAAPwAAAACAAAAAgAAAAQZ2x5ZgAAAlgAAABcAAAAnMvguMloZWFkAAABMAAAAC8AAAA2C5Ap72hoZWEAAAFgAAAAHQAAACQGbQPHaG10eAAAAdgAAAAUAAAAHAoAAABsb2NhAAACRAAAABIAAAASAIwAYG1heHAAAAGAAAAAFgAAACAACwAKbmFtZQAAArQAAAECAAACZxWCgKhwb3N0AAADuAAAADUAAABZCrApUXicY2BkYGAA4rDECVrx/DZfGbhZGEDgyqNPOxH0/wNMq5kPALkcDEwgUQBWRA0dAHicY2BkYGA+8P8AAwMLAwgwrWZgZEAFbABY4QM8AAAAeJxjYGRgYOAAQiYGEICQSAAAAi8AFgAAeJxjYGY6yziBgZWBgWkm0xkGBoZ+CM34msGYkZMBFTAKoAkwODAwvmRiPvD/AIMDMxCD1CDJKjAwAgBktQsXAHicY2GAAMZQCM0EwqshbAALxAEKeJxjYGBgZoBgGQZGBhCIAPIYwXwWBhsgzcXAwcAEhIwMCi+Z/v/9/x+sSuElA4T9/4k4K1gHFwMMMILMY2QDYmaoABOQYGJABUA7WBiGNwAAJd4NIQAAAAAAAAAACAAIABAAGAAmAEAATgAAeJyNjLENgDAMBP9tIURJwQCMQccSZgk2i5fIYBDAidJjycXr7x5EPwE2wY8si7jmyBNXGo/bNBerxJNrpxhbO3/fEFpx8ZICpV+ghxJ74fAMe+h7Ox14AbrsHB14nK2QQWrDMBRER4mTkhQK3ZRQKOgCNk7oGQqhhEIX2WSlWEI1BAlkJ5CDdNsj5Ey9Rncdi38ES+jzNJo/HwTgATcoDEthhY3wBHc4CE+pfwsX5F/hGe7Vo/AcK/UhvMSz+mGXKhZU6pww8ISz3oWn1BvhgnwTnuEJf8Jz1OpFeIlX9YULDLdFi4ASHolkSR0iuYdjLak1vAequBhj21D61Nqyi6l3qWybGPjySbPHGScGJl6dP58MYcQRI0bts7mjebBqrFENH7t3qWtj0OuqHnXcW7b0HOTZFnKryRGW2hFX1m0O2vEM3opNMfTau+CS6Z3Vx6veNnEXY6jwDxhsc2gAAHicY2BiwA84GBgYmRiYGJkZmBlZGFkZ2djScyoLMgzZS/MyDQwMwLSrpYEBlIbxjQDrzgsuAAAAAAEAAf//AA94nGNgZGBg4AFiMSBmYmAEQnYgZgHzGAAD6wA2eJxjYGBgZACCKyoz1cD0o087YTQATOcIewAAAA==) format('woff');
15
- font-weight: normal;
16
- font-style: normal;
17
- }
18
- </style>
19
- `;
20
-
21
- document.head.appendChild(template.content);
22
-
23
- registerStyles(
24
- 'vaadin-grid-sorter',
25
- css`
26
- :host {
27
- display: inline-flex;
28
- cursor: pointer;
29
- max-width: 100%;
30
- }
31
-
32
- [part='content'] {
33
- flex: 1 1 auto;
34
- }
35
-
36
- [part='indicators'] {
37
- position: relative;
38
- align-self: center;
39
- flex: none;
40
- }
41
-
42
- [part='order'] {
43
- display: inline;
44
- vertical-align: super;
45
- }
46
-
47
- [part='indicators']::before {
48
- font-family: 'vaadin-grid-sorter-icons';
49
- display: inline-block;
50
- }
51
-
52
- :host(:not([direction])) [part='indicators']::before {
53
- content: '\\e901';
54
- }
55
-
56
- :host([direction='asc']) [part='indicators']::before {
57
- content: '\\e900';
58
- }
59
-
60
- :host([direction='desc']) [part='indicators']::before {
61
- content: '\\e902';
62
- }
63
- `,
64
- { moduleId: 'vaadin-grid-sorter-styles' },
65
- );
66
6
 
67
7
  /**
68
8
  * A mixin providing common sorter functionality.
@@ -8,6 +8,7 @@ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
11
+ import { gridSorterStyles } from './styles/vaadin-grid-sorter-core-styles.js';
11
12
  import { GridSorterMixin } from './vaadin-grid-sorter-mixin.js';
12
13
 
13
14
  /**
@@ -60,6 +61,10 @@ class GridSorter extends GridSorterMixin(ThemableMixin(DirMixin(PolylitMixin(Lit
60
61
  return 'vaadin-grid-sorter';
61
62
  }
62
63
 
64
+ static get styles() {
65
+ return gridSorterStyles;
66
+ }
67
+
63
68
  /** @protected */
64
69
  render() {
65
70
  return html`