@vaadin/select 25.0.0-alpha2 → 25.0.0-alpha20
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 +16 -19
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/styles/vaadin-select-base-styles.js +38 -0
- package/src/{vaadin-select-overlay-core-styles.js → styles/vaadin-select-overlay-base-styles.js} +8 -6
- package/src/styles/vaadin-select-value-button-base-styles.js +34 -0
- package/src/vaadin-select-base-mixin.d.ts +1 -4
- package/src/vaadin-select-base-mixin.js +39 -36
- package/src/vaadin-select-item.js +3 -2
- package/src/vaadin-select-list-box.js +3 -2
- package/src/vaadin-select-overlay-mixin.js +31 -12
- package/src/vaadin-select-overlay.js +5 -4
- package/src/vaadin-select-value-button.js +3 -2
- package/src/vaadin-select.d.ts +38 -32
- package/src/vaadin-select.js +52 -35
- package/vaadin-select.js +1 -1
- package/web-types.json +3 -25
- package/web-types.lit.json +3 -10
- package/src/vaadin-select-base-styles.js +0 -36
- package/src/vaadin-select-core-styles.d.ts +0 -8
- package/src/vaadin-select-core-styles.js +0 -16
- package/src/vaadin-select-overlay-base-styles.js +0 -23
- package/src/vaadin-select-value-button-base-styles.js +0 -32
- package/src/vaadin-select-value-button-core-styles.js +0 -49
- package/theme/lumo/vaadin-select-styles.d.ts +0 -9
- package/theme/lumo/vaadin-select-styles.js +0 -135
- package/theme/lumo/vaadin-select.d.ts +0 -7
- package/theme/lumo/vaadin-select.js +0 -7
- /package/src/{vaadin-select-base-styles.d.ts → styles/vaadin-select-base-styles.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/select",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha20",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,9 +23,6 @@
|
|
|
23
23
|
"lit.d.ts",
|
|
24
24
|
"lit.js",
|
|
25
25
|
"src",
|
|
26
|
-
"!src/*-base-styles.d.ts",
|
|
27
|
-
"!src/*-base-styles.js",
|
|
28
|
-
"theme",
|
|
29
26
|
"vaadin-*.d.ts",
|
|
30
27
|
"vaadin-*.js",
|
|
31
28
|
"web-types.json",
|
|
@@ -39,28 +36,28 @@
|
|
|
39
36
|
],
|
|
40
37
|
"dependencies": {
|
|
41
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
42
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
43
|
-
"@vaadin/button": "25.0.0-
|
|
44
|
-
"@vaadin/component-base": "25.0.0-
|
|
45
|
-
"@vaadin/field-base": "25.0.0-
|
|
46
|
-
"@vaadin/input-container": "25.0.0-
|
|
47
|
-
"@vaadin/item": "25.0.0-
|
|
48
|
-
"@vaadin/list-box": "25.0.0-
|
|
49
|
-
"@vaadin/lit-renderer": "25.0.0-
|
|
50
|
-
"@vaadin/overlay": "25.0.0-
|
|
51
|
-
"@vaadin/vaadin-
|
|
52
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha2",
|
|
39
|
+
"@vaadin/a11y-base": "25.0.0-alpha20",
|
|
40
|
+
"@vaadin/button": "25.0.0-alpha20",
|
|
41
|
+
"@vaadin/component-base": "25.0.0-alpha20",
|
|
42
|
+
"@vaadin/field-base": "25.0.0-alpha20",
|
|
43
|
+
"@vaadin/input-container": "25.0.0-alpha20",
|
|
44
|
+
"@vaadin/item": "25.0.0-alpha20",
|
|
45
|
+
"@vaadin/list-box": "25.0.0-alpha20",
|
|
46
|
+
"@vaadin/lit-renderer": "25.0.0-alpha20",
|
|
47
|
+
"@vaadin/overlay": "25.0.0-alpha20",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha20",
|
|
53
49
|
"lit": "^3.0.0"
|
|
54
50
|
},
|
|
55
51
|
"devDependencies": {
|
|
56
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
57
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
52
|
+
"@vaadin/chai-plugins": "25.0.0-alpha20",
|
|
53
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha20",
|
|
58
54
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
59
|
-
"
|
|
55
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha20",
|
|
56
|
+
"sinon": "^21.0.0"
|
|
60
57
|
},
|
|
61
58
|
"web-types": [
|
|
62
59
|
"web-types.json",
|
|
63
60
|
"web-types.lit.json"
|
|
64
61
|
],
|
|
65
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c948aae591a30b432f3784000d4677674cae56e0"
|
|
66
63
|
}
|
|
@@ -28,7 +28,7 @@ export class SelectRendererDirective extends LitRendererDirective<Select, Select
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* A Lit directive for populating the content of the `<vaadin-select
|
|
31
|
+
* A Lit directive for populating the content of the `<vaadin-select>` element.
|
|
32
32
|
*
|
|
33
33
|
* The directive accepts a renderer callback returning a Lit template and assigns it to the select
|
|
34
34
|
* via the `renderer` property. The renderer is called once to populate the content when assigned
|
|
@@ -32,7 +32,7 @@ export class SelectRendererDirective extends LitRendererDirective {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* A Lit directive for populating the content of the `<vaadin-select
|
|
35
|
+
* A Lit directive for populating the content of the `<vaadin-select>` element.
|
|
36
36
|
*
|
|
37
37
|
* The directive accepts a renderer callback returning a Lit template and assigns it to the select
|
|
38
38
|
* via the `renderer` property. The renderer is called once to populate the content when assigned
|
|
@@ -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/styles/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
|
+
`;
|
package/src/{vaadin-select-overlay-core-styles.js → styles/vaadin-select-overlay-base-styles.js}
RENAMED
|
@@ -11,13 +11,15 @@ export const selectOverlayStyles = css`
|
|
|
11
11
|
justify-content: flex-start;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
min-width: var(--vaadin-select-overlay-width, var(--
|
|
14
|
+
[part='overlay'] {
|
|
15
|
+
min-width: var(--vaadin-select-overlay-width, var(--_vaadin-select-overlay-default-width));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
[part='content'] {
|
|
19
|
+
padding: var(--vaadin-item-overlay-padding, 4px);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[part='backdrop'] {
|
|
23
|
+
background: transparent;
|
|
22
24
|
}
|
|
23
25
|
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
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([placeholder]) {
|
|
28
|
+
color: var(--vaadin-input-field-placeholder-color, var(--vaadin-text-color-secondary));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([disabled]) {
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
@@ -10,7 +10,6 @@ import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
|
10
10
|
import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
|
|
11
11
|
import type { TabindexMixinClass } from '@vaadin/a11y-base/src/tabindex-mixin.js';
|
|
12
12
|
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
13
|
-
import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
14
13
|
import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
15
14
|
import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
16
15
|
import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
@@ -25,7 +24,6 @@ export declare function SelectBaseMixin<T extends Constructor<HTMLElement>>(
|
|
|
25
24
|
Constructor<FocusMixinClass> &
|
|
26
25
|
Constructor<KeyboardMixinClass> &
|
|
27
26
|
Constructor<LabelMixinClass> &
|
|
28
|
-
Constructor<OverlayClassMixinClass> &
|
|
29
27
|
Constructor<SelectBaseMixinClass> &
|
|
30
28
|
Constructor<TabindexMixinClass> &
|
|
31
29
|
Constructor<ValidateMixinClass> &
|
|
@@ -64,8 +62,7 @@ export declare class SelectBaseMixinClass {
|
|
|
64
62
|
* Custom function for rendering the content of the `<vaadin-select>`.
|
|
65
63
|
* Receives two arguments:
|
|
66
64
|
*
|
|
67
|
-
* - `root` The
|
|
68
|
-
* DOM element. Append your content to it.
|
|
65
|
+
* - `root` The internal container DOM element. Append your content to it.
|
|
69
66
|
* - `select` The reference to the `<vaadin-select>` element.
|
|
70
67
|
*/
|
|
71
68
|
renderer: SelectRenderer | undefined;
|
|
@@ -8,7 +8,6 @@ import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.j
|
|
|
8
8
|
import { KeyboardMixin } from '@vaadin/a11y-base/src/keyboard-mixin.js';
|
|
9
9
|
import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
10
10
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
11
|
-
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
12
11
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
13
12
|
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
14
13
|
import { FieldMixin } from '@vaadin/field-base/src/field-mixin.js';
|
|
@@ -21,12 +20,9 @@ import { ButtonController } from './button-controller.js';
|
|
|
21
20
|
* @mixes DelegateStateMixin
|
|
22
21
|
* @mixes FieldMixin
|
|
23
22
|
* @mixes KeyboardMixin
|
|
24
|
-
* @mixes OverlayClassMixin
|
|
25
23
|
*/
|
|
26
24
|
export const SelectBaseMixin = (superClass) =>
|
|
27
|
-
class SelectBaseMixin extends
|
|
28
|
-
DelegateFocusMixin(DelegateStateMixin(KeyboardMixin(FieldMixin(superClass)))),
|
|
29
|
-
) {
|
|
25
|
+
class SelectBaseMixin extends DelegateFocusMixin(DelegateStateMixin(KeyboardMixin(FieldMixin(superClass)))) {
|
|
30
26
|
static get properties() {
|
|
31
27
|
return {
|
|
32
28
|
/**
|
|
@@ -63,6 +59,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
63
59
|
type: Boolean,
|
|
64
60
|
value: false,
|
|
65
61
|
notify: true,
|
|
62
|
+
observer: '_openedChanged',
|
|
66
63
|
reflectToAttribute: true,
|
|
67
64
|
sync: true,
|
|
68
65
|
},
|
|
@@ -71,8 +68,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
71
68
|
* Custom function for rendering the content of the `<vaadin-select>`.
|
|
72
69
|
* Receives two arguments:
|
|
73
70
|
*
|
|
74
|
-
* - `root` The
|
|
75
|
-
* DOM element. Append your content to it.
|
|
71
|
+
* - `root` The internal container DOM element. Append your content to it.
|
|
76
72
|
* - `select` The reference to the `<vaadin-select>` element.
|
|
77
73
|
* @type {!SelectRenderer | undefined}
|
|
78
74
|
*/
|
|
@@ -160,11 +156,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
160
156
|
}
|
|
161
157
|
|
|
162
158
|
static get observers() {
|
|
163
|
-
return [
|
|
164
|
-
'_updateAriaExpanded(opened, focusElement)',
|
|
165
|
-
'_updateSelectedItem(value, _items, placeholder)',
|
|
166
|
-
'_openedChanged(opened, _overlayElement)',
|
|
167
|
-
];
|
|
159
|
+
return ['_updateAriaExpanded(opened, focusElement)', '_updateSelectedItem(value, _items, placeholder)'];
|
|
168
160
|
}
|
|
169
161
|
|
|
170
162
|
constructor() {
|
|
@@ -207,6 +199,15 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
207
199
|
this.addController(this._tooltipController);
|
|
208
200
|
}
|
|
209
201
|
|
|
202
|
+
/** @protected */
|
|
203
|
+
updated(props) {
|
|
204
|
+
super.updated(props);
|
|
205
|
+
|
|
206
|
+
if (props.has('_phone')) {
|
|
207
|
+
this.toggleAttribute('phone', this._phone);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
210
211
|
/**
|
|
211
212
|
* Requests an update for the content of the select.
|
|
212
213
|
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
@@ -219,10 +220,6 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
this._overlayElement.requestContentUpdate();
|
|
222
|
-
|
|
223
|
-
if (this._menuElement && this._menuElement.items) {
|
|
224
|
-
this._updateSelectedItem(this.value, this._menuElement.items);
|
|
225
|
-
}
|
|
226
223
|
}
|
|
227
224
|
|
|
228
225
|
/**
|
|
@@ -283,6 +280,12 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
283
280
|
// Store the menu element reference
|
|
284
281
|
this.__lastMenuElement = menuElement;
|
|
285
282
|
}
|
|
283
|
+
|
|
284
|
+
// When the renderer was re-assigned so that menu element is preserved
|
|
285
|
+
// but its items have changed, make sure selected property is updated.
|
|
286
|
+
if (this._menuElement && this._menuElement.items) {
|
|
287
|
+
this._updateSelectedItem(this.value, this._menuElement.items);
|
|
288
|
+
}
|
|
286
289
|
}
|
|
287
290
|
|
|
288
291
|
/** @private */
|
|
@@ -326,6 +329,12 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
326
329
|
// Prevent mousedown event to avoid blur and preserve focused state
|
|
327
330
|
// while opening, and to restore focus-ring attribute on closing.
|
|
328
331
|
event.preventDefault();
|
|
332
|
+
|
|
333
|
+
// Clicking the `vaadin-input-container` focuses the value button
|
|
334
|
+
// but clicking the toggle button does not, so we handle it here.
|
|
335
|
+
if (!this.opened) {
|
|
336
|
+
this.focusElement.focus();
|
|
337
|
+
}
|
|
329
338
|
}
|
|
330
339
|
|
|
331
340
|
/**
|
|
@@ -358,17 +367,21 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
358
367
|
* @protected
|
|
359
368
|
*/
|
|
360
369
|
_onKeyDownInside(e) {
|
|
361
|
-
if (
|
|
370
|
+
if (e.key === 'Tab') {
|
|
371
|
+
// Temporarily set tabindex to prevent moving focus
|
|
372
|
+
// to the value button element on item Shift + Tab
|
|
373
|
+
this.focusElement.setAttribute('tabindex', '-1');
|
|
374
|
+
this._overlayElement.restoreFocusOnClose = false;
|
|
362
375
|
this.opened = false;
|
|
376
|
+
setTimeout(() => {
|
|
377
|
+
this.focusElement.setAttribute('tabindex', '0');
|
|
378
|
+
this._overlayElement.restoreFocusOnClose = true;
|
|
379
|
+
});
|
|
363
380
|
}
|
|
364
381
|
}
|
|
365
382
|
|
|
366
383
|
/** @private */
|
|
367
|
-
_openedChanged(opened,
|
|
368
|
-
if (!overlayElement) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
|
|
384
|
+
_openedChanged(opened, oldOpened) {
|
|
372
385
|
if (opened) {
|
|
373
386
|
if (this.disabled || this.readonly) {
|
|
374
387
|
// Disallow programmatic opening when disabled or readonly
|
|
@@ -379,8 +392,6 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
379
392
|
// Avoid multiple announcements when a value gets selected from the dropdown
|
|
380
393
|
this._updateAriaLive(false);
|
|
381
394
|
|
|
382
|
-
overlayElement.style.setProperty('--vaadin-select-text-field-width', `${this._inputContainer.offsetWidth}px`);
|
|
383
|
-
|
|
384
395
|
// Preserve focus-ring to restore it later
|
|
385
396
|
const hasFocusRing = this.hasAttribute('focus-ring');
|
|
386
397
|
this._openedWithFocusRing = hasFocusRing;
|
|
@@ -389,7 +400,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
389
400
|
if (hasFocusRing) {
|
|
390
401
|
this.removeAttribute('focus-ring');
|
|
391
402
|
}
|
|
392
|
-
} else if (
|
|
403
|
+
} else if (oldOpened) {
|
|
393
404
|
if (this._openedWithFocusRing) {
|
|
394
405
|
this.setAttribute('focus-ring', '');
|
|
395
406
|
}
|
|
@@ -401,8 +412,6 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
401
412
|
this._requestValidation();
|
|
402
413
|
}
|
|
403
414
|
}
|
|
404
|
-
|
|
405
|
-
this.__oldOpened = opened;
|
|
406
415
|
}
|
|
407
416
|
|
|
408
417
|
/** @private */
|
|
@@ -590,8 +599,8 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
590
599
|
* @protected
|
|
591
600
|
* @override
|
|
592
601
|
*/
|
|
593
|
-
_shouldRemoveFocus() {
|
|
594
|
-
return !this.
|
|
602
|
+
_shouldRemoveFocus(event) {
|
|
603
|
+
return !this.contains(event.relatedTarget);
|
|
595
604
|
}
|
|
596
605
|
|
|
597
606
|
/**
|
|
@@ -644,13 +653,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
644
653
|
}
|
|
645
654
|
|
|
646
655
|
/** @private */
|
|
647
|
-
|
|
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
|
-
|
|
656
|
+
__dispatchChange() {
|
|
654
657
|
this._requestValidation();
|
|
655
658
|
this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
|
|
656
659
|
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-
|
|
10
|
+
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-base-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-
|
|
11
|
+
import { listBoxStyles } from '@vaadin/list-box/src/styles/vaadin-list-box-base-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,
|
|
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,
|
|
48
|
-
if (opened &&
|
|
49
|
-
|
|
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-base-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-
|
|
12
|
+
import { selectOverlayStyles } from './styles/vaadin-select-overlay-base-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"
|
|
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-
|
|
12
|
+
import { valueButton } from './styles/vaadin-select-value-button-base-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
|
}
|
package/src/vaadin-select.d.ts
CHANGED
|
@@ -26,8 +26,7 @@ export type SelectChangeEvent = Event & {
|
|
|
26
26
|
* Function for rendering the content of the `<vaadin-select>`.
|
|
27
27
|
* Receives two arguments:
|
|
28
28
|
*
|
|
29
|
-
* - `root` The
|
|
30
|
-
* DOM element. Append your content to it.
|
|
29
|
+
* - `root` The internal container DOM element. Append your content to it.
|
|
31
30
|
* - `select` The reference to the `<vaadin-select>` element.
|
|
32
31
|
*/
|
|
33
32
|
export type SelectRenderer = (root: HTMLElement, select: Select) => void;
|
|
@@ -126,43 +125,50 @@ export interface SelectEventMap extends HTMLElementEventMap, SelectCustomEventMa
|
|
|
126
125
|
*
|
|
127
126
|
* The following custom properties are available for styling:
|
|
128
127
|
*
|
|
129
|
-
* Custom property
|
|
130
|
-
*
|
|
131
|
-
* `--vaadin-field-default-width`
|
|
132
|
-
* `--vaadin-select-
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* `
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
128
|
+
* Custom property | Description | Default
|
|
129
|
+
* ---------------------------------|-----------------------------|--------
|
|
130
|
+
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
131
|
+
* `--vaadin-select-overlay-width` | Width of the overlay |
|
|
132
|
+
*
|
|
133
|
+
* The following shadow DOM parts are available for styling:
|
|
134
|
+
*
|
|
135
|
+
* Part name | Description
|
|
136
|
+
* ---------------------|----------------
|
|
137
|
+
* `label` | The label element
|
|
138
|
+
* `input-field` | The element that wraps prefix, value and toggle button
|
|
139
|
+
* `field-button` | Set on the toggle button
|
|
140
|
+
* `error-message` | The error message element
|
|
141
|
+
* `helper-text` | The helper text element wrapper
|
|
142
|
+
* `required-indicator` | The `required` state indicator element
|
|
143
|
+
* `toggle-button` | The toggle button
|
|
144
|
+
* `backdrop` | Backdrop of the overlay
|
|
145
|
+
* `overlay` | The overlay container
|
|
146
|
+
* `content` | The overlay content
|
|
147
|
+
*
|
|
148
|
+
* The following state attributes are available for styling:
|
|
149
|
+
*
|
|
150
|
+
* Attribute | Description
|
|
151
|
+
* ---------------------|---------------------------------
|
|
152
|
+
* `disabled` | Set when the element is disabled
|
|
153
|
+
* `has-value` | Set when the element has a value
|
|
154
|
+
* `has-label` | Set when the element has a label
|
|
155
|
+
* `has-helper` | Set when the element has helper text or slot
|
|
156
|
+
* `has-error-message` | Set when the element has an error message
|
|
157
|
+
* `invalid` | Set when the element is invalid
|
|
158
|
+
* `focused` | Set when the element is focused
|
|
159
|
+
* `focus-ring` | Set when the element is keyboard focused
|
|
160
|
+
* `readonly` | Set when the element is readonly
|
|
161
|
+
* `opened` | Set when the overlay is opened
|
|
162
|
+
* `phone` | Set when the overlay is shown in phone mode
|
|
154
163
|
*
|
|
155
164
|
* ### Internal components
|
|
156
165
|
*
|
|
157
166
|
* In addition to `<vaadin-select>` itself, the following internal
|
|
158
167
|
* components are themable:
|
|
159
168
|
*
|
|
160
|
-
* - `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
|
|
161
169
|
* - `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](#/elements/vaadin-button).
|
|
162
|
-
* - [`<vaadin-
|
|
163
|
-
*
|
|
164
|
-
* Note: the `theme` attribute value set on `<vaadin-select>` is
|
|
165
|
-
* propagated to the internal components listed above.
|
|
170
|
+
* - `<vaadin-select-list-box>` - has the same API as [`<vaadin-list-box>`](#/elements/vaadin-list-box).
|
|
171
|
+
* - `<vaadin-select-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
|
|
166
172
|
*
|
|
167
173
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
168
174
|
*
|