@prosperitainova/dumbo-react-native
Version:
Dumbo for React Native Library
79 lines (77 loc) • 2.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DataTableHeader = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _colors = require("../../styles/colors");
var _helpers = require("../../helpers");
var _Button = require("../Button");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** Props for DataTableHeader component */
/**
* 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}
*/
class DataTableHeader extends _react.default.Component {
get styles() {
return _reactNative.StyleSheet.create({
wrapper: {
height: 48,
backgroundColor: (0, _colors.getColor)('layer01'),
flexDirection: 'row'
},
secondaryActions: {
flexDirection: 'row',
flex: 1
}
});
}
get secondaryActions() {
const {
secondaryActions
} = this.props;
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
bounces: false,
horizontal: true,
style: this.styles.secondaryActions,
children: (secondaryActions || []).map((item, index) => {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
...item,
overrideColor: item.overrideColor || (0, _colors.getColor)('iconPrimary'),
kind: item.kind || 'ghost'
}, index);
})
});
}
get primaryAction() {
const {
primaryAction
} = this.props;
if (primaryAction) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.Button, {
...primaryAction
});
}
return null;
}
render() {
const {
componentProps,
style
} = this.props;
const finalStyles = (0, _helpers.styleReferenceBreaker)(this.styles.wrapper, style);
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: finalStyles,
...(componentProps || {}),
accessibilityRole: "menubar",
children: [this.secondaryActions, this.primaryAction]
});
}
}
exports.DataTableHeader = DataTableHeader;
//# sourceMappingURL=DataTableHeader.js.map