@@ -41,20 +41,27 @@ const getOptionsGroup = (value, lastClicked, options) => {
41
41
return [ ...options . slice ( startIndex , endIndex ) . map ( ( { value } ) => value . toString ( ) ) ] ;
42
42
} ;
43
43
44
- const List = ( { value, optionClick, noOptionsTitle, filterValue, filterValueText, ...rest } ) => (
45
- < select className = "pf-c-form-control pf-u-pr-sm ddorg__pf4-component-mapper__dual-list-select" multiple { ...rest } >
44
+ const List = ( { value, optionClick, noOptionsTitle, filterValue, filterValueText, selectedValues , ...rest } ) => (
45
+ < div className = "pf-c-form-control pf-u-pr-sm ddorg__pf4-component-mapper__dual-list-select" { ...rest } >
46
46
{ value . length < 1 && (
47
- < option className = "ddorg__pf4-component-mapper__dual-list-select-option" disabled >
47
+ < div className = "ddorg__pf4-component-mapper__dual-list-select-option-text ddorg__pf4-component-mapper__dual-list-select-option- disabled" >
48
48
{ filterValue ? filterValueText : noOptionsTitle }
49
- </ option >
49
+ </ div >
50
50
) }
51
51
{ value . length > 0 &&
52
52
value . map ( ( { value, label } ) => (
53
- < option onClick = { optionClick } key = { value } value = { value } >
53
+ < div
54
+ onClick = { ( e ) => optionClick ( e , value ) }
55
+ key = { value }
56
+ value = { value }
57
+ className = { `ddorg__pf4-component-mapper__dual-list-select-option ${
58
+ selectedValues . includes ( value ) ? 'ddorg__pf4-component-mapper__dual-list-select-option-selected' : ''
59
+ } `}
60
+ >
54
61
{ label }
55
- </ option >
62
+ </ div >
56
63
) ) }
57
- </ select >
64
+ </ div >
58
65
) ;
59
66
60
67
List . propTypes = {
@@ -67,7 +74,8 @@ List.propTypes = {
67
74
optionClick : PropTypes . func . isRequired ,
68
75
noOptionsTitle : PropTypes . node ,
69
76
filterValue : PropTypes . string ,
70
- filterValueText : PropTypes . node
77
+ filterValueText : PropTypes . node ,
78
+ selectedValues : PropTypes . array
71
79
} ;
72
80
73
81
List . defaultProps = {
@@ -181,7 +189,6 @@ const DualList = (props) => {
181
189
moveLeftTitle,
182
190
options,
183
191
rightTitle,
184
- size,
185
192
label,
186
193
isRequired,
187
194
helperText,
@@ -199,10 +206,7 @@ const DualList = (props) => {
199
206
200
207
const showError = touched && error ;
201
208
202
- const handleOptionClicked = ( event , options , isRight ) => {
203
- const {
204
- target : { value }
205
- } = event ;
209
+ const handleOptionClicked = ( event , value , options , isRight ) => {
206
210
const selectedKey = isRight ? 'selectedLeftValues' : 'selectedRightValues' ;
207
211
const lastKey = isRight ? 'lastLeftClicked' : 'lastRightClicked' ;
208
212
if ( event . shiftKey && state [ lastKey ] ) {
@@ -266,12 +270,12 @@ const DualList = (props) => {
266
270
</ GridItem >
267
271
< GridItem md = { 12 } >
268
272
< List
269
- size = { size }
270
- optionClick = { ( event ) => handleOptionClicked ( event , leftValues , true ) }
273
+ optionClick = { ( event , value ) => handleOptionClicked ( event , value , leftValues , true ) }
271
274
value = { leftValues }
272
275
noOptionsTitle = { noOptionsTitle }
273
276
filterValue = { state . filterOptions }
274
277
filterValueText = { filterOptionsText }
278
+ selectedValues = { state . selectedLeftValues }
275
279
/>
276
280
</ GridItem >
277
281
</ Grid >
@@ -341,12 +345,12 @@ const DualList = (props) => {
341
345
</ GridItem >
342
346
< GridItem md = { 12 } >
343
347
< List
344
- size = { size }
345
- optionClick = { ( event ) => handleOptionClicked ( event , rightValues , false ) }
348
+ optionClick = { ( event , value ) => handleOptionClicked ( event , value , rightValues , false ) }
346
349
value = { rightValues }
347
350
noOptionsTitle = { noValueTitle }
348
351
filterValue = { state . filterValue }
349
352
filterValueText = { filterValueText }
353
+ selectedValues = { state . selectedRightValues }
350
354
/>
351
355
</ GridItem >
352
356
</ Grid >
@@ -366,7 +370,6 @@ DualList.propTypes = {
366
370
) ,
367
371
leftTitle : PropTypes . node ,
368
372
rightTitle : PropTypes . node ,
369
- size : PropTypes . number ,
370
373
moveLeftTitle : PropTypes . node ,
371
374
moveRightTitle : PropTypes . node ,
372
375
clearRightValue : PropTypes . bool ,
@@ -387,7 +390,6 @@ DualList.propTypes = {
387
390
DualList . defaultProps = {
388
391
leftTitle : 'Options' ,
389
392
rightTitle : 'Selected' ,
390
- size : 15 ,
391
393
moveLeftTitle : 'Move selected to left' ,
392
394
moveRightTitle : 'Move selected to right' ,
393
395
moveAllRightTitle : 'Move all to right' ,
0 commit comments