UNPKG

@grafana/ui

Version:
44 lines (41 loc) 1.79 kB
import { css } from '@emotion/css'; import { ExpanderHeader, EmptyExpanderHeader, ExpanderCell } from './Expander/index.mjs'; "use strict"; const EXPANDER_CELL_ID = "__expander"; function getColumns(columns, showExpandAll = false) { return [ { id: EXPANDER_CELL_ID, Cell: ExpanderCell, Header: showExpandAll ? ExpanderHeader : EmptyExpanderHeader, disableSortBy: true, width: 0 }, // @ts-expect-error react-table expects each column key(id) to have data associated with it and therefore complains about // column.id being possibly undefined and not keyof T (where T is the data object) // We do not want to be that strict as we simply pass undefined to cells that do not have data associated with them. ...columns.map((column) => { var _a; return { id: column.id, accessor: column.id, Header: column.header || (() => null), sortType: column.sortType || "alphanumeric", disableSortBy: !Boolean(column.sortType), width: (_a = column.width) != null ? _a : column.disableGrow ? 0 : void 0, minWidth: column.minWidth, maxWidth: column.maxWidth, widthClass: css({ width: typeof column.width === "number" && column.width > 0 ? column.width : void 0, minWidth: typeof column.minWidth === "number" && column.minWidth > 0 ? column.minWidth : void 0, maxWidth: typeof column.maxWidth === "number" && column.maxWidth > 0 ? column.maxWidth : void 0 }), visible: column.visible, ...column.sortDescFirst !== void 0 && { sortDescFirst: column.sortDescFirst }, ...column.cell && { Cell: column.cell } }; }) ]; } export { EXPANDER_CELL_ID, getColumns }; //# sourceMappingURL=utils.mjs.map