import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import React from 'react';
import { getDateForNative, getDateForComponent } from "../utils";
import { jsStyles } from "../NativeDateInput.styles";
var DEFAULT_MIN_DATE = '1900-01-01';
var DEFAULT_MAX_DATE = '2099-12-31';
export var NativeDateInput = /*#__PURE__*/function (_React$Component) {
  function NativeDateInput() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;

    /**
     * @public
     */
    _this.focus = function () {
      if (_this.input) {
        _this.input.focus();
      }
    };

    /**
     * @public
     */
    _this.click = function () {
      if (_this.input) {
        _this.input.click();
      }
    };
    _this.refInput = function (element) {
      _this.input = element;
    };
    return _this;
  }
  _inheritsLoose(NativeDateInput, _React$Component);
  var _proto = NativeDateInput.prototype;
  _proto.render = function render() {
    var _this2 = this;
    return /*#__PURE__*/React.createElement("input", {
      type: 'date',
      max: this.props.maxDate ? getDateForNative(this.props.maxDate) : DEFAULT_MAX_DATE,
      min: this.props.minDate ? getDateForNative(this.props.minDate) : DEFAULT_MIN_DATE,
      value: getDateForNative(this.props.value),
      onChange: function onChange(e) {
        if (_this2.props.onValueChange) {
          _this2.props.onValueChange(getDateForComponent(e.target.value));
        }
      },
      className: jsStyles.inputTypeDate(),
      ref: this.refInput,
      disabled: this.props.disabled,
      tabIndex: -1
    });
  };
  return NativeDateInput;
}(React.Component);
NativeDateInput.__KONTUR_REACT_UI__ = 'NativeDatePicker';
NativeDateInput.displayName = 'NativeDatePicker';