Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/components/Common/DataView/DataTable/DataTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ describe('DataTable Component', () => {
expect(screen.getByText('Name').closest('div')?.className).toMatch(/cellEnd/)
expect(screen.getByText('Alice').closest('div')?.className).toMatch(/cellEnd/)
})

test('does not wrap content when justify is unset — even for the last column', () => {
// Alignment is now driven solely by column.justify; there is no implicit
// "last column right-aligns" behavior, so an unset column must not be wrapped.
renderTable({
columns: [{ key: 'name', title: 'Name', render: item => item.name }],
})

expect(screen.getByText('Name').closest('div')?.className ?? '').not.toMatch(/cellEnd/)
expect(screen.getByText('Alice').closest('div')?.className ?? '').not.toMatch(/cellEnd/)
})

test('end-aligns the injected actions column so the row menu stays flush-right', () => {
renderTable({
columns: [{ key: 'name', title: 'Name', render: item => item.name }],
itemMenu: item => <button type="button">Menu for {item.name}</button>,
})

expect(screen.getByText('Menu for Alice').closest('div')?.className).toMatch(/cellEnd/)
})
})

describe('accessibility', () => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/Common/DataView/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export const DataTable = <T,>({
? [
{
key: 'actions-header',
content: <VisuallyHidden>{t('table.actionsColumnHeader')}</VisuallyHidden>,
content: withJustify(
<VisuallyHidden>{t('table.actionsColumnHeader')}</VisuallyHidden>,
'end',
),
},
]
: []),
Expand Down Expand Up @@ -176,7 +179,7 @@ export const DataTable = <T,>({
? [
{
key: `menu-${rowIndex}`,
content: itemMenu(item),
content: withJustify(itemMenu(item), 'end'),
},
]
: []),
Expand Down
19 changes: 19 additions & 0 deletions src/components/Common/DataView/DataView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,22 @@ export const DataViewWithFooter = () => {

return <DataView label="Data View with Footer" {...dataProps} />
}

// Alignment is driven entirely by column.justify: the numeric "Amount" column
// right-aligns (header, body, and footer), while text columns stay left. The
// injected row-menu column is always flush-right.
export const DataViewWithJustifiedColumns = () => {
const justifiedColumns: useDataViewProp<CompensationRow>['columns'] = [
{ key: 'jobTitle', title: 'Job Title' },
{ key: 'payType', title: 'Pay Type' },
{ key: 'amount', title: 'Amount', justify: 'end' },
{ key: 'payTimePeriod', title: 'Pay Time Period' },
]
const dataProps = useDataView({
data: compensationData,
columns: justifiedColumns,
itemMenu: renderItemMenu,
footer: () => ({ jobTitle: 'Total', amount: '$1,050.15' }),
})
return <DataView label="Data View with Justified Columns" {...dataProps} />
}
7 changes: 0 additions & 7 deletions src/components/Common/UI/Table/Table.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@
outline: var(--g-focusRingWidth) solid var(--g-focusRingColor);
outline-offset: -2px;
}
&:last-child {
text-align: right;

:global(.react-aria-Button) {
display: inline-flex;
}
}

// Empty state row styling
:global(.react-aria-Row[data-empty-state='true']) & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function TaxRateHistorySection({ group, showHeader = true }: TaxRateHisto
...requirementColumns.map(column => ({
key: column.key,
title: column.label ?? column.key,
justify: 'end' as const,
render: (row: HistoryRow) => row.values[column.key] ?? '',
})),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export const PaymentStatementPresentation = ({
},
{
title: t('amountColumn'),
justify: 'end',
render: ({ amount }) => amount || '',
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function JobsListPresentation({
{
key: 'rate',
title: t('allCompensations.amountColumn'),
justify: 'end',
render: (job: Job) => job.rate?.toString() || '',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function DeductionsCardContent({ employeeId, onEvent, LoaderComponent }: Deducti
{
key: 'amount',
title: t('columns.withhold'),
justify: 'end' as const,
render: (garnishment: Garnishment) =>
formatDeductionAmount(garnishment, {
formatCurrency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function DeductionsList({
{
key: 'amount',
title: t('withheldColumn'),
justify: 'end',
render: deduction =>
formatDeductionAmount(deduction, {
formatCurrency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function ListViewReady({
{
key: 'splitAmount',
title: t('allocationColumn'),
justify: 'end',
render: bankAccount => {
const splitAmount =
paymentMethod.splits?.find(split => split.uuid === bankAccount.uuid)?.splitAmount ?? 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function PaystubsCardReady({
{
key: 'checkAmount',
title: t('checkAmount'),
justify: 'end' as const,
render: (payStub: EmployeePayStub) => {
if (!payStub.netPay) return '-'
const amount = parseFloat(payStub.netPay)
Expand All @@ -208,6 +209,7 @@ function PaystubsCardReady({
{
key: 'grossPay',
title: t('grossPay'),
justify: 'end' as const,
render: (payStub: EmployeePayStub) => {
if (!payStub.grossPay) return '-'
const amount = parseFloat(payStub.grossPay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
:global(.react-aria-Cell) {
width: 50%;
text-align: left;

&:last-child {
text-align: left;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const PayrollConfigurationPresentation = ({
},
{
title: t('tableColumns.hours'),
justify: 'end',
render: (item: PayrollEmployeeCompensationsType) => {
const hours = getRegularHours(item)
const overtimeHours = getOvertimeHours(item)
Expand All @@ -224,13 +225,15 @@ export const PayrollConfigurationPresentation = ({
},
{
title: t('tableColumns.timeOff'),
justify: 'end',
render: (item: PayrollEmployeeCompensationsType) => {
const ptoHours = getTotalPtoHours(item)
return formatHoursDisplay(ptoHours)
},
},
{
title: t('tableColumns.additionalEarnings'),
justify: 'end',
render: (item: PayrollEmployeeCompensationsType) => {
const earnings = getAdditionalEarnings(item)
return formatNumberAsCurrency(earnings)
Expand All @@ -240,6 +243,7 @@ export const PayrollConfigurationPresentation = ({
? [
{
title: t('tableColumns.reimbursements'),
justify: 'end' as const,
render: (item: PayrollEmployeeCompensationsType) => {
const reimbursements = getReimbursements(item)
return formatNumberAsCurrency(reimbursements)
Expand All @@ -249,6 +253,7 @@ export const PayrollConfigurationPresentation = ({
: []),
{
title: t('tableColumns.totalPay'),
justify: 'end',
render: (item: PayrollEmployeeCompensationsType) => {
const employee = employeeMap.get(item.employeeUuid || '')
const calculatedGrossPay = employee
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export const PayrollEditEmployeePresentation = ({
{
key: 'amount',
title: t('reimbursementAmountColumn'),
justify: 'end',
render: row => formatNumberAsCurrency(parseFloat(row.amount || '0')),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export const PayrollHistoryPresentation = ({
},
{
title: t('columns.totalPayroll'),
justify: 'end',
render: (item: Payroll) => formatNumberAsCurrency(calculateTotalPayroll(item)),
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export const PayrollOverviewPresentation = ({
const companyPaysColumns: Array<{
key: string
title: string
justify?: 'start' | 'end'
render: (item: EmployeeCompensations) => React.ReactNode
}> = [
{
Expand All @@ -236,6 +237,7 @@ export const PayrollOverviewPresentation = ({
{
key: 'grossPay',
title: t('tableHeaders.grossPay'),
justify: 'end',
render: (employeeCompensations: EmployeeCompensations) =>
formatCurrency(Number(employeeCompensations.grossPay!)),
},
Expand All @@ -244,6 +246,7 @@ export const PayrollOverviewPresentation = ({
{
key: 'reimbursements',
title: t('tableHeaders.reimbursements'),
justify: 'end' as const,
render: (employeeCompensation: EmployeeCompensations) =>
formatCurrency(getReimbursements(employeeCompensation)),
},
Expand All @@ -252,18 +255,21 @@ export const PayrollOverviewPresentation = ({
{
key: 'companyTaxes',
title: t('tableHeaders.companyTaxes'),
justify: 'end',
render: (employeeCompensation: EmployeeCompensations) =>
formatCurrency(getCompanyTaxes(employeeCompensation)),
},
{
key: 'companyBenefits',
title: t('tableHeaders.companyBenefits'),
justify: 'end',
render: (employeeCompensation: EmployeeCompensations) =>
formatCurrency(getCompanyBenefits(employeeCompensation)),
},
{
key: 'companyPays',
title: t('tableHeaders.companyPays'),
justify: 'end',
render: (employeeCompensation: EmployeeCompensations) =>
formatCurrency(getCompanyCost(employeeCompensation)),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const PayrollReceiptsPresentation = ({
},
{
title: t('breakdown.amount'),
justify: 'end',
render: (item: { label: string; amount: number }) =>
formatNumberAsCurrency(item.amount),
},
Expand All @@ -204,6 +205,7 @@ export const PayrollReceiptsPresentation = ({
},
{
title: t('tax.amount'),
justify: 'end',
render: (tax: TaxBreakdownItem) =>
formatNumberAsCurrency(parseFloat(tax.amount || '0')),
},
Expand Down Expand Up @@ -259,25 +261,29 @@ export const PayrollReceiptsPresentation = ({
},
{
title: t('employee.childSupport'),
justify: 'end',
render: (employee: EmployeeBreakdownItem) =>
formatNumberAsCurrency(parseFloat(employee.childSupportGarnishment || '0')),
},
...(withReimbursements
? [
{
title: t('employee.reimbursement'),
justify: 'end' as const,
render: (employee: EmployeeBreakdownItem) =>
formatNumberAsCurrency(parseFloat(employee.totalReimbursement || '0')),
},
]
: []),
{
title: t('employee.totalTaxes'),
justify: 'end',
render: (employee: EmployeeBreakdownItem) =>
formatNumberAsCurrency(parseFloat(employee.totalTax || '0')),
},
{
title: t('employee.netPay'),
justify: 'end',
render: (employee: EmployeeBreakdownItem) =>
formatNumberAsCurrency(parseFloat(employee.netPay || '0')),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function Root({ companyId, dictionary, onEvent }: RecoveryCasesListProps) {
{
key: 'totalAmount',
title: t('columns.totalAmount'),
justify: 'end',
render: recoveryCase => (
<Text>
{recoveryCase.eventTotalAmount
Expand All @@ -143,6 +144,7 @@ function Root({ companyId, dictionary, onEvent }: RecoveryCasesListProps) {
{
key: 'amountOutstanding',
title: t('columns.amountOutstanding'),
justify: 'end',
render: recoveryCase => (
<Text>
{recoveryCase.amountOutstanding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
display: flex;
flex-direction: column;
gap: toRem(16);

&:not([data-has-menu]) {
:global(.react-aria-Cell),
:global(.react-aria-Column) {
&:last-child {
text-align: left;
}
}
}
}

.searchContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function EmployeeTable<T extends EmployeeTableItem>({
} as useDataViewProp<T>)

return (
<div className={styles.root} data-has-menu={itemMenu ? true : undefined}>
<div className={styles.root}>
{!hideSearch && (
<div className={styles.searchContainer}>
<Components.TextInput
Expand Down
Loading