Skip to content

Commit

Permalink
refactor(Table): expose SortByColumnOptions through TableColumn inter…
Browse files Browse the repository at this point in the history
…face
  • Loading branch information
maxime-gendron committed Jun 2, 2021
1 parent 740bbdb commit 2d0a7f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/components/table/table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
import { CellProps, Column, Row, TableState, useSortBy, useTable } from 'react-table';
import { CellProps, Column, Row, TableState, useSortBy, useTable, UseSortByColumnOptions } from 'react-table';
import styled from 'styled-components';
import { Theme } from '../../themes';
import { DeviceType, useDeviceContext } from '../device-context-provider/device-context-provider';
Expand All @@ -18,7 +18,7 @@ interface StyledTableProps {
rowSize?: RowSize;
}

type CustomColumn<T extends object> = Column<T> & {
type CustomColumn<T extends object> = Column<T> & UseSortByColumnOptions<T> & {
defaultSort?: ColumnSort;
sortable?: boolean,
textAlign?: string,
Expand Down
16 changes: 8 additions & 8 deletions packages/storybook/stories/table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,14 @@ export const SmallRows: Story = () => {
};

export const RowClickCallback: Story = () => {
const columns: TableColumn<Data> = [
interface DataWithHref {
column1: string;
column2: string;
column3: string;
href: string;
}

const columns: TableColumn<DataWithHref> = [
{
Header: 'Column 1',
accessor: 'column1',
Expand All @@ -275,13 +282,6 @@ export const RowClickCallback: Story = () => {
},
];

interface DataWithHref {
column1: string;
column2: string;
column3: string;
href: string;
}

const data: TableRow<DataWithHref>[] = [
{
column1: 'a',
Expand Down

0 comments on commit 2d0a7f5

Please sign in to comment.