var _excluded = ["min", "max", "value", "onError", "onChange", "className"];
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); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
import Combo from "./../../WeekCombo";

// 内库使用-start
import DateUtil from "./../../../../utils/DateUtil";
import Input from "./../../../Input";
// 内库使用-end

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

// 周选择
var Week = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var min = _ref.min,
    max = _ref.max,
    value = _ref.value,
    onError = _ref.onError,
    _onChange = _ref.onChange,
    className = _ref.className,
    props = _objectWithoutProperties(_ref, _excluded);
  // 显示文本
  var displayValue = DateUtil.format(value, 'week');
  var rootRef = useRef(null);
  useImperativeHandle(ref, function () {
    return {
      rootDOM: rootRef === null || rootRef === void 0 ? void 0 : rootRef.current,
      getRootDOM: function getRootDOM() {
        return rootRef === null || rootRef === void 0 ? void 0 : rootRef.current;
      },
      // 显示文本
      displayValue: displayValue,
      getDisplayValue: function getDisplayValue() {
        return DateUtil.format(value, 'week');
      }
    };
  });

  // 向前
  function handlePrev(e) {
    if (value instanceof Date === false) return;
    _onChange && _onChange(DateUtil.previousWeek(value));
  }

  // 向后
  function handleNext(e) {
    if (value instanceof Date === false) return;
    _onChange && _onChange(DateUtil.nextWeek(value));
  }
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input.IconLeftArrow, {
    className: "datepicker-types-previous",
    onClick: handlePrev
  }), /*#__PURE__*/React.createElement(Combo, _extends({}, props, {
    value: value,
    className: "datepicker-types-date".concat(className ? ' ' + className : ''),
    onChange: function onChange(newValue) {
      _onChange && _onChange(newValue);
    }
  }), /*#__PURE__*/React.createElement("p", null, displayValue || '')), /*#__PURE__*/React.createElement(Input.IconRightArrow, {
    className: "datepicker-types-next",
    onClick: handleNext
  }));
});
export default Week;