UNPKG

@talend/react-components

Version:
64 lines (63 loc) 2.18 kB
/* eslint-disable react/no-unused-prop-types */ import PropTypes from 'prop-types'; import { Column } from 'react-virtualized'; import TooltipTrigger from '../TooltipTrigger'; import { jsx as _jsx } from "react/jsx-runtime"; function DefaultRenderer({ cellData, columnData, rowData }) { const { getTooltipLabel } = columnData; let tooltipLabel = columnData.tooltipLabel != null ? columnData.tooltipLabel : cellData; if (typeof getTooltipLabel === 'function') { tooltipLabel = getTooltipLabel(rowData); } return tooltipLabel != null ? /*#__PURE__*/_jsx(TooltipTrigger, { label: tooltipLabel, tooltipPlacement: columnData.tooltipPlacement || 'top', children: /*#__PURE__*/_jsx("div", { className: "tc-virtualizedlist-default-cell", "data-test": "tc-virtualizedlist-default-cell-tooltip", "data-testid": "tc-virtualizedlist-default-cell-tooltip", children: cellData }) }) : /*#__PURE__*/_jsx("div", { className: "tc-virtualizedlist-default-cell", children: cellData }); } DefaultRenderer.propTypes = { cellData: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), rowData: PropTypes.object, columnData: PropTypes.shape({ tooltipLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), tooltipPlacement: PropTypes.string, getTooltipLabel: PropTypes.func }) }; export const defaultColumnConfiguration = { ...Column.defaultProps, cellRenderer: DefaultRenderer, width: -1 }; // this is a fake component to be usable in JSX, // but the element is used as props object internally (VirtualizedList / RV) export default function Content() { return null; } Content.displayName = 'Content'; Content.defaultProps = defaultColumnConfiguration; Content.propTypes = { label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, dataKey: PropTypes.string.isRequired, width: PropTypes.number.isRequired, columnData: PropTypes.shape({ tooltipLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), tooltipPlacement: PropTypes.string, getTooltipLabel: PropTypes.func }).isRequired }; //# sourceMappingURL=Content.component.js.map