@pantheon-systems/design-toolkit-react
Version:
Pantheon's React Design Toolkit
51 lines (48 loc) • 2.61 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { Radio } from 'informed';
import PropTypes from 'prop-types';
import Card from '../../Cards/Card.js';
import CardContent from '../../Cards/CardContent.js';
import { jsx, jsxs } from 'react/jsx-runtime';
var _excluded = ["children", "disabled", "fieldValue", "id", "value"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var BASE_CLASSES = 'card-option flex flex-col relative rounded focus-within:outline-none focus-within:shadow-focus';
var CardSelectRadio = function CardSelectRadio(_ref) {
var children = _ref.children,
disabled = _ref.disabled,
fieldValue = _ref.fieldValue,
id = _ref.id,
value = _ref.value,
rest = _objectWithoutProperties(_ref, _excluded);
var isSelected = fieldValue === value;
return /*#__PURE__*/jsx("label", {
className: [BASE_CLASSES, disabled ? 'disabled cursor-not-allowed' : 'hover:shadow-dropdown', isSelected ? 'selected' : ''].join(' '),
htmlFor: id,
children: /*#__PURE__*/jsxs(Card, {
children: [/*#__PURE__*/jsx(Radio, _objectSpread({
className: "absolute top-0 left-0 opacity-0",
disabled: disabled,
id: id,
value: value
}, rest)), /*#__PURE__*/jsx(CardContent, {
children: children
})]
})
});
};
CardSelectRadio.defaultProps = {
disabled: false,
fieldValue: undefined
};
CardSelectRadio.propTypes = {
children: PropTypes.node.isRequired,
disabled: PropTypes.bool,
fieldValue: PropTypes.string,
id: PropTypes.string.isRequired,
value: PropTypes.string.isRequired
};
var CardSelectRadio$1 = CardSelectRadio;
export { CardSelectRadio$1 as default };
//# sourceMappingURL=CardSelectRadio.js.map