@talend/react-components
Version:
Set of react components.
52 lines • 2.4 kB
JavaScript
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import TooltipTrigger from '../../../TooltipTrigger';
import FormatValue from '../../../FormatValue/FormatValue.component';
import theme from './DefaultValueRenderer.module.scss';
import { has } from "lodash";
import { jsx as _jsx } from "react/jsx-runtime";
export const DEFAULT_VALUE_PROP_TYPES = PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number, PropTypes.shape({
bytes: PropTypes.string
})]);
export default class DefaultValueRenderer extends Component {
render() {
let stringValue;
if (this.props.value === null || this.props.value === undefined) {
stringValue = '';
} else if (has(this.props.value, 'bytes')) {
stringValue = this.props.value.bytes;
} else {
stringValue = String(this.props.value);
}
const formattedContent = /*#__PURE__*/_jsx(FormatValue, {
value: stringValue
});
const content = /*#__PURE__*/_jsx("div", {
ref: this.setDOMElement,
className: classNames(theme['td-default-cell'], this.props.className, 'td-default-cell', {
[theme['shrink-value']]: this.props.isValueOverflown,
[theme['wrap-value']]: this.props.isLongValueToggled
}),
children: formattedContent
});
if (this.props.isValueOverflown) {
return /*#__PURE__*/_jsx(TooltipTrigger, {
tooltipPlacement: "bottom",
label: formattedContent,
children: content
});
}
return content;
}
}
_defineProperty(DefaultValueRenderer, "propTypes", {
className: PropTypes.string,
value: DEFAULT_VALUE_PROP_TYPES,
isValueOverflown: PropTypes.bool,
isLongValueToggled: PropTypes.bool
});
//# sourceMappingURL=DefaultValueRenderer.component.js.map