UNPKG

2.01 kBJavaScriptView Raw
1function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
3import * as React from 'react';
4import { StyleSheet } from 'react-native';
5import Text from '../Typography/Text';
6import TouchableRipple from '../TouchableRipple/TouchableRipple';
7
8/**
9 * A component to show a single cell inside of a table.
10 *
11 * <div class="screenshots">
12 * <figure>
13 * <img class="medium" src="screenshots/data-table-row-cell.png" />
14 * </figure>
15 * </div>
16 *
17 *
18 * ## Usage
19 * ```js
20 * import * as React from 'react';
21 * import { DataTable } from 'react-native-paper';
22 *
23 * const MyComponent = () => (
24 * <DataTable.Row>
25 * <DataTable.Cell numeric>1</DataTable.Cell>
26 * <DataTable.Cell numeric>2</DataTable.Cell>
27 * <DataTable.Cell numeric>3</DataTable.Cell>
28 * <DataTable.Cell numeric>4</DataTable.Cell>
29 * </DataTable.Row>
30 * );
31 *
32 * export default MyComponent;
33 * ```
34 *
35 * If you want to support multiline text, please use View instead, as multiline text doesn't comply with
36 * MD Guidelines (https://github.com/callstack/react-native-paper/issues/2381).
37 */
38const DataTableCell = _ref => {
39 let {
40 children,
41 textStyle,
42 style,
43 numeric,
44 ...rest
45 } = _ref;
46 return /*#__PURE__*/React.createElement(TouchableRipple, _extends({}, rest, {
47 style: [styles.container, numeric && styles.right, style]
48 }), /*#__PURE__*/React.createElement(Text, {
49 style: textStyle,
50 numberOfLines: 1
51 }, children));
52};
53
54DataTableCell.displayName = 'DataTable.Cell';
55const styles = StyleSheet.create({
56 container: {
57 flex: 1,
58 flexDirection: 'row',
59 alignItems: 'center'
60 },
61 right: {
62 justifyContent: 'flex-end'
63 }
64});
65export default DataTableCell;
66//# sourceMappingURL=DataTableCell.js.map
\No newline at end of file