pull/846/head
Cory LaViska 2022-08-01 11:41:51 -04:00
rodzic 92a73f21eb
commit f5bcd03c3f
2 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -20,6 +20,8 @@ const RADIO_CHILDREN = ['sl-radio', 'sl-radio-button'];
* @slot - The default slot where radio controls are placed. * @slot - The default slot where radio controls are placed.
* @slot label - The radio group label. Required for proper accessibility. Alternatively, you can use the label prop. * @slot label - The radio group label. Required for proper accessibility. Alternatively, you can use the label prop.
* *
* @event sl-change - Emitted when the radio group's selected value changes.
*
* @csspart base - The component's internal wrapper. * @csspart base - The component's internal wrapper.
* @csspart label - The radio group's label. * @csspart label - The radio group's label.
* @csspart button-group - The button group that wraps radio buttons. * @csspart button-group - The button group that wraps radio buttons.
@ -81,7 +83,7 @@ export default class SlRadioGroup extends LitElement {
get validity(): ValidityState { get validity(): ValidityState {
const hasMissingData = !((this.value && this.required) || !this.required); const hasMissingData = !((this.value && this.required) || !this.required);
const hasCustomError = this.customErrorMessage !== ''; const hasCustomError = this.customErrorMessage !== '';
return { return {
badInput: false, badInput: false,
customError: hasCustomError, customError: hasCustomError,
@ -99,7 +101,7 @@ export default class SlRadioGroup extends LitElement {
reportValidity() { reportValidity() {
const validity = this.validity; const validity = this.validity;
this.errorMessage = this.customErrorMessage || validity.valid ? '' : this.input.validationMessage; this.errorMessage = this.customErrorMessage || validity.valid ? '' : this.input.validationMessage;
this.isInvalid = !validity.valid; this.isInvalid = !validity.valid;

Wyświetl plik

@ -13,7 +13,6 @@ import type { CSSResultGroup } from 'lit';
* @slot - The radio's label. * @slot - The radio's label.
* *
* @event sl-blur - Emitted when the control loses focus. * @event sl-blur - Emitted when the control loses focus.
* @event sl-change - Emitted when the control's checked state changes.
* @event sl-focus - Emitted when the control gains focus. * @event sl-focus - Emitted when the control gains focus.
* *
* @csspart base - The component's internal wrapper. * @csspart base - The component's internal wrapper.
@ -27,9 +26,8 @@ export default class SlRadio extends LitElement {
@query('.radio__input') input: HTMLInputElement; @query('.radio__input') input: HTMLInputElement;
@state() protected hasFocus = false;
@state() checked = false; @state() checked = false;
@state() protected hasFocus = false;
/** The radio's name attribute. */ /** The radio's name attribute. */
@property({ reflect: true }) name: string; @property({ reflect: true }) name: string;
@ -74,9 +72,9 @@ export default class SlRadio extends LitElement {
} }
private addEventListeners() { private addEventListeners() {
this.addEventListener('blur', () => this.handleBlur()) this.addEventListener('blur', () => this.handleBlur());
this.addEventListener('click', () => this.handleClick()) this.addEventListener('click', () => this.handleClick());
this.addEventListener('focus', () => this.handleFocus()) this.addEventListener('focus', () => this.handleFocus());
} }
private setInitialAttributes() { private setInitialAttributes() {
@ -109,7 +107,7 @@ export default class SlRadio extends LitElement {
<span part="label" class="radio__label"> <span part="label" class="radio__label">
<slot></slot> <slot></slot>
</span> </span>
</label> </span>
`; `;
} }
} }