@vaadin/item 22.0.0-alpha7 → 22.0.0-beta2
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 +25 -22
- package/package.json +7 -6
- package/src/vaadin-item-mixin.d.ts +20 -23
- package/src/vaadin-item-mixin.js +57 -79
- package/src/vaadin-item.d.ts +18 -12
- package/src/vaadin-item.js +15 -11
- package/theme/lumo/vaadin-item-styles.js +27 -6
- package/theme/material/vaadin-item-styles.js +21 -6
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vaadin/item
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
|
5
|
-
[API documentation ↗](https://vaadin.com/components/vaadin-item/html-api)
|
|
3
|
+
A web component for displaying items in list-box, context-menu or select components.
|
|
6
4
|
|
|
7
|
-
[
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/components/vaadin-item/html-examples)
|
|
8
6
|
|
|
9
7
|
[](https://www.npmjs.com/package/@vaadin/item)
|
|
10
|
-
[](https://vaadin.com/directory/component/vaadinvaadin-item)
|
|
11
8
|
[](https://discord.gg/PHmkCKC)
|
|
12
9
|
|
|
13
10
|
```html
|
|
@@ -18,37 +15,40 @@
|
|
|
18
15
|
|
|
19
16
|
## Installation
|
|
20
17
|
|
|
21
|
-
Install
|
|
18
|
+
Install the component:
|
|
22
19
|
|
|
23
20
|
```sh
|
|
24
|
-
npm i @vaadin/item
|
|
21
|
+
npm i @vaadin/item
|
|
25
22
|
```
|
|
26
23
|
|
|
27
|
-
Once installed, import
|
|
24
|
+
Once installed, import the component in your application:
|
|
28
25
|
|
|
29
26
|
```js
|
|
30
|
-
import '@vaadin/item
|
|
27
|
+
import '@vaadin/item';
|
|
31
28
|
```
|
|
32
29
|
|
|
33
|
-
##
|
|
30
|
+
## Themes
|
|
34
31
|
|
|
35
|
-
Vaadin components
|
|
32
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
|
|
33
|
+
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/item/vaadin-item.js) of the package uses Lumo theme.
|
|
36
34
|
|
|
37
|
-
To use the Material theme, import the
|
|
35
|
+
To use the Material theme, import the component from the `theme/material` folder:
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`theme/lumo/vaadin-item.js`
|
|
37
|
+
```js
|
|
38
|
+
import '@vaadin/item/theme/material/vaadin-item.js';
|
|
39
|
+
```
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
You can also import the Lumo version of the component explicitly:
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
```js
|
|
44
|
+
import '@vaadin/item/theme/lumo/vaadin-item.js';
|
|
45
|
+
```
|
|
48
46
|
|
|
49
|
-
-
|
|
47
|
+
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
```js
|
|
50
|
+
import '@vaadin/item/src/vaadin-item.js';
|
|
51
|
+
```
|
|
52
52
|
|
|
53
53
|
## Contributing
|
|
54
54
|
|
|
@@ -57,3 +57,6 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
|
|
|
57
57
|
## License
|
|
58
58
|
|
|
59
59
|
Apache License 2.0
|
|
60
|
+
|
|
61
|
+
Vaadin collects usage statistics at development time to improve this product.
|
|
62
|
+
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/item",
|
|
3
|
-
"version": "22.0.0-
|
|
3
|
+
"version": "22.0.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,16 +32,17 @@
|
|
|
32
32
|
"polymer"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
36
|
"@polymer/polymer": "^3.0.0",
|
|
36
|
-
"@vaadin/component-base": "22.0.0-
|
|
37
|
-
"@vaadin/vaadin-lumo-styles": "22.0.0-
|
|
38
|
-
"@vaadin/vaadin-material-styles": "22.0.0-
|
|
39
|
-
"@vaadin/vaadin-themable-mixin": "22.0.0-
|
|
37
|
+
"@vaadin/component-base": "22.0.0-beta2",
|
|
38
|
+
"@vaadin/vaadin-lumo-styles": "22.0.0-beta2",
|
|
39
|
+
"@vaadin/vaadin-material-styles": "22.0.0-beta2",
|
|
40
|
+
"@vaadin/vaadin-themable-mixin": "22.0.0-beta2"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@esm-bundle/chai": "^4.3.4",
|
|
43
44
|
"@vaadin/testing-helpers": "^0.3.0",
|
|
44
45
|
"sinon": "^9.2.1"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f13833683e6667f6ca6678452db14aa6b7eac4a4"
|
|
47
48
|
}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import { ActiveMixinClass } from '@vaadin/component-base/src/active-mixin.js';
|
|
8
|
+
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
9
|
+
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* A mixin providing `focused`, `focus-ring`, `active`, `disabled` and `selected`.
|
|
3
13
|
*
|
|
4
14
|
* `focused`, `active` and `focus-ring` are set as only as attributes.
|
|
5
15
|
*/
|
|
6
|
-
declare function ItemMixin<T extends
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
export declare function ItemMixin<T extends Constructor<HTMLElement>>(
|
|
17
|
+
base: T
|
|
18
|
+
): T &
|
|
19
|
+
Constructor<ItemMixinClass> &
|
|
20
|
+
Constructor<ActiveMixinClass> &
|
|
21
|
+
Constructor<DisabledMixinClass> &
|
|
22
|
+
Constructor<FocusMixinClass>;
|
|
23
|
+
|
|
24
|
+
export declare class ItemMixinClass {
|
|
13
25
|
value: string;
|
|
14
26
|
|
|
15
27
|
/**
|
|
@@ -17,25 +29,10 @@ interface ItemMixin {
|
|
|
17
29
|
* e.g. in VaadinListMixin it filters items by using the
|
|
18
30
|
* `element._hasVaadinItemMixin` condition.
|
|
19
31
|
*/
|
|
20
|
-
_hasVaadinItemMixin: boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* If true, the user cannot interact with this element.
|
|
24
|
-
*/
|
|
25
|
-
disabled: boolean;
|
|
32
|
+
protected _hasVaadinItemMixin: boolean;
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
35
|
* If true, the item is in selected state.
|
|
29
36
|
*/
|
|
30
37
|
selected: boolean;
|
|
31
|
-
|
|
32
|
-
_setFocused(focused: boolean): void;
|
|
33
|
-
|
|
34
|
-
_setActive(active: boolean): void;
|
|
35
|
-
|
|
36
|
-
_onKeydown(event: KeyboardEvent): void;
|
|
37
|
-
|
|
38
|
-
_onKeyup(event: KeyboardEvent): void;
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
export { ItemMixin, ItemMixinConstructor };
|
package/src/vaadin-item-mixin.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
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 { ActiveMixin } from '@vaadin/component-base/src/active-mixin.js';
|
|
7
|
+
import { FocusMixin } from '@vaadin/component-base/src/focus-mixin.js';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* A mixin providing `focused`, `focus-ring`, `active`, `disabled` and `selected`.
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
* @polymerMixin
|
|
12
14
|
*/
|
|
13
15
|
export const ItemMixin = (superClass) =>
|
|
14
|
-
class VaadinItemMixin extends superClass {
|
|
16
|
+
class VaadinItemMixin extends ActiveMixin(FocusMixin(superClass)) {
|
|
15
17
|
static get properties() {
|
|
16
18
|
return {
|
|
17
19
|
/**
|
|
@@ -24,17 +26,6 @@ export const ItemMixin = (superClass) =>
|
|
|
24
26
|
value: true
|
|
25
27
|
},
|
|
26
28
|
|
|
27
|
-
/**
|
|
28
|
-
* If true, the user cannot interact with this element.
|
|
29
|
-
* @type {boolean}
|
|
30
|
-
*/
|
|
31
|
-
disabled: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
value: false,
|
|
34
|
-
observer: '_disabledChanged',
|
|
35
|
-
reflectToAttribute: true
|
|
36
|
-
},
|
|
37
|
-
|
|
38
29
|
/**
|
|
39
30
|
* If true, the item is in selected state.
|
|
40
31
|
* @type {boolean}
|
|
@@ -51,6 +42,18 @@ export const ItemMixin = (superClass) =>
|
|
|
51
42
|
};
|
|
52
43
|
}
|
|
53
44
|
|
|
45
|
+
/**
|
|
46
|
+
* By default, `Space` is the only possible activation key for a focusable HTML element.
|
|
47
|
+
* Nonetheless, the item is an exception as it can be also activated by pressing `Enter`.
|
|
48
|
+
* See the "Keyboard Support" section in https://www.w3.org/TR/wai-aria-practices/examples/menubar/menubar-1/menubar-1.html.
|
|
49
|
+
*
|
|
50
|
+
* @protected
|
|
51
|
+
* @override
|
|
52
|
+
*/
|
|
53
|
+
get _activeKeys() {
|
|
54
|
+
return ['Enter', ' '];
|
|
55
|
+
}
|
|
56
|
+
|
|
54
57
|
/**
|
|
55
58
|
* @return {string}
|
|
56
59
|
*/
|
|
@@ -73,31 +76,30 @@ export const ItemMixin = (superClass) =>
|
|
|
73
76
|
if (attrValue !== null) {
|
|
74
77
|
this.value = attrValue;
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
this.addEventListener('focus', () => this._setFocused(true), true);
|
|
78
|
-
this.addEventListener('blur', () => this._setFocused(false), true);
|
|
79
|
-
this.addEventListener('mousedown', () => {
|
|
80
|
-
this._setActive((this._mousedown = true));
|
|
81
|
-
const mouseUpListener = () => {
|
|
82
|
-
this._setActive((this._mousedown = false));
|
|
83
|
-
document.removeEventListener('mouseup', mouseUpListener);
|
|
84
|
-
};
|
|
85
|
-
document.addEventListener('mouseup', mouseUpListener);
|
|
86
|
-
});
|
|
87
|
-
this.addEventListener('keydown', (e) => this._onKeydown(e));
|
|
88
|
-
this.addEventListener('keyup', (e) => this._onKeyup(e));
|
|
89
79
|
}
|
|
90
80
|
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (this.
|
|
99
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Override native `focus` to set focused attribute
|
|
83
|
+
* when focusing the item programmatically.
|
|
84
|
+
* @protected
|
|
85
|
+
* @override
|
|
86
|
+
*/
|
|
87
|
+
focus() {
|
|
88
|
+
if (this.disabled) {
|
|
89
|
+
return;
|
|
100
90
|
}
|
|
91
|
+
|
|
92
|
+
super.focus();
|
|
93
|
+
this._setFocused(true);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {KeyboardEvent | MouseEvent} _event
|
|
98
|
+
* @protected
|
|
99
|
+
* @override
|
|
100
|
+
*/
|
|
101
|
+
_shouldSetActive(event) {
|
|
102
|
+
return !this.disabled && !(event.type === 'keydown' && event.defaultPrevented);
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
/** @private */
|
|
@@ -105,64 +107,40 @@ export const ItemMixin = (superClass) =>
|
|
|
105
107
|
this.setAttribute('aria-selected', selected);
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Override an observer from `DisabledMixin`.
|
|
112
|
+
* @protected
|
|
113
|
+
* @override
|
|
114
|
+
*/
|
|
109
115
|
_disabledChanged(disabled) {
|
|
116
|
+
super._disabledChanged(disabled);
|
|
117
|
+
|
|
110
118
|
if (disabled) {
|
|
111
119
|
this.selected = false;
|
|
112
|
-
this.setAttribute('aria-disabled', 'true');
|
|
113
120
|
this.blur();
|
|
114
|
-
} else {
|
|
115
|
-
this.removeAttribute('aria-disabled');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @param {boolean} focused
|
|
121
|
-
* @protected
|
|
122
|
-
*/
|
|
123
|
-
_setFocused(focused) {
|
|
124
|
-
if (focused) {
|
|
125
|
-
this.setAttribute('focused', '');
|
|
126
|
-
if (!this._mousedown) {
|
|
127
|
-
this.setAttribute('focus-ring', '');
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
this.removeAttribute('focused');
|
|
131
|
-
this.removeAttribute('focus-ring');
|
|
132
|
-
this._setActive(false);
|
|
133
121
|
}
|
|
134
122
|
}
|
|
135
123
|
|
|
136
124
|
/**
|
|
137
|
-
*
|
|
125
|
+
* In order to be fully accessible from the keyboard, the item should
|
|
126
|
+
* manually fire the `click` event once an activation key is pressed.
|
|
127
|
+
*
|
|
128
|
+
* According to the UI Events specifications,
|
|
129
|
+
* the `click` event should be fired exactly on `keydown`:
|
|
130
|
+
* https://www.w3.org/TR/uievents/#event-type-keydown
|
|
131
|
+
*
|
|
132
|
+
* @param {KeyboardEvent} event
|
|
138
133
|
* @protected
|
|
134
|
+
* @override
|
|
139
135
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.setAttribute('active', '');
|
|
143
|
-
} else {
|
|
144
|
-
this.removeAttribute('active');
|
|
145
|
-
}
|
|
146
|
-
}
|
|
136
|
+
_onKeyDown(event) {
|
|
137
|
+
super._onKeyDown(event);
|
|
147
138
|
|
|
148
|
-
|
|
149
|
-
* @param {!KeyboardEvent} event
|
|
150
|
-
* @protected
|
|
151
|
-
*/
|
|
152
|
-
_onKeydown(event) {
|
|
153
|
-
if (/^( |SpaceBar|Enter)$/.test(event.key) && !event.defaultPrevented) {
|
|
139
|
+
if (this._activeKeys.includes(event.key) && !event.defaultPrevented) {
|
|
154
140
|
event.preventDefault();
|
|
155
|
-
this._setActive(true);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
141
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* @protected
|
|
162
|
-
*/
|
|
163
|
-
_onKeyup() {
|
|
164
|
-
if (this.hasAttribute('active')) {
|
|
165
|
-
this._setActive(false);
|
|
142
|
+
// `DisabledMixin` overrides the standard `click()` method
|
|
143
|
+
// so that it doesn't fire the `click` event when the element is disabled.
|
|
166
144
|
this.click();
|
|
167
145
|
}
|
|
168
146
|
}
|
package/src/vaadin-item.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
1
6
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
2
|
-
|
|
3
7
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
|
-
|
|
5
8
|
import { ItemMixin } from './vaadin-item-mixin.js';
|
|
6
9
|
|
|
7
10
|
/**
|
|
@@ -25,19 +28,22 @@ import { ItemMixin } from './vaadin-item-mixin.js';
|
|
|
25
28
|
*
|
|
26
29
|
* The following shadow DOM parts are available for styling:
|
|
27
30
|
*
|
|
28
|
-
* Part name
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
31
|
+
* Part name | Description
|
|
32
|
+
* -------------|----------------
|
|
33
|
+
* `checkmark` | The graphical checkmark shown for a selected item
|
|
34
|
+
* `content` | The element that wraps the slot
|
|
31
35
|
*
|
|
32
36
|
* The following state attributes are available for styling:
|
|
33
37
|
*
|
|
34
|
-
* Attribute
|
|
35
|
-
*
|
|
36
|
-
* `
|
|
37
|
-
* `
|
|
38
|
-
* `focus-ring` | Set when the
|
|
39
|
-
* `
|
|
40
|
-
* `
|
|
38
|
+
* Attribute | Description
|
|
39
|
+
* -------------|-------------
|
|
40
|
+
* `active` | Set when the item is pressed down, either with mouse, touch or the keyboard.
|
|
41
|
+
* `disabled` | Set when the item is disabled.
|
|
42
|
+
* `focus-ring` | Set when the item is focused using the keyboard.
|
|
43
|
+
* `focused` | Set when the item is focused.
|
|
44
|
+
* `selected` | Set when the item is selected
|
|
45
|
+
*
|
|
46
|
+
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
41
47
|
*/
|
|
42
48
|
declare class Item extends ItemMixin(ThemableMixin(DirMixin(HTMLElement))) {
|
|
43
49
|
/**
|
package/src/vaadin-item.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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 {
|
|
6
|
+
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
7
|
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
|
import { ItemMixin } from './vaadin-item-mixin.js';
|
|
@@ -29,19 +29,22 @@ import { ItemMixin } from './vaadin-item-mixin.js';
|
|
|
29
29
|
*
|
|
30
30
|
* The following shadow DOM parts are available for styling:
|
|
31
31
|
*
|
|
32
|
-
* Part name
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
32
|
+
* Part name | Description
|
|
33
|
+
* -------------|----------------
|
|
34
|
+
* `checkmark` | The graphical checkmark shown for a selected item
|
|
35
|
+
* `content` | The element that wraps the slot
|
|
35
36
|
*
|
|
36
37
|
* The following state attributes are available for styling:
|
|
37
38
|
*
|
|
38
|
-
* Attribute
|
|
39
|
-
*
|
|
40
|
-
* `
|
|
41
|
-
* `
|
|
42
|
-
* `focus-ring` | Set when the
|
|
43
|
-
* `
|
|
44
|
-
* `
|
|
39
|
+
* Attribute | Description
|
|
40
|
+
* -------------|-------------
|
|
41
|
+
* `active` | Set when the item is pressed down, either with mouse, touch or the keyboard.
|
|
42
|
+
* `disabled` | Set when the item is disabled.
|
|
43
|
+
* `focus-ring` | Set when the item is focused using the keyboard.
|
|
44
|
+
* `focused` | Set when the item is focused.
|
|
45
|
+
* `selected` | Set when the item is selected
|
|
46
|
+
*
|
|
47
|
+
* See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
|
|
45
48
|
*
|
|
46
49
|
* @extends HTMLElement
|
|
47
50
|
* @mixes ItemMixin
|
|
@@ -60,6 +63,7 @@ class Item extends ItemMixin(ThemableMixin(DirMixin(PolymerElement))) {
|
|
|
60
63
|
display: none !important;
|
|
61
64
|
}
|
|
62
65
|
</style>
|
|
66
|
+
<span part="checkmark" aria-hidden="true"></span>
|
|
63
67
|
<div part="content">
|
|
64
68
|
<slot></slot>
|
|
65
69
|
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-lumo-styles/font-icons.js';
|
|
3
2
|
import '@vaadin/vaadin-lumo-styles/sizing.js';
|
|
4
3
|
import '@vaadin/vaadin-lumo-styles/spacing.js';
|
|
5
4
|
import '@vaadin/vaadin-lumo-styles/style.js';
|
|
6
5
|
import '@vaadin/vaadin-lumo-styles/typography.js';
|
|
6
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
7
7
|
|
|
8
8
|
const item = css`
|
|
9
9
|
:host {
|
|
@@ -13,15 +13,19 @@ const item = css`
|
|
|
13
13
|
font-family: var(--lumo-font-family);
|
|
14
14
|
font-size: var(--lumo-font-size-m);
|
|
15
15
|
line-height: var(--lumo-line-height-xs);
|
|
16
|
-
padding: 0.5em
|
|
16
|
+
padding: 0.5em calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4) 0.5em
|
|
17
|
+
var(--_lumo-list-box-item-padding-left, calc(var(--lumo-border-radius-m) / 4));
|
|
17
18
|
min-height: var(--lumo-size-m);
|
|
19
|
+
outline: none;
|
|
20
|
+
border-radius: var(--lumo-border-radius-m);
|
|
21
|
+
cursor: var(--lumo-clickable-cursor);
|
|
18
22
|
-webkit-font-smoothing: antialiased;
|
|
19
23
|
-moz-osx-font-smoothing: grayscale;
|
|
20
|
-
-webkit-tap-highlight-color:
|
|
24
|
+
-webkit-tap-highlight-color: var(--lumo-primary-color-10pct);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/* Checkmark */
|
|
24
|
-
|
|
28
|
+
[part='checkmark']::before {
|
|
25
29
|
display: var(--_lumo-item-selected-icon-display, none);
|
|
26
30
|
content: var(--lumo-icons-checkmark);
|
|
27
31
|
font-family: lumo-icons;
|
|
@@ -37,11 +41,11 @@ const item = css`
|
|
|
37
41
|
transition: transform 0.2s cubic-bezier(0.12, 0.32, 0.54, 2), opacity 0.1s;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
:host([selected])::before {
|
|
44
|
+
:host([selected]) [part='checkmark']::before {
|
|
41
45
|
opacity: 1;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
:host([active]:not([selected]))::before {
|
|
48
|
+
:host([active]:not([selected])) [part='checkmark']::before {
|
|
45
49
|
transform: scale(0.8);
|
|
46
50
|
opacity: 0;
|
|
47
51
|
transition-duration: 0s;
|
|
@@ -58,6 +62,23 @@ const item = css`
|
|
|
58
62
|
pointer-events: none;
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
/* TODO a workaround until we have "focus-follows-mouse". After that, use the hover style for focus-ring as well */
|
|
66
|
+
@media (any-hover: hover) {
|
|
67
|
+
:host(:hover:not([disabled])) {
|
|
68
|
+
background-color: var(--lumo-primary-color-10pct);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([focus-ring]:not([disabled])) {
|
|
72
|
+
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* RTL specific styles */
|
|
77
|
+
:host([dir='rtl']) {
|
|
78
|
+
padding-left: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
|
|
79
|
+
padding-right: var(--_lumo-list-box-item-padding-left, calc(var(--lumo-border-radius-m) / 4));
|
|
80
|
+
}
|
|
81
|
+
|
|
61
82
|
/* Slotted icons */
|
|
62
83
|
:host ::slotted(vaadin-icon),
|
|
63
84
|
:host ::slotted(iron-icon) {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
|
|
2
1
|
import '@vaadin/vaadin-material-styles/font-icons.js';
|
|
3
2
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
4
3
|
import '@vaadin/vaadin-material-styles/typography.js';
|
|
4
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
5
5
|
|
|
6
6
|
const item = css`
|
|
7
7
|
:host {
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
10
|
box-sizing: border-box;
|
|
11
|
+
min-height: 36px;
|
|
12
|
+
padding: 8px 32px 8px 10px;
|
|
11
13
|
overflow: hidden;
|
|
12
14
|
font-family: var(--material-font-family);
|
|
13
|
-
font-size: var(--material-
|
|
15
|
+
font-size: var(--material-small-font-size);
|
|
14
16
|
line-height: 24px;
|
|
15
|
-
padding: 4px 0;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/* It's the list-box's responsibility to add the focus style */
|
|
@@ -21,7 +22,7 @@ const item = css`
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/* Checkmark */
|
|
24
|
-
|
|
25
|
+
[part='checkmark']::before {
|
|
25
26
|
display: var(--_material-item-selected-icon-display, none);
|
|
26
27
|
content: '';
|
|
27
28
|
font-family: material-icons;
|
|
@@ -35,10 +36,20 @@ const item = css`
|
|
|
35
36
|
flex: none;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
:host([selected])::before {
|
|
39
|
+
:host([selected]) [part='checkmark']::before {
|
|
39
40
|
content: var(--material-icons-check);
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
@media (any-hover: hover) {
|
|
44
|
+
:host(:hover:not([disabled])) {
|
|
45
|
+
background-color: var(--material-secondary-background-color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host([focused]:not([disabled])) {
|
|
49
|
+
background-color: var(--material-divider-color);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
/* Disabled */
|
|
43
54
|
:host([disabled]) {
|
|
44
55
|
color: var(--material-disabled-text-color);
|
|
@@ -47,7 +58,11 @@ const item = css`
|
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
/* RTL specific styles */
|
|
50
|
-
:host([dir='rtl'])
|
|
61
|
+
:host([dir='rtl']) {
|
|
62
|
+
padding: 8px 10px 8px 32px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([dir='rtl']) [part='checkmark']::before {
|
|
51
66
|
margin-right: 0;
|
|
52
67
|
margin-left: 10px;
|
|
53
68
|
}
|