UNPKG

@grafana/ui

Version:
49 lines (44 loc) 1.88 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var css = require('@emotion/css'); var index = require('./Expander/index.cjs'); "use strict"; const EXPANDER_CELL_ID = "__expander"; function getColumns(columns, showExpandAll = false) { return [ { id: EXPANDER_CELL_ID, Cell: index.ExpanderCell, Header: showExpandAll ? index.ExpanderHeader : index.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.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 } }; }) ]; } exports.EXPANDER_CELL_ID = EXPANDER_CELL_ID; exports.getColumns = getColumns; //# sourceMappingURL=utils.cjs.map