import { ListFormComponent } from "server/plugins/engine/components/ListFormComponent" ; import { FormData , FormSubmissionErrors } from "server/plugins/engine/types" ; import { ListItem } from "server/plugins/engine/components/types" ; /**
 * "Selection controls" are checkboxes and radios (and switches), as per Material UI nomenclature.
 */ export class SelectionControlField extends ListFormComponent { getViewModel ( formData , errors ) { const { name , items } = this ; const options = this . options ; const viewModel = super . getViewModel ( formData , errors ) ; viewModel . fieldset = { legend : viewModel . label , } ; viewModel . items = items . map ( ( item ) => { const itemModel = { text : item . text , value : item . value , checked : `${ item . value }` === `${ formData [ name ] }` , } ; if ( options . bold ) { itemModel . label = { classes : "govuk-label--s" , } ; } if ( item . description ) { itemModel . hint = { html : this . localisedString ( item . description ) , } ; } return itemModel ; } ) ; return viewModel ; } }