@vaadin/select 22.0.0-beta1 → 22.0.1
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
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vaadin/select
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
|
5
|
-
[API documentation ↗](https://vaadin.com/components/vaadin-select/html-api)
|
|
3
|
+
A web component for selecting a single value from a list of options presented in an overlay.
|
|
6
4
|
|
|
7
|
-
[
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/select)
|
|
8
6
|
|
|
9
7
|
[](https://www.npmjs.com/package/@vaadin/vaadin-select)
|
|
10
|
-
[](https://vaadin.com/directory/component/vaadinvaadin-select)
|
|
11
8
|
[](https://discord.gg/PHmkCKC)
|
|
12
9
|
|
|
13
10
|
```html
|
|
14
|
-
<vaadin-select></vaadin-select>
|
|
11
|
+
<vaadin-select label="Sort by"></vaadin-select>
|
|
15
12
|
<script>
|
|
16
13
|
document.querySelector('vaadin-select').renderer = (root) => {
|
|
17
14
|
if (root.firstElementChild) {
|
|
@@ -19,55 +16,58 @@
|
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
// Note that innerHTML is only used for demo purposes here!
|
|
22
|
-
//
|
|
19
|
+
// Consider using Lit or another template library instead.
|
|
23
20
|
root.innerHTML = `
|
|
24
21
|
<vaadin-list-box>
|
|
25
|
-
<vaadin-item>
|
|
26
|
-
<vaadin-item>
|
|
27
|
-
<vaadin-item>
|
|
28
|
-
<
|
|
29
|
-
<vaadin-item
|
|
22
|
+
<vaadin-item value="recent">Most recent first</vaadin-item>
|
|
23
|
+
<vaadin-item value="rating-desc">Rating: high to low</vaadin-item>
|
|
24
|
+
<vaadin-item value="rating-asc">Rating: low to high</vaadin-item>
|
|
25
|
+
<vaadin-item value="price-desc">Price: high to low</vaadin-item>
|
|
26
|
+
<vaadin-item value="price-asc">Price: low to high</vaadin-item>
|
|
30
27
|
</vaadin-list-box>
|
|
31
28
|
`;
|
|
32
29
|
};
|
|
33
30
|
</script>
|
|
34
31
|
```
|
|
35
32
|
|
|
36
|
-
[<img src="https://raw.githubusercontent.com/vaadin/
|
|
33
|
+
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/select/screenshot.png" width="231" alt="Screenshot of vaadin-select">](https://vaadin.com/docs/latest/ds/components/select)
|
|
37
34
|
|
|
38
35
|
## Installation
|
|
39
36
|
|
|
40
|
-
Install
|
|
37
|
+
Install the component:
|
|
41
38
|
|
|
42
39
|
```sh
|
|
43
|
-
npm i @vaadin/
|
|
40
|
+
npm i @vaadin/select
|
|
44
41
|
```
|
|
45
42
|
|
|
46
|
-
Once installed, import
|
|
43
|
+
Once installed, import the component in your application:
|
|
47
44
|
|
|
48
45
|
```js
|
|
49
|
-
import '@vaadin/
|
|
46
|
+
import '@vaadin/select';
|
|
50
47
|
```
|
|
51
48
|
|
|
52
|
-
##
|
|
49
|
+
## Themes
|
|
53
50
|
|
|
54
|
-
Vaadin components
|
|
51
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
|
|
52
|
+
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/select/vaadin-select.js) of the package uses the Lumo theme.
|
|
55
53
|
|
|
56
|
-
To use the Material theme, import the
|
|
54
|
+
To use the Material theme, import the component from the `theme/material` folder:
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
`theme/lumo/vaadin-select.js`
|
|
56
|
+
```js
|
|
57
|
+
import '@vaadin/select/theme/material/vaadin-select.js';
|
|
58
|
+
```
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
You can also import the Lumo version of the component explicitly:
|
|
65
61
|
|
|
66
|
-
|
|
62
|
+
```js
|
|
63
|
+
import '@vaadin/select/theme/lumo/vaadin-select.js';
|
|
64
|
+
```
|
|
67
65
|
|
|
68
|
-
-
|
|
66
|
+
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
```js
|
|
69
|
+
import '@vaadin/select/src/vaadin-select.js';
|
|
70
|
+
```
|
|
71
71
|
|
|
72
72
|
## Contributing
|
|
73
73
|
|
|
@@ -77,4 +77,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
|
|
|
77
77
|
|
|
78
78
|
Apache License 2.0
|
|
79
79
|
|
|
80
|
-
Vaadin collects development time
|
|
80
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
81
|
+
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/select",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,24 +34,24 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@polymer/iron-media-query": "^3.0.0",
|
|
36
36
|
"@polymer/polymer": "^3.2.0",
|
|
37
|
-
"@vaadin/button": "22.0.
|
|
38
|
-
"@vaadin/component-base": "22.0.
|
|
39
|
-
"@vaadin/field-base": "22.0.
|
|
40
|
-
"@vaadin/input-container": "22.0.
|
|
41
|
-
"@vaadin/item": "22.0.
|
|
42
|
-
"@vaadin/list-box": "22.0.
|
|
43
|
-
"@vaadin/vaadin-list-mixin": "22.0.
|
|
44
|
-
"@vaadin/vaadin-lumo-styles": "22.0.
|
|
45
|
-
"@vaadin/vaadin-material-styles": "22.0.
|
|
46
|
-
"@vaadin/vaadin-overlay": "22.0.
|
|
47
|
-
"@vaadin/vaadin-themable-mixin": "22.0.
|
|
37
|
+
"@vaadin/button": "^22.0.1",
|
|
38
|
+
"@vaadin/component-base": "^22.0.1",
|
|
39
|
+
"@vaadin/field-base": "^22.0.1",
|
|
40
|
+
"@vaadin/input-container": "^22.0.1",
|
|
41
|
+
"@vaadin/item": "^22.0.1",
|
|
42
|
+
"@vaadin/list-box": "^22.0.1",
|
|
43
|
+
"@vaadin/vaadin-list-mixin": "^22.0.1",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.1",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "^22.0.1",
|
|
46
|
+
"@vaadin/vaadin-overlay": "^22.0.1",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
51
|
-
"@vaadin/polymer-legacy-adapter": "22.0.
|
|
52
|
-
"@vaadin/testing-helpers": "^0.3.
|
|
51
|
+
"@vaadin/polymer-legacy-adapter": "^22.0.1",
|
|
52
|
+
"@vaadin/testing-helpers": "^0.3.2",
|
|
53
53
|
"lit": "^2.0.0",
|
|
54
54
|
"sinon": "^9.2.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "2b0a2bff0369d6020f7cc33ad35506aa2d1f6f68"
|
|
57
57
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { OverlayElement } from '@vaadin/vaadin-overlay/src/vaadin-overlay.js';
|
|
7
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
8
7
|
import { PositionMixin } from '@vaadin/vaadin-overlay/src/vaadin-overlay-position-mixin.js';
|
|
8
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
9
|
|
|
10
10
|
registerStyles(
|
|
11
11
|
'vaadin-select-overlay',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { Button } from '@vaadin/button/src/vaadin-button.js';
|
|
7
|
-
import {
|
|
7
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
8
|
|
|
9
9
|
registerStyles(
|
|
10
10
|
'vaadin-select-value-button',
|
package/src/vaadin-select.js
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
|
|
7
6
|
import '@polymer/iron-media-query/iron-media-query.js';
|
|
7
|
+
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
8
|
+
import './vaadin-select-overlay.js';
|
|
9
|
+
import './vaadin-select-value-button.js';
|
|
10
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
12
|
import { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
10
13
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
@@ -12,11 +15,7 @@ import { DelegateFocusMixin } from '@vaadin/field-base/src/delegate-focus-mixin.
|
|
|
12
15
|
import { FieldMixin } from '@vaadin/field-base/src/field-mixin.js';
|
|
13
16
|
import { fieldShared } from '@vaadin/field-base/src/styles/field-shared-styles.js';
|
|
14
17
|
import { inputFieldContainer } from '@vaadin/field-base/src/styles/input-field-container-styles.js';
|
|
15
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
|
-
import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
17
|
-
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
18
|
-
import './vaadin-select-overlay.js';
|
|
19
|
-
import './vaadin-select-value-button.js';
|
|
18
|
+
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
20
19
|
|
|
21
20
|
registerStyles('vaadin-select', [fieldShared, inputFieldContainer], { moduleId: 'vaadin-select-styles' });
|
|
22
21
|
|
|
@@ -344,6 +343,10 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
|
|
|
344
343
|
* It is not guaranteed that the update happens immediately (synchronously) after it is requested.
|
|
345
344
|
*/
|
|
346
345
|
requestContentUpdate() {
|
|
346
|
+
if (!this._overlayElement) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
347
350
|
this._overlayElement.requestContentUpdate();
|
|
348
351
|
|
|
349
352
|
// Ensure menu element is set
|
|
@@ -380,7 +383,9 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
|
|
|
380
383
|
this._items.forEach((item) => item.setAttribute('role', 'option'));
|
|
381
384
|
});
|
|
382
385
|
menuElement.addEventListener('selected-changed', () => this.__updateValueButton());
|
|
383
|
-
|
|
386
|
+
// Use capture phase to make it possible for `<vaadin-grid-pro-edit-select>`
|
|
387
|
+
// to override and handle the keydown event before the value change happens.
|
|
388
|
+
menuElement.addEventListener('keydown', (e) => this._onKeyDownInside(e), true);
|
|
384
389
|
menuElement.addEventListener(
|
|
385
390
|
'click',
|
|
386
391
|
() => {
|
|
@@ -484,13 +489,9 @@ class Select extends DelegateFocusMixin(FieldMixin(SlotMixin(ElementMixin(Themab
|
|
|
484
489
|
|
|
485
490
|
this._menuElement.focus();
|
|
486
491
|
} else if (wasOpened) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.focus();
|
|
491
|
-
if (this._openedWithFocusRing) {
|
|
492
|
-
this.setAttribute('focus-ring', '');
|
|
493
|
-
}
|
|
492
|
+
this.focus();
|
|
493
|
+
if (this._openedWithFocusRing) {
|
|
494
|
+
this.setAttribute('focus-ring', '');
|
|
494
495
|
}
|
|
495
496
|
this.validate();
|
|
496
497
|
}
|
|
@@ -3,33 +3,37 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
7
6
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
8
7
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
9
8
|
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
10
|
-
import { menuOverlay } from '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js';
|
|
11
9
|
import { inputFieldShared } from '@vaadin/vaadin-lumo-styles/mixins/input-field-shared.js';
|
|
10
|
+
import { menuOverlay } from '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js';
|
|
11
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
12
|
|
|
13
13
|
const select = css`
|
|
14
14
|
:host(:not([theme*='align'])) ::slotted([slot='value']) {
|
|
15
15
|
text-align: start;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
[part='input-field'] {
|
|
19
|
+
cursor: var(--lumo-clickable-cursor);
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
[part='input-field'] ::slotted([slot='value']) {
|
|
19
23
|
font-weight: 500;
|
|
20
24
|
}
|
|
21
25
|
|
|
26
|
+
[part='input-field'] ::slotted([slot='value']:not([placeholder])) {
|
|
27
|
+
color: var(--lumo-body-text-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
/* placeholder styles */
|
|
23
|
-
|
|
31
|
+
[part='input-field'] ::slotted([slot='value'][placeholder]) {
|
|
24
32
|
color: inherit;
|
|
25
33
|
transition: opacity 0.175s 0.1s;
|
|
26
34
|
opacity: 0.5;
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
:host [part='input-field'] ::slotted([slot='value']) {
|
|
30
|
-
color: var(--lumo-body-text-color);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
37
|
[part='toggle-button']::before {
|
|
34
38
|
content: var(--lumo-icons-dropdown);
|
|
35
39
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
7
6
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
8
|
-
import { menuOverlay } from '@vaadin/vaadin-material-styles/mixins/menu-overlay.js';
|
|
9
7
|
import { inputFieldShared } from '@vaadin/vaadin-material-styles/mixins/input-field-shared.js';
|
|
8
|
+
import { menuOverlay } from '@vaadin/vaadin-material-styles/mixins/menu-overlay.js';
|
|
9
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
10
10
|
|
|
11
11
|
const select = css`
|
|
12
12
|
:host {
|