import { __assign, __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback } from 'react';
import cx from 'classnames';
import { RadioGroup } from '../../radio';
import { FormField } from '../Field';
import { useEventCallbackRef } from '../../utils/hooks/useEventCallbackRef';
function RadioGroupField(_a) {
    var childProps = _a.childProps, props = _a.props;
    var onChangeRef = useEventCallbackRef(childProps.onChange);
    var onChange = useCallback(function (e) {
        var _a;
        (_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, e.target.value);
    }, [onChangeRef]);
    return (_jsx(RadioGroup, __assign({}, props.props, childProps, { onChange: onChange }, { children: props.children }), void 0));
}
export function FormRadioGroupField(props) {
    var _a;
    var className = props.className, rest = __rest(props, ["className"]);
    return (_jsx(FormField, __assign({}, rest, { className: cx(className, 'zent-form-radio-group-field'), defaultValue: (_a = props.defaultValue) !== null && _a !== void 0 ? _a : null }, { children: function (childProps) { return _jsx(RadioGroupField, { childProps: childProps, props: props }, void 0); } }), void 0));
}
