Skip to content

Commit

Permalink
chore: add multiselection-mode prop
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra committed Jun 28, 2024
1 parent aec945b commit 0f20a82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/blade/src/components/Table/Table.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { useTheme as useTableTheme } from '@table-library/react-table-library/th
import type { MiddlewareFunction } from '@table-library/react-table-library/types/common';
import { useSort } from '@table-library/react-table-library/sort';
import { usePagination } from '@table-library/react-table-library/pagination';
import { SelectTypes, useRowSelect } from '@table-library/react-table-library/select';
import {
SelectClickTypes,
SelectTypes,
useRowSelect,
} from '@table-library/react-table-library/select';
import styled from 'styled-components';
import usePresence from 'use-presence';
import type { TableContextType } from './TableContext';
Expand Down Expand Up @@ -116,6 +120,7 @@ const RefreshWrapper = styled(BaseBox)<{
const _Table = <Item,>({
children,
data,
multiSelectionMode = 'row',
selectionType = 'none',
onSelectionChange,
isHeaderSticky,
Expand Down Expand Up @@ -257,6 +262,8 @@ const _Table = <Item,>({
onChange: onSelectChange,
},
{
clickType:
multiSelectionMode === 'row' ? SelectClickTypes.RowClick : SelectClickTypes.ButtonClick,
rowSelect: selectionType !== 'none' ? rowSelectType[selectionType] : undefined,
},
);
Expand Down
5 changes: 5 additions & 0 deletions packages/blade/src/components/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ type TableProps<Item> = {
* The object should have an id property that is a unique identifier for the row.
*/
data: TableData<Item>;
/**
* Selection mode determines how the table rows can be selected.
* @default 'row'
**/
multiSelectionMode?: 'checkbox' | 'row';
/**
* The selectionType prop determines the type of selection that is allowed on the table.
* The selectionType prop can be 'none', 'single' or 'multiple'.
Expand Down

0 comments on commit 0f20a82

Please sign in to comment.