/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * OpenCRVS is also distributed under the terms of the Civil Registration * & Healthcare Disclaimer located at http://opencrvs.org/license. * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as React from 'react' import { RadioButton } from './RadioButton' import { NoticeWrapper } from '../DateField' import { InputLabel } from '../InputField/InputLabel' import styled from 'styled-components' const Wrapper = styled.div` width: 100%; ` const List = styled.ul<{ flexDirection?: string }>` list-style: none; margin: 0; padding: 0; & > div { margin-bottom: 4px; } ${({ flexDirection }) => flexDirection && `display: flex; & > div { margin-right: 16px; }`} ` const LargeList = styled.ul<{ flexDirection?: string }>` list-style: none; margin: 0; padding: 0; & > div { margin-bottom: 4px; } ${({ flexDirection }) => flexDirection && `display: flex; & > div { margin-right: 16px; }`} ` const NestedChildren = styled.div` margin: 15px 0px 0px 18px; padding-left: 33px; border-left: 4px solid ${({ theme }) => theme.colors.copy}; padding-top: 0px !important; ` export enum RadioSize { LARGE = 'large', NORMAL = 'normal' } interface IConditionals { action: string expression: string } export interface IRadioOption { label: string value: string | boolean param?: Record conditionals?: IConditionals[] disabled?: boolean } export interface IRadioGroupProps { options: IRadioOption[] name: string value: string size?: RadioSize notice?: string nestedFields?: { [key: string]: JSX.Element[] } flexDirection?: string onChange: (value: string) => void } export const RadioGroup = ({ options, value, name, size, notice, nestedFields, flexDirection, ...props }: IRadioGroupProps) => ( {notice && ( {notice} )} {size && size === RadioSize.LARGE ? ( {options.map((option) => { return (
{nestedFields && value === option.value && nestedFields[value] && ( {nestedFields[value]} )}
) })}
) : ( {options.map((option) => { return (
) })}
)}
)