"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); }

require("./demo1.css");

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

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

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

var _2 = require("../..");

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

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; }

function onSearch(v) {
  console.log(v);
}

var dataSource = [{
  label: 'Recent label',
  value: 'Recent'
}, {
  label: 'dress label',
  value: 'dress'
}, {
  label: 'sunglasses label',
  value: 'sunglasses'
}, {
  label: 't-shirt label',
  value: 't-shirt'
}];
var sizeList = [{
  value: 'large',
  label: 'large'
}, {
  value: 'medium',
  label: 'medium'
}, {
  value: 'small',
  label: 'small'
}, {
  value: 'xs',
  label: 'xs'
}];
var typeList = [{
  value: 'normal',
  label: 'normal'
}, {
  value: 'brand',
  label: 'brand'
}, {
  value: 'dark',
  label: 'dark'
}];
var disabledList = [{
  value: true,
  label: 'true'
}, {
  value: false,
  label: 'false'
}];
var themeList = [{
  value: 'white',
  label: 'white'
}, {
  value: 'grey',
  label: 'grey'
}];
var menuData = [{
  label: 'Products',
  value: 'Products'
}, {
  label: 'Products1',
  value: 'Products1'
}, {
  label: 'Products2',
  value: 'Products2'
}, {
  label: 'Products3',
  value: 'Products3'
}, {
  label: 'Products4',
  value: 'Products4'
}, {
  label: 'Products5',
  value: 'Products5'
}, {
  label: 'Products6',
  value: 'Products6'
}, {
  label: 'Products7',
  value: 'Products7'
}, {
  label: 'Products8',
  value: 'Products8'
}, {
  label: 'Products9',
  value: 'Products9'
}, {
  label: 'Products10',
  value: 'Products10'
}, {
  label: 'Suppliers1111111111',
  value: 'Suppliers1111111111'
}];

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

  var _super = _createSuper(App);

  function App(props) {
    var _this;

    _classCallCheck(this, App);

    _this = _super.call(this, props);

    _defineProperty(_assertThisInitialized(_this), "handleSize", function (size) {
      _this.setState({
        size: size
      });
    });

    _defineProperty(_assertThisInitialized(_this), "handleDisabled", function (disabled) {
      _this.setState({
        disabled: disabled
      });
    });

    _defineProperty(_assertThisInitialized(_this), "handleTheme", function (theme) {
      _this.setState({
        theme: theme
      });
    });

    _defineProperty(_assertThisInitialized(_this), "handleType", function (type) {
      _this.setState({
        type: type
      });
    });

    _defineProperty(_assertThisInitialized(_this), "onSearch", function (value, filterValue) {
      console.log(value, filterValue);
    });

    _defineProperty(_assertThisInitialized(_this), "onChange", function (value) {
      _this.setState({
        value: value
      });
    });

    _this.state = {
      size: 'large',
      menuData: menuData,
      value: '',
      disabled: false,
      theme: 'white',
      type: 'normal'
    };
    return _this;
  }

  _createClass(App, [{
    key: "onFilterChange",
    value: // value is filter value，obj is the search value
    function onFilterChange(value) {
      console.log(value);
    }
  }, {
    key: "renderMenu",
    value: function renderMenu() {
      var menuData = this.state.menuData;
      return /*#__PURE__*/_react["default"].createElement(_2.Menu, {
        onSelect: this.onFilterChange.bind(this),
        rtl: true,
        className: "diy-menu",
        selectMode: "single"
      }, /*#__PURE__*/_react["default"].createElement(_2.Menu.Group, {
        label: "Recent",
        key: "xxx"
      }, menuData.map(function (item) {
        return /*#__PURE__*/_react["default"].createElement(_2.Menu.Item, {
          key: item.value
        }, item.label);
      })));
    }
  }, {
    key: "render",
    value: function render() {
      var _this$state = this.state,
          size = _this$state.size,
          disabled = _this$state.disabled,
          theme = _this$state.theme,
          type = _this$state.type;
      return /*#__PURE__*/_react["default"].createElement(_2.ConfigProvider, {
        theme: theme
      }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
        className: "demo-label"
      }, "Select Size\uFF1A"), /*#__PURE__*/_react["default"].createElement(_2.Radio.Group, {
        defaultValue: "medium",
        dataSource: sizeList,
        value: this.state.size,
        onChange: this.handleSize
      }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("span", {
        className: "demo-label"
      }, "Select Disabled\uFF1A"), /*#__PURE__*/_react["default"].createElement(_2.Radio.Group, {
        defaultValue: false // @ts-ignore
        ,
        dataSource: disabledList,
        value: this.state.disabled,
        onChange: this.handleDisabled
      }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("span", {
        className: "demo-label"
      }, "Select Theme\uFF1A"), /*#__PURE__*/_react["default"].createElement(_2.Radio.Group, {
        defaultValue: "white" // @ts-ignore
        ,
        dataSource: themeList,
        value: this.state.theme,
        onChange: this.handleTheme
      }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("span", {
        className: "demo-label"
      }, "Select Type\uFF1A"), /*#__PURE__*/_react["default"].createElement(_2.Radio.Group, {
        defaultValue: "white" // @ts-ignore
        ,
        dataSource: typeList,
        value: this.state.type,
        onChange: this.handleType
      }), /*#__PURE__*/_react["default"].createElement("div", {
        className: type === 'brand' ? type : theme
      }, /*#__PURE__*/_react["default"].createElement("p", {
        key: "1"
      }, "default"), /*#__PURE__*/_react["default"].createElement(_["default"], {
        key: "2" // theme={theme}
        ,
        size: size,
        type: type,
        disabled: disabled,
        onSearch: onSearch,
        style: {
          width: '400px'
        }
      }), /*#__PURE__*/_react["default"].createElement("p", {
        key: "3"
      }, "custom text "), /*#__PURE__*/_react["default"].createElement(_["default"], {
        key: "4" // theme={theme}
        ,
        size: size,
        type: type,
        disabled: disabled,
        searchText: "search",
        onSearch: onSearch,
        style: {
          width: '400px'
        }
      }), /*#__PURE__*/_react["default"].createElement("p", {
        key: "5"
      }, "custom text widthout icon"), /*#__PURE__*/_react["default"].createElement(_["default"], {
        key: "6" // theme={theme}
        ,
        size: size,
        type: type,
        hasIcon: false,
        disabled: disabled,
        searchText: /*#__PURE__*/_react["default"].createElement("span", null, "search"),
        onSearch: onSearch,
        style: {
          width: '400px'
        }
      }), /*#__PURE__*/_react["default"].createElement("p", {
        key: "7"
      }, "Suppliers"), /*#__PURE__*/_react["default"].createElement(_["default"] // theme={theme}
      , {
        size: size,
        type: type,
        disabled: disabled,
        onChange: this.onChange,
        onSearch: onSearch,
        filterProps: {
          autoWidth: false,
          color: 'red'
        },
        defaultFilterValue: "Suppliers",
        filter: dataSource,
        onFilterChange: this.onFilterChange.bind(this),
        style: {
          width: '400px'
        }
      }), /*#__PURE__*/_react["default"].createElement("p", {
        key: "8"
      }, "Suppliers and relevance"), /*#__PURE__*/_react["default"].createElement(_["default"] // theme={theme}
      , {
        size: size,
        type: type,
        disabled: disabled,
        onChange: this.onChange,
        onSearch: onSearch,
        filterProps: {
          autoWidth: true,
          color: 'red'
        },
        defaultFilterValue: "Suppliers",
        filter: dataSource,
        dataSource: dataSource,
        onFilterChange: this.onFilterChange.bind(this),
        style: {
          width: '400px'
        }
      }))));
    }
  }]);

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

_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(App, null), document.getElementById('search-demo-1'));