UNPKG

@grafana/ui

Version:
55 lines (52 loc) 1.81 kB
import { jsx } from 'react/jsx-runtime'; import { css } from '@emotion/css'; import memoize from 'micro-memoize'; import { formattedValueToString } from '@grafana/data'; import { MaybeWrapWithLink } from '../components/MaybeWrapWithLink.mjs'; import { TABLE } from '../constants.mjs'; import { getActiveCellSelector, isTableCellStylesKeyEqual } from '../styles.mjs'; "use strict"; function AutoCell({ value, field, rowIdx }) { const displayValue = field.display(value); const formattedValue = formattedValueToString(displayValue); return /* @__PURE__ */ jsx(MaybeWrapWithLink, { field, rowIdx, children: formattedValue }); } const getStyles = memoize( (_theme, { textWrap, shouldOverflow, maxHeight }) => css({ ...textWrap && { whiteSpace: "pre-line" }, ...shouldOverflow && { [getActiveCellSelector(Boolean(maxHeight))]: { whiteSpace: "pre-line" } }, ...maxHeight != null && textWrap && { height: "auto", overflowY: "hidden", display: "-webkit-box", WebkitBoxOrient: "vertical", WebkitLineClamp: Math.floor(maxHeight / TABLE.LINE_HEIGHT), [getActiveCellSelector(true)]: { display: "flex", WebkitLineClamp: "none", WebkitBoxOrient: "unset", overflowY: "auto", height: "fit-content" } } }), { isMatchingKey: isTableCellStylesKeyEqual } ); const getJsonCellStyles = memoize( (_theme, { textWrap, shouldOverflow, maxHeight }) => css({ fontFamily: "monospace", ...textWrap && { whiteSpace: "pre" }, ...shouldOverflow && { [getActiveCellSelector(Boolean(maxHeight))]: { whiteSpace: "pre" } } }), { isMatchingKey: isTableCellStylesKeyEqual } ); export { AutoCell, getJsonCellStyles, getStyles }; //# sourceMappingURL=AutoCell.mjs.map