
* Added Short Unique ID npm library * Added unique ID to form-control * Added unique ID to form-group * Unique ID added to <form> * Added unique IDs to control components * Added IDs to label and fieldset * Update Form.astro with requested changes Co-authored-by: Ayo Ayco <ayo@ayco.io> * Adjustments for requested changes. Co-authored-by: Ayo Ayco <ayo@ayco.io>
40 lines
735 B
Text
40 lines
735 B
Text
---
|
|
/**
|
|
* RADIO GROUP COMPONENT
|
|
*/
|
|
import type { Radio, ControlOption } from '@astro-reactive/common';
|
|
|
|
export interface Props {
|
|
control: Radio;
|
|
readOnly?: boolean;
|
|
}
|
|
|
|
const { control, readOnly = false } = Astro.props;
|
|
|
|
const options = control.options.map((option: string | ControlOption) => {
|
|
if (typeof option === 'string') {
|
|
return {
|
|
label: option,
|
|
value: option,
|
|
};
|
|
}
|
|
return option;
|
|
});
|
|
---
|
|
|
|
{
|
|
options.map((option: ControlOption) => (
|
|
<div class="radio-option">
|
|
<input
|
|
type="radio"
|
|
id={control.id}
|
|
name={control.name}
|
|
value={option.value}
|
|
checked={option.value === control.value}
|
|
readonly={readOnly || null}
|
|
disabled={readOnly || null}
|
|
/>{' '}
|
|
{option.label}
|
|
</div>
|
|
))
|
|
}
|