Skip to content

Commit

Permalink
Merge branch 'select-all-items-row' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Oct 6, 2023
2 parents e6bb71e + 1763e56 commit daba5d5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-formiga-table",
"version": "0.8.7-rc.0",
"version": "0.8.7-rc.1",
"scripts": {
"start": "while :; do tsc && vite build --watch --force; done",
"build": "tsc && vite build",
Expand Down
24 changes: 11 additions & 13 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export const Table = (props: TableProps) => {
return loadingComponent;
}

const numberOfColumns = 1 + columns.length + (!!onRowStatus ? 1 : 0);
const numberOfVisibleSelectedRows = dataSource
.filter((entry) => getLevelForKey(entry.id) === 0)
.filter((entry) => selectedRowKeys.includes(entry.id)).length;
Expand All @@ -103,6 +102,17 @@ export const Table = (props: TableProps) => {
canClick={onRowDoubleClick !== undefined}
readonly={readonly}
>
{onSelectAllRecords && (
<SelectAllRecordsRow
numberOfVisibleSelectedRows={numberOfVisibleSelectedRows}
numberOfRealSelectedRows={selectedRowKeys.length}
numberOfTotalRows={dataSource.length}
totalRecords={totalItems}
translations={translations}
onSelectAllRecords={onSelectAllRecords}
loadingComponent={loadingComponent}
/>
)}
<table>
<thead>
<tr>
Expand All @@ -121,18 +131,6 @@ export const Table = (props: TableProps) => {
</tr>
</thead>
<tbody>
{onSelectAllRecords && (
<SelectAllRecordsRow
numberOfColumns={numberOfColumns}
numberOfVisibleSelectedRows={numberOfVisibleSelectedRows}
numberOfRealSelectedRows={selectedRowKeys.length}
numberOfTotalRows={dataSource.length}
totalRecords={totalItems}
translations={translations}
onSelectAllRecords={onSelectAllRecords}
loadingComponent={loadingComponent}
/>
)}
<Rows
dataSource={dataSource}
columns={columns}
Expand Down
19 changes: 7 additions & 12 deletions src/components/SelectAllRecordsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import styled from "styled-components";
import { LocalizedStrings } from "../types";
import { useState } from "react";

export const Container = styled.tr`
cursor: auto !important;
export const Container = styled.div`
height: 50px;
&:hover {
background-color: transparent !important;
}
display: flex;
align-items: center;
justify-content: center;
`;

export const SelectAllRecordsRow = ({
numberOfColumns,
numberOfVisibleSelectedRows,
totalRecords,
numberOfTotalRows,
Expand All @@ -20,7 +18,6 @@ export const SelectAllRecordsRow = ({
loadingComponent,
numberOfRealSelectedRows,
}: {
numberOfColumns: number;
numberOfVisibleSelectedRows: number;
totalRecords: number;
numberOfTotalRows: number;
Expand Down Expand Up @@ -81,11 +78,9 @@ export const SelectAllRecordsRow = ({

return (
<Container>
<td colSpan={numberOfColumns} style={{ textAlign: "center" }}>
{numberOfRealSelectedRows > numberOfTotalRows
? allRowsAreSelected
: selectRowsComponent}
</td>
{numberOfRealSelectedRows > numberOfTotalRows
? allRowsAreSelected
: selectRowsComponent}
</Container>
);
};

0 comments on commit daba5d5

Please sign in to comment.