generated from gravity-ui/package-example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
alx-chernigin
committed
Oct 22, 2024
1 parent
3dee229
commit f63db62
Showing
7 changed files
with
125 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {block} from '../../utils'; | ||
|
||
export const b = block('row-actions'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/components/RowActions/__stories__/stories/RowActionsWithCustomRendering.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
|
||
import {Select} from '@gravity-ui/uikit'; | ||
import type {ColumnDef, RowSelectionState} from '@tanstack/react-table'; | ||
|
||
import {ACTIONS_COLUMN_ID, getActionsColumn, selectionColumn} from '../../../../constants'; | ||
import {useTable} from '../../../../hooks'; | ||
import type {Item} from '../../../BaseTable/__stories__/types'; | ||
import {generateData} from '../../../BaseTable/__stories__/utils'; | ||
import {Table} from '../../../Table/Table'; | ||
import {actionsSettings, baseColumns} from '../constants'; | ||
|
||
const data = generateData(5); | ||
|
||
const columns: ColumnDef<Item>[] = [ | ||
selectionColumn as ColumnDef<Item>, | ||
...baseColumns, | ||
getActionsColumn<Item>(ACTIONS_COLUMN_ID, { | ||
...actionsSettings, | ||
renderRowActions: ({row}) => { | ||
const {index} = row; | ||
if (index % 2) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Select | ||
options={[ | ||
{value: '1', text: 'action 1', content: 'action 1'}, | ||
{value: '2', text: 'action 2', content: 'action 2'}, | ||
{value: '3', text: 'action 3', content: 'action 3'}, | ||
]} | ||
size="s" | ||
title="Actions select example" | ||
/> | ||
); | ||
}, | ||
}), | ||
]; | ||
|
||
export const RowActionsWithCustomRendering = () => { | ||
const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({}); | ||
const table = useTable({ | ||
columns, | ||
data, | ||
state: {rowSelection}, | ||
enableRowSelection: true, | ||
enableMultiRowSelection: true, | ||
onRowSelectionChange: setRowSelection, | ||
}); | ||
|
||
return <Table table={table} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters