-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathDataTableRow.tsx
More file actions
107 lines (98 loc) · 2.45 KB
/
DataTableRow.tsx
File metadata and controls
107 lines (98 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import * as React from 'react';
import {
GestureResponderEvent,
StyleProp,
StyleSheet,
View,
ViewProps,
ViewStyle,
} from 'react-native';
import color from 'color';
import { useInternalTheme } from '../../core/theming';
import { black, white } from '../../styles/themes/v2/colors';
import type { $RemoveChildren, ThemeProp } from '../../types';
import TouchableRipple from '../TouchableRipple/TouchableRipple';
export type Props = $RemoveChildren<typeof TouchableRipple> & {
/**
* Content of the `DataTableRow`.
*/
children: React.ReactNode;
/**
* Function to execute on press.
*/
onPress?: (e: GestureResponderEvent) => void;
style?: StyleProp<ViewStyle>;
/**
* @optional
*/
theme?: ThemeProp;
/**
* `pointerEvents` passed to the `View` container, which is wrapping children within `TouchableRipple`.
*/
pointerEvents?: ViewProps['pointerEvents'];
};
/**
* A component to show a single row inside of a table.
*
* ## Usage
* ```js
* import * as React from 'react';
* import { DataTable } from 'react-native-paper';
*
* const MyComponent = () => (
* <DataTable.Row>
* <DataTable.Cell numeric>1</DataTable.Cell>
* <DataTable.Cell numeric>2</DataTable.Cell>
* <DataTable.Cell numeric>3</DataTable.Cell>
* <DataTable.Cell numeric>4</DataTable.Cell>
* </DataTable.Row>
* );
*
* export default MyComponent;
* ```
*
* @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
*/
const DataTableRow = ({
onPress,
style,
children,
pointerEvents,
theme: themeOverrides,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const borderBottomColor = theme.isV3
? theme.colors.surfaceVariant
: color(theme.dark ? white : black)
.alpha(0.12)
.rgb()
.string();
return (
<TouchableRipple
{...rest}
onPress={onPress}
style={[styles.container, { borderBottomColor }, style]}
>
<View style={styles.content} pointerEvents={pointerEvents}>
{children}
</View>
</TouchableRipple>
);
};
DataTableRow.displayName = 'DataTable.Row';
const styles = StyleSheet.create({
container: {
borderStyle: 'solid',
borderBottomWidth: StyleSheet.hairlineWidth,
minHeight: 48,
paddingHorizontal: 16,
},
content: {
flex: 1,
flexDirection: 'row',
},
});
export default DataTableRow;
// @component-docs ignore-next-line
export { DataTableRow };