import {classMap} from "lit/directives/class-map.js"; import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit'; import { customErrorValidityState, FormControlController, validValidityState, valueMissingValidityState } from "../../internal/form"; import {HasSlotController} from "../../internal/slot"; import {property, query, state} from 'lit/decorators.js'; import {watch} from '../../internal/watch'; import ZincElement from '../../internal/zinc-element'; import type {ZincFormControl} from '../../internal/zinc-element'; import type ZnRadio from "../radio"; import styles from './radio-group.scss'; /** * @summary Short summary of the component's intended use. * @documentation https://zinc.style/components/radio-group * @status experimental * @since 1.0 * * @dependency zn-example * * @event zn-event-name - Emitted as an example. * * @slot - The default slot. * @slot example - An example slot. * * @csspart base - The component's base wrapper. * * @cssproperty --example - An example CSS custom property. */ export default class ZnRadioGroup extends ZincElement implements ZincFormControl { static styles: CSSResultGroup = unsafeCSS(styles); protected readonly formControlController = new FormControlController(this); private readonly hasSlotController = new HasSlotController(this, 'help-text', 'label'); private customValidityMessage = ''; private validationTimeout: number; @query('slot:not([name])') defaultSlot: HTMLSlotElement; @query('.radio-group__validation-input') validationInput: HTMLInputElement; @state() private errorMessage = ''; @state() defaultValue = ''; /** * The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot * instead. */ @property() label = ''; /** Text that appears in a tooltip next to the label. If you need to display HTML in the tooltip, use the `label-tooltip` slot instead. */ @property({attribute: 'label-tooltip'}) labelTooltip = ''; /** The radio groups' help text. If you need to display HTML, use the `help-text` slot instead. */ @property({attribute: 'help-text'}) helpText = ''; /** The name of the radio group, submitted as a name/value pair with form data. */ @property() name = ''; /** The current value of the radio group, submitted as a name/value pair with form data. */ @property({reflect: true}) value = ''; /** The radio group's size. This size will be applied to all child radios */ @property({reflect: true}) size: 'small' | 'medium' | 'large' = 'medium'; /** The checkbox group's orientation. Changes the group's layout from the default (vertical) to horizontal. */ @property({type: Boolean, reflect: true}) horizontal = false; /** The checkbox group's style. Changes the group's style from the default (plain) style to the 'contained' style. This style will be applied to all child checkboxes. */ @property({type: Boolean, reflect: true}) contained = false; /** * By default, form controls are associated with the nearest containing `