@vaadin/select 25.0.0-alpha1 → 25.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/select",
3
- "version": "25.0.0-alpha1",
3
+ "version": "25.0.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,8 +23,8 @@
23
23
  "lit.d.ts",
24
24
  "lit.js",
25
25
  "src",
26
- "!src/*-base-styles.d.ts",
27
- "!src/*-base-styles.js",
26
+ "!src/styles/*-base-styles.d.ts",
27
+ "!src/styles/*-base-styles.js",
28
28
  "theme",
29
29
  "vaadin-*.d.ts",
30
30
  "vaadin-*.js",
@@ -39,28 +39,28 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "@open-wc/dedupe-mixin": "^1.3.0",
42
- "@vaadin/a11y-base": "25.0.0-alpha1",
43
- "@vaadin/button": "25.0.0-alpha1",
44
- "@vaadin/component-base": "25.0.0-alpha1",
45
- "@vaadin/field-base": "25.0.0-alpha1",
46
- "@vaadin/input-container": "25.0.0-alpha1",
47
- "@vaadin/item": "25.0.0-alpha1",
48
- "@vaadin/list-box": "25.0.0-alpha1",
49
- "@vaadin/lit-renderer": "25.0.0-alpha1",
50
- "@vaadin/overlay": "25.0.0-alpha1",
51
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha1",
52
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha1",
42
+ "@vaadin/a11y-base": "25.0.0-alpha10",
43
+ "@vaadin/button": "25.0.0-alpha10",
44
+ "@vaadin/component-base": "25.0.0-alpha10",
45
+ "@vaadin/field-base": "25.0.0-alpha10",
46
+ "@vaadin/input-container": "25.0.0-alpha10",
47
+ "@vaadin/item": "25.0.0-alpha10",
48
+ "@vaadin/list-box": "25.0.0-alpha10",
49
+ "@vaadin/lit-renderer": "25.0.0-alpha10",
50
+ "@vaadin/overlay": "25.0.0-alpha10",
51
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha10",
52
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha10",
53
53
  "lit": "^3.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@vaadin/chai-plugins": "25.0.0-alpha1",
57
- "@vaadin/test-runner-commands": "25.0.0-alpha1",
58
- "@vaadin/testing-helpers": "^1.1.0",
56
+ "@vaadin/chai-plugins": "25.0.0-alpha10",
57
+ "@vaadin/test-runner-commands": "25.0.0-alpha10",
58
+ "@vaadin/testing-helpers": "^2.0.0",
59
59
  "sinon": "^18.0.0"
60
60
  },
61
61
  "web-types": [
62
62
  "web-types.json",
63
63
  "web-types.lit.json"
64
64
  ],
65
- "gitHead": "b8c22a4a0c64156210d0daac96b43ae4e5526d49"
65
+ "gitHead": "6cc6c94079e805fa5b2f0af4dbf3b2a7485e57d0"
66
66
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 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 selectStyles = css`
10
+ :host {
11
+ position: relative;
12
+ }
13
+
14
+ ::slotted([slot='value']) {
15
+ flex: 1;
16
+ }
17
+
18
+ ::slotted(div[slot='overlay']) {
19
+ display: contents;
20
+ }
21
+
22
+ :host(:not([focus-ring])) [part='input-field'] {
23
+ outline: none;
24
+ }
25
+
26
+ :host([readonly]:not([focus-ring])) [part='input-field'] {
27
+ --vaadin-input-field-border-color: inherit;
28
+ }
29
+
30
+ [part='input-field'],
31
+ :host(:not([readonly])) ::slotted([slot='value']) {
32
+ cursor: var(--vaadin-clickable-cursor);
33
+ }
34
+
35
+ [part='toggle-button']::before {
36
+ mask-image: var(--_vaadin-icon-chevron-down);
37
+ }
38
+ `;
@@ -13,4 +13,8 @@ export const selectStyles = css`
13
13
  ::slotted([slot='value']) {
14
14
  flex-grow: 1;
15
15
  }
16
+
17
+ ::slotted(div[slot='overlay']) {
18
+ display: contents;
19
+ }
16
20
  `;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 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
+ export const selectOverlayStyles = css`
9
+ :host {
10
+ align-items: flex-start;
11
+ justify-content: flex-start;
12
+ }
13
+
14
+ :host(:not([phone])) [part='overlay'] {
15
+ min-width: var(--vaadin-select-overlay-width, var(--_vaadin-select-overlay-default-width));
16
+ }
17
+
18
+ [part='content'] {
19
+ padding: var(--vaadin-item-overlay-padding, 4px);
20
+ }
21
+ `;
@@ -12,7 +12,7 @@ export const selectOverlayStyles = css`
12
12
  }
13
13
 
14
14
  :host(:not([phone])) [part='overlay'] {
15
- min-width: var(--vaadin-select-overlay-width, var(--vaadin-select-text-field-width));
15
+ min-width: var(--vaadin-select-overlay-width, var(--_vaadin-select-overlay-default-width));
16
16
  }
17
17
 
18
18
  @media (forced-colors: active) {
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 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
+ export const valueButton = css`
9
+ :host {
10
+ min-height: 1lh;
11
+ outline: none;
12
+ overflow: hidden;
13
+ white-space: nowrap;
14
+ width: 100%;
15
+ }
16
+
17
+ ::slotted(*) {
18
+ padding: 0;
19
+ cursor: inherit;
20
+ }
21
+
22
+ .vaadin-button-container,
23
+ [part='label'] {
24
+ display: contents;
25
+ }
26
+
27
+ :host([disabled]) {
28
+ pointer-events: none;
29
+ }
30
+ `;
@@ -63,6 +63,7 @@ export const SelectBaseMixin = (superClass) =>
63
63
  type: Boolean,
64
64
  value: false,
65
65
  notify: true,
66
+ observer: '_openedChanged',
66
67
  reflectToAttribute: true,
67
68
  sync: true,
68
69
  },
@@ -160,11 +161,7 @@ export const SelectBaseMixin = (superClass) =>
160
161
  }
161
162
 
162
163
  static get observers() {
163
- return [
164
- '_updateAriaExpanded(opened, focusElement)',
165
- '_updateSelectedItem(value, _items, placeholder)',
166
- '_openedChanged(opened, _overlayElement)',
167
- ];
164
+ return ['_updateAriaExpanded(opened, focusElement)', '_updateSelectedItem(value, _items, placeholder)'];
168
165
  }
169
166
 
170
167
  constructor() {
@@ -207,6 +204,15 @@ export const SelectBaseMixin = (superClass) =>
207
204
  this.addController(this._tooltipController);
208
205
  }
209
206
 
207
+ /** @protected */
208
+ updated(props) {
209
+ super.updated(props);
210
+
211
+ if (props.has('_phone')) {
212
+ this.toggleAttribute('phone', this._phone);
213
+ }
214
+ }
215
+
210
216
  /**
211
217
  * Requests an update for the content of the select.
212
218
  * While performing the update, it invokes the renderer passed in the `renderer` property.
@@ -219,10 +225,6 @@ export const SelectBaseMixin = (superClass) =>
219
225
  }
220
226
 
221
227
  this._overlayElement.requestContentUpdate();
222
-
223
- if (this._menuElement && this._menuElement.items) {
224
- this._updateSelectedItem(this.value, this._menuElement.items);
225
- }
226
228
  }
227
229
 
228
230
  /**
@@ -283,6 +285,12 @@ export const SelectBaseMixin = (superClass) =>
283
285
  // Store the menu element reference
284
286
  this.__lastMenuElement = menuElement;
285
287
  }
288
+
289
+ // When the renderer was re-assigned so that menu element is preserved
290
+ // but its items have changed, make sure selected property is updated.
291
+ if (this._menuElement && this._menuElement.items) {
292
+ this._updateSelectedItem(this.value, this._menuElement.items);
293
+ }
286
294
  }
287
295
 
288
296
  /** @private */
@@ -326,6 +334,12 @@ export const SelectBaseMixin = (superClass) =>
326
334
  // Prevent mousedown event to avoid blur and preserve focused state
327
335
  // while opening, and to restore focus-ring attribute on closing.
328
336
  event.preventDefault();
337
+
338
+ // Clicking the `vaadin-input-container` focuses the value button
339
+ // but clicking the toggle button does not, so we handle it here.
340
+ if (!this.opened) {
341
+ this.focusElement.focus();
342
+ }
329
343
  }
330
344
 
331
345
  /**
@@ -358,17 +372,21 @@ export const SelectBaseMixin = (superClass) =>
358
372
  * @protected
359
373
  */
360
374
  _onKeyDownInside(e) {
361
- if (/^(Tab)$/u.test(e.key)) {
375
+ if (e.key === 'Tab') {
376
+ // Temporarily set tabindex to prevent moving focus
377
+ // to the value button element on item Shift + Tab
378
+ this.focusElement.setAttribute('tabindex', '-1');
379
+ this._overlayElement.restoreFocusOnClose = false;
362
380
  this.opened = false;
381
+ setTimeout(() => {
382
+ this.focusElement.setAttribute('tabindex', '0');
383
+ this._overlayElement.restoreFocusOnClose = true;
384
+ });
363
385
  }
364
386
  }
365
387
 
366
388
  /** @private */
367
- _openedChanged(opened, overlayElement) {
368
- if (!overlayElement) {
369
- return;
370
- }
371
-
389
+ _openedChanged(opened, oldOpened) {
372
390
  if (opened) {
373
391
  if (this.disabled || this.readonly) {
374
392
  // Disallow programmatic opening when disabled or readonly
@@ -379,8 +397,6 @@ export const SelectBaseMixin = (superClass) =>
379
397
  // Avoid multiple announcements when a value gets selected from the dropdown
380
398
  this._updateAriaLive(false);
381
399
 
382
- overlayElement.style.setProperty('--vaadin-select-text-field-width', `${this._inputContainer.offsetWidth}px`);
383
-
384
400
  // Preserve focus-ring to restore it later
385
401
  const hasFocusRing = this.hasAttribute('focus-ring');
386
402
  this._openedWithFocusRing = hasFocusRing;
@@ -389,7 +405,7 @@ export const SelectBaseMixin = (superClass) =>
389
405
  if (hasFocusRing) {
390
406
  this.removeAttribute('focus-ring');
391
407
  }
392
- } else if (this.__oldOpened) {
408
+ } else if (oldOpened) {
393
409
  if (this._openedWithFocusRing) {
394
410
  this.setAttribute('focus-ring', '');
395
411
  }
@@ -401,8 +417,6 @@ export const SelectBaseMixin = (superClass) =>
401
417
  this._requestValidation();
402
418
  }
403
419
  }
404
-
405
- this.__oldOpened = opened;
406
420
  }
407
421
 
408
422
  /** @private */
@@ -590,8 +604,8 @@ export const SelectBaseMixin = (superClass) =>
590
604
  * @protected
591
605
  * @override
592
606
  */
593
- _shouldRemoveFocus() {
594
- return !this.opened;
607
+ _shouldRemoveFocus(event) {
608
+ return !this.contains(event.relatedTarget);
595
609
  }
596
610
 
597
611
  /**
@@ -644,13 +658,7 @@ export const SelectBaseMixin = (superClass) =>
644
658
  }
645
659
 
646
660
  /** @private */
647
- async __dispatchChange() {
648
- // Wait for the update complete to guarantee that value-changed is fired
649
- // before validated and change events when using the Lit version of the component.
650
- if (this.updateComplete) {
651
- await this.updateComplete;
652
- }
653
-
661
+ __dispatchChange() {
654
662
  this._requestValidation();
655
663
  this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
656
664
  this.__dispatchChangePending = false;
@@ -7,8 +7,9 @@ import { html, LitElement } from 'lit';
7
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
- import { itemStyles } from '@vaadin/item/src/vaadin-item-core-styles.js';
10
+ import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
11
11
  import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
12
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
12
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
14
 
14
15
  /**
@@ -21,7 +22,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
21
22
  * @mixes ThemableMixin
22
23
  * @protected
23
24
  */
24
- class SelectItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
25
+ class SelectItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
25
26
  static get is() {
26
27
  return 'vaadin-select-item';
27
28
  }
@@ -8,7 +8,8 @@ import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
8
8
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
9
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
10
10
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
11
- import { listBoxStyles } from '@vaadin/list-box/src/vaadin-list-box-core-styles.js';
11
+ import { listBoxStyles } from '@vaadin/list-box/src/styles/vaadin-list-box-core-styles.js';
12
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
12
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
14
 
14
15
  /**
@@ -21,7 +22,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
21
22
  * @mixes ThemableMixin
22
23
  * @protected
23
24
  */
24
- class SelectListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
25
+ class SelectListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
25
26
  static get is() {
26
27
  return 'vaadin-select-list-box';
27
28
  }
@@ -16,7 +16,7 @@ import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin
16
16
  export const SelectOverlayMixin = (superClass) =>
17
17
  class SelectOverlayMixin extends PositionMixin(OverlayMixin(DirMixin(superClass))) {
18
18
  static get observers() {
19
- return ['_updateOverlayWidth(opened, owner)'];
19
+ return ['_updateOverlayWidth(opened, positionTarget)'];
20
20
  }
21
21
 
22
22
  /** @protected */
@@ -26,6 +26,21 @@ export const SelectOverlayMixin = (superClass) =>
26
26
  this.restoreFocusOnClose = true;
27
27
  }
28
28
 
29
+ /**
30
+ * @override
31
+ * @protected
32
+ */
33
+ get _contentRoot() {
34
+ if (!this.__savedRoot) {
35
+ const root = document.createElement('div');
36
+ root.setAttribute('slot', 'overlay');
37
+ this.owner.appendChild(root);
38
+ this.__savedRoot = root;
39
+ }
40
+
41
+ return this.__savedRoot;
42
+ }
43
+
29
44
  /**
30
45
  * Override method inherited from `Overlay` to always close on outside click,
31
46
  * in order to avoid problem when using inside of the modeless dialog.
@@ -38,22 +53,26 @@ export const SelectOverlayMixin = (superClass) =>
38
53
  return true;
39
54
  }
40
55
 
56
+ /**
57
+ * @protected
58
+ * @override
59
+ */
60
+ _mouseDownListener(event) {
61
+ super._mouseDownListener(event);
62
+
63
+ // Prevent global mousedown event to avoid losing focus on outside click
64
+ event.preventDefault();
65
+ }
66
+
41
67
  /** @protected */
42
68
  _getMenuElement() {
43
- return Array.from(this.children).find((el) => el.localName !== 'style');
69
+ return Array.from(this._contentRoot.children).find((el) => el.localName !== 'style');
44
70
  }
45
71
 
46
72
  /** @private */
47
- _updateOverlayWidth(opened, owner) {
48
- if (opened && owner) {
49
- const widthProperty = '--vaadin-select-overlay-width';
50
- const customWidth = getComputedStyle(owner).getPropertyValue(widthProperty);
51
-
52
- if (customWidth === '') {
53
- this.style.removeProperty(widthProperty);
54
- } else {
55
- this.style.setProperty(widthProperty, customWidth);
56
- }
73
+ _updateOverlayWidth(opened, positionTarget) {
74
+ if (opened && positionTarget) {
75
+ this.style.setProperty('--_vaadin-select-overlay-default-width', `${positionTarget.offsetWidth}px`);
57
76
  }
58
77
  }
59
78
 
@@ -6,9 +6,10 @@
6
6
  import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
- import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
9
+ import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
10
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
10
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
- import { selectOverlayStyles } from './vaadin-select-overlay-core-styles.js';
12
+ import { selectOverlayStyles } from './styles/vaadin-select-overlay-core-styles.js';
12
13
  import { SelectOverlayMixin } from './vaadin-select-overlay-mixin.js';
13
14
 
14
15
  /**
@@ -20,7 +21,7 @@ import { SelectOverlayMixin } from './vaadin-select-overlay-mixin.js';
20
21
  * @mixes ThemableMixin
21
22
  * @private
22
23
  */
23
- export class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin(LitElement))) {
24
+ export class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
24
25
  static get is() {
25
26
  return 'vaadin-select-overlay';
26
27
  }
@@ -33,7 +34,7 @@ export class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin
33
34
  render() {
34
35
  return html`
35
36
  <div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
36
- <div part="overlay" id="overlay" tabindex="0">
37
+ <div part="overlay" id="overlay">
37
38
  <div part="content" id="content">
38
39
  <slot></slot>
39
40
  </div>
@@ -7,8 +7,9 @@ import { html, LitElement } from 'lit';
7
7
  import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js';
8
8
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
10
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
- import { valueButton } from './vaadin-select-value-button-core-styles.js';
12
+ import { valueButton } from './styles/vaadin-select-value-button-core-styles.js';
12
13
 
13
14
  /**
14
15
  * An element used internally by `<vaadin-select>`. Not intended to be used separately.
@@ -19,7 +20,7 @@ import { valueButton } from './vaadin-select-value-button-core-styles.js';
19
20
  * @mixes ThemableMixin
20
21
  * @protected
21
22
  */
22
- class SelectValueButton extends ButtonMixin(ThemableMixin(PolylitMixin(LitElement))) {
23
+ class SelectValueButton extends ButtonMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
23
24
  static get is() {
24
25
  return 'vaadin-select-value-button';
25
26
  }
@@ -126,11 +126,10 @@ export interface SelectEventMap extends HTMLElementEventMap, SelectCustomEventMa
126
126
  *
127
127
  * The following custom properties are available for styling:
128
128
  *
129
- * Custom property | Description | Target element | Default
130
- * -----------------------------------|------------------------------|----------------------------------
131
- * `--vaadin-field-default-width` | Default width of the field | :host | `12em`
132
- * `--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |
133
- * `--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |
129
+ * Custom property | Description | Default
130
+ * ---------------------------------|-----------------------------|--------
131
+ * `--vaadin-field-default-width` | Default width of the field | `12em`
132
+ * `--vaadin-select-overlay-width` | Width of the overlay |
134
133
  *
135
134
  * `<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
136
135
  * See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
@@ -138,15 +137,19 @@ export interface SelectEventMap extends HTMLElementEventMap, SelectCustomEventMa
138
137
  *
139
138
  * In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
140
139
  *
141
- * Part name | Description
142
- * ----------------|----------------
143
- * `toggle-button` | The toggle button
140
+ * Part name | Description
141
+ * -----------------|----------------
142
+ * `toggle-button` | The toggle button
143
+ * `backdrop` | Backdrop of the overlay
144
+ * `overlay` | The overlay container
145
+ * `content` | The overlay content
144
146
  *
145
147
  * In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
146
148
  *
147
- * Attribute | Description | Part name
148
- * ----------|-----------------------------|-----------
149
- * `opened` | Set when the select is open | :host
149
+ * Attribute | Description
150
+ * ----------|-----------------------------
151
+ * `opened` | Set when the select is open
152
+ * `phone` | Set when the overlay is shown in phone mode
150
153
  *
151
154
  * There are two exceptions in terms of styling compared to `<vaadin-text-field>`:
152
155
  * - the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.
@@ -15,9 +15,10 @@ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
15
15
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
16
16
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
17
17
  import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
18
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
18
19
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
20
+ import { selectStyles } from './styles/vaadin-select-core-styles.js';
19
21
  import { SelectBaseMixin } from './vaadin-select-base-mixin.js';
20
- import { selectStyles } from './vaadin-select-core-styles.js';
21
22
 
22
23
  /**
23
24
  * `<vaadin-select>` is a Web Component for selecting values from a list of items.
@@ -79,11 +80,10 @@ import { selectStyles } from './vaadin-select-core-styles.js';
79
80
  *
80
81
  * The following custom properties are available for styling:
81
82
  *
82
- * Custom property | Description | Target element | Default
83
- * -----------------------------------|------------------------------|----------------------------------
84
- * `--vaadin-field-default-width` | Default width of the field | :host | `12em`
85
- * `--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |
86
- * `--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |
83
+ * Custom property | Description | Default
84
+ * ---------------------------------|-----------------------------|--------
85
+ * `--vaadin-field-default-width` | Default width of the field | `12em`
86
+ * `--vaadin-select-overlay-width` | Width of the overlay |
87
87
  *
88
88
  * `<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
89
89
  * See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
@@ -91,15 +91,19 @@ import { selectStyles } from './vaadin-select-core-styles.js';
91
91
  *
92
92
  * In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
93
93
  *
94
- * Part name | Description
95
- * ----------------|----------------
96
- * `toggle-button` | The toggle button
94
+ * Part name | Description
95
+ * -----------------|----------------
96
+ * `toggle-button` | The toggle button
97
+ * `backdrop` | Backdrop of the overlay
98
+ * `overlay` | The overlay container
99
+ * `content` | The overlay content
97
100
  *
98
101
  * In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
99
102
  *
100
- * Attribute | Description | Part name
101
- * ----------|-----------------------------|-----------
102
- * `opened` | Set when the select is open | :host
103
+ * Attribute | Description
104
+ * ----------|-----------------------------
105
+ * `opened` | Set when the select is open
106
+ * `phone` | Set when the overlay is shown in phone mode
103
107
  *
104
108
  * There are two exceptions in terms of styling compared to `<vaadin-text-field>`:
105
109
  * - the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.
@@ -131,7 +135,7 @@ import { selectStyles } from './vaadin-select-core-styles.js';
131
135
  * @mixes SelectBaseMixin
132
136
  * @mixes ThemableMixin
133
137
  */
134
- class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
138
+ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
135
139
  static get is() {
136
140
  return 'vaadin-select';
137
141
  }
@@ -181,9 +185,12 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolylitMixin(Lit
181
185
  ?phone="${this._phone}"
182
186
  theme="${ifDefined(this._theme)}"
183
187
  ?no-vertical-overlap="${this.noVerticalOverlap}"
188
+ exportparts="backdrop, overlay, content"
184
189
  @opened-changed="${this._onOpenedChanged}"
185
190
  @vaadin-overlay-open="${this._onOverlayOpen}"
186
- ></vaadin-select-overlay>
191
+ >
192
+ <slot name="overlay"></slot>
193
+ </vaadin-select-overlay>
187
194
 
188
195
  <slot name="tooltip"></slot>
189
196
  <div class="sr-only">
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/select",
4
- "version": "25.0.0-alpha1",
4
+ "version": "25.0.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-select",
11
- "description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n`--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-----------------------------|-----------\n`opened` | Set when the select is open | :host\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
11
+ "description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n---------------------------------|-----------------------------|--------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n`--vaadin-select-overlay-width` | Width of the overlay |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n-----------------|----------------\n`toggle-button` | The toggle button\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description\n----------|-----------------------------\n`opened` | Set when the select is open\n`phone` | Set when the overlay is shown in phone mode\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "disabled",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/select",
4
- "version": "25.0.0-alpha1",
4
+ "version": "25.0.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-select",
19
- "description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n`--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-----------------------------|-----------\n`opened` | Set when the select is open | :host\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
19
+ "description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n---------------------------------|-----------------------------|--------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n`--vaadin-select-overlay-width` | Width of the overlay |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n-----------------|----------------\n`toggle-button` | The toggle button\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description\n----------|-----------------------------\n`opened` | Set when the select is open\n`phone` | Set when the overlay is shown in phone mode\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -1,36 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2017 - 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 selectStyles = css`
10
- @layer base {
11
- :host {
12
- position: relative;
13
- }
14
-
15
- ::slotted([slot='value']) {
16
- flex: 1;
17
- }
18
-
19
- :host(:not([focus-ring])) [part='input-field'] {
20
- outline: none;
21
- }
22
-
23
- :host([readonly]:not([focus-ring])) [part='input-field'] {
24
- --vaadin-input-field-border-color: inherit;
25
- }
26
-
27
- [part='input-field'],
28
- :host(:not([readonly])) ::slotted([slot='value']) {
29
- cursor: var(--vaadin-clickable-cursor);
30
- }
31
-
32
- [part='toggle-button']::before {
33
- mask-image: var(--_vaadin-icon-chevron-down);
34
- }
35
- }
36
- `;
@@ -1,23 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2017 - 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
- export const selectOverlayStyles = css`
9
- @layer base {
10
- :host {
11
- align-items: flex-start;
12
- justify-content: flex-start;
13
- }
14
-
15
- :host(:not([phone])) [part='overlay'] {
16
- min-width: var(--vaadin-select-overlay-width, var(--vaadin-select-text-field-width));
17
- }
18
-
19
- [part='content'] {
20
- padding: var(--vaadin-item-overlay-padding, 4px);
21
- }
22
- }
23
- `;
@@ -1,32 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2017 - 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
- export const valueButton = css`
9
- @layer base {
10
- :host {
11
- min-height: 1lh;
12
- outline: none;
13
- overflow: hidden;
14
- white-space: nowrap;
15
- width: 100%;
16
- }
17
-
18
- ::slotted(*) {
19
- padding: 0;
20
- cursor: inherit;
21
- }
22
-
23
- .vaadin-button-container,
24
- [part='label'] {
25
- display: contents;
26
- }
27
-
28
- :host([disabled]) {
29
- pointer-events: none;
30
- }
31
- }
32
- `;