UNPKG

@grafana/ui

Version:
43 lines (40 loc) 1.36 kB
import { jsx } from 'react/jsx-runtime'; import { css } from '@emotion/css'; import memoize from 'micro-memoize'; import { isTableCellStylesKeyEqual } from '../styles.mjs'; import { getCellLinks, getJustifyContent } from '../utils.mjs'; "use strict"; const DataLinksCell = ({ field, rowIdx }) => { const links = getCellLinks(field, rowIdx); if (!(links == null ? void 0 : links.length)) { return null; } return links.map((link, idx) => /* @__PURE__ */ jsx("a", { onClick: link.onClick, href: link.href, target: link.target, children: link.title }, idx)); }; const getStyles = memoize( (theme, { textWrap, textAlign }) => css({ ...textWrap && { flexDirection: "column", justifyContent: "center", alignItems: `${getJustifyContent(textAlign)} !important` // we can't guarantee order, and alignItems is set on a sibling class. }, "> a": { flexWrap: "nowrap", ...!textWrap && { paddingInline: theme.spacing(0.5), borderRight: `2px solid ${theme.colors.border.medium}`, "&:first-child": { paddingInlineStart: 0 }, "&:last-child": { paddingInlineEnd: 0, borderRight: "none" } } } }), { isMatchingKey: isTableCellStylesKeyEqual } ); export { DataLinksCell, getStyles }; //# sourceMappingURL=DataLinksCell.mjs.map