Files
bigcapital/src/components/Datatable/CellForceWidth.js
2021-11-01 09:34:58 +02:00

30 lines
628 B
JavaScript

import React from 'react';
import { get } from 'lodash';
import { getForceWidth } from 'utils';
export function CellForceWidth({
value,
column: { forceWidthAccess },
row: { original },
}) {
const forceWidthValue = forceWidthAccess
? get(original, forceWidthAccess)
: value;
return <ForceWidth forceValue={forceWidthValue}>{value}</ForceWidth>;
}
export function ForceWidth({ children, forceValue }) {
const forceWidthValue = forceValue || children;
return (
<span
className={'force-width'}
style={{ minWidth: getForceWidth(forceWidthValue) }}
>
{children}
</span>
);
}