function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from 'react';
import _ from 'lodash';
import getSelectorOptions from "./../../RangeMain/getSelectorOptions";

// 内库使用-start
import Selector from "./../../../Selector";
// 内库使用-end

/* 测试使用-start
import { Selector } from 'seedsui-react'
测试使用-end */

// 日期快捷选择
function Buttons(_ref) {
  var value = _ref.value,
    _onChange = _ref.onChange,
    rangeId = _ref.rangeId,
    ranges = _ref.ranges,
    selectorProps = _ref.selectorProps,
    allowClear = _ref.allowClear;
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Selector, _extends({
    columns: 3,
    allowClear: allowClear
  }, selectorProps, {
    value: [{
      id: rangeId
    }],
    list: getSelectorOptions(ranges),
    onChange: function onChange(newRange) {
      var _newRange$;
      if (_.isEmpty(newRange)) {
        _onChange && _onChange(null, {
          rangeId: null
        });
        return;
      }
      var newRangeId = (newRange === null || newRange === void 0 || (_newRange$ = newRange[0]) === null || _newRange$ === void 0 ? void 0 : _newRange$.id) || '';
      var newValue = newRangeId && Array.isArray(ranges[newRangeId]) && ranges[newRangeId].length === 2 ? ranges[newRangeId] : value;
      _onChange && _onChange(newValue, {
        rangeId: newRangeId
      });
    }
  })));
}
export default Buttons;