"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = require("@storybook/react");
var _react2 = _interopRequireDefault(require("react"));
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _Box = _interopRequireDefault(require("../../Box"));
var _TableActionCell = _interopRequireDefault(require("../TableActionCell"));
var _visual = require("../../utils/test-utils/visual");
var _excluded = ["componentDidMount"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/TableActionCell/test/TableActionCell.visual.jsx",
  _this = void 0;
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var interactiveDataHook = 'interactive-tableactioncell';
var clickSecondaryActions = function clickSecondaryActions() {
  return (0, _visual.clickElement)('table-action-cell-trigger-element');
};
var InteractiveEyeTest = /*#__PURE__*/function (_React$Component) {
  function InteractiveEyeTest() {
    (0, _classCallCheck2["default"])(this, InteractiveEyeTest);
    return _callSuper(this, InteractiveEyeTest, arguments);
  }
  (0, _inherits2["default"])(InteractiveEyeTest, _React$Component);
  return (0, _createClass2["default"])(InteractiveEyeTest, [{
    key: "componentDidMount",
    value: function () {
      var _componentDidMount = (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:
              this.props.componentDidMount();
            case 1:
            case "end":
              return _context.stop();
          }
        }, _callee, this);
      }));
      function componentDidMount() {
        return _componentDidMount.apply(this, arguments);
      }
      return componentDidMount;
    }()
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
        componentDidMount = _this$props.componentDidMount,
        restProps = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
      return /*#__PURE__*/_react2["default"].createElement(_Box["default"], {
        padding: 20,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 31,
          columnNumber: 7
        }
      }, /*#__PURE__*/_react2["default"].createElement(_TableActionCell["default"], (0, _extends2["default"])({
        dataHook: interactiveDataHook
      }, restProps, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 32,
          columnNumber: 9
        }
      })));
    }
  }]);
}(_react2["default"].Component);
var interactiveTests = [{
  describe: 'Primary action',
  its: [{
    it: 'Should allow making it always visible',
    props: {
      primaryAction: {
        onClick: function onClick() {},
        visibility: 'always',
        text: 'text'
      }
    }
  }, {
    it: 'Should display a premium item skin with visibility always',
    props: {
      primaryAction: {
        onClick: function onClick() {},
        visibility: 'always',
        text: 'Premium',
        skin: 'premium'
      }
    }
  }]
}, {
  describe: 'Primary action array format',
  its: [{
    it: 'Should display multiple primary actions with always show',
    props: {
      primaryAction: [{
        text: 'Edit',
        onClick: function onClick() {},
        priority: 'primary'
      }, {
        text: 'Delete',
        onClick: function onClick() {},
        priority: 'secondary'
      }],
      alwaysShowPrimaryActions: true
    }
  }, {
    it: 'Should display multiple primary actions on hover only',
    props: {
      primaryAction: [{
        text: 'Edit',
        onClick: function onClick() {},
        priority: 'primary'
      }, {
        text: 'Delete',
        onClick: function onClick() {},
        priority: 'secondary'
      }],
      alwaysShowPrimaryActions: false
    }
  }, {
    it: 'Should display multiple primary actions with primary priority',
    props: {
      primaryAction: [{
        text: 'Save',
        onClick: function onClick() {},
        priority: 'primary'
      }, {
        text: 'Cancel',
        onClick: function onClick() {},
        priority: 'primary'
      }],
      alwaysShowPrimaryActions: true
    }
  }, {
    it: 'Should display multiple primary actions with secondary priority',
    props: {
      primaryAction: [{
        text: 'View',
        onClick: function onClick() {},
        priority: 'secondary'
      }, {
        text: 'Share',
        onClick: function onClick() {},
        priority: 'secondary'
      }],
      alwaysShowPrimaryActions: true
    }
  }]
}, {
  describe: 'Secondary Actions',
  its: [{
    it: 'Should display a divider',
    props: {
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 151,
            columnNumber: 21
          }
        })
      }, {
        divider: true
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 156,
            columnNumber: 21
          }
        })
      }],
      numOfVisibleSecondaryActions: 0
    },
    componentDidMount: clickSecondaryActions
  }, {
    it: 'Should display a destructive item skin',
    props: {
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 169,
            columnNumber: 21
          }
        })
      }, {
        divider: true
      }, {
        text: 'Delete',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Delete, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 174,
            columnNumber: 21
          }
        }),
        skin: 'destructive'
      }],
      numOfVisibleSecondaryActions: 0
    },
    componentDidMount: clickSecondaryActions
  }, {
    it: 'Should display a subtitle',
    props: {
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 188,
            columnNumber: 21
          }
        }),
        subtitle: 'And sky'
      }],
      numOfVisibleSecondaryActions: 0
    },
    componentDidMount: clickSecondaryActions
  }, {
    it: 'Should display a premium item skin',
    props: {
      numOfVisibleSecondaryActions: 1,
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 203,
            columnNumber: 21
          }
        }),
        skin: 'premium'
      }]
    }
  }]
}, {
  describe: 'Placeholder icons',
  its: [{
    it: 'Should display normal placeholder icon',
    props: {
      primaryAction: {
        onClick: function onClick() {},
        text: 'text'
      }
    }
  }, {
    it: 'Should display small placeholder icon',
    props: {
      size: 'small',
      primaryAction: {
        onClick: function onClick() {},
        text: 'text'
      }
    }
  }]
}, {
  describe: 'Small actions',
  its: [{
    it: 'Should display small actions',
    props: {
      alwaysShowSecondaryActions: true,
      size: 'small',
      primaryAction: {
        onClick: function onClick() {},
        text: 'text',
        skin: 'standard',
        prefixIcon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Add, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 247,
            columnNumber: 25
          }
        }),
        suffixIcon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.ChevronDownSmall, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 248,
            columnNumber: 25
          }
        })
      },
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 253,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Star action was triggered.');
        }
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 258,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Download action was triggered.');
        }
      }, {
        text: 'Duplicate',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Duplicate, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 263,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Duplicate action was triggered.');
        }
      }, {
        text: 'Print',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Print, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 268,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Print action was triggered.');
        }
      }]
    }
  }, {
    it: 'Should display small actions',
    props: {
      alwaysShowSecondaryActions: true,
      size: 'small',
      primaryAction: {
        onClick: function onClick() {},
        text: 'text',
        skin: 'standard'
      },
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 287,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Star action was triggered.');
        }
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 292,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Download action was triggered.');
        }
      }, {
        text: 'Duplicate',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Duplicate, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 297,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Duplicate action was triggered.');
        }
      }, {
        text: 'Print',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Print, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 302,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Print action was triggered.');
        }
      }]
    }
  }, {
    it: 'Should display icon prefix in small actions',
    props: {
      alwaysShowSecondaryActions: true,
      size: 'small',
      primaryAction: {
        onClick: function onClick() {},
        text: 'text',
        skin: 'standard',
        prefixIcon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Add, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 317,
            columnNumber: 25
          }
        })
      },
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 322,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Star action was triggered.');
        }
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 327,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Download action was triggered.');
        }
      }, {
        text: 'Duplicate',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Duplicate, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 332,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Duplicate action was triggered.');
        }
      }, {
        text: 'Print',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Print, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 337,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Print action was triggered.');
        }
      }]
    }
  }, {
    it: 'Should display icon suffix in small actions',
    props: {
      alwaysShowSecondaryActions: true,
      size: 'small',
      primaryAction: {
        onClick: function onClick() {},
        text: 'text',
        skin: 'standard',
        suffixIcon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.ChevronDownSmall, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 352,
            columnNumber: 25
          }
        })
      },
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 357,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Star action was triggered.');
        }
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 362,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Download action was triggered.');
        }
      }, {
        text: 'Duplicate',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Duplicate, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 367,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Duplicate action was triggered.');
        }
      }, {
        text: 'Print',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Print, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 372,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Print action was triggered.');
        }
      }]
    }
  }]
}, {
  describe: 'Tiny actions',
  its: [{
    it: 'Should display tiny actions',
    props: {
      alwaysShowSecondaryActions: true,
      size: 'tiny',
      primaryAction: {
        onClick: function onClick() {},
        text: 'text',
        skin: 'standard',
        prefixIcon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Add, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 392,
            columnNumber: 25
          }
        }),
        suffixIcon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.ChevronDownSmall, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 393,
            columnNumber: 25
          }
        })
      },
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 398,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Star action was triggered.');
        }
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 403,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Download action was triggered.');
        }
      }, {
        text: 'Duplicate',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Duplicate, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 408,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Duplicate action was triggered.');
        }
      }, {
        text: 'Print',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Print, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 413,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {
          return window.alert('Print action was triggered.');
        }
      }]
    }
  }]
}, {
  describe: 'More actions props',
  its: [{
    it: 'Should display more actions button with tertiary priority',
    props: {
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 430,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {}
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 435,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {}
      }],
      numOfVisibleSecondaryActions: 0,
      moreActionsProps: {
        priority: 'tertiary'
      }
    }
  }, {
    it: 'Should display more actions button with dark skin',
    props: {
      secondaryActions: [{
        text: 'Star',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Star, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 451,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {}
      }, {
        text: 'Download',
        icon: /*#__PURE__*/_react2["default"].createElement(_wixUiIconsCommon.Download, {
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 456,
            columnNumber: 21
          }
        }),
        onClick: function onClick() {}
      }],
      numOfVisibleSecondaryActions: 0,
      moreActionsProps: {
        skin: 'dark'
      }
    }
  }]
}];
interactiveTests.forEach(function (_ref) {
  var describe = _ref.describe,
    its = _ref.its;
  its.forEach(function (_ref2) {
    var it = _ref2.it,
      props = _ref2.props,
      componentDidMount = _ref2.componentDidMount;
    (0, _react.storiesOf)("TableActionCell".concat(describe ? '/' + describe : ''), module).add(it, function () {
      return /*#__PURE__*/_react2["default"].createElement(InteractiveEyeTest, (0, _extends2["default"])({}, props, {
        componentDidMount: componentDidMount,
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 475,
          columnNumber: 9
        }
      }));
    });
  });
});