feat: add editingAlign to EditableTable

This commit is contained in:
Sérgio Salgado 2021-02-17 19:20:33 +00:00 committed by Josh Harvey
parent 7be120ef3a
commit b88423145c
2 changed files with 14 additions and 5 deletions

View file

@ -127,6 +127,7 @@ const ECol = ({ editing, focus, config, extraPaddingRight, extraPadding }) => {
bold, bold,
width, width,
textAlign, textAlign,
editingAlign = textAlign,
suffix, suffix,
SuffixComponent = TL2, SuffixComponent = TL2,
textStyle = it => {}, textStyle = it => {},
@ -135,20 +136,24 @@ const ECol = ({ editing, focus, config, extraPaddingRight, extraPadding }) => {
} = config } = config
const { values } = useFormikContext() const { values } = useFormikContext()
const classes = useStyles({ textAlign, size })
const isEditing = editing && editable
const isField = !bypassField
const classes = useStyles({
textAlign: isEditing ? editingAlign : textAlign,
size
})
const innerProps = { const innerProps = {
fullWidth: true, fullWidth: true,
autoFocus: focus, autoFocus: focus,
size, size,
bold, bold,
textAlign, textAlign: isEditing ? editingAlign : textAlign,
...inputProps ...inputProps
} }
const isEditing = editing && editable
const isField = !bypassField
return ( return (
<Td <Td
className={{ className={{

View file

@ -155,6 +155,7 @@ const mainFields = currency => [
display: 'Cash-in', display: 'Cash-in',
width: 169, width: 169,
size: 'lg', size: 'lg',
editingAlign: 'right',
input: NumberInput, input: NumberInput,
suffix: '%', suffix: '%',
inputProps: { inputProps: {
@ -167,6 +168,7 @@ const mainFields = currency => [
display: 'Cash-out', display: 'Cash-out',
width: 169, width: 169,
size: 'lg', size: 'lg',
editingAlign: 'right',
input: NumberInput, input: NumberInput,
suffix: '%', suffix: '%',
inputProps: { inputProps: {
@ -180,6 +182,7 @@ const mainFields = currency => [
size: 'lg', size: 'lg',
doubleHeader: 'Cash-in only', doubleHeader: 'Cash-in only',
textAlign: 'center', textAlign: 'center',
editingAlign: 'right',
input: NumberInput, input: NumberInput,
suffix: currency, suffix: currency,
inputProps: { inputProps: {
@ -193,6 +196,7 @@ const mainFields = currency => [
size: 'lg', size: 'lg',
doubleHeader: 'Cash-in only', doubleHeader: 'Cash-in only',
textAlign: 'center', textAlign: 'center',
editingAlign: 'right',
input: NumberInput, input: NumberInput,
suffix: currency, suffix: currency,
inputProps: { inputProps: {