Skip to content

Commit 440b045

Browse files
committed
fix: PR fixes
1 parent c125e88 commit 440b045

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
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: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ModuleRegistry.registerModules([
2222
ClientSideRowModelModule,
2323
]);
2424

25+
2526
const SkeletonCellRenderer = (props: { value?: ReactNode }) => {
2627
if (!props.value) {
2728
return (
@@ -35,10 +36,14 @@ const SkeletonCellRenderer = (props: { value?: ReactNode }) => {
3536
return <div className={styles.defaultCellContainer}>{props.value}</div>;
3637
};
3738

39+
const DEFAULT_COL_DEF = {
40+
cellRenderer: SkeletonCellRenderer,
41+
flex: 1,
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;
@@ -83,9 +81,10 @@ export const TableGrid = <TData extends Record<string, unknown>>({
8381
const tableGrid = (
8482
<AgGridReact<TData>
8583
className={styles.tableGrid}
84+
8685
// @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}
86+
rowData={loading ? [[]] : rowData}
87+
defaultColDef={DEFAULT_COL_DEF}
8988
columnDefs={mappedColDefs}
9089
theme={themeQuartz}
9190
domLayout="autoHeight"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ 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>[];
13+
loading?: boolean;
1414
cardProps?: Omit<CardProps<"div">, "children" | "footer"> & {
1515
nonInteractive?: true;
1616
};
1717
pagination?: boolean;
18-
} & Omit<AgGridReactProps<TData>, "rowData" | "defaultColDef" | "columnDefs">;
18+
} & Omit<AgGridReactProps<TData>, "rowData" | "defaultColDef" | "columnDefs" | "loading">;

0 commit comments

Comments
 (0)