UNPKG

8.66 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.StyledTableEmptyMessage = exports.StyledTableLoadingMessage = exports.StyledTableBodyCell = exports.StyledTableBodyRow = exports.StyledTableBody = exports.StyledSortNoneIcon = exports.StyledSortDescIcon = exports.StyledSortAscIcon = exports.StyledTableHeadCellSortable = exports.StyledTableHeadCell = exports.StyledTableHeadRow = exports.StyledTableHead = exports.StyledTable = exports.StyledRoot = void 0;
7
8var _blank = _interopRequireDefault(require("../icon/blank.js"));
9
10var _chevronDown = _interopRequireDefault(require("../icon/chevron-down.js"));
11
12var _chevronUp = _interopRequireDefault(require("../icon/chevron-up.js"));
13
14var _index = require("../styles/index.js");
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
20function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
22function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
24var StyledRoot = (0, _index.styled)('div', function (_ref) {
25 var $theme = _ref.$theme;
26 return _objectSpread({}, (0, _index.expandBorderStyles)($theme.borders.border300), {
27 position: 'relative',
28 overflow: 'auto',
29 WebkitOverflowScrolling: 'touch',
30 backgroundColor: $theme.colors.tableBackground,
31 borderTopLeftRadius: $theme.borders.radius200,
32 borderTopRightRadius: $theme.borders.radius200,
33 borderBottomRightRadius: $theme.borders.radius200,
34 borderBottomLeftRadius: $theme.borders.radius200,
35 // Creates a stacking context so we can use z-index on the StyledTableHeadCell
36 // without affecting anything outside of this component.
37 transform: 'scale(1)'
38 });
39});
40exports.StyledRoot = StyledRoot;
41StyledRoot.displayName = "StyledRoot";
42var StyledTable = (0, _index.styled)('table', function (_ref2) {
43 var $theme = _ref2.$theme,
44 $width = _ref2.$width;
45 return {
46 borderCollapse: 'collapse',
47 boxSizing: 'border-box',
48 minWidth: '100%',
49 width: $width || null
50 };
51});
52exports.StyledTable = StyledTable;
53StyledTable.displayName = "StyledTable";
54var StyledTableHead = (0, _index.styled)('thead', function (_ref3) {
55 var $theme = _ref3.$theme;
56 return {};
57});
58exports.StyledTableHead = StyledTableHead;
59StyledTableHead.displayName = "StyledTableHead";
60var StyledTableHeadRow = (0, _index.styled)('tr', function (_ref4) {
61 var $theme = _ref4.$theme;
62 return {};
63});
64exports.StyledTableHeadRow = StyledTableHeadRow;
65StyledTableHeadRow.displayName = "StyledTableHeadRow";
66var StyledTableHeadCell = (0, _index.styled)('th', function (_ref5) {
67 var _before;
68
69 var $theme = _ref5.$theme;
70 var borderDir = $theme.direction === 'rtl' ? 'left' : 'right';
71 return _objectSpread({}, $theme.typography.font350, {
72 position: 'sticky',
73 top: 0,
74 paddingTop: $theme.sizing.scale500,
75 paddingRight: $theme.sizing.scale600,
76 paddingBottom: $theme.sizing.scale500,
77 paddingLeft: $theme.sizing.scale600,
78 backgroundColor: $theme.colors.tableHeadBackgroundColor,
79 color: $theme.colors.contentPrimary,
80 textAlign: $theme.direction === 'rtl' ? 'right' : 'left',
81 verticalAlign: 'top',
82 whiteSpace: 'nowrap',
83 zIndex: 1,
84 // We have to use pseudo elements to add the border for headers
85 // because browsers don't properly handle borders on sticky cells.
86 // The cells stay fixed in place, but the borders scroll.
87 '::before': (_before = {
88 content: '""',
89 position: 'absolute',
90 top: '0'
91 }, _defineProperty(_before, borderDir, '100%'), _defineProperty(_before, "bottom", '0'), _defineProperty(_before, "borderLeftColor", $theme.borders.border300.borderColor), _defineProperty(_before, "borderLeftStyle", $theme.borders.border300.borderStyle), _defineProperty(_before, "borderLeftWidth", $theme.borders.border300.borderWidth), _before),
92 // We have to use pseudo elements to add the shadow to prevent
93 // the shadows from casting on sibling cells.
94 '::after': {
95 content: '""',
96 position: 'absolute',
97 top: '100%',
98 right: '0',
99 left: '0',
100 height: $theme.sizing.scale100,
101 pointerEvents: 'none',
102 backgroundImage: "\n linear-gradient(\n to bottom,\n rgba(0, 0, 0, 0.16),\n rgba(0, 0, 0, 0)\n )\n "
103 }
104 });
105});
106exports.StyledTableHeadCell = StyledTableHeadCell;
107StyledTableHeadCell.displayName = "StyledTableHeadCell";
108var StyledTableHeadCellSortable = (0, _index.withStyle)(StyledTableHeadCell, function (_ref6) {
109 var $theme = _ref6.$theme,
110 $isFocusVisible = _ref6.$isFocusVisible;
111 return {
112 cursor: 'pointer',
113 paddingRight: $theme.sizing.scale1000,
114 outline: 'none',
115 ':focus': {
116 outline: $isFocusVisible ? "3px solid ".concat($theme.colors.accent) : 'none',
117 outlineOffset: '-3px'
118 },
119 ':hover': {
120 backgroundColor: $theme.colors.tableStripedBackground
121 }
122 };
123});
124exports.StyledTableHeadCellSortable = StyledTableHeadCellSortable;
125StyledTableHeadCellSortable.displayName = "StyledTableHeadCellSortable";
126var StyledSortAscIcon = (0, _index.styled)(_chevronDown.default, function (_ref7) {
127 var $theme = _ref7.$theme;
128 return {
129 position: 'absolute',
130 top: '50%',
131 right: $theme.sizing.scale500,
132 transform: 'translateY(-50%)'
133 };
134});
135exports.StyledSortAscIcon = StyledSortAscIcon;
136StyledSortAscIcon.displayName = "StyledSortAscIcon";
137var StyledSortDescIcon = (0, _index.styled)(_chevronUp.default, function (_ref8) {
138 var $theme = _ref8.$theme;
139 return {
140 position: 'absolute',
141 top: '50%',
142 right: $theme.sizing.scale500,
143 transform: 'translateY(-50%)'
144 };
145});
146exports.StyledSortDescIcon = StyledSortDescIcon;
147StyledSortDescIcon.displayName = "StyledSortDescIcon";
148var StyledSortNoneIcon = (0, _index.styled)(_blank.default, function (_ref9) {
149 var $theme = _ref9.$theme;
150 return {
151 position: 'absolute',
152 top: '50%',
153 right: $theme.sizing.scale500,
154 transform: 'translateY(-50%)'
155 };
156});
157exports.StyledSortNoneIcon = StyledSortNoneIcon;
158StyledSortNoneIcon.displayName = "StyledSortNoneIcon";
159var StyledTableBody = (0, _index.styled)('tbody', function (_ref10) {
160 var $theme = _ref10.$theme;
161 return {};
162});
163exports.StyledTableBody = StyledTableBody;
164StyledTableBody.displayName = "StyledTableBody";
165var StyledTableBodyRow = (0, _index.styled)('tr', function (_ref11) {
166 var $theme = _ref11.$theme;
167 return {
168 ':hover': {
169 backgroundColor: $theme.colors.tableStripedBackground
170 }
171 };
172});
173exports.StyledTableBodyRow = StyledTableBodyRow;
174StyledTableBodyRow.displayName = "StyledTableBodyRow";
175var StyledTableBodyCell = (0, _index.styled)('td', function (_ref12) {
176 var $theme = _ref12.$theme,
177 $isNumeric = _ref12.$isNumeric;
178 return _objectSpread({}, $theme.typography.font200, {
179 paddingTop: $theme.sizing.scale300,
180 paddingRight: $theme.sizing.scale600,
181 paddingBottom: $theme.sizing.scale300,
182 paddingLeft: $theme.sizing.scale600,
183 color: $theme.colors.contentPrimary,
184 textAlign: $isNumeric ? 'right' : null,
185 verticalAlign: 'top'
186 });
187});
188exports.StyledTableBodyCell = StyledTableBodyCell;
189StyledTableBodyCell.displayName = "StyledTableBodyCell";
190var StyledTableLoadingMessage = (0, _index.styled)('div', function (_ref13) {
191 var $theme = _ref13.$theme;
192 return _objectSpread({}, $theme.typography.ParagraphSmall, {
193 color: $theme.colors.contentPrimary,
194 padding: $theme.sizing.scale600
195 });
196});
197exports.StyledTableLoadingMessage = StyledTableLoadingMessage;
198StyledTableLoadingMessage.displayName = "StyledTableLoadingMessage";
199var StyledTableEmptyMessage = StyledTableLoadingMessage;
200exports.StyledTableEmptyMessage = StyledTableEmptyMessage;
\No newline at end of file