zent
Version:
一套前端设计语言和基于React的实现
14 lines (13 loc) • 814 B
JavaScript
import { __assign, __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import cx from 'classnames';
import Switch from '../../switch';
import { FormField } from '../Field';
function renderSwitch(childProps, props) {
var value = childProps.value, passedProps = __rest(childProps, ["value"]);
return _jsx(Switch, __assign({}, props.props, passedProps, { checked: value }), void 0);
}
export var FormSwitchField = function (props) {
var className = props.className, rest = __rest(props, ["className"]);
return (_jsx(FormField, __assign({}, rest, { className: cx(className, 'zent-form-switch-field'), defaultValue: typeof props.defaultValue === 'boolean' ? props.defaultValue : false }, { children: function (childProps) { return renderSwitch(childProps, props); } }), void 0));
};