Skip to content

Commit

Permalink
Merge 3870eb0 into beca480
Browse files Browse the repository at this point in the history
  • Loading branch information
Haprog committed May 6, 2020
2 parents beca480 + 3870eb0 commit af3452f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bower.json
Expand Up @@ -27,8 +27,8 @@
],
"dependencies": {
"polymer": "^2.0.0",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.2.1",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.3.0",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.6.1",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.4.1",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.1.0",
"vaadin-material-styles": "vaadin/vaadin-material-styles#^1.1.0"
},
Expand Down
9 changes: 9 additions & 0 deletions gen-tsd.json
@@ -0,0 +1,9 @@
{
"excludeFiles": [
"wct.conf.js",
"index.html",
"demo/**/*",
"test/**/*",
"theme/**/*"
]
}
14 changes: 14 additions & 0 deletions magi-p3-post.js
@@ -0,0 +1,14 @@
module.exports = {
files: [
'vaadin-item.js',
'vaadin-item-mixin.js'
],
from: [
/import '\.\/theme\/lumo\/vaadin-(.+)\.js';/,
/import ('\.\/src\/vaadin-item-mixin\.js');/
],
to: [
`import './theme/lumo/vaadin-$1.js';\nexport * from './src/vaadin-$1.js';`,
`export * from $1;`
]
};
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -18,6 +18,7 @@
},
"homepage": "https://vaadin.com/components",
"files": [
"vaadin-*.d.ts",
"vaadin-*.js",
"src",
"theme"
Expand Down
33 changes: 30 additions & 3 deletions src/vaadin-item-mixin.html
Expand Up @@ -25,13 +25,15 @@
* Used for mixin detection because `instanceof` does not work with mixins.
* e.g. in VaadinListMixin it filters items by using the
* `element._hasVaadinItemMixin` condition.
* @type {boolean}
*/
_hasVaadinItemMixin: {
value: true
},

/**
* If true, the user cannot interact with this element.
* @type {boolean}
*/
disabled: {
type: Boolean,
Expand All @@ -42,6 +44,7 @@

/**
* If true, the item is in selected state.
* @type {boolean}
*/
selected: {
type: Boolean,
Expand All @@ -50,18 +53,26 @@
observer: '_selectedChanged'
},

/** @private */
_value: String
};
}

/**
* @return {string}
*/
get value() {
return this._value !== undefined ? this._value : this.textContent.trim();
}

/**
* @param {string} value
*/
set value(value) {
this._value = value;
}

/** @protected */
ready() {
super.ready();

Expand All @@ -84,9 +95,7 @@
this.addEventListener('keyup', e => this._onKeyup(e));
}

/**
* @protected
*/
/** @protected */
disconnectedCallback() {
super.disconnectedCallback();

Expand All @@ -98,10 +107,12 @@
}
}

/** @private */
_selectedChanged(selected) {
this.setAttribute('aria-selected', selected);
}

/** @private */
_disabledChanged(disabled) {
if (disabled) {
this.selected = false;
Expand All @@ -112,6 +123,10 @@
}
}

/**
* @param {boolean} focused
* @protected
*/
_setFocused(focused) {
if (focused) {
this.setAttribute('focused', '');
Expand All @@ -125,6 +140,10 @@
}
}

/**
* @param {boolean} active
* @protected
*/
_setActive(active) {
if (active) {
this.setAttribute('active', '');
Expand All @@ -133,13 +152,21 @@
}
}

/**
* @param {!KeyboardEvent} event
* @protected
*/
_onKeydown(event) {
if (/^( |SpaceBar|Enter)$/.test(event.key) && !event.defaultPrevented) {
event.preventDefault();
this._setActive(true);
}
}

/**
* @param {!KeyboardEvent} event
* @protected
*/
_onKeyup(event) {
if (this.hasAttribute('active')) {
this._setActive(false);
Expand Down
1 change: 1 addition & 0 deletions src/vaadin-item.html
Expand Up @@ -64,6 +64,7 @@
* @memberof Vaadin
* @mixes Vaadin.ItemMixin
* @mixes Vaadin.ThemableMixin
* @mixes Vaadin.DirMixin
*/
class ItemElement extends Vaadin.ItemMixin(Vaadin.ThemableMixin(Vaadin.DirMixin(Polymer.Element))) {
static get is() {
Expand Down

0 comments on commit af3452f

Please sign in to comment.