UNPKG

@prosperitainova/dumbo-react-native

Version:
73 lines (71 loc) 2 kB
"use strict"; import React from 'react'; import { StyleSheet, View, ScrollView } from 'react-native'; import { getColor } from '../../styles/colors'; import { styleReferenceBreaker } from '../../helpers'; import { Button } from '../Button'; /** Props for DataTableHeader component */ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /** * DataTableHeader component for rendering a data table header. * 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 DataTableHeader extends React.Component { get styles() { return StyleSheet.create({ wrapper: { height: 48, backgroundColor: getColor('layer01'), flexDirection: 'row' }, secondaryActions: { flexDirection: 'row', flex: 1 } }); } get secondaryActions() { const { secondaryActions } = this.props; return /*#__PURE__*/_jsx(ScrollView, { bounces: false, horizontal: true, style: this.styles.secondaryActions, children: (secondaryActions || []).map((item, index) => { return /*#__PURE__*/_jsx(Button, { ...item, overrideColor: item.overrideColor || getColor('iconPrimary'), kind: item.kind || 'ghost' }, index); }) }); } get primaryAction() { const { primaryAction } = this.props; if (primaryAction) { return /*#__PURE__*/_jsx(Button, { ...primaryAction }); } return null; } render() { const { componentProps, style } = this.props; const finalStyles = styleReferenceBreaker(this.styles.wrapper, style); return /*#__PURE__*/_jsxs(View, { style: finalStyles, ...(componentProps || {}), accessibilityRole: "menubar", children: [this.secondaryActions, this.primaryAction] }); } } //# sourceMappingURL=DataTableHeader.js.map