Skip to content

Commit

Permalink
perf(core): ⚡ improve code
Browse files Browse the repository at this point in the history
improve code

ref: #336
  • Loading branch information
anantakumarghosh committed Aug 29, 2024
1 parent eadfe54 commit 6854a11
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
22 changes: 1 addition & 21 deletions package/components/dataDisplay/CoreTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,13 @@ import React from "react";

import { NativeTable } from "@wrappid/native";

import { getUUID } from "../../utils/appUtils";
import { sanitizeComponentProps } from "../../utils/componentUtil";

export default function CoreTable(props) {
let _uuid = getUUID();
// eslint-disable-next-line no-unused-vars
let containerId = props?.coreId ? "tc_" + props.coreId : "tc_" + _uuid;

props = sanitizeComponentProps(CoreTable, props);

const {
children,
component,
padding,
size,
stickyHeader,
} = props;

return (
<NativeTable
component={component}
padding={padding}
size={size}
stickyHeader={stickyHeader}
>
{children}
</NativeTable>
<NativeTable {...props} />
);
}

Expand Down
2 changes: 1 addition & 1 deletion package/components/dataDisplay/CoreTableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { sanitizeComponentProps } from "../../utils/componentUtil";

export default function CoreTableBody(props) {
props = sanitizeComponentProps(CoreTableBody, props);
return <NativeTableBody {...props}>{props?.children}</NativeTableBody>;
return <NativeTableBody {...props} />;
}

CoreTableBody.displayName = "CoreTableBody";
Expand Down
2 changes: 1 addition & 1 deletion package/components/dataDisplay/CoreTableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { sanitizeComponentProps } from "../../utils/componentUtil";

export default function CoreTableContainer(props) {
props = sanitizeComponentProps(CoreTableContainer, props);
return <NativeTableContainer {...props}>{props?.children}</NativeTableContainer>;
return <NativeTableContainer {...props} />;
}

CoreTableContainer.displayName = "CoreTableContainer";
Expand Down
2 changes: 1 addition & 1 deletion package/components/dataDisplay/CoreTableFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { sanitizeComponentProps } from "../../utils/componentUtil";

export default function CoreTableFooter(props) {
props = sanitizeComponentProps(CoreTableFooter, props);
return <NativeTableFooter {...props}>{props?.children}</NativeTableFooter>;
return <NativeTableFooter {...props} />;
}
CoreTableFooter.displayName = "CoreTableFooter";
CoreTableFooter.validProps = [
Expand Down
13 changes: 10 additions & 3 deletions package/components/dataDisplay/CoreTablePagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ import CoreTableCell from "./CoreTableCell";
import { DATA_TABLE_CONST } from "../../config/dataTableConstants";
import { sanitizeComponentProps } from "../../utils/componentUtil";

/**
* CoreTablePagination is a component that displays pagination controls for a table.
* @todo rowsPerPageOptions via wrappid style context.
* @param {*} props
* @returns
*/
export default function CoreTablePagination(props) {
props = sanitizeComponentProps(CoreTablePagination, props);
const { rowsPerPageOptions, ...restProps } = props;

return (
<NativeTablePagination
component={"div"}
labelRowsPerPage="" // make it clean
rowsPerPageOptions={DATA_TABLE_CONST.ROWS_PER_PAGE_OPTIONS}
{...props}
rowsPerPageOptions={rowsPerPageOptions || DATA_TABLE_CONST.ROWS_PER_PAGE_OPTIONS}
{...restProps}
/>
);
}
Expand Down

0 comments on commit 6854a11

Please sign in to comment.