@@ -3,6 +3,8 @@ import TextField from '@material-ui/core/TextField';
33import IconButton from '@material-ui/core/IconButton' ;
44import Icon from '@material-ui/core/Icon' ;
55import Tooltip from './Tooltip'
6+ import Chip from '@material-ui/core/Chip'
7+ import Grid from '@material-ui/core/Grid'
68/**
79 * Generic List/Dict Component
810 */
@@ -31,6 +33,9 @@ export default class ListComponent extends Component {
3133 valid = false ;
3234 }
3335 } ) ;
36+ if ( value . endsWith ( ',' ) ) {
37+ valid = false ;
38+ }
3439 break ;
3540 case 'dict' :
3641 var valid = ( value . match ( / : / g) || [ ] ) . length == 1 && ! value . startsWith ( ':' ) && ! value . endsWith ( ':' ) ;
@@ -208,66 +213,48 @@ export default class ListComponent extends Component {
208213 var value = this . state . children [ key ] ;
209214 }
210215 return (
211- < div
212- key = { key }
213- style = { this . props . realType != 'dict(dict())' ? { marginRight : 30 , float : 'left' } : { marginRight : 30 } }
214- >
215- < TextField
216- value = { value }
217- id = { this . props . id + index }
218- disabled
219- />
220- < IconButton
221- id = { this . props . id + index + "RemoveButton" }
222- className = { 'listButtonSmall' }
223- onClick = { ( ) => this . removeChild ( key ) }
224- tooltip-data = 'Remove item from the list'
225- >
226- < Icon className = { 'fa fa-minus-circle listIcon' } />
227- </ IconButton >
228- </ div >
216+ < Grid item key = { key } >
217+ < Chip key = { key } label = { value } onDelete = { ( ) => this . removeChild ( key ) } color = "primary" />
218+ </ Grid >
229219 )
220+
230221 } ) ;
231222
232223 return (
233- < div >
234- < div style = { { display : 'flex' , alignItems : 'baseline' } } >
235- < TextField
236- id = { this . props . id }
237- label = { this . props . label ? 'Add new ' + this . props . label : 'Add new item' }
238- onChange = { this . handleNewItemChange }
239- onKeyPress = { e => e . key === 'Enter' ? this . addChild ( ) : null }
240- value = { this . state . newItemValue }
241- style = { { width : '100%' } }
242- helperText = { this . state . newItemErrorText }
243- />
244- { ! this . state . newItemErrorText
245- && (
246- < span >
247- < Tooltip title = "Add item to the list" placement = "top" >
248- < IconButton
249- id = { this . props . id + "AddButton" }
250- className = { 'listButtonLarge' }
251- onClick = { this . addChild }
252- >
253- < Icon className = { 'fa fa-plus-circle listIcon' } />
254- </ IconButton >
255- </ Tooltip >
256-
257- </ span >
258- )
259- }
260- </ div >
261-
224+ < Grid container spacing = { 1 } >
225+ < Grid container item xs = { 12 } >
226+ < Grid item xs = { 11 } >
227+ < TextField
228+ variant = "filled"
229+ id = { this . props . id }
230+ label = { this . props . label ? 'Add new ' + this . props . label : 'Add new item' }
231+ onChange = { this . handleNewItemChange }
232+ onKeyPress = { e => e . key === 'Enter' ? this . addChild ( ) : null }
233+ value = { this . state . newItemValue }
234+ style = { { width : '100%' } }
235+ helperText = { this . state . newItemErrorText }
236+ />
237+ </ Grid >
262238
263- { childrenWithExtraProp . length > 0 && (
264- < div
265- style = { { marginTop : '15px' , marginLeft : '50px' , paddingRight : '15px' , padding : '0px 5px' , float : 'left' } }
266- >
267- { childrenWithExtraProp }
268- </ div >
269- ) }
270- </ div >
239+ < Grid item xs = { 1 } >
240+ < Tooltip title = "Add item to the list" placement = "top" >
241+ < IconButton
242+ onClick = { this . addChild }
243+ color = "primary"
244+ >
245+ < Icon className = "fa fa-plus-circle" />
246+ </ IconButton >
247+ </ Tooltip >
248+ </ Grid >
249+
250+ </ Grid >
251+
252+ < Grid container item xs = { 12 } spacing = { 1 } >
253+ { childrenWithExtraProp }
254+
255+ </ Grid >
256+
257+ </ Grid >
271258 )
272259 }
273260}
0 commit comments