Restore copy on text
Summary: Some folks were missing the copy as text ManagedTable used to have, so introduced both the options to either copy as text (visible columns or custom copy handler) or as JSON Changelog: It is now possible to both copy as text or as JSON from data tables Reviewed By: jknoxville Differential Revision: D29712096 fbshipit-source-id: 27bd2e869a247bd0896ce2774c08651123fd531d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1e93055eb5
commit
d23ccfcd44
@@ -10,7 +10,7 @@
|
||||
import React, {CSSProperties, memo} from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import {theme} from '../theme';
|
||||
import type {TableRowRenderContext} from './DataTable';
|
||||
import {DataTableColumn, TableRowRenderContext} from './DataTable';
|
||||
import {Width} from '../../utils/widthUtils';
|
||||
import {DataFormatter} from '../DataFormatter';
|
||||
import {Dropdown} from 'antd';
|
||||
@@ -121,9 +121,12 @@ export const TableRow = memo(function TableRow<T>({
|
||||
{config.columns
|
||||
.filter((col) => col.visible)
|
||||
.map((col) => {
|
||||
const value = col.onRender
|
||||
? (col as any).onRender(record, highlighted, itemIndex)
|
||||
: DataFormatter.format((record as any)[col.key], col.formatters);
|
||||
const value = renderColumnValue<T>(
|
||||
col,
|
||||
record,
|
||||
highlighted,
|
||||
itemIndex,
|
||||
);
|
||||
|
||||
return (
|
||||
<TableBodyColumnContainer
|
||||
@@ -147,3 +150,14 @@ export const TableRow = memo(function TableRow<T>({
|
||||
return row;
|
||||
}
|
||||
});
|
||||
|
||||
export function renderColumnValue<T>(
|
||||
col: DataTableColumn<any>,
|
||||
record: T,
|
||||
highlighted: boolean,
|
||||
itemIndex: number,
|
||||
) {
|
||||
return col.onRender
|
||||
? col.onRender(record, highlighted, itemIndex)
|
||||
: DataFormatter.format((record as any)[col.key], col.formatters);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user