File

projects/ui-kit-lib/src/lib/v2/radio-button/radio.ts

Description

Single radio button component.

Responsibilities:

  • Manages its own checked/disabled state.
  • Coordinates with its parent MDRadioGroup.
  • Emits change when user selects it.
  • Handles focus/keyboard via CDK FocusMonitor.

Implements

OnInit AfterViewInit DoCheck OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

constructor()

Inject parent group (optional) and host tabindex. Also initializes disabledInteractive default.

Inputs

aria-describedby
Type : string

Id of element that describes this input.

aria-label
Type : string

ARIA label text for input (if no external label).

aria-labelledby
Type : string

Id of element that labels this input.

checked
Type : boolean

Checked state with group coordination and dispatcher notify.

disabled
Type : boolean

Disabled state; considers group-level disabled as well.

disabledInteractive
Type : boolean

If true, item remains interactive/focusable even when disabled. Also considers group-level disabledInteractive.

id
Type : string
Default value : this._uniqueId

Element id (defaults to unique id).

name
Type : string

Shared group name; set by group or consumer.

required
Type : boolean

Required state; considers group-level required as well.

tabIndex
Type : number
Default value : 0

Tabindex for internal input; normalized via numberAttribute. Default is 0 so item can be focused when selected.

value
Type : any

Arbitrary value associated with this radio.

Outputs

change
Type : EventEmitter<RadioChange>

Emits when this particular radio is selected by the user.

Methods

_markForCheck
_markForCheck()

Ask view to update (used by group).

Returns : void
_onInputInteraction
_onInputInteraction(event: Event)

Handles interaction on the real input. Ensures single selection, emits change, updates group model.

Parameters :
Name Type Optional
event Event No
Returns : void
_onTouchTargetClick
_onTouchTargetClick(event: Event)

Click on the visual/touch target should behave like clicking the input. Also refocus the input if allowed.

Parameters :
Name Type Optional
event Event No
Returns : void
Protected _setDisabled
_setDisabled(value: boolean)

Setter for disabled that triggers CD when value changes.

Parameters :
Name Type Optional
value boolean No
Returns : void
focus
focus(options?: FocusOptions, origin?: FocusOrigin)

Programmatic focus API. If origin provided, uses FocusMonitor to set proper focus classes.

Parameters :
Name Type Optional
options FocusOptions Yes
origin FocusOrigin Yes
Returns : void

Properties

Protected _elementRef
Type : unknown
Default value : inject(ElementRef)

Host element reference (used by FocusMonitor and listeners).

_inputElement
Type : ElementRef<HTMLInputElement>
Decorators :
@ViewChild('input')

Template refs.

_noopAnimations
Type : unknown
Default value : false
Decorators :
@ViewChild('formField', {read: ElementRef, static: true})

Placeholder for potential animations flag (wired via template).

radioGroup
Type : MDRadioGroup

Optional reference to parent group (injected).

Accessors

checked
getchecked()

Checked state with group coordination and dispatcher notify.

Returns : boolean
setchecked(value: boolean)
Parameters :
Name Type Optional
value boolean No
Returns : void
value
getvalue()

Arbitrary value associated with this radio.

Returns : any
setvalue(value: any)
Parameters :
Name Type Optional
value any No
Returns : void
disabled
getdisabled()

Disabled state; considers group-level disabled as well.

Returns : boolean
setdisabled(value: boolean)
Parameters :
Name Type Optional
value boolean No
Returns : void
required
getrequired()

Required state; considers group-level required as well.

Returns : boolean
setrequired(value: boolean)
Parameters :
Name Type Optional
value boolean No
Returns : void
disabledInteractive
getdisabledInteractive()

If true, item remains interactive/focusable even when disabled. Also considers group-level disabledInteractive.

Returns : boolean
setdisabledInteractive(value: boolean)
Parameters :
Name Type Optional
value boolean No
Returns : void
inputId
getinputId()

Id for internal input element.

Returns : string

results matching ""

    No results matching ""