UNPKG

1.2 kBJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import { useBootstrapPrefix } from './ThemeProvider';
4import Button from './Button';
5import { jsx as _jsx } from "react/jsx-runtime";
6import { Fragment as _Fragment } from "react/jsx-runtime";
7import { jsxs as _jsxs } from "react/jsx-runtime";
8
9const noop = () => undefined;
10
11const ToggleButton = /*#__PURE__*/React.forwardRef(({
12 bsPrefix,
13 name,
14 className,
15 checked,
16 type,
17 onChange,
18 value,
19 disabled,
20 id,
21 inputRef,
22 ...props
23}, ref) => {
24 bsPrefix = useBootstrapPrefix(bsPrefix, 'btn-check');
25 return /*#__PURE__*/_jsxs(_Fragment, {
26 children: [/*#__PURE__*/_jsx("input", {
27 className: bsPrefix,
28 name: name,
29 type: type,
30 value: value,
31 ref: inputRef,
32 autoComplete: "off",
33 checked: !!checked,
34 disabled: !!disabled,
35 onChange: onChange || noop,
36 id: id
37 }), /*#__PURE__*/_jsx(Button, { ...props,
38 ref: ref,
39 className: classNames(className, disabled && 'disabled'),
40 type: undefined,
41 role: undefined,
42 as: "label",
43 htmlFor: id
44 })]
45 });
46});
47ToggleButton.displayName = 'ToggleButton';
48export default ToggleButton;
\No newline at end of file