Skip to content

Commit

Permalink
chore(react): make table component public
Browse files Browse the repository at this point in the history
  • Loading branch information
cafrias committed Dec 2, 2024
1 parent a4671d4 commit af560c6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { BaseTableCellProps } from './types';
import { BaseTableCellProps } from '../types';

const css = {
header: 'nds-table-cell__header',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useRef, useState } from 'react';
import { BaseTableCell } from './BaseTableCell';
import { SortingCellData, useSortingState } from '../ComposableTable/SortingContext';
import { TableCellProps } from './types';
import { TableCellProps } from '../types';
import { useHeaderFor } from '../ComposableTable/HeadersContext';

function getSiblingIndex(el: HTMLElement): number {
Expand Down
24 changes: 0 additions & 24 deletions packages/react/src/components/Table/TableCell/types.ts

This file was deleted.

8 changes: 8 additions & 0 deletions packages/react/src/components/Table/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './types';

export { Table } from './Table';
export { TableHeader } from './TableHeader/TableHeader';
export { TableHeaderCell } from './TableHeaderCell/TableHeaderCell';
export { TableRow } from './TableRow/TableRow';
export { TableBody } from './TableBody/TableBody';
export { TableCell } from './TableCell/TableCell';
23 changes: 23 additions & 0 deletions packages/react/src/components/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,26 @@ export interface TableRowProps extends React.TableHTMLAttributes<HTMLTableRowEle
*/
className?: string;
}

export interface BaseTableCellProps extends React.TableHTMLAttributes<HTMLTableCellElement> {
/**
* The content of the header that corresponds to this cell.
* This will only render in the XS breakpoint to give visual context
* to users.
*/
header?: React.ReactNode;
}

export interface TableCellProps extends BaseTableCellProps {
/**
* Override or extend existing table style.
*/
className?: string;

/**
* The value of the cell.
* In uncontrolled sorting the value is used to sort the column. If none is defined
* the text content of the cell is used as value.
*/
value?: SortableValue;
}
1 change: 1 addition & 0 deletions packages/react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './ResponseIndicator';
export * from './Spinner';
export * from './StepIndicator';
export * from './Switch';
export * from './Table';
export * from './Tabs';
export * from './Tag';
export * from './TextField';
Expand Down

0 comments on commit af560c6

Please sign in to comment.