| 1 |
import { __rest } from "tslib"; |
| 2 |
import { jsx as _jsx } from "react/jsx-runtime"; |
| 3 |
import { useState } from 'react'; |
| 4 |
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip'; |
| 5 |
import { Bullseye } from '@patternfly/react-core/dist/esm/layouts/Bullseye'; |
| 6 |
import { EmptyState } from '@patternfly/react-core/dist/esm/components/EmptyState'; |
| 7 |
import { Td } from '../../../components'; |
| 8 |
export const BodyCell = (_a) => { |
| 9 |
var { 'data-label': dataLabel = '', className = '', colSpan, component = 'td', isVisible, parentId, textCenter = false, tooltip: tooltipProp = '', onMouseEnter: onMouseEnterProp = () => { }, children, |
| 10 |
/* eslint-disable @typescript-eslint/no-unused-vars */ |
| 11 |
errorText, isValid, isOpen, ariaControls, editableValue, editableSelectProps, options, isSelectOpen, value, name } = _a, |
| 12 |
/* eslint-enable @typescript-eslint/no-unused-vars */ |
| 13 |
props = __rest(_a, ['data-label', "className", "colSpan", "component", "isVisible", "parentId", "textCenter", "tooltip", "onMouseEnter", "children", "errorText", "isValid", "isOpen", "ariaControls", "editableValue", "editableSelectProps", "options", "isSelectOpen", "value", "name"]); |
| 14 |
const [tooltip, setTooltip] = useState(''); |
| 15 |
const onMouseEnter = (event) => { |
| 16 |
if (event.target.offsetWidth < event.target.scrollWidth) { |
| 17 |
if (tooltipProp) { |
| 18 |
setTooltip(tooltipProp); |
| 19 |
} |
| 20 |
else if (typeof children === 'string') { |
| 21 |
setTooltip(children); |
| 22 |
} |
| 23 |
} |
| 24 |
else { |
| 25 |
setTooltip(''); |
| 26 |
} |
| 27 |
onMouseEnterProp(event); |
| 28 |
}; |
| 29 |
let isEmptyStateCell = false; |
| 30 |
if (children) { |
| 31 |
isEmptyStateCell = |
| 32 |
(children.type === Bullseye && |
| 33 |
children.props.children && |
| 34 |
children.props.children.type === EmptyState) || |
| 35 |
children.type === EmptyState; |
| 36 |
} |
| 37 |
const cell = (_jsx(Td, Object.assign({ className: className, component: component, dataLabel: dataLabel && parentId == null && !isEmptyStateCell ? dataLabel : null, onMouseEnter: onMouseEnter, textCenter: textCenter, colSpan: colSpan }, props, { children: children }))); |
| 38 |
const bodyCell = tooltip !== '' ? (_jsx(Tooltip, { content: tooltip, isVisible: true, children: cell })) : (cell); |
| 39 |
return (parentId !== undefined && colSpan === undefined) || !isVisible ? null : bodyCell; |
| 40 |
}; |
| 41 |
BodyCell.displayName = 'BodyCell'; |
| 42 |
//# sourceMappingURL=BodyCell.js.map |