@talend/react-components
Version:
Set of react components.
61 lines (60 loc) • 2.13 kB
JavaScript
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withTranslation } from 'react-i18next';
import { Action } from '../../../Actions';
import theme from './TreeHeader.module.scss';
import I18N_DOMAIN_COMPONENTS from '../../../constants';
import getDefaultT from '../../../translate';
/**
* A simple header customizable with collapse and expand all buttons.
*/
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function TreeHeader({
title,
otherActions,
onClickCollapseAll,
onClickExpandAll,
t
}) {
return /*#__PURE__*/_jsxs("div", {
className: classNames(theme['tc-tree-header'], 'tc-tree-header'),
children: [title, /*#__PURE__*/_jsxs("div", {
className: classNames(theme['tc-tree-header-actions'], 'tc-tree-header-actions'),
children: [onClickCollapseAll && /*#__PURE__*/_jsx(Action, {
className: classNames(theme['tc-tree-header-actions-icon'], 'tc-tree-header-actions-icon'),
"data-testid": "collapse-all",
icon: "talend-minus-circle",
id: "CollapseAllRecords",
tooltipLabel: t('RECORDS_HEADER_LABEL_CLOSE_ALL', {
defaultValue: 'Close all'
}),
onClick: onClickCollapseAll,
link: true,
hideLabel: true
}), onClickExpandAll && /*#__PURE__*/_jsx(Action, {
className: classNames(theme['tc-tree-header-actions-icon'], 'tc-tree-header-actions-icon'),
icon: "talend-table",
"data-testid": "expand-all",
id: "ExpandAllRecords",
tooltipLabel: t('RECORDS_HEADER_LABEL_EXPAND_ALL', {
defaultValue: 'Expand all'
}),
onClick: onClickExpandAll,
hideLabel: true,
link: true
})]
}), otherActions && otherActions()]
});
}
TreeHeader.defaultProps = {
t: getDefaultT()
};
TreeHeader.propTypes = {
onClickCollapseAll: PropTypes.func,
onClickExpandAll: PropTypes.func,
otherActions: PropTypes.func,
t: PropTypes.func,
title: PropTypes.string.isRequired
};
export default withTranslation(I18N_DOMAIN_COMPONENTS)(TreeHeader);
//# sourceMappingURL=TreeHeader.component.js.map