1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _clsx = _interopRequireDefault(require("clsx"));
|
21 |
|
22 | var _utils = require("@material-ui/utils");
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
27 |
|
28 | var _colorManipulator = require("../styles/colorManipulator");
|
29 |
|
30 | var _TableContext = _interopRequireDefault(require("../Table/TableContext"));
|
31 |
|
32 | var _Tablelvl2Context = _interopRequireDefault(require("../Table/Tablelvl2Context"));
|
33 |
|
34 | var styles = function styles(theme) {
|
35 | return {
|
36 |
|
37 | root: (0, _extends2.default)({}, theme.typography.body2, {
|
38 | display: 'table-cell',
|
39 | verticalAlign: 'inherit',
|
40 |
|
41 |
|
42 | borderBottom: "1px solid\n ".concat(theme.palette.type === 'light' ? (0, _colorManipulator.lighten)((0, _colorManipulator.alpha)(theme.palette.divider, 1), 0.88) : (0, _colorManipulator.darken)((0, _colorManipulator.alpha)(theme.palette.divider, 1), 0.68)),
|
43 | textAlign: 'left',
|
44 | padding: 16
|
45 | }),
|
46 |
|
47 |
|
48 | head: {
|
49 | color: theme.palette.text.primary,
|
50 | lineHeight: theme.typography.pxToRem(24),
|
51 | fontWeight: theme.typography.fontWeightMedium
|
52 | },
|
53 |
|
54 |
|
55 | body: {
|
56 | color: theme.palette.text.primary
|
57 | },
|
58 |
|
59 |
|
60 | footer: {
|
61 | color: theme.palette.text.secondary,
|
62 | lineHeight: theme.typography.pxToRem(21),
|
63 | fontSize: theme.typography.pxToRem(12)
|
64 | },
|
65 |
|
66 |
|
67 | sizeSmall: {
|
68 | padding: '6px 24px 6px 16px',
|
69 | '&:last-child': {
|
70 | paddingRight: 16
|
71 | },
|
72 | '&$paddingCheckbox': {
|
73 | width: 24,
|
74 |
|
75 | padding: '0 12px 0 16px',
|
76 | '&:last-child': {
|
77 | paddingLeft: 12,
|
78 | paddingRight: 16
|
79 | },
|
80 | '& > *': {
|
81 | padding: 0
|
82 | }
|
83 | }
|
84 | },
|
85 |
|
86 |
|
87 | paddingCheckbox: {
|
88 | width: 48,
|
89 |
|
90 | padding: '0 0 0 4px',
|
91 | '&:last-child': {
|
92 | paddingLeft: 0,
|
93 | paddingRight: 4
|
94 | }
|
95 | },
|
96 |
|
97 |
|
98 | paddingNone: {
|
99 | padding: 0,
|
100 | '&:last-child': {
|
101 | padding: 0
|
102 | }
|
103 | },
|
104 |
|
105 |
|
106 | alignLeft: {
|
107 | textAlign: 'left'
|
108 | },
|
109 |
|
110 |
|
111 | alignCenter: {
|
112 | textAlign: 'center'
|
113 | },
|
114 |
|
115 |
|
116 | alignRight: {
|
117 | textAlign: 'right',
|
118 | flexDirection: 'row-reverse'
|
119 | },
|
120 |
|
121 |
|
122 | alignJustify: {
|
123 | textAlign: 'justify'
|
124 | },
|
125 |
|
126 |
|
127 | stickyHeader: {
|
128 | position: 'sticky',
|
129 | top: 0,
|
130 | left: 0,
|
131 | zIndex: 2,
|
132 | backgroundColor: theme.palette.background.default
|
133 | }
|
134 | };
|
135 | };
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 | exports.styles = styles;
|
143 | var TableCell = React.forwardRef(function TableCell(props, ref) {
|
144 | var _props$align = props.align,
|
145 | align = _props$align === void 0 ? 'inherit' : _props$align,
|
146 | classes = props.classes,
|
147 | className = props.className,
|
148 | component = props.component,
|
149 | paddingProp = props.padding,
|
150 | scopeProp = props.scope,
|
151 | sizeProp = props.size,
|
152 | sortDirection = props.sortDirection,
|
153 | variantProp = props.variant,
|
154 | other = (0, _objectWithoutProperties2.default)(props, ["align", "classes", "className", "component", "padding", "scope", "size", "sortDirection", "variant"]);
|
155 | var table = React.useContext(_TableContext.default);
|
156 | var tablelvl2 = React.useContext(_Tablelvl2Context.default);
|
157 | var isHeadCell = tablelvl2 && tablelvl2.variant === 'head';
|
158 | var role;
|
159 | var Component;
|
160 |
|
161 | if (component) {
|
162 | Component = component;
|
163 | role = isHeadCell ? 'columnheader' : 'cell';
|
164 | } else {
|
165 | Component = isHeadCell ? 'th' : 'td';
|
166 | }
|
167 |
|
168 | var scope = scopeProp;
|
169 |
|
170 | if (!scope && isHeadCell) {
|
171 | scope = 'col';
|
172 | }
|
173 |
|
174 | var padding = paddingProp || (table && table.padding ? table.padding : 'normal');
|
175 | var size = sizeProp || (table && table.size ? table.size : 'medium');
|
176 | var variant = variantProp || tablelvl2 && tablelvl2.variant;
|
177 | var ariaSort = null;
|
178 |
|
179 | if (sortDirection) {
|
180 | ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
|
181 | }
|
182 |
|
183 | return React.createElement(Component, (0, _extends2.default)({
|
184 | ref: ref,
|
185 | className: (0, _clsx.default)(classes.root, classes[variant], className, align !== 'inherit' && classes["align".concat((0, _capitalize.default)(align))], padding !== 'normal' && classes["padding".concat((0, _capitalize.default)(padding))], size !== 'medium' && classes["size".concat((0, _capitalize.default)(size))], variant === 'head' && table && table.stickyHeader && classes.stickyHeader),
|
186 | "aria-sort": ariaSort,
|
187 | role: role,
|
188 | scope: scope
|
189 | }, other));
|
190 | });
|
191 | process.env.NODE_ENV !== "production" ? TableCell.propTypes = {
|
192 | |
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 | align: _propTypes.default.oneOf(['center', 'inherit', 'justify', 'left', 'right']),
|
199 |
|
200 | |
201 |
|
202 |
|
203 | children: _propTypes.default.node,
|
204 |
|
205 | |
206 |
|
207 |
|
208 |
|
209 | classes: _propTypes.default.object,
|
210 |
|
211 | |
212 |
|
213 |
|
214 | className: _propTypes.default.string,
|
215 |
|
216 | |
217 |
|
218 |
|
219 |
|
220 | component: _propTypes.default
|
221 |
|
222 | .elementType,
|
223 |
|
224 | |
225 |
|
226 |
|
227 |
|
228 |
|
229 | padding: (0, _utils.chainPropTypes)(_propTypes.default.oneOf(['normal', 'checkbox', 'none', 'default']), function (props) {
|
230 | if (props.padding === 'default') {
|
231 | return new Error('Material-UI: padding="default" was renamed to padding="normal" for consistency.');
|
232 | }
|
233 |
|
234 | return null;
|
235 | }),
|
236 |
|
237 | |
238 |
|
239 |
|
240 | scope: _propTypes.default.string,
|
241 |
|
242 | |
243 |
|
244 |
|
245 |
|
246 | size: _propTypes.default.oneOf(['medium', 'small']),
|
247 |
|
248 | |
249 |
|
250 |
|
251 | sortDirection: _propTypes.default.oneOf(['asc', 'desc', false]),
|
252 |
|
253 | |
254 |
|
255 |
|
256 |
|
257 | variant: _propTypes.default.oneOf(['body', 'footer', 'head'])
|
258 | } : void 0;
|
259 |
|
260 | var _default = (0, _withStyles.default)(styles, {
|
261 | name: 'MuiTableCell'
|
262 | })(TableCell);
|
263 |
|
264 | exports.default = _default; |
\ | No newline at end of file |