var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { forwardRef } from 'react';
import classnames from 'classnames';
import { isNil } from 'ramda';
import TextField from '@mui/material/TextField';
import { ReactSelectDropdownIndicatorWithIconButton } from '../ReactSelectDropdownIndicatorWithIconButton';
import { withDateRangeSelector } from '../HOCs/withDateRangeSelector';
import { useStyles } from './styles';
var DateRangeEditor = forwardRef(function (_a, ref) {
    var _b, _c;
    var label = _a.label, editorLabel = _a.editorLabel, editorPlaceholder = _a.editorPlaceholder, values = _a.values, TextFieldProps = _a.TextFieldProps, isPickingDate = _a.isPickingDate, isMenuOpen = _a.isMenuOpen, onMenuToggle = _a.onMenuToggle, otherProps = __rest(_a, ["label", "editorLabel", "editorPlaceholder", "values", "TextFieldProps", "isPickingDate", "isMenuOpen", "onMenuToggle"]);
    var styles = useStyles();
    var classes = otherProps.classes;
    return (React.createElement(TextField, __assign({}, TextFieldProps, otherProps, { ref: ref, label: label, value: (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.value) || editorLabel, onClick: onMenuToggle, variant: "filled", size: "small", InputProps: __assign({ endAdornment: (React.createElement(ReactSelectDropdownIndicatorWithIconButton, { selectProps: {
                    classes: {
                        dropdownIndicator: classnames(styles.dropdownIndicator, classes === null || classes === void 0 ? void 0 : classes.dropdownIndicator)
                    },
                    menuIsOpen: isMenuOpen
                }, innerProps: {} })), classes: {
                root: classnames(styles.inputRoot, (_b = {},
                    _b[styles.uppercase] = !isPickingDate && Array.isArray(values),
                    _b)),
                underline: classnames((_c = {}, _c[styles.underline] = isMenuOpen, _c)),
                adornedEnd: styles.adornedEnd
            }, disableUnderline: isNil(values), readOnly: true }, TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.InputProps), InputLabelProps: {
            classes: {
                root: isMenuOpen ? styles.inputLabel : undefined
            },
            shrink: !isNil(label)
        }, placeholder: editorPlaceholder })));
});
DateRangeEditor.displayName = 'DateRangeEditor';
export default withDateRangeSelector(DateRangeEditor);
