@vaadin/select 25.3.0-alpha1 → 25.3.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/custom-elements.json +451 -42
- package/package.json +16 -16
- package/src/lit/renderer-directives.d.ts +1 -0
- package/src/lit/renderer-directives.js +1 -0
- package/src/vaadin-select-base-mixin.d.ts +6 -2
- package/src/vaadin-select-base-mixin.js +82 -74
- package/src/vaadin-select-item.d.ts +44 -2
- package/src/vaadin-select-item.js +35 -2
- package/src/vaadin-select-list-box.d.ts +20 -1
- package/src/vaadin-select-list-box.js +21 -2
- package/src/vaadin-select-overlay-mixin.js +20 -9
- package/src/vaadin-select-overlay.js +4 -1
- package/src/vaadin-select-value-button.js +1 -0
- package/src/vaadin-select.d.ts +30 -9
- package/src/vaadin-select.js +27 -10
- package/vaadin-select-item.d.ts +1 -0
- package/vaadin-select-item.js +2 -0
- package/vaadin-select-list-box.d.ts +1 -0
- package/vaadin-select-list-box.js +2 -0
- package/web-types.json +156 -10
- package/web-types.lit.json +67 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/select",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/a11y-base": "25.3.0-
|
|
41
|
-
"@vaadin/button": "25.3.0-
|
|
42
|
-
"@vaadin/component-base": "25.3.0-
|
|
43
|
-
"@vaadin/field-base": "25.3.0-
|
|
44
|
-
"@vaadin/input-container": "25.3.0-
|
|
45
|
-
"@vaadin/item": "25.3.0-
|
|
46
|
-
"@vaadin/list-box": "25.3.0-
|
|
47
|
-
"@vaadin/lit-renderer": "25.3.0-
|
|
48
|
-
"@vaadin/overlay": "25.3.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "25.3.0-
|
|
40
|
+
"@vaadin/a11y-base": "25.3.0-alpha10",
|
|
41
|
+
"@vaadin/button": "25.3.0-alpha10",
|
|
42
|
+
"@vaadin/component-base": "25.3.0-alpha10",
|
|
43
|
+
"@vaadin/field-base": "25.3.0-alpha10",
|
|
44
|
+
"@vaadin/input-container": "25.3.0-alpha10",
|
|
45
|
+
"@vaadin/item": "25.3.0-alpha10",
|
|
46
|
+
"@vaadin/list-box": "25.3.0-alpha10",
|
|
47
|
+
"@vaadin/lit-renderer": "25.3.0-alpha10",
|
|
48
|
+
"@vaadin/overlay": "25.3.0-alpha10",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-alpha10",
|
|
50
50
|
"lit": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@vaadin/aura": "25.3.0-
|
|
54
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
55
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
53
|
+
"@vaadin/aura": "25.3.0-alpha10",
|
|
54
|
+
"@vaadin/chai-plugins": "25.3.0-alpha10",
|
|
55
|
+
"@vaadin/test-runner-commands": "25.3.0-alpha10",
|
|
56
56
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
57
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
57
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-alpha10",
|
|
58
58
|
"sinon": "^22.0.0"
|
|
59
59
|
},
|
|
60
60
|
"customElements": "custom-elements.json",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"web-types.json",
|
|
63
63
|
"web-types.lit.json"
|
|
64
64
|
],
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "f2833abdf9b613fa0d0ed216830e3f4de87b7dac"
|
|
66
66
|
}
|
|
@@ -52,6 +52,7 @@ export class SelectRendererDirective extends LitRendererDirective<Select, Select
|
|
|
52
52
|
* @param renderer the renderer callback that returns a Lit template.
|
|
53
53
|
* @param dependencies a single dependency or an array of dependencies
|
|
54
54
|
* which trigger a re-render when changed.
|
|
55
|
+
* @deprecated Use a slotted `<vaadin-select-list-box>` or the `items` property instead
|
|
55
56
|
*/
|
|
56
57
|
export declare function selectRenderer(
|
|
57
58
|
renderer: SelectLitRenderer,
|
|
@@ -56,5 +56,6 @@ export class SelectRendererDirective extends LitRendererDirective {
|
|
|
56
56
|
* @param renderer the renderer callback that returns a Lit template.
|
|
57
57
|
* @param dependencies a single dependency or an array of dependencies
|
|
58
58
|
* which trigger a re-render when changed.
|
|
59
|
+
* @deprecated Use a slotted `<vaadin-select-list-box>` or the `items` property instead
|
|
59
60
|
*/
|
|
60
61
|
export const selectRenderer = directive(SelectRendererDirective);
|
|
@@ -13,7 +13,7 @@ import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegat
|
|
|
13
13
|
import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
14
14
|
import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
15
15
|
import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
16
|
-
import type {
|
|
16
|
+
import type { SelectItemData, SelectRenderer } from './vaadin-select.js';
|
|
17
17
|
|
|
18
18
|
export declare function SelectBaseMixin<T extends Constructor<HTMLElement>>(
|
|
19
19
|
base: T,
|
|
@@ -49,7 +49,7 @@ export declare class SelectBaseMixinClass {
|
|
|
49
49
|
* Note: each item is rendered by default as the internal `<vaadin-select-item>` that is an extension of `<vaadin-item>`.
|
|
50
50
|
* To render the item with a custom component, provide a tag name by the `component` property.
|
|
51
51
|
*/
|
|
52
|
-
items:
|
|
52
|
+
items: SelectItemData[] | null | undefined;
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Set when the select is open
|
|
@@ -62,6 +62,8 @@ export declare class SelectBaseMixinClass {
|
|
|
62
62
|
*
|
|
63
63
|
* - `root` The internal container DOM element. Append your content to it.
|
|
64
64
|
* - `select` The reference to the `<vaadin-select>` element.
|
|
65
|
+
*
|
|
66
|
+
* @deprecated Use a slotted `<vaadin-select-list-box>` or the `items` property instead
|
|
65
67
|
*/
|
|
66
68
|
renderer: SelectRenderer | undefined;
|
|
67
69
|
|
|
@@ -110,6 +112,8 @@ export declare class SelectBaseMixinClass {
|
|
|
110
112
|
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
111
113
|
*
|
|
112
114
|
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
115
|
+
*
|
|
116
|
+
* @deprecated This method is deprecated and will be removed in Vaadin 26
|
|
113
117
|
*/
|
|
114
118
|
requestContentUpdate(): void;
|
|
115
119
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { setAriaIDReference } from '@vaadin/a11y-base/src/aria-id-reference.js';
|
|
7
6
|
import { DelegateFocusMixin } from '@vaadin/a11y-base/src/delegate-focus-mixin.js';
|
|
8
7
|
import { KeyboardMixin } from '@vaadin/a11y-base/src/keyboard-mixin.js';
|
|
9
8
|
import { DelegateStateMixin } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
9
|
+
import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
10
10
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
11
11
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
12
12
|
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
@@ -37,11 +37,10 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
37
37
|
* Note: each item is rendered by default as the internal `<vaadin-select-item>` that is an extension of `<vaadin-item>`.
|
|
38
38
|
* To render the item with a custom component, provide a tag name by the `component` property.
|
|
39
39
|
*
|
|
40
|
-
* @type {!Array<!
|
|
40
|
+
* @type {!Array<!SelectItemData>}
|
|
41
41
|
*/
|
|
42
42
|
items: {
|
|
43
43
|
type: Array,
|
|
44
|
-
observer: '__itemsChanged',
|
|
45
44
|
},
|
|
46
45
|
|
|
47
46
|
/**
|
|
@@ -62,7 +61,9 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
62
61
|
*
|
|
63
62
|
* - `root` The internal container DOM element. Append your content to it.
|
|
64
63
|
* - `select` The reference to the `<vaadin-select>` element.
|
|
64
|
+
*
|
|
65
65
|
* @type {!SelectRenderer | undefined}
|
|
66
|
+
* @deprecated Use a slotted `<vaadin-select-list-box>` or the `items` property instead
|
|
66
67
|
*/
|
|
67
68
|
renderer: {
|
|
68
69
|
type: Object,
|
|
@@ -138,6 +139,15 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
138
139
|
|
|
139
140
|
/** @private */
|
|
140
141
|
_items: Object,
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The `<vaadin-select-list-box>` slotted directly into the overlay slot.
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
__slottedListBox: {
|
|
148
|
+
type: Object,
|
|
149
|
+
sync: true,
|
|
150
|
+
},
|
|
141
151
|
};
|
|
142
152
|
}
|
|
143
153
|
|
|
@@ -199,6 +209,38 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
199
209
|
if (props.has('_phone')) {
|
|
200
210
|
this.toggleAttribute('phone', this._phone);
|
|
201
211
|
}
|
|
212
|
+
|
|
213
|
+
if (props.has('items') || props.has('renderer') || props.has('__slottedListBox')) {
|
|
214
|
+
if (this.__slottedListBox && (this.items?.length || this.renderer)) {
|
|
215
|
+
throw new Error(
|
|
216
|
+
'A slotted <vaadin-select-list-box> cannot be used together with the "items" or "renderer" property.',
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (props.has('items')) {
|
|
222
|
+
this._overlayElement.requestContentUpdate();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (props.has('__slottedListBox')) {
|
|
226
|
+
const slottedListBox = this.__slottedListBox;
|
|
227
|
+
if (slottedListBox) {
|
|
228
|
+
this._assignMenuElement(slottedListBox);
|
|
229
|
+
} else if (props.get('__slottedListBox')) {
|
|
230
|
+
this._menuElement = null;
|
|
231
|
+
this._items = null;
|
|
232
|
+
this.__lastMenuElement = null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (props.has('accessibleName')) {
|
|
237
|
+
this._srLabelController.setLabel(this.accessibleName);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Validate when the required constraint is removed.
|
|
241
|
+
if (props.has('required') && this.required === false) {
|
|
242
|
+
this._requestValidation();
|
|
243
|
+
}
|
|
202
244
|
}
|
|
203
245
|
|
|
204
246
|
/**
|
|
@@ -206,6 +248,8 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
206
248
|
* While performing the update, it invokes the renderer passed in the `renderer` property.
|
|
207
249
|
*
|
|
208
250
|
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
251
|
+
*
|
|
252
|
+
* @deprecated This method is deprecated and will be removed in Vaadin 26
|
|
209
253
|
*/
|
|
210
254
|
requestContentUpdate() {
|
|
211
255
|
if (!this._overlayElement) {
|
|
@@ -216,29 +260,14 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
216
260
|
}
|
|
217
261
|
|
|
218
262
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
263
|
+
* Detects a `<vaadin-select-list-box>` slotted directly into the overlay
|
|
264
|
+
* slot (instead of the default one rendered into slotted `div` element).
|
|
221
265
|
*
|
|
222
|
-
* @
|
|
223
|
-
* @override
|
|
224
|
-
*/
|
|
225
|
-
_requiredChanged(required) {
|
|
226
|
-
super._requiredChanged(required);
|
|
227
|
-
|
|
228
|
-
if (required === false) {
|
|
229
|
-
this._requestValidation();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @param {SelectItem[] | undefined | null} newItems
|
|
235
|
-
* @param {SelectItem[] | undefined | null} oldItems
|
|
266
|
+
* @param {!Event} e
|
|
236
267
|
* @private
|
|
237
268
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.requestContentUpdate();
|
|
241
|
-
}
|
|
269
|
+
__onOverlaySlotChange(e) {
|
|
270
|
+
this.__slottedListBox = e.target.assignedElements().find((el) => el._hasVaadinListMixin);
|
|
242
271
|
}
|
|
243
272
|
|
|
244
273
|
/**
|
|
@@ -438,11 +467,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
438
467
|
/** @private */
|
|
439
468
|
_updateAriaLive(ariaLive) {
|
|
440
469
|
if (this.focusElement) {
|
|
441
|
-
|
|
442
|
-
this.focusElement.setAttribute('aria-live', 'polite');
|
|
443
|
-
} else {
|
|
444
|
-
this.focusElement.removeAttribute('aria-live');
|
|
445
|
-
}
|
|
470
|
+
setOrRemoveAttribute(this.focusElement, 'aria-live', ariaLive && 'polite');
|
|
446
471
|
}
|
|
447
472
|
}
|
|
448
473
|
|
|
@@ -467,7 +492,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
467
492
|
}
|
|
468
493
|
|
|
469
494
|
/**
|
|
470
|
-
* @param {!
|
|
495
|
+
* @param {!SelectItemData} item
|
|
471
496
|
* @private
|
|
472
497
|
*/
|
|
473
498
|
__createItemElement(item) {
|
|
@@ -503,44 +528,6 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
503
528
|
itemElement.setAttribute('id', this._itemId);
|
|
504
529
|
}
|
|
505
530
|
|
|
506
|
-
/**
|
|
507
|
-
* @param {string} accessibleName
|
|
508
|
-
* @protected
|
|
509
|
-
*/
|
|
510
|
-
_accessibleNameChanged(accessibleName) {
|
|
511
|
-
this._srLabelController.setLabel(accessibleName);
|
|
512
|
-
this._setCustomAriaLabelledBy(accessibleName ? this._srLabelController.defaultId : null);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* @param {string} accessibleNameRef
|
|
517
|
-
* @protected
|
|
518
|
-
*/
|
|
519
|
-
_accessibleNameRefChanged(accessibleNameRef) {
|
|
520
|
-
this._setCustomAriaLabelledBy(accessibleNameRef);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* @param {string} ariaLabelledby
|
|
525
|
-
* @private
|
|
526
|
-
*/
|
|
527
|
-
_setCustomAriaLabelledBy(ariaLabelledby) {
|
|
528
|
-
const labelId = this._getLabelIdWithItemId(ariaLabelledby);
|
|
529
|
-
this._fieldAriaController.setLabelId(labelId, true);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* @param {string | null} labelId
|
|
534
|
-
* @returns string | null
|
|
535
|
-
* @private
|
|
536
|
-
*/
|
|
537
|
-
_getLabelIdWithItemId(labelId) {
|
|
538
|
-
const selected = this._items ? this._items[this._menuElement.selected] : false;
|
|
539
|
-
const itemId = selected || this.placeholder ? this._itemId : '';
|
|
540
|
-
|
|
541
|
-
return labelId ? `${labelId} ${itemId}`.trim() : null;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
531
|
/** @private */
|
|
545
532
|
__updateValueButton() {
|
|
546
533
|
const valueButton = this.focusElement;
|
|
@@ -572,13 +559,7 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
572
559
|
delete this._selectedChanging;
|
|
573
560
|
}
|
|
574
561
|
|
|
575
|
-
|
|
576
|
-
selected || this.placeholder ? { newId: this._itemId } : { oldId: this._itemId };
|
|
577
|
-
|
|
578
|
-
setAriaIDReference(valueButton, 'aria-labelledby', labelledIdReferenceConfig);
|
|
579
|
-
if (this.accessibleName || this.accessibleNameRef) {
|
|
580
|
-
this._setCustomAriaLabelledBy(this.accessibleNameRef || this._srLabelController.defaultId);
|
|
581
|
-
}
|
|
562
|
+
this.__updateFieldAriaControllerLabelledBy();
|
|
582
563
|
}
|
|
583
564
|
|
|
584
565
|
/** @private */
|
|
@@ -674,4 +655,31 @@ export const SelectBaseMixin = (superClass) =>
|
|
|
674
655
|
this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
|
|
675
656
|
this.__dispatchChangePending = false;
|
|
676
657
|
}
|
|
658
|
+
|
|
659
|
+
/** @override */
|
|
660
|
+
__updateFieldAriaControllerLabel() {
|
|
661
|
+
// NO-OP
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** @override */
|
|
665
|
+
__updateFieldAriaControllerLabelledBy() {
|
|
666
|
+
let labelId;
|
|
667
|
+
if (this.accessibleNameRef) {
|
|
668
|
+
labelId = this.accessibleNameRef;
|
|
669
|
+
} else if (this.accessibleName) {
|
|
670
|
+
labelId = this._srLabelController.defaultId;
|
|
671
|
+
} else if (this.hasAttribute('has-label')) {
|
|
672
|
+
labelId = this._labelNode?.id;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const selectedItem = this._items?.[this._menuElement.selected];
|
|
676
|
+
const itemId = selectedItem || this.placeholder ? this._itemId : null;
|
|
677
|
+
|
|
678
|
+
const ids = [labelId, itemId].filter(Boolean);
|
|
679
|
+
if (ids.length > 0) {
|
|
680
|
+
this._fieldAriaController.setLabelledBy(ids.join(' '));
|
|
681
|
+
} else {
|
|
682
|
+
this._fieldAriaController.setLabelledBy(null);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
677
685
|
};
|
|
@@ -8,9 +8,51 @@ import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* `<vaadin-select-item>` is a Web Component for creating `<vaadin-select>` items.
|
|
12
|
+
*
|
|
13
|
+
* ### Styling
|
|
14
|
+
*
|
|
15
|
+
* The following shadow DOM parts are available for styling:
|
|
16
|
+
*
|
|
17
|
+
* Part name | Description
|
|
18
|
+
* -------------|----------------
|
|
19
|
+
* `checkmark` | The graphical checkmark shown for a selected item
|
|
20
|
+
* `content` | The element that wraps the slot
|
|
21
|
+
*
|
|
22
|
+
* The following state attributes are available for styling:
|
|
23
|
+
*
|
|
24
|
+
* Attribute | Description
|
|
25
|
+
* -------------|-------------
|
|
26
|
+
* `active` | Set when the item is pressed down, either with mouse, touch or the keyboard.
|
|
27
|
+
* `disabled` | Set when the item is disabled.
|
|
28
|
+
* `focus-ring` | Set when the item is focused using the keyboard.
|
|
29
|
+
* `focused` | Set when the item is focused.
|
|
30
|
+
* `selected` | Set when the item is selected
|
|
31
|
+
*
|
|
32
|
+
* The following custom CSS properties are available for styling:
|
|
33
|
+
*
|
|
34
|
+
* Custom CSS property |
|
|
35
|
+
* :----------------------------------|
|
|
36
|
+
* | `--vaadin-item-border-radius` |
|
|
37
|
+
* | `--vaadin-item-checkmark-color` |
|
|
38
|
+
* | `--vaadin-item-gap` |
|
|
39
|
+
* | `--vaadin-item-height` |
|
|
40
|
+
* | `--vaadin-item-padding` |
|
|
41
|
+
* | `--vaadin-item-text-align` |
|
|
42
|
+
*
|
|
43
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
12
44
|
*/
|
|
13
|
-
declare class SelectItem extends ItemMixin(DirMixin(ThemableMixin(HTMLElement))) {
|
|
45
|
+
declare class SelectItem extends ItemMixin(DirMixin(ThemableMixin(HTMLElement))) {
|
|
46
|
+
/**
|
|
47
|
+
* Submittable string value. The default value is the trimmed text content of the element.
|
|
48
|
+
*/
|
|
49
|
+
value: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* String that can be set to visually represent the selected item in `vaadin-select`.
|
|
53
|
+
*/
|
|
54
|
+
label: string | undefined;
|
|
55
|
+
}
|
|
14
56
|
|
|
15
57
|
declare global {
|
|
16
58
|
interface HTMLElementTagNameMap {
|
|
@@ -13,11 +13,44 @@ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection
|
|
|
13
13
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* `<vaadin-select-item>` is a Web Component for creating `<vaadin-select>` items.
|
|
17
17
|
*
|
|
18
|
+
* ### Styling
|
|
19
|
+
*
|
|
20
|
+
* The following shadow DOM parts are available for styling:
|
|
21
|
+
*
|
|
22
|
+
* Part name | Description
|
|
23
|
+
* -------------|----------------
|
|
24
|
+
* `checkmark` | The graphical checkmark shown for a selected item
|
|
25
|
+
* `content` | The element that wraps the slot
|
|
26
|
+
*
|
|
27
|
+
* The following state attributes are available for styling:
|
|
28
|
+
*
|
|
29
|
+
* Attribute | Description
|
|
30
|
+
* -------------|-------------
|
|
31
|
+
* `active` | Set when the item is pressed down, either with mouse, touch or the keyboard.
|
|
32
|
+
* `disabled` | Set when the item is disabled.
|
|
33
|
+
* `focus-ring` | Set when the item is focused using the keyboard.
|
|
34
|
+
* `focused` | Set when the item is focused.
|
|
35
|
+
* `selected` | Set when the item is selected
|
|
36
|
+
*
|
|
37
|
+
* The following custom CSS properties are available for styling:
|
|
38
|
+
*
|
|
39
|
+
* Custom CSS property |
|
|
40
|
+
* :----------------------------------|
|
|
41
|
+
* | `--vaadin-item-border-radius` |
|
|
42
|
+
* | `--vaadin-item-checkmark-color` |
|
|
43
|
+
* | `--vaadin-item-gap` |
|
|
44
|
+
* | `--vaadin-item-height` |
|
|
45
|
+
* | `--vaadin-item-padding` |
|
|
46
|
+
* | `--vaadin-item-text-align` |
|
|
47
|
+
*
|
|
48
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
49
|
+
*
|
|
50
|
+
* @prop {string} label - String that can be set to visually represent the selected item in `vaadin-select`.
|
|
51
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
18
52
|
* @customElement vaadin-select-item
|
|
19
53
|
* @extends HTMLElement
|
|
20
|
-
* @protected
|
|
21
54
|
*/
|
|
22
55
|
class SelectItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
23
56
|
static get is() {
|
|
@@ -8,7 +8,26 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* `<vaadin-select-list-box>` is a Web Component for wrapping `<vaadin-select>` items.
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <vaadin-select>
|
|
15
|
+
* <vaadin-select-list-box slot="overlay">
|
|
16
|
+
* <vaadin-select-item value="foo">Foo</vaadin-select-item>
|
|
17
|
+
* <vaadin-select-item value="bar">Bar</vaadin-select-item>
|
|
18
|
+
* </vaadin-select-list-box>
|
|
19
|
+
* </vaadin-select>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* ### Styling
|
|
23
|
+
*
|
|
24
|
+
* The following shadow DOM parts are available for styling:
|
|
25
|
+
*
|
|
26
|
+
* Part name | Description
|
|
27
|
+
* ------------------|------------------------
|
|
28
|
+
* `items` | The items container
|
|
29
|
+
*
|
|
30
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
12
31
|
*/
|
|
13
32
|
declare class SelectListBox extends ListMixin(DirMixin(ThemableMixin(HTMLElement))) {}
|
|
14
33
|
|
|
@@ -13,11 +13,30 @@ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection
|
|
|
13
13
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* `<vaadin-select-list-box>` is a Web Component for wrapping `<vaadin-select>` items.
|
|
17
17
|
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <vaadin-select>
|
|
20
|
+
* <vaadin-select-list-box slot="overlay">
|
|
21
|
+
* <vaadin-select-item value="foo">Foo</vaadin-select-item>
|
|
22
|
+
* <vaadin-select-item value="bar">Bar</vaadin-select-item>
|
|
23
|
+
* </vaadin-select-list-box>
|
|
24
|
+
* </vaadin-select>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ### Styling
|
|
28
|
+
*
|
|
29
|
+
* The following shadow DOM parts are available for styling:
|
|
30
|
+
*
|
|
31
|
+
* Part name | Description
|
|
32
|
+
* ------------------|------------------------
|
|
33
|
+
* `items` | The items container
|
|
34
|
+
*
|
|
35
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
36
|
+
*
|
|
37
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
18
38
|
* @customElement vaadin-select-list-box
|
|
19
39
|
* @extends HTMLElement
|
|
20
|
-
* @protected
|
|
21
40
|
*/
|
|
22
41
|
class SelectListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
23
42
|
static get is() {
|
|
@@ -9,8 +9,14 @@ import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin
|
|
|
9
9
|
|
|
10
10
|
export const SelectOverlayMixin = (superClass) =>
|
|
11
11
|
class SelectOverlayMixin extends PositionMixin(OverlayMixin(DirMixin(superClass))) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** @protected */
|
|
13
|
+
willUpdate(props) {
|
|
14
|
+
super.willUpdate(props);
|
|
15
|
+
|
|
16
|
+
// Update width here so that `PositionMixin` uses correct width in `updated()`.
|
|
17
|
+
if ((props.has('opened') || props.has('positionTarget')) && this.opened && this.positionTarget) {
|
|
18
|
+
this._updateOverlayWidth();
|
|
19
|
+
}
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
/** @protected */
|
|
@@ -21,12 +27,14 @@ export const SelectOverlayMixin = (superClass) =>
|
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
/**
|
|
24
|
-
* Override method from OverlayFocusMixin to use
|
|
30
|
+
* Override method from OverlayFocusMixin to use the content root that
|
|
31
|
+
* actually holds the focused item, so focus is restored on close.
|
|
32
|
+
*
|
|
25
33
|
* @protected
|
|
26
34
|
* @override
|
|
27
35
|
*/
|
|
28
36
|
get _contentRoot() {
|
|
29
|
-
return this._rendererRoot;
|
|
37
|
+
return this.owner.__slottedListBox || this._rendererRoot;
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
/**
|
|
@@ -70,14 +78,17 @@ export const SelectOverlayMixin = (superClass) =>
|
|
|
70
78
|
|
|
71
79
|
/** @protected */
|
|
72
80
|
_getMenuElement() {
|
|
73
|
-
|
|
81
|
+
const slot = this.owner.shadowRoot.querySelector('slot[name="overlay"]');
|
|
82
|
+
const assigned = slot.assignedElements();
|
|
83
|
+
return (
|
|
84
|
+
assigned.find((el) => el._hasVaadinListMixin) ||
|
|
85
|
+
assigned.flatMap((el) => [...el.children]).find((el) => el._hasVaadinListMixin)
|
|
86
|
+
);
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
/** @private */
|
|
77
|
-
_updateOverlayWidth(
|
|
78
|
-
|
|
79
|
-
this.style.setProperty('--_vaadin-select-overlay-default-width', `${positionTarget.offsetWidth}px`);
|
|
80
|
-
}
|
|
90
|
+
_updateOverlayWidth() {
|
|
91
|
+
this.style.setProperty('--_vaadin-select-overlay-default-width', `${this.positionTarget.offsetWidth}px`);
|
|
81
92
|
}
|
|
82
93
|
|
|
83
94
|
requestContentUpdate() {
|
|
@@ -15,11 +15,12 @@ import { SelectOverlayMixin } from './vaadin-select-overlay-mixin.js';
|
|
|
15
15
|
/**
|
|
16
16
|
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
17
17
|
*
|
|
18
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
18
19
|
* @customElement vaadin-select-overlay
|
|
19
20
|
* @extends HTMLElement
|
|
20
21
|
* @private
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
23
24
|
static get is() {
|
|
24
25
|
return 'vaadin-select-overlay';
|
|
25
26
|
}
|
|
@@ -51,3 +52,5 @@ export class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
defineCustomElement(SelectOverlay);
|
|
55
|
+
|
|
56
|
+
export { SelectOverlay };
|
|
@@ -14,6 +14,7 @@ import { valueButton } from './styles/vaadin-select-value-button-base-styles.js'
|
|
|
14
14
|
/**
|
|
15
15
|
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
16
16
|
*
|
|
17
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
17
18
|
* @customElement vaadin-select-value-button
|
|
18
19
|
* @extends HTMLElement
|
|
19
20
|
* @protected
|