@@ -35,6 +35,7 @@ export const KeyValueTable = <K extends string>({
35
35
onDelete,
36
36
placeholder,
37
37
isAdditionNotAllowed,
38
+ readOnly,
38
39
} : KeyValueTableProps < K > ) => {
39
40
// CONSTANTS
40
41
const { headers, rows } = config
@@ -168,7 +169,7 @@ export const KeyValueTable = <K extends string>({
168
169
return (
169
170
< div className = "dc__border br-4 w-100 bcn-0 key-value" >
170
171
< div
171
- className = { `key-value__row flexbox dc__align-items-center bcn-50 ${ ! isAdditionNotAllowed || updatedRows . length ? 'dc__border-bottom-n1' : '' } ` }
172
+ className = { `key-value__row flexbox dc__align-items-center bcn-50 ${ ( ! readOnly && ! isAdditionNotAllowed ) || updatedRows . length ? 'dc__border-bottom-n1' : '' } ` }
172
173
>
173
174
{ headers . map ( ( { key, label, className } ) =>
174
175
isSortable && key === firstHeaderKey ? (
@@ -197,18 +198,18 @@ export const KeyValueTable = <K extends string>({
197
198
) }
198
199
{ ! ! headerComponent && < div className = "px-12" > { headerComponent } </ div > }
199
200
</ div >
200
- { ! isAdditionNotAllowed && (
201
+ { ! readOnly && ! isAdditionNotAllowed && (
201
202
< div
202
203
className = { `key-value__row flexbox dc__align-items-center ${ updatedRows . length ? 'dc__border-bottom-n1' : '' } ` }
203
204
>
204
205
{ headers . map ( ( { key } ) => (
205
206
< div
206
207
key = { key }
207
- className = { `cn-9 fs-13 lh-20 py-8 px-12 flex dc__overflow-auto ${ key === firstHeaderKey ? 'dc__align-self-stretch dc__border-right--n1 key-value__header__col-1' : 'flex-grow-1' } ` }
208
+ className = { `cn-9 fs-13 lh-20 flex dc__overflow-auto ${ key === firstHeaderKey ? 'dc__align-self-stretch dc__border-right--n1 key-value__header__col-1' : 'flex-grow-1' } ` }
208
209
>
209
210
< textarea
210
211
ref = { key === firstHeaderKey ? inputRowRef : undefined }
211
- className = "key-value__row-input key-value__row-input--add placeholder-cn5 p-0 lh-20 fs-13 fw-4 dc__no-border-imp dc__no-border-radius"
212
+ className = "key-value__row-input key-value__row-input--add placeholder-cn5 py-8 px-12 lh-20 fs-13 fw-4 dc__no-border-imp dc__no-border-radius"
212
213
value = ""
213
214
rows = { 1 }
214
215
placeholder = { placeholder [ key ] }
@@ -226,15 +227,15 @@ export const KeyValueTable = <K extends string>({
226
227
{ headers . map ( ( { key } ) => (
227
228
< div
228
229
key = { key }
229
- className = { `cn-9 fs-13 lh-20 px-12 dc__overflow-auto flexbox dc__align-items-center dc__gap-4 ${ key === firstHeaderKey ? 'dc__align-self-stretch dc__border-right--n1 key-value__header__col-1' : 'flex-grow-1' } ` }
230
+ className = { `cn-9 fs-13 lh-20 dc__overflow-auto flexbox dc__align-items-center dc__gap-4 ${ key === firstHeaderKey ? 'dc__align-self-stretch dc__border-right--n1 key-value__header__col-1' : 'flex-grow-1' } ` }
230
231
>
231
232
{ maskValue ?. [ key ] && row . data [ key ] . value ? (
232
233
DEFAULT_SECRET_PLACEHOLDER
233
234
) : (
234
235
< >
235
236
< ResizableTagTextArea
236
237
{ ...row . data [ key ] }
237
- className = "key-value__row-input placeholder-cn5 py-8 px-0 dc__no-border-imp dc__no-border-radius"
238
+ className = "key-value__row-input placeholder-cn5 py-8 px-12 dc__no-border-imp dc__no-border-radius"
238
239
minHeight = { 20 }
239
240
maxHeight = { 160 }
240
241
value = { row . data [ key ] . value }
@@ -251,6 +252,7 @@ export const KeyValueTable = <K extends string>({
251
252
? valueTextAreaRef . current ?. [ row . id ]
252
253
: keyTextAreaRef . current ?. [ row . id ]
253
254
}
255
+ disabled = { readOnly || row . data [ key ] . disabled }
254
256
disableOnBlurResizeToMinHeight
255
257
/>
256
258
{ row . data [ key ] . required && (
@@ -260,13 +262,18 @@ export const KeyValueTable = <K extends string>({
260
262
) }
261
263
</ div >
262
264
) ) }
263
- < button
264
- type = "button"
265
- className = "dc__unset-button-styles dc__align-self-stretch dc__no-shrink flex py-10 px-8 dc__border-left-n1--important dc__hover-n50"
266
- onClick = { onRowDelete ( row ) }
267
- >
268
- < ICCross aria-label = "delete-row" className = "icon-dim-16 fcn-4 dc__align-self-start cursor" />
269
- </ button >
265
+ { ! readOnly && (
266
+ < button
267
+ type = "button"
268
+ className = "dc__unset-button-styles dc__align-self-stretch dc__no-shrink flex py-10 px-8 dc__border-left-n1--important dc__hover-n50"
269
+ onClick = { onRowDelete ( row ) }
270
+ >
271
+ < ICCross
272
+ aria-label = "delete-row"
273
+ className = "icon-dim-16 fcn-4 dc__align-self-start cursor"
274
+ />
275
+ </ button >
276
+ ) }
270
277
</ div >
271
278
) ) }
272
279
</ div >
0 commit comments