Skip to content

Commit c69cbc8

Browse files
docs: Update readme
1 parent edbe70b commit c69cbc8

File tree

1 file changed

+58
-54
lines changed

1 file changed

+58
-54
lines changed

README.md

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
- [Component Props](#22-component-props)
1111
- [Customization](#3-customization)
1212
- [Column Configuration](#31-column-configuration)
13-
- [Features](#32-features)
14-
- [Pagination](#33-pagination)
15-
- [Selection](#34-selection)
16-
- [Theme Customization](#35-theme-customization)
13+
- [Expand Icon Customization](#32-expand-icon-customization)
14+
- [Selection Props](#33-selection-props)
15+
- [Sort Icons](#34-sort-icons)
16+
- [Pagination](#35-pagination)
17+
- [Theme Customization](#36-theme-customization)
1718
- [Development](#4-development)
1819
- [Project Structure](#41-project-structure)
1920
- [Development Commands](#42-development-commands)
@@ -126,7 +127,6 @@ The MultiLevelTable component accepts the following props:
126127
|------|------|----------|---------|-------------|
127128
| data | array | Yes | - | Array of data objects to display in the table |
128129
| columns | array | Yes | - | Array of column configurations |
129-
| childrenKey | string | No | 'children' | Key to use for nested data |
130130
| pageSize | number | No | 10 | Number of rows to display per page |
131131
| theme | object | No | - | Custom theme object for styling the table |
132132
| renderCustomPagination | function | No | null | Custom pagination component render function |
@@ -152,16 +152,60 @@ Each column object should have the following properties:
152152
| sortable | boolean | No | Whether the column can be sorted |
153153
| customSortFn | function | No | Custom sorting function. Receives (rowA: DataItem, rowB: DataItem, columnId: string) as parameters |
154154

155-
### 3.2 Features
155+
### 3.2 Expand Icon Customization
156156

157-
- **Multi-level Data Structure**: Display hierarchical data with parent-child relationships
158-
- **Sorting**: Click column headers to sort data (applies to parent rows only)
159-
- **Filtering**: Real-time filtering for specified columns (applies to parent rows only)
160-
- **Pagination**: Navigate through pages with configurable page sizes
161-
- **Custom Rendering**: Customize cell content with render functions
162-
- **TypeScript Support**: Full TypeScript support with proper type definitions
157+
You can customize the expand icon for rows with children using the `expandIcon` prop:
163158

164-
### 3.3 Pagination
159+
```tsx
160+
<MultiLevelTable
161+
data={data}
162+
columns={columns}
163+
expandIcon={<CustomExpandIcon />} // Your custom expand icon component
164+
/>
165+
```
166+
167+
The expand icon will be displayed for rows that have children. You can provide any React component as the icon.
168+
169+
### 3.3 Selection Props
170+
171+
The table supports row selection with the following props:
172+
173+
```tsx
174+
<MultiLevelTable
175+
data={data}
176+
columns={columns}
177+
selectable={true} // Enable row selection
178+
onSelectionChange={(selectedRows) => {
179+
console.log('Selected rows:', selectedRows);
180+
}}
181+
/>
182+
```
183+
184+
| Prop | Type | Description |
185+
|------|------|-------------|
186+
| selectable | boolean | Enable/disable row selection functionality |
187+
| onSelectionChange | function | Callback function that receives a Set of selected row IDs |
188+
189+
### 3.4 Sort Icons
190+
191+
You can customize the sort icons for ascending and descending states:
192+
193+
```tsx
194+
<MultiLevelTable
195+
data={data}
196+
columns={columns}
197+
sortable={true}
198+
ascendingIcon={<CustomAscendingIcon />} // Custom icon for ascending sort
199+
descendingIcon={<CustomDescendingIcon />} // Custom icon for descending sort
200+
/>
201+
```
202+
203+
| Prop | Type | Description |
204+
|------|------|-------------|
205+
| ascendingIcon | ReactNode | Custom icon component for ascending sort state |
206+
| descendingIcon | ReactNode | Custom icon component for descending sort state |
207+
208+
### 3.5 Pagination
165209

166210
The table component provides comprehensive pagination functionality. You can either use the default pagination or create a custom one using the pagination props:
167211

@@ -230,47 +274,7 @@ const CustomPagination = ({
230274
/>
231275
```
232276

233-
### 3.4 Selection
234-
235-
The table component supports row selection functionality. When enabled, it provides a selection state with the following properties:
236-
237-
```tsx
238-
interface SelectionState {
239-
selectedRows: Set<string | number>; // Set of selected row IDs
240-
isAllSelected: boolean; // Whether all rows are selected
241-
}
242-
```
243-
244-
Example of using selection:
245-
246-
```tsx
247-
function App() {
248-
const [selectedRows, setSelectedRows] = useState<Set<string | number>>(new Set());
249-
const [isAllSelected, setIsAllSelected] = useState(false);
250-
251-
const handleSelectionChange = (selectionState: SelectionState) => {
252-
setSelectedRows(selectionState.selectedRows);
253-
setIsAllSelected(selectionState.isAllSelected);
254-
};
255-
256-
return (
257-
<MultiLevelTable
258-
data={data}
259-
columns={columns}
260-
selectable={true}
261-
onSelectionChange={handleSelectionChange}
262-
/>
263-
);
264-
}
265-
```
266-
267-
The selection functionality provides:
268-
- Individual row selection
269-
- Select all functionality
270-
- Selection state management
271-
- Custom selection change handling
272-
273-
### 3.5 Theme Customization
277+
### 3.6 Theme Customization
274278

275279
The table component supports theme customization through the `theme` prop. Here's the complete theme interface:
276280

0 commit comments

Comments
 (0)