"use strict";
exports.__esModule = true;
exports.FileField = exports.cnFileField = void 0;
var tslib_1 = require("tslib");
require("./FileField.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var MixVisuallyHidden_1 = require("../../mixs/MixVisuallyHidden/MixVisuallyHidden");
var bem_1 = require("../../utils/bem");
function isRenderFn(fn) {
    return fn.call !== undefined;
}
exports.cnFileField = (0, bem_1.cn)('FileField');
var FileField = function (props) {
    var className = props.className, children = props.children, id = props.id, inputRef = props.inputRef, _a = props["aria-label"], ariaLabel = _a === void 0 ? 'File input' : _a, inputProps = (0, tslib_1.__rest)(props, ["className", "children", "id", "inputRef", 'aria-label']);
    var content = isRenderFn(children) ? children({ role: 'button', as: 'span' }) : children;
    return (react_1["default"].createElement("label", { htmlFor: id, className: (0, exports.cnFileField)(null, [className]) },
        react_1["default"].createElement("input", (0, tslib_1.__assign)({}, inputProps, { className: (0, exports.cnFileField)('Input', [(0, MixVisuallyHidden_1.cnMixVisuallyHidden)()]), id: id, type: "file", "aria-label": ariaLabel, ref: inputRef })),
        content));
};
exports.FileField = FileField;
