@vaadin/select 24.8.0-alpha9 → 25.0.0-alpha1
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 +18 -19
- package/src/{vaadin-lit-select-item.d.ts → vaadin-select-base-styles.d.ts} +3 -1
- package/src/vaadin-select-base-styles.js +36 -0
- package/src/{vaadin-lit-select.d.ts → vaadin-select-core-styles.d.ts} +3 -1
- package/src/{vaadin-lit-select-list-box.d.ts → vaadin-select-core-styles.js} +11 -1
- package/src/vaadin-select-item.js +28 -19
- package/src/vaadin-select-list-box.d.ts +1 -2
- package/src/vaadin-select-list-box.js +15 -26
- package/src/vaadin-select-overlay-base-styles.js +23 -0
- package/src/vaadin-select-overlay-core-styles.js +23 -0
- package/src/vaadin-select-overlay.js +21 -26
- package/src/vaadin-select-value-button-base-styles.js +32 -0
- package/src/vaadin-select-value-button.js +11 -7
- package/src/vaadin-select.js +34 -72
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
- package/src/vaadin-lit-select-item.js +0 -70
- package/src/vaadin-lit-select-list-box.js +0 -85
- package/src/vaadin-lit-select-overlay.js +0 -70
- package/src/vaadin-lit-select-value-button.js +0 -42
- package/src/vaadin-lit-select.js +0 -122
- 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.d.ts +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-value-button-styles.js → vaadin-select-value-button-core-styles.js} +0 -0
package/src/vaadin-select.js
CHANGED
|
@@ -8,19 +8,16 @@ 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 {
|
|
17
|
-
import {
|
|
18
|
-
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
17
|
+
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
18
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
19
19
|
import { SelectBaseMixin } from './vaadin-select-base-mixin.js';
|
|
20
|
-
|
|
21
|
-
registerStyles('vaadin-select', [fieldShared, inputFieldContainer, screenReaderOnly], {
|
|
22
|
-
moduleId: 'vaadin-select-styles',
|
|
23
|
-
});
|
|
20
|
+
import { selectStyles } from './vaadin-select-core-styles.js';
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
23
|
* `<vaadin-select>` is a Web Component for selecting values from a list of items.
|
|
@@ -134,40 +131,35 @@ registerStyles('vaadin-select', [fieldShared, inputFieldContainer, screenReaderO
|
|
|
134
131
|
* @mixes SelectBaseMixin
|
|
135
132
|
* @mixes ThemableMixin
|
|
136
133
|
*/
|
|
137
|
-
class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(
|
|
134
|
+
class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
138
135
|
static get is() {
|
|
139
136
|
return 'vaadin-select';
|
|
140
137
|
}
|
|
141
138
|
|
|
142
|
-
static get
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
:host {
|
|
146
|
-
position: relative;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
::slotted([slot='value']) {
|
|
150
|
-
flex-grow: 1;
|
|
151
|
-
}
|
|
152
|
-
</style>
|
|
139
|
+
static get styles() {
|
|
140
|
+
return [inputFieldShared, screenReaderOnly, selectStyles];
|
|
141
|
+
}
|
|
153
142
|
|
|
143
|
+
/** @protected */
|
|
144
|
+
render() {
|
|
145
|
+
return html`
|
|
154
146
|
<div class="vaadin-select-container">
|
|
155
|
-
<div part="label"
|
|
147
|
+
<div part="label" @click="${this._onClick}">
|
|
156
148
|
<slot name="label"></slot>
|
|
157
|
-
<span part="required-indicator" aria-hidden="true"
|
|
149
|
+
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
158
150
|
</div>
|
|
159
151
|
|
|
160
152
|
<vaadin-input-container
|
|
161
153
|
part="input-field"
|
|
162
|
-
readonly="
|
|
163
|
-
disabled="
|
|
164
|
-
invalid="
|
|
165
|
-
theme
|
|
166
|
-
|
|
154
|
+
.readonly="${this.readonly}"
|
|
155
|
+
.disabled="${this.disabled}"
|
|
156
|
+
.invalid="${this.invalid}"
|
|
157
|
+
theme="${ifDefined(this._theme)}"
|
|
158
|
+
@click="${this._onClick}"
|
|
167
159
|
>
|
|
168
160
|
<slot name="prefix" slot="prefix"></slot>
|
|
169
161
|
<slot name="value"></slot>
|
|
170
|
-
<div part="toggle-button" slot="suffix" aria-hidden="true"
|
|
162
|
+
<div part="toggle-button" slot="suffix" aria-hidden="true" @mousedown="${this._onToggleMouseDown}"></div>
|
|
171
163
|
</vaadin-input-container>
|
|
172
164
|
|
|
173
165
|
<div part="helper-text">
|
|
@@ -181,14 +173,16 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolymerElement))
|
|
|
181
173
|
|
|
182
174
|
<vaadin-select-overlay
|
|
183
175
|
id="overlay"
|
|
184
|
-
owner="
|
|
185
|
-
|
|
186
|
-
opened="{
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
176
|
+
.owner="${this}"
|
|
177
|
+
.positionTarget="${this._inputContainer}"
|
|
178
|
+
.opened="${this.opened}"
|
|
179
|
+
.withBackdrop="${this._phone}"
|
|
180
|
+
.renderer="${this.renderer || this.__defaultRenderer}"
|
|
181
|
+
?phone="${this._phone}"
|
|
182
|
+
theme="${ifDefined(this._theme)}"
|
|
183
|
+
?no-vertical-overlap="${this.noVerticalOverlap}"
|
|
184
|
+
@opened-changed="${this._onOpenedChanged}"
|
|
185
|
+
@vaadin-overlay-open="${this._onOverlayOpen}"
|
|
192
186
|
></vaadin-select-overlay>
|
|
193
187
|
|
|
194
188
|
<slot name="tooltip"></slot>
|
|
@@ -198,41 +192,9 @@ class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolymerElement))
|
|
|
198
192
|
`;
|
|
199
193
|
}
|
|
200
194
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
__overlayOwner: {
|
|
205
|
-
value() {
|
|
206
|
-
return this;
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
static get observers() {
|
|
213
|
-
return ['_rendererChanged(renderer, _overlayElement)'];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** @protected */
|
|
217
|
-
ready() {
|
|
218
|
-
super.ready();
|
|
219
|
-
|
|
220
|
-
processTemplates(this);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* @param {SelectRenderer | undefined | null} renderer
|
|
225
|
-
* @param {SelectOverlay | undefined} overlay
|
|
226
|
-
* @private
|
|
227
|
-
*/
|
|
228
|
-
_rendererChanged(renderer, overlay) {
|
|
229
|
-
if (!overlay) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
overlay.renderer = renderer || this.__defaultRenderer;
|
|
234
|
-
|
|
235
|
-
this.requestContentUpdate();
|
|
195
|
+
/** @private */
|
|
196
|
+
_onOpenedChanged(event) {
|
|
197
|
+
this.opened = event.detail.value;
|
|
236
198
|
}
|
|
237
199
|
|
|
238
200
|
/** @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-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-select",
|
|
11
|
-
"description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n`--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
11
|
+
"description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n`--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-----------------------------|-----------\n`opened` | Set when the select is open | :host\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
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-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-select",
|
|
19
|
-
"description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n`--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/
|
|
19
|
+
"description": "`<vaadin-select>` is a Web Component for selecting values from a list of items.\n\n### Items\n\nUse the `items` property to define possible options for the select:\n\n```html\n<vaadin-select id=\"select\"></vaadin-select>\n```\n```js\nconst select = document.querySelector('#select');\nselect.items = [\n { label: 'Most recent first', value: 'recent' },\n { component: 'hr' },\n { label: 'Rating: low to high', value: 'rating-asc', className: 'asc' },\n { label: 'Rating: high to low', value: 'rating-desc', className: 'desc' },\n { component: 'hr' },\n { label: 'Price: low to high', value: 'price-asc', disabled: true },\n { label: 'Price: high to low', value: 'price-desc', disabled: true }\n];\n```\n\n### Rendering\n\nAlternatively, the content of the select can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `select` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `select`.\n\n```js\nconst select = document.querySelector('#select');\nselect.renderer = function(root, select) {\n const listBox = document.createElement('vaadin-list-box');\n // append 3 <vaadin-item> elements\n ['Jose', 'Manolo', 'Pedro'].forEach(function(name) {\n const item = document.createElement('vaadin-item');\n item.textContent = name;\n item.setAttribute('label', name)\n listBox.appendChild(item);\n });\n\n // update the content\n root.appendChild(listBox);\n};\n```\n\nRenderer is called on initialization of new select and on its opening.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n* Hint: By setting the `label` property of inner vaadin-items you will\nbe able to change the visual representation of the selected value in the input part.\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Target element | Default\n-----------------------------------|------------------------------|----------------------------------\n`--vaadin-field-default-width` | Default width of the field | :host | `12em`\n`--vaadin-select-text-field-width` | Effective width of the field | `vaadin-select-overlay` |\n`--vaadin-select-overlay-width` | Width of the overlay | `vaadin-select-overlay` |\n\n`<vaadin-select>` provides mostly the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-text-field) for the styling documentation.\n\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-----------------------------|-----------\n`opened` | Set when the select is open | :host\n\nThere are two exceptions in terms of styling compared to `<vaadin-text-field>`:\n- the `clear-button` shadow DOM part does not exist in `<vaadin-select>`.\n- the `input-prevented` state attribute is not supported by `<vaadin-select>`.\n\n### Internal components\n\nIn addition to `<vaadin-select>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-select-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-overlay).\n- `<vaadin-select-value-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-button).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha1/#/elements/vaadin-input-container) - an internal element wrapping the button.\n\nNote: the `theme` attribute value set on `<vaadin-select>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { css, 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 { ItemMixin } from '@vaadin/item/src/vaadin-item-mixin.js';
|
|
11
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
15
|
-
*
|
|
16
|
-
* @extends HTMLElement
|
|
17
|
-
* @mixes DirMixin
|
|
18
|
-
* @mixes ItemMixin
|
|
19
|
-
* @mixes ThemableMixin
|
|
20
|
-
* @protected
|
|
21
|
-
*/
|
|
22
|
-
class SelectItem extends ItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
23
|
-
static get is() {
|
|
24
|
-
return 'vaadin-select-item';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static get styles() {
|
|
28
|
-
return css`
|
|
29
|
-
:host {
|
|
30
|
-
display: inline-block;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:host([hidden]) {
|
|
34
|
-
display: none !important;
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static get properties() {
|
|
40
|
-
return {
|
|
41
|
-
/**
|
|
42
|
-
* Use property instead of setting an attribute in `ready()`
|
|
43
|
-
* for cloning the selected item attached to the value button:
|
|
44
|
-
* in this case, `role` attribute is removed synchronously, and
|
|
45
|
-
* using `ready()` would incorrectly restore the attribute.
|
|
46
|
-
*
|
|
47
|
-
* @protected
|
|
48
|
-
*/
|
|
49
|
-
role: {
|
|
50
|
-
type: String,
|
|
51
|
-
value: 'option',
|
|
52
|
-
reflectToAttribute: true,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** @protected */
|
|
58
|
-
render() {
|
|
59
|
-
return html`
|
|
60
|
-
<span part="checkmark" aria-hidden="true"></span>
|
|
61
|
-
<div part="content">
|
|
62
|
-
<slot></slot>
|
|
63
|
-
</div>
|
|
64
|
-
`;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
defineCustomElement(SelectItem);
|
|
69
|
-
|
|
70
|
-
export { SelectItem };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { css, 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 { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
15
|
-
*
|
|
16
|
-
* @extends HTMLElement
|
|
17
|
-
* @mixes DirMixin
|
|
18
|
-
* @mixes ListMixin
|
|
19
|
-
* @mixes ThemableMixin
|
|
20
|
-
* @protected
|
|
21
|
-
*/
|
|
22
|
-
class SelectListBox extends ListMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
|
|
23
|
-
static get is() {
|
|
24
|
-
return 'vaadin-select-list-box';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static get styles() {
|
|
28
|
-
return css`
|
|
29
|
-
:host {
|
|
30
|
-
display: flex;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:host([hidden]) {
|
|
34
|
-
display: none !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[part='items'] {
|
|
38
|
-
height: 100%;
|
|
39
|
-
width: 100%;
|
|
40
|
-
overflow-y: auto;
|
|
41
|
-
-webkit-overflow-scrolling: touch;
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static get properties() {
|
|
47
|
-
return {
|
|
48
|
-
// We don't need to define this property since super default is vertical,
|
|
49
|
-
// but we don't want it to be modified, or be shown in the API docs.
|
|
50
|
-
/** @private */
|
|
51
|
-
orientation: {
|
|
52
|
-
readOnly: true,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @return {!HTMLElement}
|
|
59
|
-
* @protected
|
|
60
|
-
* @override
|
|
61
|
-
*/
|
|
62
|
-
get _scrollerElement() {
|
|
63
|
-
return this.shadowRoot.querySelector('[part="items"]');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** @protected */
|
|
67
|
-
render() {
|
|
68
|
-
return html`
|
|
69
|
-
<div part="items">
|
|
70
|
-
<slot></slot>
|
|
71
|
-
</div>
|
|
72
|
-
`;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** @protected */
|
|
76
|
-
ready() {
|
|
77
|
-
super.ready();
|
|
78
|
-
|
|
79
|
-
this.setAttribute('role', 'listbox');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
defineCustomElement(SelectListBox);
|
|
84
|
-
|
|
85
|
-
export { SelectListBox };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import { css, 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 { SelectOverlayMixin } from './vaadin-select-overlay-mixin.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* An element used internally by `<vaadin-select>`. Not intended to be used separately.
|
|
15
|
-
*
|
|
16
|
-
* @extends HTMLElement
|
|
17
|
-
* @mixes SelectOverlayMixin
|
|
18
|
-
* @mixes ThemableMixin
|
|
19
|
-
* @protected
|
|
20
|
-
*/
|
|
21
|
-
class SelectOverlay extends SelectOverlayMixin(ThemableMixin(PolylitMixin(LitElement))) {
|
|
22
|
-
static get is() {
|
|
23
|
-
return 'vaadin-select-overlay';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static get styles() {
|
|
27
|
-
return [
|
|
28
|
-
overlayStyles,
|
|
29
|
-
css`
|
|
30
|
-
:host {
|
|
31
|
-
align-items: flex-start;
|
|
32
|
-
justify-content: flex-start;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
:host(:not([phone])) [part='overlay'] {
|
|
36
|
-
min-width: var(--vaadin-select-overlay-width, var(--vaadin-select-text-field-width));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@media (forced-colors: active) {
|
|
40
|
-
[part='overlay'] {
|
|
41
|
-
outline: 3px solid;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`,
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** @protected */
|
|
49
|
-
render() {
|
|
50
|
-
return html`
|
|
51
|
-
<div id="backdrop" part="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
52
|
-
<div part="overlay" id="overlay" tabindex="0">
|
|
53
|
-
<div part="content" id="content">
|
|
54
|
-
<slot></slot>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** @protected */
|
|
61
|
-
updated(props) {
|
|
62
|
-
super.updated(props);
|
|
63
|
-
|
|
64
|
-
if (props.has('renderer')) {
|
|
65
|
-
this.requestContentUpdate();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
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-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);
|
package/src/vaadin-lit-select.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import '@vaadin/input-container/src/vaadin-lit-input-container.js';
|
|
7
|
-
import './vaadin-lit-select-item.js';
|
|
8
|
-
import './vaadin-lit-select-list-box.js';
|
|
9
|
-
import './vaadin-lit-select-overlay.js';
|
|
10
|
-
import './vaadin-lit-select-value-button.js';
|
|
11
|
-
import { css, html, LitElement } from 'lit';
|
|
12
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
|
-
import { screenReaderOnly } from '@vaadin/a11y-base/src/styles/sr-only-styles.js';
|
|
14
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
15
|
-
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
16
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
17
|
-
import { fieldShared } from '@vaadin/field-base/src/styles/field-shared-styles.js';
|
|
18
|
-
import { inputFieldContainer } from '@vaadin/field-base/src/styles/input-field-container-styles.js';
|
|
19
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
20
|
-
import { SelectBaseMixin } from './vaadin-select-base-mixin.js';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* LitElement based version of `<vaadin-select>` web component.
|
|
24
|
-
*
|
|
25
|
-
* ## Disclaimer
|
|
26
|
-
*
|
|
27
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
28
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
29
|
-
* Feel free to try this code in your apps as per Apache 2.0 license.
|
|
30
|
-
*
|
|
31
|
-
* @extends HTMLElement
|
|
32
|
-
*/
|
|
33
|
-
class Select extends SelectBaseMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
34
|
-
static get is() {
|
|
35
|
-
return 'vaadin-select';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static get styles() {
|
|
39
|
-
return [
|
|
40
|
-
fieldShared,
|
|
41
|
-
inputFieldContainer,
|
|
42
|
-
screenReaderOnly,
|
|
43
|
-
css`
|
|
44
|
-
:host {
|
|
45
|
-
position: relative;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
::slotted([slot='value']) {
|
|
49
|
-
flex-grow: 1;
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @protected */
|
|
56
|
-
render() {
|
|
57
|
-
return html`
|
|
58
|
-
<div class="vaadin-select-container">
|
|
59
|
-
<div part="label" @click="${this._onClick}">
|
|
60
|
-
<slot name="label"></slot>
|
|
61
|
-
<span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
<vaadin-input-container
|
|
65
|
-
part="input-field"
|
|
66
|
-
.readonly="${this.readonly}"
|
|
67
|
-
.disabled="${this.disabled}"
|
|
68
|
-
.invalid="${this.invalid}"
|
|
69
|
-
theme="${ifDefined(this._theme)}"
|
|
70
|
-
@click="${this._onClick}"
|
|
71
|
-
>
|
|
72
|
-
<slot name="prefix" slot="prefix"></slot>
|
|
73
|
-
<slot name="value"></slot>
|
|
74
|
-
<div part="toggle-button" slot="suffix" aria-hidden="true" @mousedown="${this._onToggleMouseDown}"></div>
|
|
75
|
-
</vaadin-input-container>
|
|
76
|
-
|
|
77
|
-
<div part="helper-text">
|
|
78
|
-
<slot name="helper"></slot>
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
<div part="error-message">
|
|
82
|
-
<slot name="error-message"></slot>
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
<vaadin-select-overlay
|
|
87
|
-
id="overlay"
|
|
88
|
-
.owner="${this}"
|
|
89
|
-
.positionTarget="${this._inputContainer}"
|
|
90
|
-
.opened="${this.opened}"
|
|
91
|
-
.withBackdrop="${this._phone}"
|
|
92
|
-
.renderer="${this.renderer || this.__defaultRenderer}"
|
|
93
|
-
?phone="${this._phone}"
|
|
94
|
-
theme="${ifDefined(this._theme)}"
|
|
95
|
-
?no-vertical-overlap="${this.noVerticalOverlap}"
|
|
96
|
-
@opened-changed="${this._onOpenedChanged}"
|
|
97
|
-
@vaadin-overlay-open="${this._onOverlayOpen}"
|
|
98
|
-
></vaadin-select-overlay>
|
|
99
|
-
|
|
100
|
-
<slot name="tooltip"></slot>
|
|
101
|
-
<div class="sr-only">
|
|
102
|
-
<slot name="sr-label"></slot>
|
|
103
|
-
</div>
|
|
104
|
-
`;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** @private */
|
|
108
|
-
_onOpenedChanged(event) {
|
|
109
|
-
this.opened = event.detail.value;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** @private */
|
|
113
|
-
_onOverlayOpen() {
|
|
114
|
-
if (this._menuElement) {
|
|
115
|
-
this._menuElement.focus();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
defineCustomElement(Select);
|
|
121
|
-
|
|
122
|
-
export { Select };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
-
*/
|
|
6
|
-
import '@vaadin/input-container/theme/material/vaadin-input-container-styles.js';
|
|
7
|
-
import '@vaadin/vaadin-material-styles/font-icons.js';
|