@coreui/react
Version:
UI Components Library for React.js
39 lines (35 loc) • 1.78 kB
JavaScript
'use strict';
var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
var React = require('react');
var PropTypes = require('prop-types');
var index = require('../../_virtual/index.js');
var CFormLabel = require('./CFormLabel.js');
var CFormSwitch = React.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 = tslib_es6.__rest(_a, ["className", "id", "invalid", "label", "reverse", "size", "type", "valid"]);
return (React.createElement("div", { className: index.default('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", tslib_es6.__assign({ type: type, className: index.default('form-check-input', {
'is-invalid': invalid,
'is-valid': valid,
}), id: id }, rest, { ref: ref })),
label && (React.createElement(CFormLabel.CFormLabel, tslib_es6.__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';
exports.CFormSwitch = CFormSwitch;
//# sourceMappingURL=CFormSwitch.js.map