diff --git a/package.json b/package.json index 7d40ca2..0d43544 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@koupr/ui", - "version": "1.10.8", + "version": "1.10.9", "license": "MIT", "type": "module", "source": "src/index.ts", @@ -11,9 +11,6 @@ "type": "git", "url": "https://github.com/kouprlabs/koupr-ui.git" }, - "engines": { - "node": ">=20.x" - }, "scripts": { "build": "rollup -c && node ./scripts/cleanup.js", "tsc": "tsc", diff --git a/src/components/data-table.tsx b/src/components/data-table.tsx index b5ca233..5bca472 100644 --- a/src/components/data-table.tsx +++ b/src/components/data-table.tsx @@ -20,6 +20,7 @@ export interface DataTableProps { items: T[] columns: DataTableColumn[] actions?: DataTableAction[] + pagination?: ReactElement } export interface DataTableColumn { @@ -39,70 +40,81 @@ export interface DataTableAction { onClick?: (item: T) => void } -export function DataTable({ items, columns, actions }: DataTableProps) { +export function DataTable({ + items, + columns, + actions, + pagination, +}: DataTableProps) { return ( - - - - {columns.map((column, columnIndex) => ( - - ))} - {actions ? : null} - - - - {items.map((item, itemIndex) => ( - - {columns.map((column, colIndex) => ( - +
+
{column.title}
- {column.renderCell(item)} -
+ + + {columns.map((column, columnIndex) => ( + ))} - {actions ? ( - - ) : null} + {actions ? : null} - ))} - -
{column.title} - - } - variant="ghost" - title="Action menu" - aria-label="Action menu" - /> - - - {actions - ?.filter( - (action) => - !!(!action.isHidden && !action.isHiddenFn?.(item)), - ) - .map((action, actionIndex) => ( - action.onClick?.(item)} - > - {action.label} - - ))} - - - -
+ + + {items.map((item, itemIndex) => ( + + {columns.map((column, colIndex) => ( + + {column.renderCell(item)} + + ))} + {actions ? ( + + + } + variant="ghost" + title="Action menu" + aria-label="Action menu" + /> + + + {actions + ?.filter( + (action) => + !!( + !action.isHidden && !action.isHiddenFn?.(item) + ), + ) + .map((action, actionIndex) => ( + action.onClick?.(item)} + > + {action.label} + + ))} + + + + + ) : null} + + ))} + + + {pagination ?
{pagination}
: null} + ) } diff --git a/src/stories/common/list.tsx b/src/stories/common/list.tsx index 5611db6..decd8c0 100644 --- a/src/stories/common/list.tsx +++ b/src/stories/common/list.tsx @@ -20,59 +20,55 @@ export const List = () => { }) return ( -
- ( -
- - {item.name} -
- ), - }, - { - title: 'Symbol', - renderCell: (item) => {item.symbol}, - }, - { - title: 'Date of Birth', - renderCell: (item) => ( - {new Date(item.dateOfBirth).toLocaleString()} - ), - }, - ]} - actions={[ - { - label: 'Mark As Favorite', - icon: , - onClick: (item) => console.log(`Marking ${item.name} as favorite!`), - }, - { - label: 'Start Conversation', - icon: , - isDisabled: true, - onClick: (item) => - console.log(`Starting a conversation with ${item.name}.`), - }, - { - label: 'Remove From Organization', - icon: , - isDestructive: true, - onClick: (item) => - console.log(`Removing ${item.name} from organization...`), - }, - ]} - /> -
+ ( +
+ + {item.name} +
+ ), + }, + { + title: 'Symbol', + renderCell: (item) => {item.symbol}, + }, + { + title: 'Date of Birth', + renderCell: (item) => ( + {new Date(item.dateOfBirth).toLocaleString()} + ), + }, + ]} + actions={[ + { + label: 'Mark As Favorite', + icon: , + onClick: (item) => console.log(`Marking ${item.name} as favorite!`), + }, + { + label: 'Start Conversation', + icon: , + isDisabled: true, + onClick: (item) => + console.log(`Starting a conversation with ${item.name}.`), + }, + { + label: 'Remove From Organization', + icon: , + isDestructive: true, + onClick: (item) => + console.log(`Removing ${item.name} from organization...`), + }, + ]} + pagination={ { setPage={setPage} setSize={setSize} /> -
-
+ } + /> ) }