Debian Codegraph @

node/@patternfly/react-table/dist/js/deprecated/components/Table/BodyCell.js

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