GitHub

Radio

Radio is used to select a single value from a selection of values.

Components

import { DaffRadioComponent } from '@daffodil/design/radio'

@Component()
class DaffRadioComponent implements OnInit {
  disabled: boolean = false
  focused: boolean = false

  @Input() checked: boolean
  @Input() value: any
  @Input() id: string = 'daff-radio-' + radioUniqueId
  @Input() name: string = ''
  @Input() label: string = this.name
  @Input() labelledby: string

  @Output() selectionChange: EventEmitter<boolean> = new EventEmitter()

  onFocus(): void
  onBlur(): void
  select(): void
  deselect(): void
  onChange(): void
}

Inputs

checked
boolean
Default
Description

The checked property of the radio

value
any
Default
Description

The value of the radio

id
string
Default'daff-radio-' + radioUniqueId
Description

The id of the radio. It is uniquely generated but can be overwritten by the user. Must be unique.

name
string
Default''
Description

Name of the Radio

label
string
Defaultthis.name
Description

Used for aria-label. Default to name if user does not input a label.

labelledby
string
Default
Description

Used for aria-labelledby.

Outputs

selectionChange
EventEmitter
Default
Description

Output event of selection being changed

() Methods

onFocus
void

updates Focus styling

onBlur
void

updates Blur styling

select
void

toggles checked attribute on

deselect
void

toggles checked attribute off

onChange
void

import { DaffRadioSetComponent } from '@daffodil/design/radio'

@Component()
class DaffRadioSetComponent {
  @Input() name: string
}

Inputs

name
string
Default
Description

Directives

import { DaffRadioControlValueAccessorDirective } from '@daffodil/design/radio'

ControlValueAccessor functionality for the DaffRadio

@Directive()
class DaffRadioControlValueAccessorDirective implements OnInit, ControlValueAccessor {
  _onChange: () => void
  _onTouched: () => void
  @Optional() @Self() _control: NgControl

  @Input() value: any
  @Input() name: string

  writeValue(value: any): void
  registerOnChange(fn: any): void
  registerOnTouched(fn: any): void
  setDisabledState(isDisabled: boolean): void
  fireSelect(): void
  fireDeselect(): void
}

Inputs

value
any
Default
Description

The value of the ControlValueAccessor

name
string
Default
Description

The name of the ControlValueAccessor

() Methods

writeValue
void

writeValue function from the CVA interface

Parameters
Parametervalue: any
Description
registerOnChange
void

registerOnChange implemented from the CVA interface

Parameters
Parameterfn: any
Description
registerOnTouched
void

registerOnTouch implemented from the CVA interface

Parameters
Parameterfn: any
Description
setDisabledState
void

sets the disabled state.

Parameters
ParameterisDisabled: boolean
Description
fireSelect
void

calls select function for the radio

fireDeselect
void

calls deselect function for the radio


Modules

import { DaffRadioModule } from '@daffodil/design/radio'

@NgModule()
class DaffRadioModule {}