1 | import { __rest } from "tslib";
|
2 | import * as React from 'react';
|
3 | import { css } from '@patternfly/react-styles';
|
4 | import styles from '@patternfly/react-styles/css/components/DataList/data-list';
|
5 | import { Tooltip } from '../Tooltip';
|
6 | export const DataListText = (_a) => {
|
7 | var { children = null, className = '', component = 'span', wrapModifier = null, tooltip: tooltipProp = '', onMouseEnter: onMouseEnterProp = () => { } } = _a, props = __rest(_a, ["children", "className", "component", "wrapModifier", "tooltip", "onMouseEnter"]);
|
8 | const Component = component;
|
9 | const [tooltip, setTooltip] = React.useState('');
|
10 | const onMouseEnter = (event) => {
|
11 | if (event.target.offsetWidth < event.target.scrollWidth) {
|
12 | setTooltip(tooltipProp || event.target.innerHTML);
|
13 | }
|
14 | else {
|
15 | setTooltip('');
|
16 | }
|
17 | onMouseEnterProp(event);
|
18 | };
|
19 | const text = (React.createElement(Component, Object.assign({ onMouseEnter: onMouseEnter, className: css(className, wrapModifier && styles.modifiers[wrapModifier], styles.dataListText) }, props), children));
|
20 | return tooltip !== '' ? (React.createElement(Tooltip, { content: tooltip, isVisible: true }, text)) : (text);
|
21 | };
|
22 | DataListText.displayName = 'DataListText';
|
23 |
|
\ | No newline at end of file |