|
|
|
@@ -20,6 +20,7 @@ import { SparklineCell, getStyles as getSparklineCellStyles } from './SparklineC
|
|
|
|
|
const AutoCellRenderer = memo((props: TableCellRendererProps) => (
|
|
|
|
|
<AutoCell value={props.value} field={props.field} rowIdx={props.rowIdx} />
|
|
|
|
|
));
|
|
|
|
|
AutoCellRenderer.displayName = 'AutoCellRenderer';
|
|
|
|
|
|
|
|
|
|
function isCustomCellOptions(options: TableCellOptions): options is TableCustomCellOptions {
|
|
|
|
|
return options.type === TableCellDisplayMode.Custom;
|
|
|
|
@@ -56,16 +57,19 @@ const CELL_REGISTRY: Record<TableCellOptions['type'], CellRegistryEntry> = {
|
|
|
|
|
getStyles: mixinAutoCellStyles(getJsonCellStyles),
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Actions]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => (
|
|
|
|
|
<ActionsCell field={props.field} rowIdx={props.rowIdx} getActions={props.getActions ?? (() => [])} />
|
|
|
|
|
)),
|
|
|
|
|
getStyles: getActionsCellStyles,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.DataLinks]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => <DataLinksCell field={props.field} rowIdx={props.rowIdx} />),
|
|
|
|
|
getStyles: getDataLinksStyles,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Gauge]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => (
|
|
|
|
|
<BarGaugeCell
|
|
|
|
|
field={props.field}
|
|
|
|
@@ -78,6 +82,7 @@ const CELL_REGISTRY: Record<TableCellOptions['type'], CellRegistryEntry> = {
|
|
|
|
|
)),
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Sparkline]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => (
|
|
|
|
|
<SparklineCell
|
|
|
|
|
value={props.value}
|
|
|
|
@@ -91,16 +96,19 @@ const CELL_REGISTRY: Record<TableCellOptions['type'], CellRegistryEntry> = {
|
|
|
|
|
getStyles: getSparklineCellStyles,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Geo]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => <GeoCell value={props.value} height={props.height} />),
|
|
|
|
|
getStyles: getGeoCellStyles,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Image]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => (
|
|
|
|
|
<ImageCell cellOptions={props.cellOptions} field={props.field} value={props.value} rowIdx={props.rowIdx} />
|
|
|
|
|
)),
|
|
|
|
|
getStyles: getImageStyles,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Pill]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => (
|
|
|
|
|
<PillCell rowIdx={props.rowIdx} field={props.field} theme={props.theme} />
|
|
|
|
|
)),
|
|
|
|
@@ -108,6 +116,7 @@ const CELL_REGISTRY: Record<TableCellOptions['type'], CellRegistryEntry> = {
|
|
|
|
|
testField: (field: Field) => field.type === FieldType.string,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Markdown]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => (
|
|
|
|
|
<MarkdownCell field={props.field} rowIdx={props.rowIdx} disableSanitizeHtml={props.disableSanitizeHtml} />
|
|
|
|
|
)),
|
|
|
|
@@ -115,6 +124,7 @@ const CELL_REGISTRY: Record<TableCellOptions['type'], CellRegistryEntry> = {
|
|
|
|
|
testField: (field: Field) => field.type === FieldType.string,
|
|
|
|
|
},
|
|
|
|
|
[TableCellDisplayMode.Custom]: {
|
|
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
|
|
renderer: memo((props: TableCellRendererProps) => {
|
|
|
|
|
if (!isCustomCellOptions(props.cellOptions) || !props.cellOptions.cellComponent) {
|
|
|
|
|
return null; // nonsensical case, but better to typeguard it than throw.
|
|
|
|
|