UNPKG

@gssfed/vital-ui-kit-react

Version:
53 lines (43 loc) 1.83 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _templateObject = _taggedTemplateLiteral([''], ['']); function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } /** * * Copyright © 2018 Galaxy Software Services https://github.com/GSS-FED/vital-ui-kit-react * MIT license */ import * as React from 'react'; import styled from 'styled-components'; import Radio from './Radio'; var Root = styled.div(_templateObject); /** * @render react * @name Radio * @description Group of radio buttons * @example * <RadioGroup items={[{name: 'color', value: 'red', label: 'Red'}, {name: 'color', value: 'blue', label: 'Blue', defaultChecked: true}, {name: 'color', value:'yello', label: 'Yellow'}]} /> */ var RadioGroup = function RadioGroup(_ref) { var isDisabled = _ref.isDisabled, items = _ref.items, onRadioChange = _ref.onRadioChange, props = _objectWithoutProperties(_ref, ['isDisabled', 'items', 'onRadioChange']); return React.createElement( Root, null, items.map(function (item) { return React.createElement(Radio, _extends({ isDisabled: isDisabled }, item, { key: item.value }, props, { onChange: onRadioChange })); }) ); }; RadioGroup.defaultProps = { isDisabled: false }; export default RadioGroup;