@@ -39,8 +39,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
39
39
headers,
40
40
readOnly,
41
41
isDeletionNotAllowed,
42
- validationSchema = ( ) => ( { isValid : true , errorMessages : [ ] } ) ,
43
- showError,
42
+ cellError = { } ,
44
43
actionButtonConfig = null ,
45
44
onRowEdit,
46
45
onRowDelete,
@@ -86,7 +85,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
86
85
87
86
cellRef . current = updatedCellRef
88
87
}
89
- } , [ rows ] )
88
+ } , [ rows . length ] )
90
89
91
90
// METHODS
92
91
const onChange =
@@ -237,12 +236,12 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
237
236
)
238
237
239
238
const renderErrorMessages = ( row : DynamicDataTableRowType < K , CustomStateType > , key : K ) => {
240
- const { isValid, errorMessages } = ! row . data [ key ] . disabled
241
- ? validationSchema ( row . data [ key ] . value , key , row )
242
- : { isValid : true , errorMessages : [ ] }
243
- const showErrorMessages = showError && ! isValid
239
+ const { isValid, errorMessages } =
240
+ ! row . data [ key ] . disabled && cellError [ row . id ] ?. [ key ]
241
+ ? cellError [ row . id ] [ key ]
242
+ : { isValid : true , errorMessages : [ ] }
244
243
245
- if ( ! showErrorMessages ) {
244
+ if ( isValid ) {
246
245
return null
247
246
}
248
247
@@ -265,7 +264,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
265
264
plugins = { [ followCursor ] }
266
265
>
267
266
< div
268
- className = { `dynamic-data-table__cell bcn-0 flexbox dc__align-items-center dc__gap-4 dc__position-rel ${ isDisabled ? 'cursor-not-allowed no-hover' : '' } ${ showError && ! isDisabled && ! validationSchema ( row . data [ key ] . value , key , row ) . isValid ? 'dynamic-data-table__cell--error no-hover' : '' } ${ ! rowTypeHasInputField ( row . data [ key ] . type ) ? 'no-hover no-focus' : '' } ` }
267
+ className = { `dynamic-data-table__cell bcn-0 flexbox dc__align-items-center dc__gap-4 dc__position-rel ${ isDisabled ? 'cursor-not-allowed no-hover' : '' } ${ ! isDisabled && ! cellError [ row . id ] ?. [ key ] ? .isValid ? 'dynamic-data-table__cell--error no-hover' : '' } ${ ! rowTypeHasInputField ( row . data [ key ] . type ) ? 'no-hover no-focus' : '' } ` }
269
268
>
270
269
{ renderCellIcon ( row , key , true ) }
271
270
{ renderCellContent ( row , key ) }
@@ -279,7 +278,13 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
279
278
const actionButtonIndex = getActionButtonPosition ( { headers, actionButtonConfig } )
280
279
if ( actionButtonIndex === index ) {
281
280
const { renderer, position = 'start' } = actionButtonConfig
282
- const actionButtonNode = < div className = "dc__overflow-hidden flex top bcn-0" > { renderer ( row ) } </ div >
281
+ const actionButtonNode = (
282
+ < div
283
+ className = { `dc__overflow-hidden flex top bcn-0 ${ ( position === 'start' && key === headers [ 0 ] . key ) || ( isDeletionNotAllowed && position === 'end' && key === headers [ headers . length - 1 ] . key ) ? 'dynamic-data-table__cell' : '' } ` }
284
+ >
285
+ { renderer ( row ) }
286
+ </ div >
287
+ )
283
288
284
289
return position === 'start' ? (
285
290
< >
0 commit comments