UNPKG

@talend/react-bootstrap

Version:

Bootstrap 3 components built with React

70 lines (69 loc) 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _propTypes = _interopRequireDefault(require("prop-types")); var _react = _interopRequireDefault(require("react")); var _Button = _interopRequireDefault(require("./Button")); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const propTypes = { /** * The `<input>` `type` * @type {[type]} */ type: _propTypes.default.oneOf(['checkbox', 'radio']), /** * The HTML input name, used to group like checkboxes or radio buttons together * semantically */ name: _propTypes.default.string, /** * The checked state of the input, managed by `<ToggleButtonGroup>`` automatically */ checked: _propTypes.default.bool, /** * The disabled state of both the label and input */ disabled: _propTypes.default.bool, /** * [onChange description] */ onChange: _propTypes.default.func, /** * The value of the input, and unique identifier in the ToggleButtonGroup */ value: _propTypes.default.any.isRequired }; class ToggleButton extends _react.default.Component { render() { const { children, name, checked, type, onChange, value, ...props } = this.props; const disabled = props.disabled; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, { ...props, active: !!checked, componentClass: "label", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", { name: name, type: type, autoComplete: "off", value: value, checked: !!checked, disabled: !!disabled, onChange: onChange }), children] }); } } ToggleButton.propTypes = propTypes; var _default = exports.default = ToggleButton; //# sourceMappingURL=ToggleButton.js.map