@@ -2,8 +2,7 @@ import { createElement, createRef, Fragment, ReactElement, RefObject, useEffect,
2
2
// eslint-disable-next-line import/no-extraneous-dependencies
3
3
import { followCursor } from 'tippy.js'
4
4
5
- import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
6
- import { DEFAULT_SECRET_PLACEHOLDER } from '@Shared/constants'
5
+ import { ReactComponent as ICCross } from '@Icons/ic-cross.svg'
7
6
import { Tooltip } from '@Common/Tooltip'
8
7
9
8
import { ConditionalWrap } from '@Common/Helper'
@@ -32,7 +31,6 @@ const conditionalWrap =
32
31
export const DynamicDataTableRow = < K extends string > ( {
33
32
rows = [ ] ,
34
33
headers,
35
- maskValue,
36
34
readOnly,
37
35
isAdditionNotAllowed,
38
36
isDeletionNotAllowed,
@@ -122,6 +120,7 @@ export const DynamicDataTableRow = <K extends string>({
122
120
< SelectPicker < string , false >
123
121
{ ...row . data [ key ] . props }
124
122
inputId = { `data-table-${ row . id } -${ key } -cell` }
123
+ classNamePrefix = "dynamic-data-table__cell__select-picker"
125
124
variant = { SelectPickerVariantType . BORDER_LESS }
126
125
value = { getSelectPickerOptionByValue ( row . data [ key ] . props ?. options , row . data [ key ] . value ) }
127
126
onChange = { onChange ( row , key ) }
@@ -140,7 +139,10 @@ export const DynamicDataTableRow = <K extends string>({
140
139
inputId = { `data-table-${ row . id } -${ key } -cell` }
141
140
disabled = { readOnly || row . data [ key ] . disabled }
142
141
refVar = { cellRef ?. current ?. [ row . id ] ?. [ key ] }
143
- dependentRef = { cellRef ?. current ?. [ row . id ] }
142
+ dependentRefs = { cellRef ?. current ?. [ row . id ] }
143
+ selectPickerProps = { {
144
+ classNamePrefix : 'dynamic-data-table__cell__select-picker' ,
145
+ } }
144
146
textAreaProps = { {
145
147
...row . data [ key ] . props ?. textAreaProps ,
146
148
className : 'dynamic-data-table__cell-input placeholder-cn5 py-8 pr-8 cn-9 fs-13 lh-20' ,
@@ -172,14 +174,15 @@ export const DynamicDataTableRow = <K extends string>({
172
174
return (
173
175
< ResizableTagTextArea
174
176
{ ...row . data [ key ] . props }
177
+ id = { `data-table-${ row . id } -${ key } -cell` }
175
178
className = { `dynamic-data-table__cell-input placeholder-cn5 p-8 cn-9 fs-13 lh-20 dc__align-self-start dc__no-border-radius ${ readOnly || row . data [ key ] . disabled ? 'cursor-not-allowed' : '' } ` }
176
179
minHeight = { 20 }
177
180
maxHeight = { 160 }
178
181
value = { row . data [ key ] . value }
179
182
onChange = { onChange ( row , key ) }
180
183
disabled = { readOnly || row . data [ key ] . disabled }
181
184
refVar = { cellRef ?. current ?. [ row . id ] ?. [ key ] }
182
- dependentRef = { cellRef ?. current ?. [ row . id ] }
185
+ dependentRefs = { cellRef ?. current ?. [ row . id ] }
183
186
disableOnBlurResizeToMinHeight
184
187
/>
185
188
)
@@ -206,7 +209,7 @@ export const DynamicDataTableRow = <K extends string>({
206
209
207
210
const renderErrorMessage = ( errorMessage : string ) => (
208
211
< div key = { errorMessage } className = "flexbox align-items-center dc__gap-4" >
209
- < ICClose className = "icon-dim-16 fcr-5 dc__align-self-start dc__no-shrink" />
212
+ < ICCross className = "icon-dim-16 fcr-5 dc__align-self-start dc__no-shrink" />
210
213
< p className = "fs-12 lh-16 cn-7 m-0" > { errorMessage } </ p >
211
214
</ div >
212
215
)
@@ -236,17 +239,11 @@ export const DynamicDataTableRow = <K extends string>({
236
239
< div
237
240
className = { `dynamic-data-table__cell bcn-0 flexbox dc__align-items-center dc__gap-4 dc__position-rel ${ readOnly || row . data [ key ] . disabled ? 'cursor-not-allowed no-hover' : '' } ${ showError && ! validationSchema ( row . data [ key ] . value , key , row ) . isValid ? 'dynamic-data-table__cell--error no-hover' : '' } ${ ! rowTypeHasInputField ( row . data [ key ] . type ) ? 'no-hover no-focus' : '' } ` }
238
241
>
239
- { maskValue ?. [ key ] && row . data [ key ] . value ? (
240
- < div className = "py-8 px-12 h-36 flex" > { DEFAULT_SECRET_PLACEHOLDER } </ div >
241
- ) : (
242
- < >
243
- { renderCellIcon ( row , key , true ) }
244
- { renderCellContent ( row , key ) }
245
- { renderAsterisk ( row , key ) }
246
- { renderCellIcon ( row , key ) }
247
- { renderErrorMessages ( row , key ) }
248
- </ >
249
- ) }
242
+ { renderCellIcon ( row , key , true ) }
243
+ { renderCellContent ( row , key ) }
244
+ { renderAsterisk ( row , key ) }
245
+ { renderCellIcon ( row , key ) }
246
+ { renderErrorMessages ( row , key ) }
250
247
</ div >
251
248
</ Tooltip >
252
249
)
@@ -274,35 +271,30 @@ export const DynamicDataTableRow = <K extends string>({
274
271
275
272
return hasRows ? (
276
273
< div className = "bcn-2 px-1 pb-1 dc__bottom-radius-4" >
277
- { ! ! rows . length && (
278
- < div
279
- className = { `dynamic-data-table w-100 bcn-1 dc__bottom-radius-4 ${ ! readOnly ? 'three-columns' : 'two-columns' } ` }
280
- style = { {
281
- gridTemplateColumns : rowGridTemplateColumn ,
282
- } }
283
- >
284
- { rows . map ( ( row ) => (
285
- < div key = { row . id } className = "dynamic-data-table__row" >
286
- { headers . map ( ( { key } , index ) => (
287
- < Fragment key = { key } > { renderCell ( row , key , index ) } </ Fragment >
288
- ) ) }
289
- { ! isDeletionNotAllowed && ! readOnly && (
290
- < button
291
- type = "button"
292
- className = { `dynamic-data-table__row-delete-btn dc__unset-button-styles dc__align-self-stretch dc__no-shrink flex py-10 px-8 bcn-0 dc__hover-n50 dc__tab-focus ${ disableDeleteRow ? 'dc__disabled' : '' } ` }
293
- onClick = { onDelete ( row ) }
294
- disabled = { disableDeleteRow }
295
- >
296
- < ICClose
297
- aria-label = "delete-row"
298
- className = "icon-dim-16 fcn-4 dc__align-self-start"
299
- />
300
- </ button >
301
- ) }
302
- </ div >
303
- ) ) }
304
- </ div >
305
- ) }
274
+ < div
275
+ className = { `dynamic-data-table w-100 bcn-1 dc__bottom-radius-4 ${ ! readOnly ? 'row-column' : 'header-column' } ` }
276
+ style = { {
277
+ gridTemplateColumns : rowGridTemplateColumn ,
278
+ } }
279
+ >
280
+ { rows . map ( ( row ) => (
281
+ < div key = { row . id } className = "dynamic-data-table__row" >
282
+ { headers . map ( ( { key } , index ) => (
283
+ < Fragment key = { key } > { renderCell ( row , key , index ) } </ Fragment >
284
+ ) ) }
285
+ { ! isDeletionNotAllowed && ! readOnly && (
286
+ < button
287
+ type = "button"
288
+ className = { `dynamic-data-table__row-delete-btn dc__unset-button-styles dc__align-self-stretch dc__no-shrink flex py-10 px-8 bcn-0 ${ disableDeleteRow ? 'dc__disabled' : 'dc__hover-n50 dc__tab-focus' } ` }
289
+ onClick = { onDelete ( row ) }
290
+ disabled = { disableDeleteRow }
291
+ >
292
+ < ICCross aria-label = "delete-row" className = "icon-dim-16 fcn-4 dc__align-self-start" />
293
+ </ button >
294
+ ) }
295
+ </ div >
296
+ ) ) }
297
+ </ div >
306
298
</ div >
307
299
) : null
308
300
}
0 commit comments