@grafana/ui
Version:
Grafana Components Library
65 lines (58 loc) • 2.19 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var css = require('@emotion/css');
var memoize = require('micro-memoize');
var data = require('@grafana/data');
var MaybeWrapWithLink = require('../components/MaybeWrapWithLink.cjs');
var constants = require('../constants.cjs');
var styles = require('../styles.cjs');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
var memoize__default = /*#__PURE__*/_interopDefaultCompat(memoize);
;
function AutoCell({ value, field, rowIdx }) {
const displayValue = field.display(value);
const formattedValue = data.formattedValueToString(displayValue);
return /* @__PURE__ */ jsxRuntime.jsx(MaybeWrapWithLink.MaybeWrapWithLink, { field, rowIdx, children: formattedValue });
}
const getStyles = memoize__default.default(
(_theme, { textWrap, shouldOverflow, maxHeight }) => css.css({
...textWrap && { whiteSpace: "pre-line" },
...shouldOverflow && {
[styles.getActiveCellSelector(Boolean(maxHeight))]: {
whiteSpace: "pre-line"
}
},
...maxHeight != null && textWrap && {
height: "auto",
overflowY: "hidden",
display: "-webkit-box",
WebkitBoxOrient: "vertical",
WebkitLineClamp: Math.floor(maxHeight / constants.TABLE.LINE_HEIGHT),
[styles.getActiveCellSelector(true)]: {
display: "flex",
WebkitLineClamp: "none",
WebkitBoxOrient: "unset",
overflowY: "auto",
height: "fit-content"
}
}
}),
{ isMatchingKey: styles.isTableCellStylesKeyEqual }
);
const getJsonCellStyles = memoize__default.default(
(_theme, { textWrap, shouldOverflow, maxHeight }) => css.css({
fontFamily: "monospace",
...textWrap && { whiteSpace: "pre" },
...shouldOverflow && {
[styles.getActiveCellSelector(Boolean(maxHeight))]: {
whiteSpace: "pre"
}
}
}),
{ isMatchingKey: styles.isTableCellStylesKeyEqual }
);
exports.AutoCell = AutoCell;
exports.getJsonCellStyles = getJsonCellStyles;
exports.getStyles = getStyles;
//# sourceMappingURL=AutoCell.cjs.map