@vaadin/active-state-mixin
Advanced tools
Comparing version 0.1.2 to 0.1.3
import { LitElement } from 'lit-element'; | ||
export declare abstract class ActiveStateClass extends LitElement { | ||
protected _onKeyDown?(event: KeyboardEvent): void; | ||
protected _onKeyUp?(event: KeyboardEvent): void; | ||
protected _onMouseDown?(event: MouseEvent): void; | ||
@@ -6,0 +4,0 @@ protected _onTouchStart?(event: TouchEvent): void; |
@@ -0,6 +1,6 @@ | ||
import { Constructor } from '@vaadin/mixin-utils'; | ||
import { DisabledStateInterface } from '@vaadin/disabled-state-mixin'; | ||
import { KeyboardClass } from '@vaadin/keyboard-mixin/keyboard-class.js'; | ||
import { ActiveStateClass } from './active-state-class'; | ||
declare type Constructor<T = object> = new (...args: any[]) => T; | ||
export declare const ActiveStateMixin: <T extends Constructor<DisabledStateInterface & ActiveStateClass>>(base: T) => T & Constructor<ActiveStateClass>; | ||
export {}; | ||
export declare const ActiveStateMixin: <T extends Constructor<DisabledStateInterface & ActiveStateClass & KeyboardClass>>(base: T) => T & Constructor<ActiveStateClass>; | ||
//# sourceMappingURL=active-state-mixin.d.ts.map |
@@ -0,3 +1,4 @@ | ||
import { KeyboardMixin } from '@vaadin/keyboard-mixin/keyboard-mixin.js'; | ||
export const ActiveStateMixin = (base) => { | ||
class ActiveState extends base { | ||
class ActiveState extends KeyboardMixin(base) { | ||
firstUpdated(props) { | ||
@@ -8,8 +9,2 @@ super.firstUpdated(props); | ||
}); | ||
this.addEventListener('keydown', (event) => { | ||
this._onKeyDown(event); | ||
}); | ||
this.addEventListener('keyup', (event) => { | ||
this._onKeyUp(event); | ||
}); | ||
this.addEventListener('touchstart', (event) => { | ||
@@ -31,2 +26,3 @@ this._onTouchStart(event); | ||
_onKeyDown(event) { | ||
super._onKeyDown && super._onKeyDown(event); | ||
if (/^( |SpaceBar|Enter)$/.test(event.key) && !this.disabled && !event.defaultPrevented) { | ||
@@ -37,3 +33,4 @@ event.preventDefault(); | ||
} | ||
_onKeyUp(_event) { | ||
_onKeyUp(event) { | ||
super._onKeyUp && super._onKeyUp(event); | ||
this._setActive(false); | ||
@@ -40,0 +37,0 @@ } |
{ | ||
"name": "@vaadin/active-state-mixin", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Vaadin Ltd", | ||
@@ -18,3 +18,5 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@vaadin/disabled-state-mixin": "^0.1.0", | ||
"@vaadin/disabled-state-mixin": "^0.1.1", | ||
"@vaadin/keyboard-mixin": "^0.1.0", | ||
"@vaadin/mixin-utils": "^0.1.0", | ||
"lit-element": "^2.0.0", | ||
@@ -30,3 +32,3 @@ "lit-html": "^1.0.0" | ||
}, | ||
"gitHead": "f5071de4574cadf60279853ae957abdadb5cd176" | ||
"gitHead": "ff5f69931daced1cb7176b7774547752c1c982c7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21206
5
75
+ Added@vaadin/mixin-utils@^0.1.0
+ Added@vaadin/keyboard-mixin@0.1.2(transitive)