wix-style-react
Version:
wix-style-react
197 lines (168 loc) • 7.08 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TableEmptyStateExample = undefined;
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _Table = require('wix-style-react/Table');
var _TableToolbar = require('wix-style-react/TableToolbar');
var _Card = require('wix-style-react/Card');
var _Card2 = _interopRequireDefault(_Card);
var _Search = require('wix-style-react/Search');
var _Search2 = _interopRequireDefault(_Search);
var _Dropdown = require('wix-style-react/Dropdown');
var _Dropdown2 = _interopRequireDefault(_Dropdown);
var _TextLink = require('wix-style-react/TextLink');
var _TextLink2 = _interopRequireDefault(_TextLink);
var _newIcons = require('wix-style-react/new-icons');
var _ImagePlaceholder = require('../assets/ImagePlaceholder');
var _ImagePlaceholder2 = _interopRequireDefault(_ImagePlaceholder);
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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var TableEmptyStateExample = exports.TableEmptyStateExample = function (_React$Component) {
_inherits(TableEmptyStateExample, _React$Component);
function TableEmptyStateExample() {
_classCallCheck(this, TableEmptyStateExample);
return _possibleConstructorReturn(this, (TableEmptyStateExample.__proto__ || Object.getPrototypeOf(TableEmptyStateExample)).apply(this, arguments));
}
_createClass(TableEmptyStateExample, [{
key: 'render',
value: function render() {
return _react2.default.createElement(
_Card2.default,
null,
_react2.default.createElement(
_Table.Table,
{
dataHook: 'story-table-empty-state-example',
data: [],
itemsPerPage: 20,
columns: [{
title: 'Name',
render: function render(row) {
return _react2.default.createElement(
'span',
null,
row.name
);
},
width: '30%',
minWidth: '150px'
}, {
title: 'SKU',
render: function render(row) {
return _react2.default.createElement(
'span',
null,
row.SKU
);
},
width: '20%',
minWidth: '100px'
}, {
title: 'Price',
render: function render(row) {
return _react2.default.createElement(
'span',
null,
row.price
);
},
width: '20%',
minWidth: '100px'
}, {
title: 'Inventory',
render: function render(row) {
return _react2.default.createElement(
'span',
null,
row.inventory
);
},
width: '20%',
minWidth: '100px'
}],
showSelection: true
},
_react2.default.createElement(MainToolbar, null),
_react2.default.createElement(
_Table.Table.EmptyState,
{
title: 'You haven\'t added any items yet',
subtitle: 'Add items to your website so people can buy them',
image: _react2.default.createElement(_ImagePlaceholder2.default, null)
},
_react2.default.createElement(
_TextLink2.default,
{ suffixIcon: _react2.default.createElement(_newIcons.ExternalLink, null) },
'Learn how to add items'
)
)
)
);
}
}]);
return TableEmptyStateExample;
}(_react2.default.Component);
var MainToolbar = function MainToolbar() {
var collectionOptions = [{ id: 0, value: 'All Products' }, { id: 1, value: 'Towels' }, { id: 2, value: 'Slippers' }];
var filterOptions = [{ id: 0, value: 'All' }, { id: 1, value: 'Red' }, { id: 2, value: 'Cyan' }];
return _react2.default.createElement(
_TableToolbar.TableToolbar,
null,
_react2.default.createElement(
_TableToolbar.ItemGroup,
{ position: 'start' },
_react2.default.createElement(
_TableToolbar.Item,
null,
_react2.default.createElement(
_TableToolbar.Title,
null,
'My Table'
)
),
_react2.default.createElement(
_TableToolbar.Item,
null,
_react2.default.createElement(
_TableToolbar.Label,
null,
'Collection',
_react2.default.createElement(
'span',
{ style: { width: '150px' } },
_react2.default.createElement(_Dropdown2.default, { options: collectionOptions, selectedId: 0, roundInput: true })
)
)
),
_react2.default.createElement(
_TableToolbar.Item,
null,
_react2.default.createElement(
_TableToolbar.Label,
null,
'Filter By',
_react2.default.createElement(
'span',
{ style: { width: '86px' } },
_react2.default.createElement(_Dropdown2.default, { options: filterOptions, selectedId: 0, roundInput: true })
)
)
)
),
_react2.default.createElement(
_TableToolbar.ItemGroup,
{ position: 'end' },
_react2.default.createElement(
_TableToolbar.Item,
null,
_react2.default.createElement(_Search2.default, null)
)
)
);
};