File size: 1,291 Bytes
5144199 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | //#region src/flex-render.ts
/**
* Renders a static value or render function with the provided props.
*
* Framework adapters use this helper to support column definitions that contain either plain values or template functions.
*/
function flexRender(comp, props) {
if (comp == null) return null;
if (typeof comp === "function") return comp(props);
return comp;
}
/**
* Renders a static value or render function with the provided props.
*
* Framework adapters use this helper to support column definitions that contain either plain values or template functions.
*/
function FlexRender(props) {
if ("cell" in props && props.cell) {
const cell = props.cell;
const def = cell.column.columnDef;
const groupingCell = cell;
const groupingDef = def;
if (groupingCell.getIsAggregated?.()) return flexRender(groupingDef.aggregatedCell ?? def.cell, cell.getContext());
if (groupingCell.getIsPlaceholder?.()) return null;
return flexRender(def.cell, cell.getContext());
}
if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
return null;
}
//#endregion
export { FlexRender, flexRender }; |