"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

var _checkbox = _interopRequireDefault(require("../../checkbox"));

var _ = _interopRequireDefault(require(".."));

var _icon = _interopRequireDefault(require("../../icon"));

var _input = _interopRequireDefault(require("../../input"));

var _numberPicker = _interopRequireDefault(require("../../number-picker"));

var _radio = _interopRequireDefault(require("../../radio"));

var _range = _interopRequireDefault(require("../../range"));

var _rating = _interopRequireDefault(require("../../rating"));

var _react = _interopRequireDefault(require("react"));

var _reactDom = _interopRequireDefault(require("react-dom"));

var _select = _interopRequireDefault(require("../../select"));

var _switch = _interopRequireDefault(require("../../switch"));

var _upload = _interopRequireDefault(require("../../upload"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || 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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var FormItem = _["default"].Item;
var formItemLayout = {
  labelCol: {
    span: 7
  },
  wrapperCol: {
    span: 16
  }
};
var fileList = [{
  uid: '0',
  name: 'IMG.png',
  state: 'done',
  url: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
  downloadURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
  imgURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg'
}, {
  uid: '1',
  name: 'IMG.png',
  percent: 50,
  state: 'uploading',
  url: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
  downloadURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
  imgURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg'
}, {
  uid: '2',
  name: 'IMG.png',
  state: 'error',
  url: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
  downloadURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg',
  imgURL: 'https://img.alicdn.com/tps/TB19O79MVXXXXcZXVXXXXXXXXXX-1024-1024.jpg'
}];

var Demo = /*#__PURE__*/function (_React$Component) {
  _inherits(Demo, _React$Component);

  var _super = _createSuper(Demo);

  function Demo(props) {
    var _this;

    _classCallCheck(this, Demo);

    _this = _super.call(this, props);

    _defineProperty(_assertThisInitialized(_this), "submitHandler", void 0);

    _defineProperty(_assertThisInitialized(_this), "onPreviewChange", void 0);

    _defineProperty(_assertThisInitialized(_this), "ratingPreview", void 0);

    _this.state = {
      preview: false
    };

    _this.submitHandler = function (e) {
      console.log(e);
    };

    _this.onPreviewChange = function (checked) {
      _this.setState({
        preview: checked
      });
    };

    _this.ratingPreview = function (value) {
      return /*#__PURE__*/_react["default"].createElement("p", null, value, " ", value > 2.5 ? /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        type: "smile"
      }) : /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        type: "cry"
      }));
    };

    return _this;
  }

  _createClass(Demo, [{
    key: "render",
    value: function render() {
      return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_["default"], _extends({}, formItemLayout, {
        isPreview: this.state.preview,
        style: {
          maxWidth: '800px'
        }
      }), /*#__PURE__*/_react["default"].createElement(FormItem, {
        label: "preview: ",
        isPreview: false,
        size: "small",
        style: {
          marginBottom: 0
        }
      }, /*#__PURE__*/_react["default"].createElement(_switch["default"], {
        size: "medium",
        onChange: this.onPreviewChange
      })), /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          height: 1,
          width: '100%',
          margin: '20px 0'
        }
      }), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Username:"
      }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
        defaultValue: "Fusion",
        placeholder: "Please enter your username",
        id: "username",
        name: "username",
        "aria-required": "true"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Password:"
      }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
        defaultValue: "Fusion@2019",
        htmlType: "password",
        placeholder: "Please enter your password",
        id: "password",
        name: "password",
        "aria-required": "true"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Link:"
      }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
        name: "link",
        addonTextBefore: "http://",
        addonTextAfter: ".com",
        defaultValue: "alibaba",
        "aria-label": "input with config of addonTextBefore and addonTextAfter"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Number:"
      }, /*#__PURE__*/_react["default"].createElement(_numberPicker["default"], {
        name: "number",
        defaultValue: 1
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "autoComplete:"
      }, /*#__PURE__*/_react["default"].createElement(_select["default"].AutoComplete, {
        name: "autoComplete",
        defaultValue: "selected"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "multiple Select:"
      }, /*#__PURE__*/_react["default"].createElement(_select["default"], {
        name: "select",
        defaultValue: ['apple', 'banana'],
        mode: "multiple"
      }, /*#__PURE__*/_react["default"].createElement(_select["default"].Option, {
        value: "apple"
      }, "Apple"), /*#__PURE__*/_react["default"].createElement(_select["default"].Option, {
        value: "banana"
      }, "Banana"))), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Rating:"
      }, /*#__PURE__*/_react["default"].createElement(_rating["default"], {
        defaultValue: 4.5 // @ts-ignore
        ,
        name: "rate",
        "aria-label": "what's the rate score"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Custom Render Rating:",
        renderPreview: this.ratingPreview
      }, /*#__PURE__*/_react["default"].createElement(_rating["default"], {
        defaultValue: 4.5 // @ts-ignore
        ,
        name: "rate2",
        "aria-label": "what's the rate2 score"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Checkbox:"
      }, /*#__PURE__*/_react["default"].createElement(_checkbox["default"].Group, {
        name: "checkbox",
        defaultValue: ['react', 'vue']
      }, /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
        value: "react"
      }, "React"), /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
        value: "vue"
      }, "Vue"), /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
        value: "angular"
      }, "Angular"))), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Radio:"
      }, /*#__PURE__*/_react["default"].createElement(_radio["default"].Group, {
        name: "radio",
        defaultValue: 'react'
      }, /*#__PURE__*/_react["default"].createElement(_radio["default"], {
        value: "react"
      }, "React"), /*#__PURE__*/_react["default"].createElement(_radio["default"], {
        value: "vue"
      }, "Vue"), /*#__PURE__*/_react["default"].createElement(_radio["default"], {
        value: "angular"
      }, "Angular"))), /*#__PURE__*/_react["default"].createElement(FormItem, {
        required: true,
        label: "Range:"
      }, /*#__PURE__*/_react["default"].createElement(_range["default"] // @ts-ignore
      , {
        name: "range",
        slider: "double",
        defaultValue: [10, 80]
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        label: "Note:"
      }, /*#__PURE__*/_react["default"].createElement(_input["default"].TextArea, {
        placeholder: "description",
        name: "a11yRemark",
        defaultValue: "Fusion \u662F\u4E00\u5957\u4F01\u4E1A\u7EA7\u4E2D\u540E\u53F0UI\u7684\u89E3\u51B3\u65B9\u6848\uFF0C\u81F4\u529B\u4E8E\u89E3\u51B3\u8BBE\u8BA1\u5E08\u4E0E\u524D\u7AEF\u5728\u4EA7\u54C1\u4F53\u9A8C\u4E00\u81F4\u6027\u3001\u5DE5\u4F5C\u534F\u540C\u3001\u5F00\u53D1\u6548\u7387\u65B9\u9762\u7684\u95EE\u9898\u3002\u901A\u8FC7\u534F\u52A9\u4E1A\u52A1\u7EBF\u6784\u5EFA\u8BBE\u8BA1\u7CFB\u7EDF\uFF0C\u63D0\u4F9B\u7CFB\u7EDF\u5316\u5DE5\u5177\u534F\u52A9\u8BBE\u8BA1\u5E08\u524D\u7AEF\u4F7F\u7528\u8BBE\u8BA1\u7CFB\u7EDF\uFF0C\u4E0B\u6E38\u63D0\u4F9B\u4E00\u7AD9\u5F0F\u8BBE\u8BA1\u9879\u76EE\u534F\u4F5C\u5E73\u53F0\uFF1B\u6253\u901A\u4E92\u8054\u7F51\u4EA7\u54C1\u4ECE\u8BBE\u8BA1\u5230\u5F00\u53D1\u7684\u5DE5\u4F5C\u6D41\u3002"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        label: "Upload:"
      }, /*#__PURE__*/_react["default"].createElement(_upload["default"], {
        name: "upload",
        defaultValue: fileList,
        listType: "text"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        label: "Upload:"
      }, /*#__PURE__*/_react["default"].createElement(_upload["default"], {
        name: "upload2",
        defaultValue: fileList,
        listType: "image"
      })), /*#__PURE__*/_react["default"].createElement(FormItem, {
        wrapperCol: {
          offset: 7
        }
      }, /*#__PURE__*/_react["default"].createElement(_["default"].Submit, {
        validate: true,
        type: "primary",
        onClick: this.submitHandler
      }, "Submit"), /*#__PURE__*/_react["default"].createElement(_["default"].Reset, {
        style: {
          marginLeft: 10
        }
      }, "Reset"))));
    }
  }]);

  return Demo;
}(_react["default"].Component);

_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(Demo, null), document.getElementById('form-demo-14'));