import _Input from "@alifd/next/es/input";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
var _excluded = ["componentType", "value"];
import React from 'react';
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"];
  }
});
// console.log(ComponenChild)
// ComponenChild['Switch'] = Switch;
// ComponenChild['Rating'] = Rating;
var RenderChild = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(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 = _objectWithoutPropertiesLoose(_this$props, _excluded);
    var View = ComponenChild[componentType];
    return View ? /*#__PURE__*/React.createElement(View, _extends({}, otherProps, {
      value: value,
      onChange: function onChange(value) {
        _this2.change(value);
      }
    })) : /*#__PURE__*/React.createElement(_Input, _extends({
      onChange: function onChange(value) {
        _this2.change(value);
      }
    }, otherProps));
  };
  return RenderChild;
}(React.Component);
RenderChild.displayName = 'RenderChild';
export default RenderChild;