1
+ import { useEffect } from 'react'
1
2
import { Meta , StoryObj } from '@storybook/react'
2
3
import {
3
4
Button ,
@@ -18,24 +19,13 @@ import {
18
19
import { ReactComponent as ICPlay } from '@Icons/ic-play-outline.svg'
19
20
import { ReactComponent as ICPause } from '@Icons/ic-pause.svg'
20
21
import { ReactComponent as ICWarning } from '@Icons/ic-warning-y6.svg'
21
- import { useEffect , useState } from 'react'
22
-
23
- const CellComponent = ( { field, value, signals, row } : TableCellComponentProps ) => {
24
- const [ isRowActive , setIsRowActive ] = useState ( false )
25
22
23
+ const CellComponent = ( { field, value, signals, row, isRowActive } : TableCellComponentProps ) => {
26
24
const handleButtonClick = ( ) => {
27
25
alert ( `Row ${ value } clicked` )
28
26
}
29
27
30
28
useEffect ( ( ) => {
31
- const rowChangeCallback = ( {
32
- detail : {
33
- activeRowData : { id } ,
34
- } ,
35
- } ) => {
36
- setIsRowActive ( id === row . id )
37
- }
38
-
39
29
const rowEnterPressedCallback = ( {
40
30
detail : {
41
31
activeRowData : { id } ,
@@ -46,13 +36,9 @@ const CellComponent = ({ field, value, signals, row }: TableCellComponentProps)
46
36
}
47
37
}
48
38
49
- signals . addEventListener ( TableSignalEnum . ACTIVE_ROW_CHANGED , rowChangeCallback )
50
-
51
39
signals . addEventListener ( TableSignalEnum . ENTER_PRESSED , rowEnterPressedCallback )
52
40
53
41
return ( ) => {
54
- signals . removeEventListener ( TableSignalEnum . ACTIVE_ROW_CHANGED , rowChangeCallback )
55
-
56
42
signals . removeEventListener ( TableSignalEnum . ENTER_PRESSED , rowEnterPressedCallback )
57
43
}
58
44
} , [ ] )
@@ -166,7 +152,7 @@ export default meta
166
152
type Story = StoryObj < typeof meta >
167
153
168
154
const BulkActionsComponent = ( ) => (
169
- < >
155
+ < div className = "flexbox dc__gap-4" >
170
156
< Button
171
157
icon = { < ICPause /> }
172
158
dataTestId = "rb-bulk-action__action-widget--cordon"
@@ -190,7 +176,7 @@ const BulkActionsComponent = () => (
190
176
onClick = { ( ) => alert ( 'Play clicked!' ) }
191
177
showAriaLabelInTippy
192
178
/>
193
- </ >
179
+ </ div >
194
180
)
195
181
196
182
const ViewWrapper = ( { children, handleSearch, searchKey } : TableViewWrapperProps ) => (
@@ -237,5 +223,8 @@ export const TableTemplate: Story = {
237
223
showSeparatorBetweenRows : true ,
238
224
} ,
239
225
ViewWrapper,
226
+ additionalFilterProps : {
227
+ initialSortKey : 'name' ,
228
+ } ,
240
229
} as TableProps ,
241
230
}
0 commit comments