"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _numberPicker = _interopRequireDefault(require("@alifd/next/lib/number-picker"));
var _rating = _interopRequireDefault(require("@alifd/next/lib/rating"));
var _switch = _interopRequireDefault(require("@alifd/next/lib/switch"));
var _timePicker = _interopRequireDefault(require("@alifd/next/lib/time-picker2"));
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker2"));
var _react = _interopRequireDefault(require("react"));
var _excluded = ["componentType", "value"];
var context = require.context('../../../components/', true, /^\.\/(?:[^/]+\/){1}index\.tsx$/);
// console.log(context)
var ComponenChild = {};
context.keys().map(function (key) {
  var _context$default;
  if ((_context$default = context(key)["default"]) !== null && _context$default !== void 0 && _context$default.displayName) {
    var _context$default2;
    ComponenChild[(_context$default2 = context(key)["default"]) === null || _context$default2 === void 0 ? void 0 : _context$default2.displayName] = context(key)["default"];
  }
});
ComponenChild['DatePicker'] = _datePicker["default"];
ComponenChild['TimePicker'] = _timePicker["default"];
ComponenChild['Switch'] = _switch["default"];
ComponenChild['Rating'] = _rating["default"];
ComponenChild['CommonNumberInput'] = _numberPicker["default"];
var RenderChild = /*#__PURE__*/function (_React$Component) {
  (0, _inheritsLoose2["default"])(RenderChild, _React$Component);
  function RenderChild(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    _this.change = function (value) {
      console.log(value);
      var onChange = _this.props.onChange;
      _this.setState({
        editValue: value
      });
      onChange && onChange(value);
    };
    _this.state = {
      editValue: _this.props.value
    };
    return _this;
  }
  var _proto = RenderChild.prototype;
  _proto.render = function render() {
    var _this2 = this;
    var _this$props = this.props,
      componentType = _this$props.componentType,
      value = _this$props.value,
      otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
    var View = ComponenChild[componentType];
    return View ? /*#__PURE__*/_react["default"].createElement(View, (0, _extends2["default"])({}, otherProps, {
      value: value,
      onChange: function onChange(value) {
        _this2.change(value);
      }
    })) : /*#__PURE__*/_react["default"].createElement(_input["default"], {
      onChange: function onChange(value) {
        _this2.change(value);
      }
    });
  };
  return RenderChild;
}(_react["default"].Component);
RenderChild.displayName = 'RenderChild';
var _default = RenderChild;
exports["default"] = _default;