1 | import classNames from 'classnames';
|
2 | import * as React from 'react';
|
3 | import { useBootstrapPrefix } from './ThemeProvider';
|
4 | import Button from './Button';
|
5 | import { jsx as _jsx } from "react/jsx-runtime";
|
6 | import { Fragment as _Fragment } from "react/jsx-runtime";
|
7 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
8 |
|
9 | const noop = () => undefined;
|
10 |
|
11 | const ToggleButton = 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 _jsxs(_Fragment, {
|
26 | children: [_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 | }), _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 | });
|
47 | ToggleButton.displayName = 'ToggleButton';
|
48 | export default ToggleButton; |
\ | No newline at end of file |