@lion/button
Advanced tools
Comparing version 0.10.1 to 0.11.0
# Change Log | ||
## 0.11.0 | ||
### Minor Changes | ||
- 43e4bb81: Type fixes and enhancements: | ||
- all protected/private entries added to form-core type definitions, and their dependents were fixed | ||
- a lot @ts-expect-error and @ts-ignore (all `get slots()` and `get modelValue()` issues are fixed) | ||
- categorized @ts-expect-error / @ts-ignore into: | ||
- [external]: when a 3rd party didn't ship types (could also be browser specs) | ||
- [allow-protected]: when we are allowed to know about protected methods. For instance when code | ||
resides in the same package | ||
- [allow-private]: when we need to check a private value inside a test | ||
- [allow]: miscellaneous allows | ||
- [editor]: when the editor complains, but the cli/ci doesn't | ||
### Patch Changes | ||
- 77a04245: add protected and private type info | ||
- Updated dependencies [77a04245] | ||
- Updated dependencies [43e4bb81] | ||
- @lion/core@0.16.0 | ||
## 0.10.1 | ||
@@ -4,0 +27,0 @@ |
@@ -71,6 +71,6 @@ { | ||
"name": "_beforeTemplate", | ||
"privacy": "public", | ||
"privacy": "protected", | ||
"return": { | ||
"type": { | ||
"text": "import(\"@lion/core\").TemplateResult" | ||
"text": "TemplateResult" | ||
} | ||
@@ -82,6 +82,6 @@ } | ||
"name": "_afterTemplate", | ||
"privacy": "public", | ||
"privacy": "protected", | ||
"return": { | ||
"type": { | ||
"text": "import(\"@lion/core\").TemplateResult" | ||
"text": "TemplateResult" | ||
} | ||
@@ -93,3 +93,3 @@ } | ||
"name": "_nativeButtonNode", | ||
"privacy": "public", | ||
"privacy": "protected", | ||
"type": { | ||
@@ -140,124 +140,45 @@ "text": "HTMLButtonElement" | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__preventEventLeakage", | ||
"privacy": "public", | ||
"description": "Prevents that someone who listens outside or on form catches the click event", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "e", | ||
"type": { | ||
"text": "Event" | ||
} | ||
} | ||
] | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__clickDelegationHandler", | ||
"privacy": "public", | ||
"description": "Delegate click, by flashing a native button as a direct child\nof the form, and firing click on this button. This will fire the form submit\nwithout side effects caused by the click bubbling back up to lion-button.", | ||
"return": { | ||
"type": { | ||
"text": "Promise<void>" | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "ev", | ||
"type": { | ||
"text": "Event" | ||
} | ||
} | ||
] | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__setupDelegationInConstructor", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
} | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__setupEvents", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
} | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__teardownEvents", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
} | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__mousedownHandler", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
} | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__keydownHandler", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "e", | ||
"type": { | ||
"text": "KeyboardEvent" | ||
} | ||
} | ||
] | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__keyupHandler", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "e", | ||
"type": { | ||
"text": "KeyboardEvent" | ||
} | ||
} | ||
] | ||
"privacy": "private" | ||
}, | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__setupSubmitAndResetHelperOnConnected", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
} | ||
"privacy": "private" | ||
}, | ||
@@ -273,10 +194,5 @@ { | ||
{ | ||
"kind": "method", | ||
"kind": "field", | ||
"name": "__teardownSubmitAndResetHelperOnDisconnected", | ||
"privacy": "public", | ||
"return": { | ||
"type": { | ||
"text": "void" | ||
} | ||
} | ||
"privacy": "private" | ||
} | ||
@@ -322,3 +238,8 @@ ] | ||
"name": "_beforeTemplate", | ||
"privacy": "public" | ||
"privacy": "protected", | ||
"return": { | ||
"type": { | ||
"text": "TemplateResult" | ||
} | ||
} | ||
}, | ||
@@ -328,3 +249,8 @@ { | ||
"name": "_afterTemplate", | ||
"privacy": "public" | ||
"privacy": "protected", | ||
"return": { | ||
"type": { | ||
"text": "TemplateResult" | ||
} | ||
} | ||
}, | ||
@@ -334,3 +260,3 @@ { | ||
"name": "_nativeButtonNode", | ||
"privacy": "public", | ||
"privacy": "protected", | ||
"type": { | ||
@@ -348,3 +274,3 @@ "text": "HTMLButtonElement" | ||
"name": "__clickDelegationHandler", | ||
"privacy": "public", | ||
"privacy": "private", | ||
"description": "Delegate click, by flashing a native button as a direct child\nof the form, and firing click on this button. This will fire the form submit\nwithout side effects caused by the click bubbling back up to lion-button.", | ||
@@ -363,3 +289,3 @@ "parameters": [ | ||
"name": "__setupDelegationInConstructor", | ||
"privacy": "public" | ||
"privacy": "private" | ||
}, | ||
@@ -369,3 +295,3 @@ { | ||
"name": "__setupEvents", | ||
"privacy": "public" | ||
"privacy": "private" | ||
}, | ||
@@ -375,3 +301,3 @@ { | ||
"name": "__teardownEvents", | ||
"privacy": "public" | ||
"privacy": "private" | ||
}, | ||
@@ -381,3 +307,3 @@ { | ||
"name": "__mousedownHandler", | ||
"privacy": "public" | ||
"privacy": "private" | ||
}, | ||
@@ -387,3 +313,3 @@ { | ||
"name": "__keydownHandler", | ||
"privacy": "public", | ||
"privacy": "private", | ||
"parameters": [ | ||
@@ -401,3 +327,3 @@ { | ||
"name": "__keyupHandler", | ||
"privacy": "public", | ||
"privacy": "private", | ||
"parameters": [ | ||
@@ -415,3 +341,3 @@ { | ||
"name": "__preventEventLeakage", | ||
"privacy": "public", | ||
"privacy": "private", | ||
"description": "Prevents that someone who listens outside or on form catches the click event", | ||
@@ -430,3 +356,3 @@ "parameters": [ | ||
"name": "__setupSubmitAndResetHelperOnConnected", | ||
"privacy": "public" | ||
"privacy": "private" | ||
}, | ||
@@ -436,3 +362,3 @@ { | ||
"name": "__teardownSubmitAndResetHelperOnDisconnected", | ||
"privacy": "public" | ||
"privacy": "private" | ||
}, | ||
@@ -439,0 +365,0 @@ { |
{ | ||
"name": "@lion/button", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "A button that is easily styleable and accessible in all contexts", | ||
@@ -39,3 +39,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@lion/core": "0.15.0" | ||
"@lion/core": "0.16.0" | ||
}, | ||
@@ -42,0 +42,0 @@ "keywords": [ |
@@ -5,2 +5,5 @@ declare const LionButton_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@lion/core/types/SlotMixinTypes").SlotHost> & Pick<typeof import("@lion/core/types/SlotMixinTypes").SlotHost, "prototype"> & Pick<{ | ||
}, "prototype"> & 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" | "render" | "styles" | "getStyles" | "properties" | "observedAttributes" | "createProperty">; | ||
/** | ||
* @typedef {import('@lion/core').TemplateResult} TemplateResult | ||
*/ | ||
export class LionButton extends LionButton_base { | ||
@@ -22,6 +25,19 @@ static get properties(): { | ||
static get styles(): import("@lion/core").CSSResult[]; | ||
_beforeTemplate(): import("@lion/core").TemplateResult; | ||
_afterTemplate(): import("@lion/core").TemplateResult; | ||
/** @type {HTMLButtonElement} */ | ||
get _nativeButtonNode(): HTMLButtonElement; | ||
/** | ||
* | ||
* @returns {TemplateResult} button template | ||
* @protected | ||
*/ | ||
protected _beforeTemplate(): TemplateResult; | ||
/** | ||
* | ||
* @returns {TemplateResult} button template | ||
* @protected | ||
*/ | ||
protected _afterTemplate(): TemplateResult; | ||
/** | ||
* @type {HTMLButtonElement} | ||
* @protected | ||
*/ | ||
protected get _nativeButtonNode(): HTMLButtonElement; | ||
role: string; | ||
@@ -36,4 +52,5 @@ type: string; | ||
* @param {Event} e | ||
* @private | ||
*/ | ||
__preventEventLeakage(e: Event): void; | ||
private __preventEventLeakage; | ||
/** | ||
@@ -44,21 +61,43 @@ * Delegate click, by flashing a native button as a direct child | ||
* @param {Event} ev | ||
* @private | ||
*/ | ||
__clickDelegationHandler(ev: Event): Promise<void>; | ||
__setupDelegationInConstructor(): void; | ||
__setupEvents(): void; | ||
__teardownEvents(): void; | ||
__mousedownHandler(): void; | ||
private __clickDelegationHandler; | ||
/** | ||
* @private | ||
*/ | ||
private __setupDelegationInConstructor; | ||
/** | ||
* @private | ||
*/ | ||
private __setupEvents; | ||
/** | ||
* @private | ||
*/ | ||
private __teardownEvents; | ||
/** | ||
* @private | ||
*/ | ||
private __mousedownHandler; | ||
/** | ||
* @param {KeyboardEvent} e | ||
* @private | ||
*/ | ||
__keydownHandler(e: KeyboardEvent): void; | ||
private __keydownHandler; | ||
/** | ||
* @param {KeyboardEvent} e | ||
* @private | ||
*/ | ||
__keyupHandler(e: KeyboardEvent): void; | ||
__setupSubmitAndResetHelperOnConnected(): void; | ||
private __keyupHandler; | ||
/** | ||
* @private | ||
*/ | ||
private __setupSubmitAndResetHelperOnConnected; | ||
_form: HTMLFormElement | null | undefined; | ||
__teardownSubmitAndResetHelperOnDisconnected(): void; | ||
/** | ||
* @private | ||
*/ | ||
private __teardownSubmitAndResetHelperOnDisconnected; | ||
} | ||
export type TemplateResult = import("@lion/core").TemplateResult; | ||
import { LitElement } from "@lion/core"; | ||
export {}; |
@@ -14,2 +14,6 @@ import { | ||
/** | ||
* @typedef {import('@lion/core').TemplateResult} TemplateResult | ||
*/ | ||
export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement)) { | ||
@@ -42,2 +46,7 @@ static get properties() { | ||
/** | ||
* | ||
* @returns {TemplateResult} button template | ||
* @protected | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this | ||
@@ -48,2 +57,7 @@ _beforeTemplate() { | ||
/** | ||
* | ||
* @returns {TemplateResult} button template | ||
* @protected | ||
*/ | ||
// eslint-disable-next-line class-methods-use-this | ||
@@ -149,3 +163,6 @@ _afterTemplate() { | ||
/** @type {HTMLButtonElement} */ | ||
/** | ||
* @type {HTMLButtonElement} | ||
* @protected | ||
*/ | ||
get _nativeButtonNode() { | ||
@@ -157,3 +174,2 @@ return /** @type {HTMLButtonElement} */ (Array.from(this.children).find( | ||
// @ts-ignore | ||
get slots() { | ||
@@ -232,2 +248,3 @@ return { | ||
* @param {Event} ev | ||
* @private | ||
*/ | ||
@@ -258,2 +275,5 @@ async __clickDelegationHandler(ev) { | ||
/** | ||
* @private | ||
*/ | ||
__setupDelegationInConstructor() { | ||
@@ -265,2 +285,5 @@ // do not move to connectedCallback, otherwise IE11 breaks. | ||
/** | ||
* @private | ||
*/ | ||
__setupEvents() { | ||
@@ -272,2 +295,5 @@ this.addEventListener('mousedown', this.__mousedownHandler); | ||
/** | ||
* @private | ||
*/ | ||
__teardownEvents() { | ||
@@ -280,2 +306,5 @@ this.removeEventListener('mousedown', this.__mousedownHandler); | ||
/** | ||
* @private | ||
*/ | ||
__mousedownHandler() { | ||
@@ -294,2 +323,3 @@ this.active = true; | ||
* @param {KeyboardEvent} e | ||
* @private | ||
*/ | ||
@@ -323,2 +353,3 @@ __keydownHandler(e) { | ||
* @param {KeyboardEvent} e | ||
* @private | ||
*/ | ||
@@ -339,2 +370,3 @@ __keyupHandler(e) { | ||
* @param {Event} e | ||
* @private | ||
*/ | ||
@@ -347,2 +379,5 @@ __preventEventLeakage(e) { | ||
/** | ||
* @private | ||
*/ | ||
__setupSubmitAndResetHelperOnConnected() { | ||
@@ -356,2 +391,5 @@ this._form = this._nativeButtonNode.form; | ||
/** | ||
* @private | ||
*/ | ||
__teardownSubmitAndResetHelperOnDisconnected() { | ||
@@ -358,0 +396,0 @@ if (this._form) { |
@@ -12,2 +12,12 @@ /* eslint-disable lit-a11y/click-events-have-key-events */ | ||
/** | ||
* @param {LionButton} el | ||
*/ | ||
function getProtectedMembers(el) { | ||
return { | ||
// @ts-ignore | ||
nativeButtonNode: el._nativeButtonNode, | ||
}; | ||
} | ||
describe('lion-button', () => { | ||
@@ -22,6 +32,8 @@ it('behaves like native `button` in terms of a11y', async () => { | ||
const el = /** @type {LionButton} */ (await fixture(`<lion-button>foo</lion-button>`)); | ||
const { nativeButtonNode } = getProtectedMembers(el); | ||
expect(el.type).to.equal('submit'); | ||
expect(el.getAttribute('type')).to.be.equal('submit'); | ||
expect(el._nativeButtonNode.type).to.equal('submit'); | ||
expect(el._nativeButtonNode.getAttribute('type')).to.be.equal('submit'); | ||
expect(nativeButtonNode.type).to.equal('submit'); | ||
expect(nativeButtonNode.getAttribute('type')).to.be.equal('submit'); | ||
}); | ||
@@ -33,6 +45,8 @@ | ||
)); | ||
const { nativeButtonNode } = getProtectedMembers(el); | ||
expect(el.type).to.equal('button'); | ||
expect(el.getAttribute('type')).to.be.equal('button'); | ||
expect(el._nativeButtonNode.type).to.equal('button'); | ||
expect(el._nativeButtonNode.getAttribute('type')).to.be.equal('button'); | ||
expect(nativeButtonNode.type).to.equal('button'); | ||
expect(nativeButtonNode.getAttribute('type')).to.be.equal('button'); | ||
}); | ||
@@ -42,4 +56,6 @@ | ||
const el = /** @type {LionButton} */ (await fixture(`<lion-button>foo</lion-button>`)); | ||
expect(el._nativeButtonNode.getAttribute('tabindex')).to.equal('-1'); | ||
expect(window.getComputedStyle(el._nativeButtonNode).clip).to.equal('rect(0px, 0px, 0px, 0px)'); | ||
const { nativeButtonNode } = getProtectedMembers(el); | ||
expect(nativeButtonNode.getAttribute('tabindex')).to.equal('-1'); | ||
expect(window.getComputedStyle(nativeButtonNode).clip).to.equal('rect(0px, 0px, 0px, 0px)'); | ||
}); | ||
@@ -230,4 +246,5 @@ | ||
const el = /** @type {LionButton} */ (await fixture('<lion-button></lion-button>')); | ||
const { nativeButtonNode } = getProtectedMembers(el); | ||
expect(el._nativeButtonNode.getAttribute('aria-hidden')).to.equal('true'); | ||
expect(nativeButtonNode.getAttribute('aria-hidden')).to.equal('true'); | ||
}); | ||
@@ -234,0 +251,0 @@ |
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
91826
1441
+ Added@lion/core@0.16.0(transitive)
- Removed@lion/core@0.15.0(transitive)
Updated@lion/core@0.16.0