var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import { Button } from '../../Button';
import { Block } from '../../Block';
import { isActiveRange, parsePreDefinedRangeConfig } from './datePickerHelpers';
var PreDefinedRangesBlock = /** @class */ (function (_super) {
    __extends(PreDefinedRangesBlock, _super);
    function PreDefinedRangesBlock() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PreDefinedRangesBlock.prototype.render = function () {
        var _a = this.props, ranges = _a.ranges, startDate = _a.startDate, endDate = _a.endDate, onPredefinedRangeButtonClick = _a.onPredefinedRangeButtonClick;
        if (_.isEmpty(ranges)) {
            return null;
        }
        var rangeButtons = _.map(ranges, function (rangeConfig, buttonText) {
            var range = parsePreDefinedRangeConfig(rangeConfig);
            return (React.createElement(Button, { key: buttonText, className: "range-predefined-btn", block: true, active: isActiveRange({ range: range, startDate: startDate, endDate: endDate }), onClick: function () {
                    return onPredefinedRangeButtonClick({
                        startDate: range.startDate,
                        endDate: range.endDate
                    });
                } }, buttonText));
        });
        return React.createElement(Block, { className: "rc-datepicker-predefined-ranges" }, rangeButtons);
    };
    PreDefinedRangesBlock.propTypes = {
        ranges: PropTypes.object,
        startDate: PropTypes.oneOfType([PropTypes.number, PropTypes.object, PropTypes.string]),
        endDate: PropTypes.oneOfType([PropTypes.number, PropTypes.object, PropTypes.string]),
        onPredefinedRangeButtonClick: PropTypes.func.isRequired
    };
    PreDefinedRangesBlock.defaultProps = {
        ranges: [],
        startDate: null,
        endDate: null
    };
    return PreDefinedRangesBlock;
}(React.PureComponent));
export { PreDefinedRangesBlock };
//# sourceMappingURL=PreDefinedRangesBlock.js.map