@prosperitainova/dumbo-react-native
Version:
Dumbo for React Native Library
69 lines (67 loc) • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DataTableRow = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _colors = require("../../styles/colors");
var _helpers = require("../../helpers");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** Props for DataTableRow component */
/**
* 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}
*/
class DataTableRow extends _react.default.Component {
get styles() {
return _reactNative.StyleSheet.create({
wrapper: {
backgroundColor: (0, _colors.getColor)('layer01'),
minHeight: 48,
flexDirection: 'row',
width: '100%',
borderTopColor: (0, _colors.getColor)('borderSubtle00'),
borderTopWidth: 1
}
});
}
getStateStyle = state => {
return state.pressed ? {
backgroundColor: (0, _colors.getColor)('layerActive01')
} : undefined;
};
render() {
const {
componentProps,
style,
onPress,
onLongPress,
rowText,
children
} = this.props;
const finalStyles = (0, _helpers.styleReferenceBreaker)(this.styles.wrapper, style);
if (onPress || onLongPress) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
style: state => (0, _helpers.pressableFeedbackStyle)(state, finalStyles, this.getStateStyle),
...(componentProps || {}),
onPress: onPress,
onLongPress: onLongPress,
accessibilityLabel: rowText,
children: children
});
} else {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: finalStyles,
...(componentProps || {}),
accessibilityLabel: rowText,
children: children
});
}
}
}
exports.DataTableRow = DataTableRow;
//# sourceMappingURL=DataTableRow.js.map