wix-style-react
Version:
wix-style-react
170 lines (156 loc) • 6.03 kB
JavaScript
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; }; }();
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; }
import React from 'react';
import { Table } from 'wix-style-react/Table';
import { TableToolbar, ItemGroup, Item, Label, Title } from 'wix-style-react/TableToolbar';
import Card from 'wix-style-react/Card';
import Search from 'wix-style-react/Search';
import Dropdown from 'wix-style-react/Dropdown';
import TextLink from 'wix-style-react/TextLink';
import { ExternalLink } from 'wix-style-react/new-icons';
import ImagePlaceholder from '../assets/ImagePlaceholder';
export var 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 React.createElement(
Card,
null,
React.createElement(
Table,
{
dataHook: 'story-table-empty-state-example',
data: [],
itemsPerPage: 20,
columns: [{
title: 'Name',
render: function render(row) {
return React.createElement(
'span',
null,
row.name
);
},
width: '30%',
minWidth: '150px'
}, {
title: 'SKU',
render: function render(row) {
return React.createElement(
'span',
null,
row.SKU
);
},
width: '20%',
minWidth: '100px'
}, {
title: 'Price',
render: function render(row) {
return React.createElement(
'span',
null,
row.price
);
},
width: '20%',
minWidth: '100px'
}, {
title: 'Inventory',
render: function render(row) {
return React.createElement(
'span',
null,
row.inventory
);
},
width: '20%',
minWidth: '100px'
}],
showSelection: true
},
React.createElement(MainToolbar, null),
React.createElement(
Table.EmptyState,
{
title: 'You haven\'t added any items yet',
subtitle: 'Add items to your website so people can buy them',
image: React.createElement(ImagePlaceholder, null)
},
React.createElement(
TextLink,
{ suffixIcon: React.createElement(ExternalLink, null) },
'Learn how to add items'
)
)
)
);
}
}]);
return TableEmptyStateExample;
}(React.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 React.createElement(
TableToolbar,
null,
React.createElement(
ItemGroup,
{ position: 'start' },
React.createElement(
Item,
null,
React.createElement(
Title,
null,
'My Table'
)
),
React.createElement(
Item,
null,
React.createElement(
Label,
null,
'Collection',
React.createElement(
'span',
{ style: { width: '150px' } },
React.createElement(Dropdown, { options: collectionOptions, selectedId: 0, roundInput: true })
)
)
),
React.createElement(
Item,
null,
React.createElement(
Label,
null,
'Filter By',
React.createElement(
'span',
{ style: { width: '86px' } },
React.createElement(Dropdown, { options: filterOptions, selectedId: 0, roundInput: true })
)
)
)
),
React.createElement(
ItemGroup,
{ position: 'end' },
React.createElement(
Item,
null,
React.createElement(Search, null)
)
)
);
};