@wix/design-system
Version:
@wix/design-system
734 lines • 20.8 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
var _excluded = ["componentDidMount"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/TableActionCell/test/TableActionCell.visual.jsx",
_this = this;
import _regeneratorRuntime from "@babel/runtime/regenerator";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(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; })(); }
import { storiesOf } from '@storybook/react';
import React from 'react';
import { Download, Star, Add, ChevronDownSmall, Duplicate, Print, Delete } from '@wix/wix-ui-icons-common';
import Box from '../../Box';
import TableActionCell from '../TableActionCell';
import { clickElement } from '../../utils/test-utils/visual';
var interactiveDataHook = 'interactive-tableactioncell';
var clickSecondaryActions = function clickSecondaryActions() {
return clickElement('table-action-cell-trigger-element');
};
var InteractiveEyeTest = /*#__PURE__*/function (_React$Component) {
function InteractiveEyeTest() {
_classCallCheck(this, InteractiveEyeTest);
return _callSuper(this, InteractiveEyeTest, arguments);
}
_inherits(InteractiveEyeTest, _React$Component);
return _createClass(InteractiveEyeTest, [{
key: "componentDidMount",
value: function () {
var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.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 = _objectWithoutProperties(_this$props, _excluded);
return /*#__PURE__*/React.createElement(Box, {
padding: 20,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 31,
columnNumber: 7
}
}, /*#__PURE__*/React.createElement(TableActionCell, _extends({
dataHook: interactiveDataHook
}, restProps, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 32,
columnNumber: 9
}
})));
}
}]);
}(React.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__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 151,
columnNumber: 21
}
})
}, {
divider: true
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 156,
columnNumber: 21
}
})
}],
numOfVisibleSecondaryActions: 0
},
componentDidMount: clickSecondaryActions
}, {
it: 'Should display a destructive item skin',
props: {
secondaryActions: [{
text: 'Star',
icon: /*#__PURE__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 169,
columnNumber: 21
}
})
}, {
divider: true
}, {
text: 'Delete',
icon: /*#__PURE__*/React.createElement(Delete, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 174,
columnNumber: 21
}
}),
skin: 'destructive'
}],
numOfVisibleSecondaryActions: 0
},
componentDidMount: clickSecondaryActions
}, {
it: 'Should display a subtitle',
props: {
secondaryActions: [{
text: 'Star',
icon: /*#__PURE__*/React.createElement(Star, {
__self: this,
__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__*/React.createElement(Star, {
__self: this,
__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__*/React.createElement(Add, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 247,
columnNumber: 25
}
}),
suffixIcon: /*#__PURE__*/React.createElement(ChevronDownSmall, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 248,
columnNumber: 25
}
})
},
secondaryActions: [{
text: 'Star',
icon: /*#__PURE__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 253,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Star action was triggered.');
}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 258,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Download action was triggered.');
}
}, {
text: 'Duplicate',
icon: /*#__PURE__*/React.createElement(Duplicate, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 263,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Duplicate action was triggered.');
}
}, {
text: 'Print',
icon: /*#__PURE__*/React.createElement(Print, {
__self: this,
__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__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 287,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Star action was triggered.');
}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 292,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Download action was triggered.');
}
}, {
text: 'Duplicate',
icon: /*#__PURE__*/React.createElement(Duplicate, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 297,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Duplicate action was triggered.');
}
}, {
text: 'Print',
icon: /*#__PURE__*/React.createElement(Print, {
__self: this,
__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__*/React.createElement(Add, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 317,
columnNumber: 25
}
})
},
secondaryActions: [{
text: 'Star',
icon: /*#__PURE__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 322,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Star action was triggered.');
}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 327,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Download action was triggered.');
}
}, {
text: 'Duplicate',
icon: /*#__PURE__*/React.createElement(Duplicate, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 332,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Duplicate action was triggered.');
}
}, {
text: 'Print',
icon: /*#__PURE__*/React.createElement(Print, {
__self: this,
__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__*/React.createElement(ChevronDownSmall, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 352,
columnNumber: 25
}
})
},
secondaryActions: [{
text: 'Star',
icon: /*#__PURE__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 357,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Star action was triggered.');
}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 362,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Download action was triggered.');
}
}, {
text: 'Duplicate',
icon: /*#__PURE__*/React.createElement(Duplicate, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 367,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Duplicate action was triggered.');
}
}, {
text: 'Print',
icon: /*#__PURE__*/React.createElement(Print, {
__self: this,
__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__*/React.createElement(Add, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 392,
columnNumber: 25
}
}),
suffixIcon: /*#__PURE__*/React.createElement(ChevronDownSmall, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 393,
columnNumber: 25
}
})
},
secondaryActions: [{
text: 'Star',
icon: /*#__PURE__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 398,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Star action was triggered.');
}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 403,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Download action was triggered.');
}
}, {
text: 'Duplicate',
icon: /*#__PURE__*/React.createElement(Duplicate, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 408,
columnNumber: 21
}
}),
onClick: function onClick() {
return window.alert('Duplicate action was triggered.');
}
}, {
text: 'Print',
icon: /*#__PURE__*/React.createElement(Print, {
__self: this,
__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__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 430,
columnNumber: 21
}
}),
onClick: function onClick() {}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__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__*/React.createElement(Star, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 451,
columnNumber: 21
}
}),
onClick: function onClick() {}
}, {
text: 'Download',
icon: /*#__PURE__*/React.createElement(Download, {
__self: this,
__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;
storiesOf("TableActionCell".concat(describe ? '/' + describe : ''), module).add(it, function () {
return /*#__PURE__*/React.createElement(InteractiveEyeTest, _extends({}, props, {
componentDidMount: componentDidMount,
__self: _this,
__source: {
fileName: _jsxFileName,
lineNumber: 475,
columnNumber: 9
}
}));
});
});
});