"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@storybook/react");
var _MultiSelect = _interopRequireDefault(require("../MultiSelect"));
var _FormField = _interopRequireDefault(require("../../FormField"));
var _RTLWrapper = require("../../../stories/utils/RTLWrapper");
var _visual = require("../../utils/test-utils/visual");
var _excluded = ["componentDidMount", "rtl"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/MultiSelect/test/MultiSelect.visual.jsx",
  _this = void 0;
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var interactiveDataHook = 'interactive-multiselect';
var inputDataHook = 'wsr-custom-input';
var options = [{
  value: 'Alabama',
  id: 'AL'
}, {
  value: 'Alaska',
  id: 'AK'
}, {
  value: 'Arizona',
  id: 'AZ'
}, {
  value: 'Arkansas',
  id: 'AR'
}, {
  value: 'California',
  id: 'CA'
}, {
  value: 'North Carolina',
  id: 'NC'
}, {
  value: 'Colorado',
  id: 'CO'
}, {
  value: 'Connecticut',
  id: 'CT'
}, {
  value: 'Delaware',
  id: 'DL'
}, {
  value: 'Florida',
  id: 'FL'
}, {
  value: 'Georgia',
  id: 'GA'
}, {
  value: 'Hawaii',
  id: 'HI'
}, {
  value: 'Idaho',
  id: 'IL'
}, {
  value: 'Illinois',
  id: 'IN'
}, {
  value: 'Indiana',
  id: 'IA'
}];
var tests = [{
  describe: 'Basic',
  its: [{
    it: 'should render MultiSelect with customSuffix over 400px width',
    props: {
      customSuffix: /*#__PURE__*/_react["default"].createElement("div", {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 38,
          columnNumber: 25
        }
      }, "some button"),
      tags: [{
        id: '1',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '2',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '3',
        label: 'aaaaaaaaaaaa'
      }]
    },
    width: '400px'
  }, {
    it: 'should render MultiSelect with customPrefix over 400px width',
    props: {
      customPrefix: /*#__PURE__*/_react["default"].createElement("div", {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 50,
          columnNumber: 25
        }
      }, "some button"),
      tags: [{
        id: '1',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '2',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '3',
        label: 'aaaaaaaaaaaa'
      }]
    },
    width: '400px'
  }, {
    it: 'should render MultiSelect with customSuffix',
    props: {
      customSuffix: /*#__PURE__*/_react["default"].createElement("div", {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 62,
          columnNumber: 25
        }
      }, "some button"),
      tags: [{
        id: '1',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '2',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '3',
        label: 'aaaaaaaaaaaa'
      }]
    }
  }, {
    it: 'should render MultiSelect with customPrefix',
    props: {
      customPrefix: /*#__PURE__*/_react["default"].createElement("div", {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 73,
          columnNumber: 25
        }
      }, "some button"),
      tags: [{
        id: '1',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '2',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '3',
        label: 'aaaaaaaaaaaa'
      }]
    }
  }, {
    it: 'should render MultiSelect with "select" mode',
    props: {
      tags: [{
        id: '1',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '2',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '3',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '4',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '5',
        label: 'aaaaaaaaaaaa'
      }, {
        id: '6',
        label: 'aaaaaaaaaaaa'
      }],
      mode: 'select'
    },
    width: '400px'
  }, {
    it: 'should fill input with tags without breaking a line',
    props: {
      tags: [{
        id: '1',
        label: 'a'
      }, {
        id: '2',
        label: 'b'
      }, {
        id: '3',
        label: 'c'
      }, {
        id: '4',
        label: 'd'
      }, {
        id: '5',
        label: 'e'
      }, {
        id: '6',
        label: 'f'
      }, {
        id: '7',
        label: 'f'
      }]
    },
    width: '400px'
  }, {
    it: 'should render tags without remove button when readOnly mode is ON',
    props: {
      readOnly: true,
      tags: [{
        id: '1',
        label: 'a'
      }, {
        id: '2',
        label: 'b'
      }]
    }
  }, {
    it: 'should render tags without remove button when readOnly mode is ON as onReorder function is passed',
    props: {
      readOnly: true,
      onReorder: function onReorder() {
        return null;
      },
      tags: [{
        id: '1',
        label: 'a'
      }, {
        id: '2',
        label: 'b'
      }]
    }
  }, {
    it: 'should render disabled MultiSelect',
    props: {
      disabled: true,
      tags: [{
        id: '1',
        label: 'Alabama'
      }, {
        id: '2',
        label: 'Alaska'
      }, {
        id: '3',
        label: 'Arizona'
      }, {
        id: '4',
        label: 'Arkansas'
      }]
    },
    width: '500px'
  }, {
    it: 'should render disabled MultiSelect with a placeholder',
    props: {
      disabled: true,
      placeholder: 'This is a MultiSelect placeholder'
    },
    width: '500px'
  }, {
    it: 'should render readOnly MultiSelect',
    props: {
      readOnly: true
    },
    width: '500px'
  }]
}, {
  describe: 'With Status',
  its: [{
    it: 'error',
    props: {
      mode: 'select',
      status: 'error'
    }
  }, {
    it: 'warning',
    props: {
      mode: 'select',
      status: 'warning'
    }
  }, {
    it: 'loading',
    props: {
      mode: 'select',
      status: 'loading'
    }
  }]
}];
tests.forEach(function (_ref) {
  var describe = _ref.describe,
    its = _ref.its;
  its.forEach(function (_ref2) {
    var it = _ref2.it,
      props = _ref2.props,
      width = _ref2.width;
    (0, _react2.storiesOf)("MultiSelect".concat(describe ? '/' + describe : ''), module).add(it, function () {
      return /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          width: width
        },
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 195,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react["default"].createElement(_MultiSelect["default"], (0, _extends2["default"])({}, props, {
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 196,
          columnNumber: 11
        }
      })));
    });
  });
});
var interactiveTests = [{
  describe: 'Directional tests',
  its: [{
    it: 'LTR should show 2 tags',
    componentDidMount: function componentDidMount() {
      return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              (0, _visual.clickElement)(inputDataHook);
              (0, _visual.focusElement)(inputDataHook);
            case 2:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }))();
    },
    props: {
      tags: [{
        id: 'AL',
        label: 'Alabama (AL)'
      }, {
        id: 'AZ',
        label: 'Arizona (AZ)'
      }],
      options: options
    }
  }, {
    it: 'RTL should show 2 tags',
    componentDidMount: function componentDidMount() {
      return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              (0, _visual.clickElement)(inputDataHook);
              (0, _visual.focusElement)(inputDataHook);
            case 2:
            case "end":
              return _context2.stop();
          }
        }, _callee2);
      }))();
    },
    props: {
      tags: [{
        id: 'AL',
        label: 'Alabama (AL)'
      }, {
        id: 'AZ',
        label: 'Arizona (AZ)'
      }],
      options: options
    },
    rtl: true
  }]
}];
var InteractiveEyeTest = function InteractiveEyeTest(_ref3) {
  var componentDidMount = _ref3.componentDidMount,
    rtl = _ref3.rtl,
    props = (0, _objectWithoutProperties2["default"])(_ref3, _excluded);
  (0, _react.useEffect)(function () {
    componentDidMount();
  }, [componentDidMount]);
  return /*#__PURE__*/_react["default"].createElement(_RTLWrapper.RTLWrapper, {
    rtl: rtl,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 245,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react["default"].createElement(_MultiSelect["default"], (0, _extends2["default"])({
    dataHook: interactiveDataHook
  }, props, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 246,
      columnNumber: 7
    }
  })));
};
interactiveTests.forEach(function (_ref4) {
  var describe = _ref4.describe,
    its = _ref4.its;
  its.forEach(function (_ref5) {
    var it = _ref5.it,
      props = _ref5.props,
      rtl = _ref5.rtl,
      componentDidMount = _ref5.componentDidMount;
    (0, _react2.storiesOf)("MultiSelect".concat(describe ? '/' + describe : ''), module).add(it, function () {
      return /*#__PURE__*/_react["default"].createElement(InteractiveEyeTest, (0, _extends2["default"])({}, props, {
        componentDidMount: componentDidMount,
        rtl: rtl,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 256,
          columnNumber: 9
        }
      }));
    });
  });
});
var multiselectWithFormFieldStatus = [{
  describe: 'Form field status',
  its: [{
    it: 'Error',
    props: {
      status: 'error',
      statusMessage: 'This is error message',
      options: options
    }
  }, {
    it: 'Warning',
    props: {
      status: 'warning',
      statusMessage: 'This is warning message',
      options: options
    }
  }, {
    it: 'Loading',
    props: {
      status: 'loading',
      statusMessage: 'This is loading message',
      options: options
    }
  }]
}];
multiselectWithFormFieldStatus.forEach(function (_ref6) {
  var describe = _ref6.describe,
    its = _ref6.its;
  its.forEach(function (_ref7) {
    var it = _ref7.it,
      props = _ref7.props;
    (0, _react2.storiesOf)("MultiSelect".concat(describe ? '/' + describe : ''), module).add(it, function () {
      return /*#__PURE__*/_react["default"].createElement(_FormField["default"], {
        status: props.status,
        statusMessage: props.statusMessage,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 303,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react["default"].createElement(_MultiSelect["default"], {
        options: props.options,
        mode: "select",
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 304,
          columnNumber: 11
        }
      }));
    });
  });
});