feat(radio-group): add types for radio-group
This commit is contained in:
parent
9263f39740
commit
50287fba72
4 changed files with 16 additions and 7 deletions
5
.changeset/early-houses-punch.md
Normal file
5
.changeset/early-houses-punch.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/radio-group': minor
|
||||
---
|
||||
|
||||
Added types for the radio-group package.
|
||||
|
|
@ -19,11 +19,10 @@ import { LionInput } from '@lion/input';
|
|||
* <lion-radio checked>
|
||||
*
|
||||
* @customElement lion-radio
|
||||
* @extends {LionInput}
|
||||
*/
|
||||
export class LionRadio extends ChoiceInputMixin(LionInput) {
|
||||
connectedCallback() {
|
||||
if (super.connectedCallback) super.connectedCallback();
|
||||
super.connectedCallback();
|
||||
this.type = 'radio';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@ import { ChoiceGroupMixin, FormGroupMixin } from '@lion/form-core';
|
|||
|
||||
/**
|
||||
* A wrapper around multiple radios.
|
||||
*
|
||||
* @extends {LionFieldset}
|
||||
*/
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/40110
|
||||
export class LionRadioGroup extends ChoiceGroupMixin(FormGroupMixin(LitElement)) {
|
||||
connectedCallback() {
|
||||
// eslint-disable-next-line wc/guard-super-call
|
||||
super.connectedCallback();
|
||||
this.setAttribute('role', 'radiogroup');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
import { expect, fixture, html } from '@open-wc/testing';
|
||||
import { expect, fixture as _fixture, html } from '@open-wc/testing';
|
||||
|
||||
import '../lion-radio-group.js';
|
||||
import '../lion-radio.js';
|
||||
|
||||
/**
|
||||
* @typedef {import('../src/LionRadioGroup').LionRadioGroup} LionRadioGroup
|
||||
* @typedef {import('../src/LionRadio').LionRadio} LionRadio
|
||||
* @typedef {import('lit-html').TemplateResult} TemplateResult
|
||||
*/
|
||||
const fixture = /** @type {(arg: TemplateResult) => Promise<LionRadioGroup>} */ (_fixture);
|
||||
|
||||
describe('<lion-radio-group>', () => {
|
||||
it('should have role = radiogroup', async () => {
|
||||
const el = await fixture(html`
|
||||
|
|
@ -24,7 +31,7 @@ describe('<lion-radio-group>', () => {
|
|||
|
||||
el.children[1].focus();
|
||||
expect(el.touched).to.equal(false, 'initially, touched state is false');
|
||||
el.children[1].checked = true;
|
||||
/** @type {LionRadio} */ (el.children[1]).checked = true;
|
||||
expect(el.touched, `focused via a mouse click, group should be touched`).to.be.true;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue