@synergy-design-system/components
Version:
This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define
99 lines (98 loc) • 4.74 kB
TypeScript
/**
* ---------------------------------------------------------------------
* 🔒 AUTOGENERATED BY VENDORISM
* Removing this comment will prevent it from being managed by it.
* ---------------------------------------------------------------------
*/
import { FormControlController } from '../../internal/form.js';
import SynergyElement from '../../internal/synergy-element.js';
import SynButtonGroup from '../button-group/button-group.component.js';
import type { CSSResultGroup } from 'lit';
import type { SynergyFormControl } from '../../internal/synergy-element.js';
/**
* @summary Radio groups are used to group multiple [radios](/components/radio) or [radio buttons](/components/radio-button) so they function as a single form control.
* @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-radio-group--docs
* @status stable
* @since 2.0
*
* @dependency syn-button-group
*
* @slot - The default slot where `<syn-radio>` or `<syn-radio-button>` elements are placed.
* @slot label - The radio group's label. Required for proper accessibility. Alternatively, you can use the `label`
* attribute.
* @slot help-text - Text that describes how to use the radio group. Alternatively, you can use the `help-text` attribute.
*
* @event syn-change - Emitted when the radio group's selected value changes.
* @event syn-input - Emitted when the radio group receives user input.
* @event syn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
*
* @csspart form-control - The form control that wraps the label, input, and help text.
* @csspart form-control-label - The label's wrapper.
* @csspart form-control-input - The input's wrapper.
* @csspart form-control-help-text - The help text's wrapper.
* @csspart button-group - The button group that wraps radio buttons.
* @csspart button-group__base - The button group's `base` part.
*/
export default class SynRadioGroup extends SynergyElement implements SynergyFormControl {
static styles: CSSResultGroup;
static dependencies: {
'syn-button-group': typeof SynButtonGroup;
};
protected readonly formControlController: FormControlController;
private readonly hasSlotController;
private customValidityMessage;
private validationTimeout;
defaultSlot: HTMLSlotElement;
validationInput: HTMLInputElement;
private hasButtonGroup;
private errorMessage;
defaultValue: string | number;
/**
* The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot
* instead.
*/
label: string;
/** The radio groups's help text. If you need to display HTML, use the `help-text` slot instead. */
helpText: string;
/** The name of the radio group, submitted as a name/value pair with form data. */
name: string;
/** The current value of the radio group, submitted as a name/value pair with form data. */
value: string | number;
/** The radio group's size. This size will be applied to all child radios and radio buttons. */
size: 'small' | 'medium' | 'large';
/**
* By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
* to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
* the same document or shadow root for this to work.
*/
form: string;
/** Ensures a child radio is checked before allowing the containing form to submit. */
required: boolean;
/** Gets the validity state object */
get validity(): ValidityState;
/** Gets the validation message */
get validationMessage(): string;
connectedCallback(): void;
firstUpdated(): void;
private getAllRadios;
private handleRadioClick;
private handleKeyDown;
private handleLabelClick;
private handleInvalid;
private syncRadioElements;
private syncRadios;
private updateCheckedRadio;
handleSizeChange(): void;
handleValueChange(): void;
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
checkValidity(): boolean;
/** Gets the associated form, if one exists. */
getForm(): HTMLFormElement | null;
/** Checks for validity and shows the browser's validation message if the control is invalid. */
reportValidity(): boolean;
/** Sets a custom validation message. Pass an empty string to restore validity. */
setCustomValidity(message?: string): void;
/** Sets focus on the radio-group. */
focus(options?: FocusOptions): void;
render(): import("lit").TemplateResult<1>;
}