@vaadin/select 24.8.4 → 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/README.md +0 -29
- package/package.json +19 -20
- package/src/styles/vaadin-select-base-styles.js +38 -0
- package/{theme/material/vaadin-lit-select.d.ts → src/styles/vaadin-select-core-styles.d.ts} +3 -2
- package/src/{vaadin-select-core-styles.js → styles/vaadin-select-core-styles.js} +4 -0
- package/src/styles/vaadin-select-overlay-base-styles.js +21 -0
- package/src/{vaadin-select-overlay-core-styles.js → styles/vaadin-select-overlay-core-styles.js} +1 -1
- package/src/styles/vaadin-select-value-button-base-styles.js +30 -0
- package/src/vaadin-select-base-mixin.js +31 -29
- package/src/vaadin-select-item.js +30 -14
- package/src/vaadin-select-list-box.d.ts +1 -2
- package/src/vaadin-select-list-box.js +17 -14
- package/src/vaadin-select-overlay-mixin.js +31 -12
- package/src/vaadin-select-overlay.js +24 -12
- package/src/vaadin-select-value-button.js +12 -7
- package/src/vaadin-select.d.ts +14 -11
- package/src/vaadin-select.js +52 -73
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
- package/src/vaadin-lit-select-item.js +0 -63
- package/src/vaadin-lit-select-list-box.js +0 -71
- package/src/vaadin-lit-select-overlay.js +0 -53
- package/src/vaadin-lit-select-value-button.js +0 -42
- package/src/vaadin-lit-select.js +0 -109
- package/theme/lumo/vaadin-lit-select.d.ts +0 -7
- package/theme/lumo/vaadin-lit-select.js +0 -7
- package/theme/material/vaadin-lit-select.js +0 -7
- package/theme/material/vaadin-select-styles.d.ts +0 -7
- package/theme/material/vaadin-select-styles.js +0 -77
- package/theme/material/vaadin-select.d.ts +0 -7
- package/theme/material/vaadin-select.js +0 -7
- package/vaadin-lit-select.d.ts +0 -1
- package/vaadin-lit-select.js +0 -2
- /package/src/{vaadin-select-core-styles.d.ts → styles/vaadin-select-base-styles.d.ts} +0 -0
- /package/src/{vaadin-select-value-button-core-styles.js → styles/vaadin-select-value-button-core-styles.js} +0 -0
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
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
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
11
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
+
import { valueButton } from './styles/vaadin-select-value-button-core-styles.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
@@ -20,12 +20,17 @@ registerStyles('vaadin-select-value-button', valueButton, { moduleId: 'vaadin-se
|
|
|
20
20
|
* @mixes ThemableMixin
|
|
21
21
|
* @protected
|
|
22
22
|
*/
|
|
23
|
-
class SelectValueButton extends ButtonMixin(ThemableMixin(
|
|
23
|
+
class SelectValueButton extends ButtonMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))) {
|
|
24
24
|
static get is() {
|
|
25
25
|
return 'vaadin-select-value-button';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
static get
|
|
28
|
+
static get styles() {
|
|
29
|
+
return valueButton;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @protected */
|
|
33
|
+
render() {
|
|
29
34
|
return html`
|
|
30
35
|
<div class="vaadin-button-container">
|
|
31
36
|
<span part="label">
|
package/src/vaadin-select.d.ts
CHANGED
|
@@ -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
|
|
130
|
-
*
|
|
131
|
-
* `--vaadin-field-default-width`
|
|
132
|
-
* `--vaadin-select-
|
|
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
|
|
142
|
-
*
|
|
143
|
-
* `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
|
|
148
|
-
*
|
|
149
|
-
* `opened` | Set when the select is open
|
|
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>`.
|
package/src/vaadin-select.js
CHANGED
|
@@ -8,19 +8,17 @@ import './vaadin-select-item.js';
|
|
|
8
8
|
import './vaadin-select-list-box.js';
|
|
9
9
|
import './vaadin-select-overlay.js';
|
|
10
10
|
import './vaadin-select-value-button.js';
|
|
11
|
-
import { html,
|
|
11
|
+
import { html, LitElement } from 'lit';
|
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
13
|
import { screenReaderOnly } from '@vaadin/a11y-base/src/styles/sr-only-styles.js';
|
|
13
14
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
14
15
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
15
|
-
import {
|
|
16
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
16
17
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
17
|
-
import {
|
|
18
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
19
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
20
|
+
import { selectStyles } from './styles/vaadin-select-core-styles.js';
|
|
18
21
|
import { SelectBaseMixin } from './vaadin-select-base-mixin.js';
|
|
19
|
-
import { selectStyles } from './vaadin-select-core-styles.js';
|
|
20
|
-
|
|
21
|
-
registerStyles('vaadin-select', [inputFieldShared, screenReaderOnly, selectStyles], {
|
|
22
|
-
moduleId: 'vaadin-select-styles',
|
|
23
|
-
});
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* `<vaadin-select>` is a Web Component for selecting values from a list of items.
|
|
@@ -82,11 +80,10 @@ registerStyles('vaadin-select', [inputFieldShared, screenReaderOnly, selectStyle
|
|
|
82
80
|
*
|
|
83
81
|
* The following custom properties are available for styling:
|
|
84
82
|
*
|
|
85
|
-
* Custom property
|
|
86
|
-
*
|
|
87
|
-
* `--vaadin-field-default-width`
|
|
88
|
-
* `--vaadin-select-
|
|
89
|
-
* `--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 |
|
|
90
87
|
*
|
|
91
88
|
* `<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
92
89
|
* See [`<vaadin-text-field>`](#/elements/vaadin-text-field) for the styling documentation.
|
|
@@ -94,15 +91,19 @@ registerStyles('vaadin-select', [inputFieldShared, screenReaderOnly, selectStyle
|
|
|
94
91
|
*
|
|
95
92
|
* In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
|
|
96
93
|
*
|
|
97
|
-
* Part name
|
|
98
|
-
*
|
|
99
|
-
* `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
|
|
100
100
|
*
|
|
101
101
|
* In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
|
|
102
102
|
*
|
|
103
|
-
* Attribute | Description
|
|
104
|
-
*
|
|
105
|
-
* `opened` | Set when the select is open
|
|
103
|
+
* Attribute | Description
|
|
104
|
+
* ----------|-----------------------------
|
|
105
|
+
* `opened` | Set when the select is open
|
|
106
|
+
* `phone` | Set when the overlay is shown in phone mode
|
|
106
107
|
*
|
|
107
108
|
* There are two exceptions in terms of styling compared to `<vaadin-text-field>`:
|
|
108
109
|
* - the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.
|
|
@@ -134,30 +135,35 @@ registerStyles('vaadin-select', [inputFieldShared, screenReaderOnly, selectStyle
|
|
|
134
135
|
* @mixes SelectBaseMixin
|
|
135
136
|
* @mixes ThemableMixin
|
|
136
137
|
*/
|
|
137
|
-
class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(
|
|
138
|
+
class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
138
139
|
static get is() {
|
|
139
140
|
return 'vaadin-select';
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
static get
|
|
143
|
+
static get styles() {
|
|
144
|
+
return [inputFieldShared, screenReaderOnly, selectStyles];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** @protected */
|
|
148
|
+
render() {
|
|
143
149
|
return html`
|
|
144
150
|
<div class="vaadin-select-container">
|
|
145
|
-
<div part="label"
|
|
151
|
+
<div part="label" @click="${this._onClick}">
|
|
146
152
|
<slot name="label"></slot>
|
|
147
|
-
<span part="required-indicator" aria-hidden="true"
|
|
153
|
+
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
148
154
|
</div>
|
|
149
155
|
|
|
150
156
|
<vaadin-input-container
|
|
151
157
|
part="input-field"
|
|
152
|
-
readonly="
|
|
153
|
-
disabled="
|
|
154
|
-
invalid="
|
|
155
|
-
theme
|
|
156
|
-
|
|
158
|
+
.readonly="${this.readonly}"
|
|
159
|
+
.disabled="${this.disabled}"
|
|
160
|
+
.invalid="${this.invalid}"
|
|
161
|
+
theme="${ifDefined(this._theme)}"
|
|
162
|
+
@click="${this._onClick}"
|
|
157
163
|
>
|
|
158
164
|
<slot name="prefix" slot="prefix"></slot>
|
|
159
165
|
<slot name="value"></slot>
|
|
160
|
-
<div part="toggle-button" slot="suffix" aria-hidden="true"
|
|
166
|
+
<div part="toggle-button" slot="suffix" aria-hidden="true" @mousedown="${this._onToggleMouseDown}"></div>
|
|
161
167
|
</vaadin-input-container>
|
|
162
168
|
|
|
163
169
|
<div part="helper-text">
|
|
@@ -171,15 +177,20 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolymerElement))
|
|
|
171
177
|
|
|
172
178
|
<vaadin-select-overlay
|
|
173
179
|
id="overlay"
|
|
174
|
-
owner="
|
|
175
|
-
|
|
176
|
-
opened="{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
.owner="${this}"
|
|
181
|
+
.positionTarget="${this._inputContainer}"
|
|
182
|
+
.opened="${this.opened}"
|
|
183
|
+
.withBackdrop="${this._phone}"
|
|
184
|
+
.renderer="${this.renderer || this.__defaultRenderer}"
|
|
185
|
+
?phone="${this._phone}"
|
|
186
|
+
theme="${ifDefined(this._theme)}"
|
|
187
|
+
?no-vertical-overlap="${this.noVerticalOverlap}"
|
|
188
|
+
exportparts="backdrop, overlay, content"
|
|
189
|
+
@opened-changed="${this._onOpenedChanged}"
|
|
190
|
+
@vaadin-overlay-open="${this._onOverlayOpen}"
|
|
191
|
+
>
|
|
192
|
+
<slot name="overlay"></slot>
|
|
193
|
+
</vaadin-select-overlay>
|
|
183
194
|
|
|
184
195
|
<slot name="tooltip"></slot>
|
|
185
196
|
<div class="sr-only">
|
|
@@ -188,41 +199,9 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolymerElement))
|
|
|
188
199
|
`;
|
|
189
200
|
}
|
|
190
201
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
__overlayOwner: {
|
|
195
|
-
value() {
|
|
196
|
-
return this;
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
static get observers() {
|
|
203
|
-
return ['_rendererChanged(renderer, _overlayElement)'];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/** @protected */
|
|
207
|
-
ready() {
|
|
208
|
-
super.ready();
|
|
209
|
-
|
|
210
|
-
processTemplates(this);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @param {SelectRenderer | undefined | null} renderer
|
|
215
|
-
* @param {SelectOverlay | undefined} overlay
|
|
216
|
-
* @private
|
|
217
|
-
*/
|
|
218
|
-
_rendererChanged(renderer, overlay) {
|
|
219
|
-
if (!overlay) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
overlay.renderer = renderer || this.__defaultRenderer;
|
|
224
|
-
|
|
225
|
-
this.requestContentUpdate();
|
|
202
|
+
/** @private */
|
|
203
|
+
_onOpenedChanged(event) {
|
|
204
|
+
this.opened = event.detail.value;
|
|
226
205
|
}
|
|
227
206
|
|
|
228
207
|
/** @private */
|
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": "
|
|
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
|
|
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",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/select",
|
|
4
|
-
"version": "
|
|
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
|
|
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,63 +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 { html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { itemStyles } from '@vaadin/item/src/vaadin-item-core-styles.js';
|
|
11
|
-
import { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
12
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
16
|
-
*
|
|
17
|
-
* @extends HTMLElement
|
|
18
|
-
* @mixes DirMixin
|
|
19
|
-
* @mixes ItemMixin
|
|
20
|
-
* @mixes ThemableMixin
|
|
21
|
-
* @protected
|
|
22
|
-
*/
|
|
23
|
-
class SelectItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
24
|
-
static get is() {
|
|
25
|
-
return 'vaadin-select-item';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get styles() {
|
|
29
|
-
return itemStyles;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static get properties() {
|
|
33
|
-
return {
|
|
34
|
-
/**
|
|
35
|
-
* Use property instead of setting an attribute in `ready()`
|
|
36
|
-
* for cloning the selected item attached to the value button:
|
|
37
|
-
* in this case, `role` attribute is removed synchronously, and
|
|
38
|
-
* using `ready()` would incorrectly restore the attribute.
|
|
39
|
-
*
|
|
40
|
-
* @protected
|
|
41
|
-
*/
|
|
42
|
-
role: {
|
|
43
|
-
type: String,
|
|
44
|
-
value: 'option',
|
|
45
|
-
reflectToAttribute: true,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @protected */
|
|
51
|
-
render() {
|
|
52
|
-
return html`
|
|
53
|
-
<span part="checkmark" aria-hidden="true"></span>
|
|
54
|
-
<div part="content">
|
|
55
|
-
<slot></slot>
|
|
56
|
-
</div>
|
|
57
|
-
`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
defineCustomElement(SelectItem);
|
|
62
|
-
|
|
63
|
-
export { SelectItem };
|
|
@@ -1,71 +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 { html, LitElement } from 'lit';
|
|
7
|
-
import { ListMixin } from '@vaadin/a11y-base/src/list-mixin.js';
|
|
8
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
|
-
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
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';
|
|
12
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
16
|
-
*
|
|
17
|
-
* @extends HTMLElement
|
|
18
|
-
* @mixes DirMixin
|
|
19
|
-
* @mixes ListMixin
|
|
20
|
-
* @mixes ThemableMixin
|
|
21
|
-
* @protected
|
|
22
|
-
*/
|
|
23
|
-
class SelectListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
24
|
-
static get is() {
|
|
25
|
-
return 'vaadin-select-list-box';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static get styles() {
|
|
29
|
-
return listBoxStyles;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static get properties() {
|
|
33
|
-
return {
|
|
34
|
-
// We don't need to define this property since super default is vertical,
|
|
35
|
-
// but we don't want it to be modified, or be shown in the API docs.
|
|
36
|
-
/** @private */
|
|
37
|
-
orientation: {
|
|
38
|
-
readOnly: true,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @return {!HTMLElement}
|
|
45
|
-
* @protected
|
|
46
|
-
* @override
|
|
47
|
-
*/
|
|
48
|
-
get _scrollerElement() {
|
|
49
|
-
return this.shadowRoot.querySelector('[part="items"]');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** @protected */
|
|
53
|
-
render() {
|
|
54
|
-
return html`
|
|
55
|
-
<div part="items">
|
|
56
|
-
<slot></slot>
|
|
57
|
-
</div>
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** @protected */
|
|
62
|
-
ready() {
|
|
63
|
-
super.ready();
|
|
64
|
-
|
|
65
|
-
this.setAttribute('role', 'listbox');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
defineCustomElement(SelectListBox);
|
|
70
|
-
|
|
71
|
-
export { SelectListBox };
|
|
@@ -1,53 +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 { html, LitElement } from 'lit';
|
|
7
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
-
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
10
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
-
import { selectOverlayStyles } from './vaadin-select-overlay-core-styles.js';
|
|
12
|
-
import { SelectOverlayMixin } from './vaadin-select-overlay-mixin.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
16
|
-
*
|
|
17
|
-
* @extends HTMLElement
|
|
18
|
-
* @mixes SelectOverlayMixin
|
|
19
|
-
* @mixes ThemableMixin
|
|
20
|
-
* @protected
|
|
21
|
-
*/
|
|
22
|
-
class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
23
|
-
static get is() {
|
|
24
|
-
return 'vaadin-select-overlay';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static get styles() {
|
|
28
|
-
return [overlayStyles, selectOverlayStyles];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** @protected */
|
|
32
|
-
render() {
|
|
33
|
-
return html`
|
|
34
|
-
<div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
35
|
-
<div part="overlay" id="overlay" tabindex="0">
|
|
36
|
-
<div part="content" id="content">
|
|
37
|
-
<slot></slot>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @protected */
|
|
44
|
-
updated(props) {
|
|
45
|
-
super.updated(props);
|
|
46
|
-
|
|
47
|
-
if (props.has('renderer')) {
|
|
48
|
-
this.requestContentUpdate();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
defineCustomElement(SelectOverlay);
|
|
@@ -1,42 +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 { html, LitElement } from 'lit';
|
|
7
|
-
import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js';
|
|
8
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
-
import { valueButton } from './vaadin-select-value-button-core-styles.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
15
|
-
*
|
|
16
|
-
* @extends HTMLElement
|
|
17
|
-
* @mixes ButtonMixin
|
|
18
|
-
* @mixes ThemableMixin
|
|
19
|
-
* @protected
|
|
20
|
-
*/
|
|
21
|
-
class SelectValueButton extends ButtonMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
22
|
-
static get is() {
|
|
23
|
-
return 'vaadin-select-value-button';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static get styles() {
|
|
27
|
-
return valueButton;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** @protected */
|
|
31
|
-
render() {
|
|
32
|
-
return html`
|
|
33
|
-
<div class="vaadin-button-container">
|
|
34
|
-
<span part="label">
|
|
35
|
-
<slot></slot>
|
|
36
|
-
</span>
|
|
37
|
-
</div>
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
defineCustomElement(SelectValueButton);
|