@prosperitainova/dumbo-react-native
Version:
Dumbo for React Native Library
63 lines (61 loc) • 1.81 kB
JavaScript
;
import React from 'react';
import { StyleSheet, Pressable, View } from 'react-native';
import { getColor } from '../../styles/colors';
import { pressableFeedbackStyle, styleReferenceBreaker } from '../../helpers';
/** Props for DataTableRow component */
import { jsx as _jsx } from "react/jsx-runtime";
/**
* DataTableRow component for rendering a data table row.
* Used as a child of DataTable
*
* {@link https://github.com/carbon-design-system/carbon-react-native/blob/main/example/src/Views/DataTable.tsx | Example code}
*/
export class DataTableRow extends React.Component {
get styles() {
return StyleSheet.create({
wrapper: {
backgroundColor: getColor('layer01'),
minHeight: 48,
flexDirection: 'row',
width: '100%',
borderTopColor: getColor('borderSubtle00'),
borderTopWidth: 1
}
});
}
getStateStyle = state => {
return state.pressed ? {
backgroundColor: getColor('layerActive01')
} : undefined;
};
render() {
const {
componentProps,
style,
onPress,
onLongPress,
rowText,
children
} = this.props;
const finalStyles = styleReferenceBreaker(this.styles.wrapper, style);
if (onPress || onLongPress) {
return /*#__PURE__*/_jsx(Pressable, {
style: state => pressableFeedbackStyle(state, finalStyles, this.getStateStyle),
...(componentProps || {}),
onPress: onPress,
onLongPress: onLongPress,
accessibilityLabel: rowText,
children: children
});
} else {
return /*#__PURE__*/_jsx(View, {
style: finalStyles,
...(componentProps || {}),
accessibilityLabel: rowText,
children: children
});
}
}
}
//# sourceMappingURL=DataTableRow.js.map