aws-northstar
Version:
NorthStar Design System
83 lines (79 loc) • 3.93 kB
JavaScript
;
/** *******************************************************************************************************************
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. *
******************************************************************************************************************** */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RadioButton = void 0;
const react_1 = __importStar(require("react"));
const styles_1 = require("@material-ui/core/styles");
const RadioGroup_1 = __importDefault(require("@material-ui/core/RadioGroup"));
const clsx_1 = __importDefault(require("clsx"));
const RadioButton_1 = __importDefault(require("../RadioButton"));
exports.RadioButton = RadioButton_1.default;
const useStyles = (0, styles_1.makeStyles)({
root: {},
div: {
extend: 'root',
textAlign: 'center',
width: 'fit-content',
},
radio: {
transform: 'scale(1)',
},
});
/**
* RadioGroup is a helpful wrapper used to group Radio components.
*/
const RadioGroup = (_a) => {
var { name, value, items = [], onChange } = _a, props = __rest(_a, ["name", "value", "items", "onChange"]);
const classes = useStyles();
return (react_1.default.createElement("div", { className: (0, clsx_1.default)(classes.root, classes.div) },
react_1.default.createElement(RadioGroup_1.default, { className: classes.radio, value: value, name: name, onChange: onChange, "data-testid": props['data-testid'] }, items.map((item, index) => (react_1.default.createElement(react_1.Fragment, { key: index }, item))))));
};
exports.default = RadioGroup;