Skip to content

Commit 42ca144

Browse files
committed
fix: PR fixes
1 parent c125e88 commit 42ca144

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

packages/component-library/src/TableGrid/index.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const meta = {
1313
layout: "padded",
1414
},
1515
argTypes: {
16-
colDefs: {
16+
columnDefs: {
1717
table: {
1818
disable: true,
1919
},
@@ -33,7 +33,7 @@ const meta = {
3333
category: "Outer Card",
3434
},
3535
},
36-
isLoading: {
36+
loading: {
3737
control: "boolean",
3838
table: {
3939
category: "State",
@@ -75,7 +75,7 @@ const FeedCellRendererLoading = () => (
7575
);
7676

7777
const args = {
78-
colDefs: [
78+
columnDefs: [
7979
{
8080
headerName: "ID",
8181
field: "id",

packages/component-library/src/TableGrid/index.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ const SkeletonCellRenderer = (props: { value?: ReactNode }) => {
3535
return <div className={styles.defaultCellContainer}>{props.value}</div>;
3636
};
3737

38+
const DEFAULT_COL_DEF = {
39+
cellRenderer: SkeletonCellRenderer,
40+
flex: 1,
41+
};
42+
3843
export const TableGrid = <TData extends Record<string, unknown>>({
3944
rowData,
40-
colDefs,
41-
isLoading,
45+
columnDefs,
46+
loading,
4247
cardProps,
4348
pagination,
4449
...props
@@ -48,25 +53,18 @@ export const TableGrid = <TData extends Record<string, unknown>>({
4853
const [currentPage, setCurrentPage] = useState(1);
4954
const [totalPages, setTotalPages] = useState(1);
5055

51-
const defaultColDef = useMemo(() => {
52-
return {
53-
cellRenderer: SkeletonCellRenderer,
54-
flex: 1,
55-
};
56-
}, []);
57-
5856
const mappedColDefs = useMemo(() => {
59-
return colDefs.map((colDef) => {
57+
return columnDefs.map((colDef) => {
6058
return {
6159
...colDef,
6260
// the types in ag-grid are `any` for the cellRenderers which is throwing an error here
6361
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
64-
cellRenderer: isLoading
62+
cellRenderer: loading
6563
? (colDef.loadingCellRenderer ?? SkeletonCellRenderer)
6664
: colDef.cellRenderer,
6765
};
6866
});
69-
}, [colDefs, isLoading]);
67+
}, [columnDefs, loading]);
7068

7169
const onPaginationChanged = useCallback(() => {
7270
const api = gridRef.current?.api;
@@ -84,8 +82,8 @@ export const TableGrid = <TData extends Record<string, unknown>>({
8482
<AgGridReact<TData>
8583
className={styles.tableGrid}
8684
// @ts-expect-error empty row data, which is throwing an error here btu required to display 1 row in the loading state
87-
rowData={isLoading ? [[]] : rowData}
88-
defaultColDef={defaultColDef}
85+
rowData={loading ? [[]] : rowData}
86+
defaultColDef={DEFAULT_COL_DEF}
8987
columnDefs={mappedColDefs}
9088
theme={themeQuartz}
9189
domLayout="autoHeight"

packages/component-library/src/TableGrid/table-grid-props.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ type ExtendedColDef<TData> = ColDef<TData> & {
99

1010
export type TableGridProps<TData extends Record<string, unknown>> = {
1111
rowData: TData[];
12-
colDefs: ExtendedColDef<TData>[];
13-
isLoading?: boolean;
12+
columnDefs: ExtendedColDef<TData>[];
1413
cardProps?: Omit<CardProps<"div">, "children" | "footer"> & {
1514
nonInteractive?: true;
1615
};

0 commit comments

Comments
 (0)