Radio button and hidden FormGroups.
1 files added
2 files modified
| | |
| | | import classNames from 'classnames'; |
| | | import {FormFeedback, Input, UncontrolledTooltip} from 'reactstrap'; |
| | | import {FormCheckbox} from "./FormCheckbox"; |
| | | import {FormRadioButton} from "./FormRadioButton"; |
| | | import {FormButton} from "./FormButton"; |
| | | import {FormSelect, FormOption} from "./FormSelect"; |
| | | import {FormOption, FormSelect} from "./FormSelect"; |
| | | import {revisedRandId} from "../../../utilities/global"; |
| | | import I18n from "../translation/I18n"; |
| | | |
| | |
| | | const FormLabelField = (props) => { |
| | | const forId = props.children.props.id || props.children.props.name || props.htmlFor || revisedRandId(); |
| | | return ( |
| | | <FormGroup> |
| | | <FormGroup className={props.className}> |
| | | <FormLabel length={props.labelLength} htmlFor={forId}> |
| | | {props.label} |
| | | </FormLabel> |
| | |
| | | |
| | | FormLabelField.propTypes = { |
| | | id: PropTypes.string, |
| | | className: PropTypes.string, |
| | | htmlFor: PropTypes.string, |
| | | validationMessage: PropTypes.string, |
| | | labelLength: PropTypes.number, |
| | |
| | | |
| | | FormLabelField.defaultProps = { |
| | | id: null, |
| | | className: null, |
| | | htmlFor: null, |
| | | validationMessage: null, |
| | | labelLength: 2, |
| | |
| | | label={props.label} |
| | | hint={props.hint} |
| | | validationState={props.validationState} |
| | | className={props.className} |
| | | > |
| | | <FormInput |
| | | id={props.id} |
| | |
| | | FormLabelInputField.propTypes = { |
| | | id: PropTypes.string, |
| | | label: PropTypes.node, |
| | | className: PropTypes.node, |
| | | labelLength: PropTypes.number, |
| | | fieldLength: PropTypes.number, |
| | | hint: PropTypes.string, |
| | |
| | | |
| | | FormLabelInputField.defaultProps = { |
| | | id: null, |
| | | className: null, |
| | | label: '', |
| | | labelLength: 2, |
| | | fieldLength: 10, |
| | |
| | | FormSelect, |
| | | FormOption, |
| | | FormCheckbox, |
| | | FormRadioButton, |
| | | FormLabelInputField, |
| | | FormFieldset, |
| | | FormButton, |
| New file |
| | |
| | | import React from 'react'; |
| | | import PropTypes from 'prop-types'; |
| | | import {UncontrolledTooltip} from 'reactstrap'; |
| | | import {revisedRandId} from "../../../utilities/global"; |
| | | import classNames from 'classnames'; |
| | | import I18n from "../translation/I18n"; |
| | | |
| | | class FormRadioButton extends React.Component { |
| | | |
| | | _id = this.props.id || revisedRandId(); |
| | | |
| | | render() { |
| | | const {id, className, labelKey, label, hint, hintKey, ...other} = this.props; |
| | | let tooltip = null; |
| | | let hintId = null; |
| | | if (hint || hintKey) { |
| | | hintId = `hint-${this._id}`; |
| | | tooltip = |
| | | <UncontrolledTooltip placement="right" target={hintId}> |
| | | {hintKey ? <I18n name={hintKey}/> : hint} |
| | | </UncontrolledTooltip>; |
| | | } |
| | | let labelNode = <label |
| | | className={'custom-control-label'} |
| | | htmlFor={this._id}> |
| | | {labelKey ? <I18n name={labelKey}/> : this.props.label} |
| | | </label>; |
| | | return ( |
| | | <React.Fragment> |
| | | <div className="custom-control custom-radio custom-control-inline" id={hintId}> |
| | | <input type="radio" |
| | | id={this._id} |
| | | className={classNames('custom-control-input', className)} |
| | | {...other} |
| | | /> |
| | | {labelNode} |
| | | </div> |
| | | {tooltip} |
| | | </React.Fragment> |
| | | ); |
| | | } |
| | | } |
| | | |
| | | FormRadioButton.propTypes = { |
| | | id: PropTypes.string, |
| | | name: PropTypes.string, |
| | | checked: PropTypes.bool, |
| | | onChange: PropTypes.func, |
| | | hint: PropTypes.string, |
| | | label: PropTypes.node, |
| | | labelKey: PropTypes.string |
| | | }; |
| | | |
| | | FormRadioButton.defaultProps = { |
| | | checked: false, |
| | | onChange: null |
| | | }; |
| | | |
| | | |
| | | export { |
| | | FormRadioButton |
| | | }; |
| | |
| | | color: #50555f; |
| | | } |
| | | |
| | | .hidden { |
| | | display: none; |
| | | } |
| | | |
| | | a:hover { |
| | | color: #47a7eb; |
| | | } |