UNPKG

@coreui/react

Version:

UI Components Library for React.js

37 lines (34 loc) 1.73 kB
import { __rest, __assign } from '../../node_modules/tslib/tslib.es6.js'; import React, { forwardRef } from 'react'; import PropTypes from 'prop-types'; import classNames from '../../_virtual/index.js'; import { CFormLabel } from './CFormLabel.js'; var CFormSwitch = forwardRef(function (_a, ref) { var _b; var className = _a.className, id = _a.id, invalid = _a.invalid, label = _a.label, reverse = _a.reverse, size = _a.size, _c = _a.type, type = _c === void 0 ? 'checkbox' : _c, valid = _a.valid, rest = __rest(_a, ["className", "id", "invalid", "label", "reverse", "size", "type", "valid"]); return (React.createElement("div", { className: classNames('form-check form-switch', (_b = { 'form-check-reverse': reverse }, _b["form-switch-".concat(size)] = size, _b['is-invalid'] = invalid, _b['is-valid'] = valid, _b), className) }, React.createElement("input", __assign({ type: type, className: classNames('form-check-input', { 'is-invalid': invalid, 'is-valid': valid, }), id: id }, rest, { ref: ref })), label && (React.createElement(CFormLabel, __assign({ customClassName: "form-check-label" }, (id && { htmlFor: id })), label)))); }); CFormSwitch.propTypes = { className: PropTypes.string, id: PropTypes.string, invalid: PropTypes.bool, label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), reverse: PropTypes.bool, size: PropTypes.oneOf(['lg', 'xl']), type: PropTypes.oneOf(['checkbox', 'radio']), valid: PropTypes.bool, }; CFormSwitch.displayName = 'CFormSwitch'; export { CFormSwitch }; //# sourceMappingURL=CFormSwitch.js.map