Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { memo, ReactElement } from 'react';
import { FlexBox } from '../../..';
import { ListCol } from '../../../List';
import { useListContext } from '../../../List/ListProvider';
import { DEFAULT_COLUMN_SIZE } from '../../constants';
import {
ExpandControl,
FilterControl,
Expand Down Expand Up @@ -56,7 +57,7 @@ export const TableHeaderRow: HeaderComponent = ({
)}
</ListCol>
)}
{columns.map(({ key, header, sortable, filters, ...colProps }) => {
{columns.map(({ key, header, sortable, filters, size, ...colProps }) => {
const rowProperty = key as string;
const renderKey = prefixId(`header-col-${rowProperty}`);
const columnText = String(header || key);
Expand All @@ -73,6 +74,7 @@ export const TableHeaderRow: HeaderComponent = ({
{...colProps}
aria-sort={sortable ? ariaSortDirection : undefined}
columnHeader
size={size ?? DEFAULT_COLUMN_SIZE}
>
<FlexBox
alignItems={selectable ? 'center' : 'flex-end'}
Expand Down
3 changes: 2 additions & 1 deletion packages/gamut/src/DataList/Tables/Rows/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ListCol, ListRow } from '../../../List';
import { ColProps } from '../../../List/elements';
import { useListContext } from '../../../List/ListProvider';
import { Shimmer } from '../../../Loading/Shimmer';
import { DEFAULT_COLUMN_SIZE } from '../../constants';
import { ExpandControl, SelectControl } from '../../Controls';
import { useControlContext } from '../../hooks/useListControls';
import { ColumnConfig, IdentifiableKeys } from '../../types';
Expand Down Expand Up @@ -108,7 +109,7 @@ export const TableRow: DataRow = ({
const newKey = prefixId(`${id}-col-${String(key)}`);
const colProps = {
...listColProps,
size,
size: size ?? DEFAULT_COLUMN_SIZE,
justify,
fill,
type,
Expand Down
3 changes: 3 additions & 0 deletions packages/gamut/src/DataList/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { DataGridColumnSize } from './types';

export const DEFAULT_COLUMN_SIZE: DataGridColumnSize = 'md';
4 changes: 3 additions & 1 deletion packages/gamut/src/DataList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export type IdentifiableKeys<T> = Extract<

export type FilterOption = string | { text: string; value: string };

export type DataGridColumnSize = Exclude<ListColProps['size'], 'content'>;

export interface ColumnConfig<T> {
key: keyof T;
/**
Expand All @@ -73,7 +75,7 @@ export interface ColumnConfig<T> {
*/
header?: string;
type?: ListColProps['type'];
size?: Exclude<ListColProps['size'], 'content'>;
size?: DataGridColumnSize;
render?: (row: T) => ReactElement<any, any> | null;
sortable?: boolean;
filters?: string[];
Expand Down
Loading