Socket
Socket
Sign inDemoInstall

@lion/switch

Package Overview
Dependencies
14
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.17.6 to 0.18.0

13

CHANGELOG.md
# Change Log
## 0.18.0
### Minor Changes
- 4ae3e9e2: Make keyup handlers protected, enables subclassers to switch using alternative keys.
### Patch Changes
- Updated dependencies [ec03d209]
- @lion/core@0.18.3
- @lion/form-core@0.15.2
- @lion/helpers@0.9.3
## 0.17.6

@@ -4,0 +17,0 @@

48

custom-elements.json

@@ -328,2 +328,38 @@ {

"privacy": "private"
},
{
"kind": "method",
"name": "_handleKeydown",
"privacy": "protected",
"return": {
"type": {
"text": "void"
}
},
"parameters": [
{
"name": "ev",
"type": {
"text": "KeyboardEvent"
}
}
]
},
{
"kind": "method",
"name": "_handleKeyup",
"privacy": "protected",
"return": {
"type": {
"text": "void"
}
},
"parameters": [
{
"name": "ev",
"type": {
"text": "KeyboardEvent"
}
}
]
}

@@ -382,7 +418,7 @@ ]

"kind": "method",
"name": "__handleKeydown",
"privacy": "private",
"name": "_handleKeydown",
"privacy": "protected",
"parameters": [
{
"name": "e",
"name": "ev",
"type": {

@@ -396,7 +432,7 @@ "text": "KeyboardEvent"

"kind": "method",
"name": "__handleKeyup",
"privacy": "private",
"name": "_handleKeyup",
"privacy": "protected",
"parameters": [
{
"name": "e",
"name": "ev",
"type": {

@@ -403,0 +439,0 @@ "text": "KeyboardEvent"

8

package.json
{
"name": "@lion/switch",
"version": "0.17.6",
"version": "0.18.0",
"description": "A Switch is used for switching a property or feature on and off",

@@ -41,5 +41,5 @@ "license": "MIT",

"dependencies": {
"@lion/core": "0.18.2",
"@lion/form-core": "0.15.1",
"@lion/helpers": "0.9.2"
"@lion/core": "0.18.3",
"@lion/form-core": "0.15.2",
"@lion/helpers": "0.9.3"
},

@@ -46,0 +46,0 @@ "keywords": [

@@ -19,16 +19,20 @@ declare const LionSwitchButton_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@lion/core/types/DisabledWithTabIndexMixinTypes").DisabledWithTabIndexHost> & Pick<typeof import("@lion/core/types/DisabledWithTabIndexMixinTypes").DisabledWithTabIndexHost, "prototype"> & import("@open-wc/dedupe-mixin").Constructor<import("@lion/core/types/DisabledMixinTypes").DisabledHost> & Pick<typeof import("@lion/core/types/DisabledMixinTypes").DisabledHost, "prototype"> & Pick<typeof LitElement, "prototype" | "_$litElement$" | "enabledWarnings" | "enableWarning" | "disableWarning" | "addInitializer" | "_initializers" | "elementProperties" | "properties" | "elementStyles" | "styles" | "observedAttributes" | "createProperty" | "shadowRootOptions">;

protected _toggleChecked(): void;
/** @private */
private __handleKeydown;
/** @private */
private __handleKeyup;
/** @private */
private __checkedStateChange;
/**
* @param {KeyboardEvent} e
* @private
* @param {KeyboardEvent} ev
* @protected
*/
private __handleKeydown;
protected _handleKeydown(ev: KeyboardEvent): void;
/**
* @param {KeyboardEvent} e
* @private
* @param {KeyboardEvent} ev
* @protected
*/
private __handleKeyup;
/** @private */
private __checkedStateChange;
protected _handleKeyup(ev: KeyboardEvent): void;
}
import { LitElement } from "@lion/core";
export {};

@@ -83,5 +83,5 @@ import { html, css, LitElement, DisabledWithTabIndexMixin } from '@lion/core';

/** @private */
this.__handleKeydown = this.__handleKeydown.bind(this);
this.__handleKeydown = this._handleKeydown.bind(this);
/** @private */
this.__handleKeyup = this.__handleKeyup.bind(this);
this.__handleKeyup = this._handleKeyup.bind(this);
}

@@ -125,10 +125,10 @@

/**
* @param {KeyboardEvent} e
* @private
* @param {KeyboardEvent} ev
* @protected
*/
// eslint-disable-next-line class-methods-use-this
__handleKeydown(e) {
_handleKeydown(ev) {
// prevent "space" scrolling on "macOS"
if (e.keyCode === 32) {
e.preventDefault();
if (ev.key === ' ') {
ev.preventDefault();
}

@@ -138,7 +138,7 @@ }

/**
* @param {KeyboardEvent} e
* @private
* @param {KeyboardEvent} ev
* @protected
*/
__handleKeyup(e) {
if ([32 /* space */, 13 /* enter */].indexOf(e.keyCode) !== -1) {
_handleKeyup(ev) {
if ([' ', 'Enter'].includes(ev.key)) {
this._toggleChecked();

@@ -145,0 +145,0 @@ }

@@ -53,2 +53,15 @@ import { expect, fixture as _fixture } from '@open-wc/testing';

it('should toggle the value of "checked" on key-up', async () => {
expect(el.checked).to.be.false;
expect(el.hasAttribute('checked')).to.be.false;
el.dispatchEvent(new KeyboardEvent('keyup', { key: 'Enter' }));
await el.updateComplete;
expect(el.checked).to.be.true;
expect(el.hasAttribute('checked')).to.be.true;
el.dispatchEvent(new KeyboardEvent('keyup', { key: ' ' }));
await el.updateComplete;
expect(el.checked).to.be.false;
expect(el.hasAttribute('checked')).to.be.false;
});
it('can be disabled', async () => {

@@ -55,0 +68,0 @@ el.disabled = true;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc