@talend/react-components
Version:
Set of react components.
63 lines • 1.72 kB
JavaScript
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Action, ActionDropdown } from '../../Actions';
import theme from './Header.module.scss';
import { createElement as _createElement } from "react";
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
function headerClasses() {
return classNames({
[theme['tc-enumeration-header']]: true,
'tc-enumeration-header': true
});
}
function getAction(action, index) {
function onClick(event) {
if (action.onClick) {
action.onClick(event, {
value: event.target.value
});
}
}
if (action.displayMode === 'dropdown') {
return /*#__PURE__*/_createElement(ActionDropdown, {
...action,
noCaret: true,
key: `${index}-enum-header-action`,
onClick: onClick,
btooltipPlacement: "bottom",
hideLabel: true,
pullRight: true,
link: true
});
}
return /*#__PURE__*/_createElement(Action, {
...action,
key: `${index}-enum-header-action`,
onClick: onClick,
btooltipPlacement: "bottom",
hideLabel: true,
link: true
});
}
function Header({
headerDefault,
required,
label
}) {
return /*#__PURE__*/_jsxs("header", {
className: headerClasses(),
children: [/*#__PURE__*/_jsxs("span", {
children: [label, required && '*']
}), /*#__PURE__*/_jsx("div", {
className: "actions",
children: headerDefault.filter(action => !action.disabled).map(getAction)
})]
});
}
Header.propTypes = {
headerDefault: PropTypes.arrayOf(PropTypes.shape(Action.propTypes)).isRequired,
required: PropTypes.bool,
label: PropTypes.string
};
export default Header;
//# sourceMappingURL=Header.component.js.map