import { __assign, __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import cn from 'classnames';
import { FormField } from '../Field';
import { ImageUpload, } from '../../upload';
import { warningDefaultValueProp } from '../utils';
import omit from '../../utils/omit';
function renderImageUpload(childProps, props) {
    var value = childProps.value, onChange = childProps.onChange;
    return (_jsx(ImageUpload, __assign({}, omit(props.props, ['defaultFileList']), { fileList: value, onChange: onChange }), void 0));
}
export function FormImageUploadField(props) {
    var _a;
    var className = props.className, rest = __rest(props, ["className"]);
    React.useEffect(function () {
        var _a;
        warningDefaultValueProp(!('defaultFileList' in ((_a = props.props) !== null && _a !== void 0 ? _a : {})), 'defaultFileList', 'FormImageUploadField');
    }, []);
    return (_jsx(FormField, __assign({}, rest, { className: cn(className, 'zent-form-upload-field'), defaultValue: (_a = props.defaultValue) !== null && _a !== void 0 ? _a : [] }, { children: function (childProps) { return renderImageUpload(childProps, props); } }), void 0));
}
