var _excluded = ["value", "index", "disabledDate", "onChange", "dateFormat", "width"],
  _excluded2 = ["value", "dateFormat", "onChange"],
  _excluded3 = ["value", "dateFormat", "onChange"],
  _excluded4 = ["value", "onChange"],
  _excluded5 = ["value", "onChange", "width"];
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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, { useEffect, useState } from 'react';
import { DatePicker, TimePicker } from 'antd';
import moment from 'dayjs';
var RangePicker = DatePicker.RangePicker;
var TimeRangePicker = TimePicker.RangePicker;
export function DatePicker_(_ref) {
  var value = _ref.value,
    index = _ref.index,
    _ref$disabledDate = _ref.disabledDate,
    disabledDate = _ref$disabledDate === void 0 ? false : _ref$disabledDate,
    onChange = _ref.onChange,
    _ref$dateFormat = _ref.dateFormat,
    dateFormat = _ref$dateFormat === void 0 ? null : _ref$dateFormat,
    _ref$width = _ref.width,
    width = _ref$width === void 0 ? 200 : _ref$width,
    others = _objectWithoutProperties(_ref, _excluded);
  var _useState = useState(value),
    _useState2 = _slicedToArray(_useState, 2),
    _value = _useState2[0],
    setValue = _useState2[1];
  useEffect(function () {
    setValue(value);
  }, [value]);
  var _dateFormat = dateFormat || 'YYYY-MM-DD';
  var handleChange = function handleChange(value, others) {
    setValue(value);
    onChange(value, others);
  };
  var disabledDateFun = function disabledDateFun(current) {
    // Can not select days before today and today
    // console.log(moment().endOf('day'), '11');
    return current && current < moment().startOf('day');
  };
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DatePicker, _extends({
    style: {
      width: width
    },
    allowClear: true,
    disabledDate: disabledDate ? disabledDateFun : function () {},
    value: _value ? moment(_value, _dateFormat) : null,
    onChange: function onChange(cur) {
      handleChange(cur ? moment(cur).format(_dateFormat) : '', others);
    }
  }, others)));
}
export function RangePickerDisabled(_ref2) {
  var value = _ref2.value,
    _ref2$dateFormat = _ref2.dateFormat,
    dateFormat = _ref2$dateFormat === void 0 ? null : _ref2$dateFormat,
    onChange = _ref2.onChange,
    others = _objectWithoutProperties(_ref2, _excluded2);
  var _dateFormat = dateFormat || 'YYYYMMDD';
  var handleChange = function handleChange(e) {
    var date = [e[0] ? moment(e[0]).format(_dateFormat) : null, e[1] ? moment(e[1]).format(_dateFormat) : null];
    onChange(date);
  };
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RangePicker, _extends({
    allowClear: true,
    onChange: function onChange(e) {
      return handleChange(e);
    }
  }, others)));
}
// tslint:disable-next-line:class-name
export function RangePicker_(_ref3) {
  var value = _ref3.value,
    _ref3$dateFormat = _ref3.dateFormat,
    dateFormat = _ref3$dateFormat === void 0 ? null : _ref3$dateFormat,
    onChange = _ref3.onChange,
    others = _objectWithoutProperties(_ref3, _excluded3);
  var _useState3 = useState(value),
    _useState4 = _slicedToArray(_useState3, 2),
    _value = _useState4[0],
    setValue = _useState4[1];
  useEffect(function () {
    setValue(value);
  }, [value]);
  console.log(others, 'others');
  var _dateFormat = dateFormat || 'YYYYMMDD';
  var handleChange = function handleChange(e, others) {
    var date = [e[0] ? moment(e[0]).format(_dateFormat) : null, e[1] ? moment(e[1]).format(_dateFormat) : null];
    setValue(date);
    onChange(date);
  };
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RangePicker, _extends({
    allowClear: true,
    value: _value && _typeof(_value) === 'object' && _value.length > 0 ? [_value[0] ? moment(_value[0], _dateFormat) : '', _value[1] ? moment(_value[1], _dateFormat) : ''] : null,
    onChange: function onChange(e) {
      return handleChange(e, others);
    }
  }, others)));
}

// tslint:disable-next-line:class-name
export function TimeRangePicker_(_ref4) {
  var value = _ref4.value,
    onChange = _ref4.onChange,
    others = _objectWithoutProperties(_ref4, _excluded4);
  var _useState5 = useState(value),
    _useState6 = _slicedToArray(_useState5, 2),
    _value = _useState6[0],
    setValue = _useState6[1];
  useEffect(function () {
    setValue(value);
  }, [value]);
  var dateFormat = 'HH:mm';
  var handleChange = function handleChange(e, others) {
    var date = [e[0] ? moment(e[0]).format(dateFormat) : null, e[1] ? moment(e[1]).format(dateFormat) : null];
    setValue(date);
    onChange(date);
  };
  return /*#__PURE__*/React.createElement(TimeRangePicker, _extends({
    allowClear: true,
    format: dateFormat,
    placeholder: "\u8BF7\u9009\u62E9",
    value: _value && _typeof(_value) === 'object' && _value.length > 0 ? [_value[0] ? moment(_value[0], dateFormat) : '', _value[1] ? moment(_value[1], dateFormat) : ''] : null,
    onChange: function onChange(e) {
      return handleChange(e, others);
    }
  }, others));
}
export function TimePicker_(_ref5) {
  var _ref5$value = _ref5.value,
    value = _ref5$value === void 0 ? null : _ref5$value,
    onChange = _ref5.onChange,
    _ref5$width = _ref5.width,
    width = _ref5$width === void 0 ? 90 : _ref5$width,
    others = _objectWithoutProperties(_ref5, _excluded5);
  var _useState7 = useState(value),
    _useState8 = _slicedToArray(_useState7, 2),
    _value = _useState8[0],
    setValue = _useState8[1];
  useEffect(function () {
    setValue(value);
  }, [value]);
  var handleChange = function handleChange(time, others) {
    setValue(time);
    onChange(time, others);
  };
  return /*#__PURE__*/React.createElement(TimePicker, _extends({
    value: _value ? moment(_value, 'HH:mm') : null,
    onChange: function onChange(time) {
      return handleChange(time ? moment(time).format('HH:mm') : '', others);
    },
    style: {
      width: width
    },
    allowClear: true,
    placeholder: "\u8BF7\u9009\u62E9"
  }, others));
}