@i-novus/ui-core
Version:
Базовые UI компоненты
16 lines (15 loc) • 991 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import RcSwitch from 'rc-switch';
import classNames from 'classnames';
import { useConfigProvider } from '../core';
export const Switch = forwardRef((props, ref) => {
const { className, checked, defaultChecked, onChange, children, visible = true, prefix, disabled = false, style, ...restProps } = props;
const { getPrefix } = useConfigProvider();
const prefixCls = getPrefix(prefix);
if (!visible) {
return null;
}
return (_jsxs("div", { className: classNames(`${prefixCls}-switch-wrapper`, className), style: style, children: [_jsx(RcSwitch, { ...restProps, prefix: prefixCls, prefixCls: `${prefixCls}-switch`, ref: ref, checked: checked, defaultChecked: defaultChecked, disabled: disabled, onChange: onChange }), children && (_jsx("span", { className: classNames(`${prefixCls}-switch-label`), children: children }))] }));
});
Switch.displayName = 'Switch';